Inheritance: Sanguosha.Core.Triggers.GameEventArgs
            void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
            {
                ShaEventArgs args = (ShaEventArgs)eventArgs;

                Trace.Assert(args != null);
                List <Card> theList;

                if (args.Card is CompositeCard)
                {
                    theList = (args.Card as CompositeCard).Subcards;
                }
                else
                {
                    theList = new List <Card>()
                    {
                        (args.Card as Card)
                    };
                }
                List <Card> handCards = new List <Card>(Game.CurrentGame.Decks[Owner, DeckType.Hand]);

                //你的"最后"一张手牌
                if (handCards.Count > 0)
                {
                    return;
                }
                //你的最后"一张"手牌
                if (theList.Count == 0)
                {
                    return;
                }
                foreach (Card c in theList)
                {
                    //"你的"最后一张"手牌"
                    if (c.Owner != Owner || c.Place.DeckType != DeckType.Hand)
                    {
                        return;
                    }
                }
                if (args.TargetApproval[0] == false)
                {
                    return;
                }
                int moreTargetsToApprove = 2;
                int i = 1;

                while (moreTargetsToApprove > 0 && i < args.TargetApproval.Count)
                {
                    if (args.TargetApproval[i] == true)
                    {
                        i++;
                        continue;
                    }
                    args.TargetApproval[i] = true;
                    i++;
                    moreTargetsToApprove--;
                    continue;
                }
            }
Esempio n. 2
0
            public ZhuGeLianNuSkill()
            {
                var trigger = new AutoNotifyPassiveSkillTrigger(
                    this,
                    (p, e, a) =>
                {
                    return(a.Source[Sha.NumberOfShaUsed] > 0 && a.Card.Type is Sha);
                },
                    (p, e, a) => { },
                    TriggerCondition.OwnerIsSource
                    );
                var trigger2 = new AutoNotifyPassiveSkillTrigger(
                    this,
                    (p, e, a) => { throw new TriggerResultException(TriggerResult.Success); },
                    TriggerCondition.OwnerIsSource
                    )
                {
                    IsAutoNotify = false
                };
                var trigger3 = new AutoNotifyPassiveSkillTrigger(
                    this,
                    (p, e, a) =>
                {
                    ShaEventArgs args      = (ShaEventArgs)a;
                    args.TargetApproval[0] = true;
                },
                    TriggerCondition.OwnerIsSource
                    )
                {
                    IsAutoNotify = false, Priority = int.MaxValue, Type = TriggerType.Skill
                };

                Triggers.Add(GameEvent.PlayerUsedCard, trigger);
                Triggers.Add(Sha.PlayerNumberOfShaCheck, trigger2);
                Triggers.Add(Sha.PlayerShaTargetValidation, trigger3);
                IsEnforced = true;
            }
Esempio n. 3
0
        public VerifierResult VerifyCore(Player source, ICard card, List<Player> targets)
        {
            if (targets != null && targets.Count > 0)
            {
                ShaEventArgs args = new ShaEventArgs();
                args.Source = source;
                args.Card = card;
                args.Targets = targets;
                args.RangeApproval = new List<bool>(targets.Count);
                args.TargetApproval = new List<bool>(targets.Count);
                foreach (Player t in targets)
                {
                    if (t == source)
                    {
                        return VerifierResult.Fail;
                    }
                    if (Game.CurrentGame.DistanceTo(source, t) <= source[Player.AttackRange] + 1)
                    {
                        args.RangeApproval.Add(true);
                    }
                    else
                    {
                        args.RangeApproval.Add(false);
                    }
                    args.TargetApproval.Add(false);
                }
                if (source[NumberOfShaUsed] <= source[AdditionalShaUsable])
                {
                    args.TargetApproval[0] = true;
                }

                try
                {
                    Game.CurrentGame.Emit(PlayerShaTargetValidation, args);
                }
                catch (TriggerResultException)
                {
                    throw new NotImplementedException();
                }

                foreach (bool b in args.TargetApproval.Concat(args.RangeApproval))
                {
                    if (!b)
                    {
                        return VerifierResult.Fail;
                    }
                }
            }
            if (targets == null || targets.Count == 0)
            {
                if (source[NumberOfShaUsed] <= source[AdditionalShaUsable])
                {
                    return VerifierResult.Partial;
                }
                try
                {
                    GameEventArgs args = new GameEventArgs();
                    args.Source = source;
                    Game.CurrentGame.Emit(PlayerNumberOfShaCheck, args);
                }
                catch (TriggerResultException e)
                {
                    if (e.Status == TriggerResult.Success)
                    {
                        return VerifierResult.Partial;
                    }
                }
                return VerifierResult.Fail;
            }
            return VerifierResult.Success;
        }
Esempio n. 4
0
        public VerifierResult VerifyCore(Player source, ICard card, List <Player> targets)
        {
            if (targets != null && targets.Count > 0)
            {
                ShaEventArgs args = new ShaEventArgs();
                args.Source         = source;
                args.Card           = card;
                args.Targets        = targets;
                args.RangeApproval  = new List <bool>(targets.Count);
                args.TargetApproval = new List <bool>(targets.Count);
                foreach (Player t in targets)
                {
                    if (t == source)
                    {
                        return(VerifierResult.Fail);
                    }
                    if (Game.CurrentGame.DistanceTo(source, t) <= source[Player.AttackRange] + 1)
                    {
                        args.RangeApproval.Add(true);
                    }
                    else
                    {
                        args.RangeApproval.Add(false);
                    }
                    args.TargetApproval.Add(false);
                }
                if (source[NumberOfShaUsed] <= source[AdditionalShaUsable])
                {
                    args.TargetApproval[0] = true;
                }

                try
                {
                    Game.CurrentGame.Emit(PlayerShaTargetValidation, args);
                }
                catch (TriggerResultException)
                {
                    throw new NotImplementedException();
                }

                foreach (bool b in args.TargetApproval.Concat(args.RangeApproval))
                {
                    if (!b)
                    {
                        return(VerifierResult.Fail);
                    }
                }
            }
            if (targets == null || targets.Count == 0)
            {
                if (source[NumberOfShaUsed] <= source[AdditionalShaUsable])
                {
                    return(VerifierResult.Partial);
                }
                try
                {
                    GameEventArgs args = new GameEventArgs();
                    args.Source = source;
                    Game.CurrentGame.Emit(PlayerNumberOfShaCheck, args);
                }
                catch (TriggerResultException e)
                {
                    if (e.Status == TriggerResult.Success)
                    {
                        return(VerifierResult.Partial);
                    }
                }
                return(VerifierResult.Fail);
            }
            return(VerifierResult.Success);
        }