Esempio n. 1
0
        void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            ISkill        skill;
            List <Card>   cards;
            List <Player> players;

            if (Owner.AskForCardUsage(new CardUsagePrompt("XiaoXi"), new XiaoXiVerifier(verifier), out skill, out cards, out players))
            {
                NotifySkillUse();
                GameEventArgs args = new GameEventArgs();
                Owner[Sha.NumberOfShaUsed]--;
                args.Source  = Owner;
                args.Targets = players;
                args.Skill   = skill == null ? new CardWrapper(Owner, new RegularSha(), false) : skill;
                args.Cards   = new List <Card>();
                CardTransformSkill transformSkill = skill as CardTransformSkill;
                if (transformSkill != null)
                {
                    CompositeCard card;
                    transformSkill.TryTransform(new List <Card>()
                    {
                        new Card()
                        {
                            Type = new RegularSha(), Place = new DeckPlace(null, DeckType.None)
                        }
                    }, players, out card);
                    card.Subcards.Clear();
                    args.Card = card;
                }
                Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
            }
        }
        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));
        }
Esempio n. 3
0
 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 ((cards == null || cards.Count == 0) && skill == null)
     {
         return(VerifierResult.Fail);
     }
     if (skill is CheatSkill)
     {
         if (!Game.CurrentGame.Settings.CheatEnabled)
         {
             return(VerifierResult.Fail);
         }
         return(VerifierResult.Success);
     }
     else if (skill is ActiveSkill)
     {
         GameEventArgs arg = new GameEventArgs();
         arg.Source  = Game.CurrentGame.CurrentPlayer;
         arg.Targets = players;
         arg.Cards   = cards;
         return(((ActiveSkill)skill).Validate(arg));
     }
     else if (skill is CardTransformSkill)
     {
         CardTransformSkill s = (CardTransformSkill)skill;
         CompositeCard      result;
         VerifierResult     ret = s.TryTransform(cards, players, out result);
         if (ret == VerifierResult.Success)
         {
             return(result.Type.Verify(Game.CurrentGame.CurrentPlayer, skill, cards, players));
         }
         if (ret == VerifierResult.Partial && players != null && players.Count != 0)
         {
             return(VerifierResult.Fail);
         }
         return(ret);
     }
     else if (skill != null)
     {
         return(VerifierResult.Fail);
     }
     if (cards[0].Place.DeckType != DeckType.Hand)
     {
         return(VerifierResult.Fail);
     }
     return(cards[0].Type.Verify(Game.CurrentGame.CurrentPlayer, skill, cards, players));
 }
Esempio n. 4
0
        void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            ISkill          skill;
            List <Card>     cards;
            List <Player>   players;
            bool            shensu1       = gameEvent == GameEvent.PhaseOutEvents[TurnPhase.Start];
            CardUsagePrompt shensu1Prompt = new CardUsagePrompt("ShenSu1", this);
            CardUsagePrompt shensu2Prompt = new CardUsagePrompt("ShenSu2", this);

            if (Owner.AskForCardUsage(shensu1 ? shensu1Prompt : shensu2Prompt, new ShenSuVerifier(shensu1, verifier), out skill, out cards, out players))
            {
                NotifySkillUse();
                if (!shensu1)
                {
                    Game.CurrentGame.HandleCardDiscard(Owner, cards);
                }
                GameEventArgs args = new GameEventArgs();
                Owner[Sha.NumberOfShaUsed]--;
                args.Source  = Owner;
                args.Targets = players;
                args.Skill   = skill == null ? new CardWrapper(Owner, new RegularSha(), false) : skill;
                args.Cards   = new List <Card>();
                CardTransformSkill transformSkill = skill as CardTransformSkill;
                if (transformSkill != null)
                {
                    CompositeCard card;
                    transformSkill.TryTransform(new List <Card>()
                    {
                        new Card()
                        {
                            Type = new RegularSha(), Place = new DeckPlace(null, DeckType.None)
                        }
                    }, players, out card);
                    card.Subcards.Clear();
                    args.Card = card;
                }
                Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
                if (shensu1)
                {
                    Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Judge);
                    Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Draw);
                }
                else
                {
                    Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Play);
                }
            }
        }
Esempio n. 5
0
            public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
            {
                Player currentPlayer = Game.CurrentGame.CurrentPlayer;

                Trace.TraceInformation("Player {0} action.", currentPlayer.Id);
                while (!currentPlayer.IsDead)
                {
                    bool newturn = false;
                    foreach (var pl in Game.CurrentGame.Players)
                    {
                        if (GetReadyToGo(pl) && pl == currentPlayer)
                        {
                            newturn = true;
                        }
                    }
                    if (newturn)
                    {
                        return;
                    }
                    Trace.Assert(Game.CurrentGame.UiProxies.ContainsKey(currentPlayer));
                    IPlayerProxy              proxy = Game.CurrentGame.UiProxies[currentPlayer];
                    ISkill                    skill;
                    List <Card>               cards;
                    List <Player>             players;
                    PlayerActionStageVerifier v = new PlayerActionStageVerifier();
                    Game.CurrentGame.Emit(GameEvent.PlayerIsAboutToUseCard, new PlayerIsAboutToUseOrPlayCardEventArgs()
                    {
                        Source = currentPlayer, Verifier = v
                    });
                    if (!proxy.AskForCardUsage(new Prompt(Prompt.PlayingPhasePrompt), v, out skill, out cards, out players))
                    {
                        break;
                    }
                    if (skill != null)
                    {
                        if (skill is CheatSkill)
                        {
                            if (!Game.CurrentGame.Settings.CheatEnabled)
                            {
                                break;
                            }
                            CheatSkill cs = skill as CheatSkill;
                            if (cs.CheatType == CheatType.Card)
                            {
                                if (Game.CurrentGame.IsClient)
                                {
                                    Game.CurrentGame.SyncUnknownLocationCardAll(null);
                                }
                                else
                                {
                                    foreach (var searchCard in Game.CurrentGame.CardSet)
                                    {
                                        if (searchCard.Id == cs.CardId)
                                        {
                                            Game.CurrentGame.SyncUnknownLocationCardAll(searchCard);
                                            break;
                                        }
                                    }
                                }
                                foreach (var searchCard in Game.CurrentGame.CardSet)
                                {
                                    if (searchCard.Id == cs.CardId)
                                    {
                                        CardsMovement move = new CardsMovement();
                                        move.Cards = new List <Card>()
                                        {
                                            searchCard
                                        };
                                        move.To     = new DeckPlace(Game.CurrentGame.CurrentPlayer, DeckType.Hand);
                                        move.Helper = new MovementHelper();
                                        Game.CurrentGame.MoveCards(move);
                                        break;
                                    }
                                }
                            }
                            else if (cs.CheatType == CheatType.Skill)
                            {
                                foreach (var hero in Game.CurrentGame.OriginalCardSet)
                                {
                                    bool found = false;
                                    if (hero.Type is HeroCardHandler)
                                    {
                                        foreach (var sk in (hero.Type as HeroCardHandler).Hero.Skills)
                                        {
                                            if (sk.GetType().Name == cs.SkillName)
                                            {
                                                Game.CurrentGame.PlayerAcquireAdditionalSkill(currentPlayer, sk.Clone() as ISkill, currentPlayer.Hero);
                                                found = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (found)
                                    {
                                        break;
                                    }
                                }
                            }
                            continue;
                        }
                        else if (skill is ActiveSkill)
                        {
                            GameEventArgs arg = new GameEventArgs();
                            arg.Source  = Game.CurrentGame.CurrentPlayer;
                            arg.Targets = players;
                            arg.Cards   = cards;
                            ((ActiveSkill)skill).NotifyAndCommit(arg);
                            Game.CurrentGame.NotificationProxy.NotifyActionComplete();
                            Game.CurrentGame.LastAction = skill;
                            continue;
                        }
                        CompositeCard      c;
                        CardTransformSkill s = (CardTransformSkill)skill;
                        VerifierResult     r = s.TryTransform(cards, players, out c);
                        Trace.TraceInformation("Player used {0}", c.Type);
                    }
                    else
                    {
                        Trace.Assert(cards[0] != null && cards.Count == 1);
                        Trace.TraceInformation("Player used {0}", cards[0].Type);
                    }
                    try
                    {
                        Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, new Triggers.GameEventArgs()
                        {
                            Skill = skill, Source = Game.CurrentGame.CurrentPlayer, Targets = players, Cards = cards
                        });
                    }
                    catch (TriggerResultException)
                    {
                    }
                    Game.CurrentGame.NotificationProxy.NotifyActionComplete();
                    Game.CurrentGame.LastAction = skill;
                }
            }
 public override VerifierResult FastVerify(Player source, ISkill skill, List <Card> cards, List <Player> players)
 {
     if (players != null && players.Count != 0)
     {
         return(VerifierResult.Fail);
     }
     if (skill != null)
     {
         CompositeCard card;
         if (!(skill is CardTransformSkill))
         {
             return(VerifierResult.Fail);
         }
         CardTransformSkill s = (CardTransformSkill)skill;
         VerifierResult     r = s.TryTransform(cards, players, out card, !isUseCard);
         if (r != VerifierResult.Success)
         {
             return(r);
         }
         if (!Match(card))
         {
             return(VerifierResult.Fail);
         }
         if (isUseCard)
         {
             if (!Game.CurrentGame.PlayerCanUseCard(source, card))
             {
                 return(VerifierResult.Fail);
             }
         }
         else
         {
             if (!Game.CurrentGame.PlayerCanPlayCard(source, card))
             {
                 return(VerifierResult.Fail);
             }
         }
         return(VerifierResult.Success);
     }
     if (cards != null && cards.Count > 1)
     {
         return(VerifierResult.Fail);
     }
     if (cards == null || cards.Count == 0)
     {
         return(VerifierResult.Partial);
     }
     if (cards[0].Place.DeckType != DeckType.Hand)
     {
         return(VerifierResult.Fail);
     }
     if (!Match(cards[0]))
     {
         return(VerifierResult.Fail);
     }
     if (isUseCard)
     {
         if (!Game.CurrentGame.PlayerCanUseCard(source, cards[0]))
         {
             return(VerifierResult.Fail);
         }
     }
     else
     {
         if (!Game.CurrentGame.PlayerCanPlayCard(source, cards[0]))
         {
             return(VerifierResult.Fail);
         }
     }
     return(VerifierResult.Success);
 }
Esempio n. 7
0
        /// <summary>
        /// 卡牌UI合法性检查
        /// </summary>
        /// <param name="source"></param>
        /// <param name="skill"></param>
        /// <param name="cards"></param>
        /// <param name="targets"></param>
        /// <param name="notReforging">不是重铸中,检查PlayerCanUseCard</param>
        /// <returns></returns>
        protected VerifierResult VerifyHelper(Player source, ISkill skill, List <Card> cards, List <Player> targets, bool isReforging)
        {
            ICard card;

            if (skill != null)
            {
                CompositeCard c;
                if (skill is CardTransformSkill)
                {
                    CardTransformSkill s = skill as CardTransformSkill;
                    VerifierResult     r = s.TryTransform(cards, targets, out c);
                    if (c != null && c.Type != null && !(this.GetType().IsAssignableFrom(c.Type.GetType())))
                    {
                        return(VerifierResult.Fail);
                    }
                    if (r != VerifierResult.Success)
                    {
                        return(r);
                    }
                    if (!isReforging)
                    {
                        if (!Game.CurrentGame.PlayerCanUseCard(source, c))
                        {
                            return(VerifierResult.Fail);
                        }
                    }
                    HoldInTemp(c.Subcards);
                    card = c;
                }
                else
                {
                    return(VerifierResult.Fail);
                }
            }
            else
            {
                if (cards == null || cards.Count != 1)
                {
                    return(VerifierResult.Fail);
                }
                card = cards[0];
                if (!(this.GetType().IsAssignableFrom(card.Type.GetType())))
                {
                    return(VerifierResult.Fail);
                }

                if (!isReforging)
                {
                    if (!Game.CurrentGame.PlayerCanUseCard(source, card))
                    {
                        return(VerifierResult.Fail);
                    }
                }
                HoldInTemp(cards);
            }

            var targetCheck = ActualTargets(source, targets, card);

            if (targetCheck != null && targetCheck.Count != 0)
            {
                if (!isReforging)
                {
                    if (!Game.CurrentGame.PlayerCanBeTargeted(source, targetCheck, card))
                    {
                        ReleaseHoldInTemp();
                        return(VerifierResult.Fail);
                    }
                }
            }
            VerifierResult ret = Verify(source, card, targets);

            ReleaseHoldInTemp();
            return(ret);
        }