Sanguosha.Expansions.Basic.Cards.DummyShaVerifier.FastVerify C# (CSharp) Method

FastVerify() public method

public FastVerify ( Player source, ISkill skill, List cards, List players ) : VerifierResult
source Sanguosha.Core.Players.Player
skill ISkill
cards List
players List
return VerifierResult
        public override VerifierResult FastVerify(Player source, ISkill skill, List<Card> cards, List<Player> players)
        {
            if (players != null && players.Any(p => p.IsDead))
            {
                return VerifierResult.Fail;
            }
            if (players == null)
            {
                players = new List<Player>();
            }
            CompositeCard sha = new CompositeCard() { Type = type };
            if (!Game.CurrentGame.PlayerCanBeTargeted(source, players, sha))
            {
                return VerifierResult.Fail;
            }
            List<Player> newList = new List<Player>(players);
            if (target != null)
            {
                if (!newList.Contains(target))
                {
                    newList.Insert(0, target);
                }
                else
                {
                    return VerifierResult.Fail;
                }
            }
            if (cards != null && cards.Count > 0)
            {
                return VerifierResult.Fail;
            }
            if (skill is CardTransformSkill)
            {
                CardTransformSkill sk = skill as CardTransformSkill;
                if (sk.TryTransform(dummyCards, null, out sha) != VerifierResult.Success)
                {
                    return VerifierResult.Fail;
                }
                if (helper != null) sha[helper] = 1;
                return new Sha().VerifyCore(source, sha, newList);
            }
            else if (skill != null)
            {
                return VerifierResult.Fail;
            }
            if (helper != null) sha[helper] = 1;
            return new Sha().VerifyCore(source, sha, newList);
        }

Usage Example

Esempio n. 1
0
 /// <summary>
 /// 某玩家对某玩家视为使用一张虚拟的杀,能被技能转化,影响选择的目标,如疠火,朱雀羽扇
 /// </summary>
 public static void UseDummyShaTo(Player source, Player target, CardHandler shaType, Prompt prompt, CardAttribute helper = null, bool notifyShaSound = true)
 {
     CompositeCard sha = new CompositeCard() { Type = shaType };
     var v1 = new DummyShaVerifier(target, shaType, helper);
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     Game.CurrentGame.Emit(GameEvent.PlayerIsAboutToUseCard, new PlayerIsAboutToUseOrPlayCardEventArgs() { Source = source, Verifier = v1 });
     source.AskForCardUsage(prompt, v1, out skill, out cards, out players);
     GameEventArgs args = new GameEventArgs();
     args.Source = source;
     args.Targets = new List<Player>(players);
     if (target != null) args.Targets.Add(target);
     args.Skill = skill == null ? new CardWrapper(source, shaType, notifyShaSound) : skill;
     args.Cards = cards;
     CompositeCard card = null;
     if (skill != null)
     {
         List<Card> dummyCards = new List<Card>() { new Card() { Type = shaType, Place = new DeckPlace(null, DeckType.None) } };
         (skill as CardTransformSkill).TryTransform(dummyCards, null, out card);
         //虚拟的杀是不能有子卡的。
         card.Subcards.Clear();
     }
     //在触发 CommitActionToTargets 的时候,只有在这里,args.Card才会被赋值,且为CompositeCard
     args.Card = card;
     if (args.Targets.Count == 0)
     {
         foreach (Player p in Game.CurrentGame.AlivePlayers)
         {
             if (p != source && v1.FastVerify(source, skill, cards, new List<Player>() { p }) != VerifierResult.Fail)
             {
                 args.Targets.Add(p);
                 break;
             }
         }
     }
     try
     {
         Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
     }
     catch (TriggerResultException)
     {
         //程序总是不应该执行到这里的
         Trace.Assert(false);
     }
 }
All Usage Examples Of Sanguosha.Expansions.Basic.Cards.DummyShaVerifier::FastVerify