Beispiel #1
0
        public void freezeTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });
            THHPlayer defaultPlayer = game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 30));
            THHPlayer elusivePlayer = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 28)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <TestFreeze>(), 2)));

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == DefaultServant.ID), 0);
            //玩家0拍白板一张

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <TestFreeze>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.hand.First(c => c.define.id == TestFreeze.ID), 0, defaultPlayer.field);
            //玩家1释放冰环

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdAttack(game, defaultPlayer.field[0], elusivePlayer.master); //被冻结的随从无法攻击
            defaultPlayer.cmdTurnEnd(game);                                              //回合结束,随从解冻

            elusivePlayer.cmdTurnEnd(game);

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdAttack(game, defaultPlayer.field[0], elusivePlayer.master);//已解除冰冻的随从可以攻击
            Assert.AreEqual(29, elusivePlayer.master.getCurrentLife(game));

            game.Dispose();
        }
Beispiel #2
0
        public void ElusiveTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });
            THHPlayer defaultPlayer = game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 28)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <TestSpellCard>(), 2)));
            THHPlayer elusivePlayer = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 29)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <ElusiveServant>(), 1)));

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == DefaultServant.ID), 0);

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <ElusiveServant>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.hand.First(c => c.define.id == ElusiveServant.ID), 0);

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <TestSpellCard>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == TestSpellCard.ID), 0, defaultPlayer.field[0]);
            Assert.AreEqual(6, defaultPlayer.field[0].getCurrentLife(game)); //没有魔免的可以被法术指定
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == TestSpellCard.ID), 0, elusivePlayer.field[0]);
            Assert.AreEqual(3, elusivePlayer.field[0].getCurrentLife(game)); //魔免无法被法术指定

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <TestDamageSkill>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.skill, 0, defaultPlayer.field[0]);
            Assert.AreEqual(5, defaultPlayer.field[0].getCurrentLife(game));//没有魔免的可以被技能指定
            elusivePlayer.cmdTurnEnd(game);

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <TestDamageSkill>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.skill, 0, elusivePlayer.field[0]);
            Assert.AreEqual(3, elusivePlayer.field[0].getCurrentLife(game));//魔免无法被技能指定

            game.Dispose();
        }
        /// <summary>
        /// 创建并开始本地游戏
        /// </summary>
        public void startLocalGame()
        {
            game = new THHGame(_option, getManager <CardManager>().GetCardDefines())
            {
                answers  = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(),
                triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(),
                time     = new GameObject(nameof(TimeManager)).AddComponent <TimeManager>(),
                logger   = new UnityLogger()
            };
            (game.answers as AnswerManager).game = game;

            //检查卡组合法性
            int[] deck = _deck;
            checkDeckValid(deck);

            THHPlayer localPlayer = game.createPlayer(1, "本地玩家", game.getCardDefine(deck[0]) as MasterCardDefine,
                                                      deck.Skip(1).Select(id => game.getCardDefine(id)));
            THHPlayer aiPlayer = game.createPlayer(2, "AI", game.getCardDefine(deck[0]) as MasterCardDefine,
                                                   deck.Skip(1).Select(id => game.getCardDefine(id)));

            displayGameUI(localPlayer);
            //AI玩家用AI
            new AI(game, aiPlayer);

            game.triggers.onEventAfter += onEventAfter;
            gameTask = game.run();
        }
Beispiel #4
0
        public IEnumerator calcActionsTest_Turn1()
        {
            THHGame   game   = TestGameflow.initGameWithoutPlayers(null, GameOption.Default);
            THHPlayer player = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant>(), 30));

            game.createPlayer(2, "玩家2", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant>(), 30));
            game.logger.log("Force Init");
            AI ai = new AI(game, player, false);

            _ = game.run();
            yield return(new WaitForSeconds(.1f));

            game.players[0].cmdInitReplace(game);
            game.players[1].cmdInitReplace(game);
            yield return(new WaitForSeconds(.1f));

            if (game.sortedPlayers[0] != player)
            {
                game.sortedPlayers[0].cmdTurnEnd(game);
                yield return(new WaitForSeconds(.1f));
            }
            var actions = ai.calcActions(game, player);

            Assert.AreEqual(player.hand.count, actions.Count);
            UseResponse use = actions.Keys.First() as UseResponse;

            Assert.NotNull(use);
        }
        public void SkillAndSpellCardTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 28)
                              .Concat(Enumerable.Repeat(game.getCardDefine <DefaultServant>(), 2)));
            game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <TestSpellCard>(), 1)));
            game.run();
            game.sortedPlayers[0].cmdInitReplace(game);
            game.sortedPlayers[1].cmdInitReplace(game);

            game.sortedPlayers[0].cmdTurnEnd(game);
            game.sortedPlayers[1].cmdUse(game, game.sortedPlayers[1].hand[0], 0);
            game.sortedPlayers[1].cmdTurnEnd(game);
            int gemNum = game.sortedPlayers[0].gem;

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].skill, 0, game.sortedPlayers[1].field[0]);
            Assert.True(game.sortedPlayers[0].skill.isUsed(game));                   //技能已使用
            Assert.AreEqual(6, game.sortedPlayers[1].field[0].getCurrentLife(game)); //敌方随从受到伤害
            Assert.AreEqual(1, gemNum - game.sortedPlayers[0].gem);                  //水晶减1
            gemNum = game.sortedPlayers[0].gem;
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0, game.sortedPlayers[1].field[0]);
            Assert.AreEqual(5, game.sortedPlayers[1].field[0].getCurrentLife(game));
            Assert.AreEqual(1, gemNum - game.sortedPlayers[0].gem);     //水晶减1
        }
Beispiel #6
0
        /// <summary>
        /// 创建并开始本地游戏
        /// </summary>
        public void startLocalGame()
        {
            _ui.Game.GameResultDialog.hide();
            if (_useTimeAsRandomSeed)
            {
                _option.randomSeed = (int)DateTime.Now.ToBinary();
            }
            game = new THHGame(_option, getManager <CardManager>().GetCardDefines())
            {
                answers  = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(),
                triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(),
                time     = new GameObject(nameof(TimeManager)).AddComponent <TimeManager>(),
                logger   = new UnityLogger()
            };
            (game.answers as AnswerManager).game = game;

            //检查卡组合法性
            int[] deck = _deck;
            checkDeckValid(deck);

            CardDefine playerMaster = game.getCardDefine(deck[0]);

            CardDefine[] playerDeck  = deck.Skip(1).Select(id => game.getCardDefine(id)).ToArray();
            THHPlayer    localPlayer = game.createPlayer(1, "本地玩家", playerMaster as MasterCardDefine,
                                                         playerDeck);
            THHPlayer aiPlayer = game.createPlayer(2, "AI", playerMaster as MasterCardDefine,
                                                   deck.Skip(1).Select(id => game.getCardDefine(id)));

            displayGameUI(localPlayer);
            //AI玩家用AI
            new AI(game, aiPlayer);
            gameTask = game.run();
        }
        public void flameFairyTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });                                                                                                                                //首先,上来先新建一个不带玩家的游戏

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <FlameFairy>() as CardDefine, 30)); //创建两个玩家,给他们设置初始英雄,套牌
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <FlameFairy>() as CardDefine, 30));
            game.run();                                                                                                                        //运行游戏

            //炎之妖精 战吼:对一个随机敌方随从造成1点伤害
            //那么我们要测试这个战吼内容

            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 1);

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);                                                     //第一个行动的玩家使用手上的第一张牌,反正满手都是炎之妖精随便用
            Assert.IsInstanceOf <FlameFairy>(game.sortedPlayers[0].field[0].define);                                                  //预期场上拍了一个炎之妖精
            //不过因为对方场上没有随从,所以啥事也没发生。
            game.sortedPlayers[0].cmdTurnEnd(game);                                                                                   //第一个行动的玩家回合结束
            game.sortedPlayers[1].cmdUse(game, game.sortedPlayers[1].hand[0], 0);
            Assert.IsInstanceOf <FlameFairy>(game.sortedPlayers[1].field[0].define);                                                  //第二个行动的玩家拍一个炎之妖精,这个时候应该触发战吼的
            Assert.AreEqual(0, game.sortedPlayers[0].field.count);                                                                    //对面的妖精应该被打死了
            var damage = game.triggers.getRecordedEvents().LastOrDefault(e => e is THHCard.DamageEventArg) as THHCard.DamageEventArg; //这会产生一个伤害事件

            Assert.AreEqual(1, damage.value);                                                                                         //伤害值为1

            //大概就是这样了,稍微测试一下保证每一张卡都在正常工作吧,能减少很多bug。
            //出了个随从重名的小问题,测试结果看看Log还是挺正常的,那就没有问题了。
            //做这个测试是为了防止以后对系统的改动导致已经做好的卡失效,这样能防止很多bug。
        }
        public void StealthTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <StealthServant>(), 1)));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <StealthServant>(), 1)));
            game.run();
            game.sortedPlayers[0].cmdInitReplace(game);
            game.sortedPlayers[1].cmdInitReplace(game);

            game.sortedPlayers[0].cmdTurnEnd(game);
            game.sortedPlayers[1].cmdUse(game, game.sortedPlayers[1].hand[1], 0);
            game.sortedPlayers[1].cmdTurnEnd(game);
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 0);
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 1);
            Assert.True(game.sortedPlayers[0].field[1].isStealth());
            game.sortedPlayers[0].cmdTurnEnd(game);


            game.sortedPlayers[1].cmdAttack(game, game.sortedPlayers[1].field[0], game.sortedPlayers[0].field[1]);
            //game.sortedPlayers[1].cmdAttack(game, game.sortedPlayers[1].field[0], game.sortedPlayers[1].master);

            Assert.AreEqual(7, game.sortedPlayers[1].field[0].getCurrentLife());
            game.sortedPlayers[1].cmdAttack(game, game.sortedPlayers[1].field[0], game.sortedPlayers[0].field[0]);
            Assert.AreEqual(6, game.sortedPlayers[1].field[0].getCurrentLife());
            game.sortedPlayers[1].cmdTurnEnd(game);
            game.sortedPlayers[0].cmdAttack(game, game.sortedPlayers[0].field[1], game.sortedPlayers[1].field[0]);
            Assert.False(game.sortedPlayers[0].field[1].isStealth());
        }
        public void SunnyMilkTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <SunnyMilk>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <SunnyMilk>() as CardDefine, 30));

            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 2);

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);
            Assert.True(game.sortedPlayers[0].field[0].isStealth());
        }
        public void startRemoteGame(ClientManager client, GameOption option, THHRoomPlayerInfo[] players)
        {
            game = new THHGame(option, getManager <CardManager>().GetCardDefines())
            {
                answers  = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(),
                triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(),
                time     = new GameObject(nameof(TimeManager)).AddComponent <TimeManager>(),
                logger   = new ULogger()
            };
            (game.answers as AnswerManager).client = client;

            foreach (var info in players)
            {
                checkDeckValid(info.deck);

                THHPlayer player = game.createPlayer(info.id, info.name, game.getCardDefine(info.deck[0]) as MasterCardDefine,
                                                     info.deck.Skip(1).Select(id => game.getCardDefine(id)));
                if (client.id == info.id)
                {
                    displayGameUI(player);
                }
            }
            game.triggers.onEventAfter += onEventAfter;
            gameTask = game.run();
        }
Beispiel #11
0
        public static THHGame initStandardGame(string name, int[] playersId, MasterCardDefine[] masters, CardDefine[][] decks, GameOption option)
        {
            THHGame game = initGameWithoutPlayers(name, option);

            if (playersId == null)
            {
                playersId = new int[] { 1, 2 }
            }
            ;
            if (masters == null)
            {
                masters = Enumerable.Repeat(game.getCardDefine <TestMaster>(), playersId.Length).ToArray();
            }
            if (decks == null)
            {
                decks = Enumerable.Repeat(Enumerable.Repeat(game.getCardDefine <TestServant>(), 30).ToArray(), playersId.Length).ToArray();
            }
            if (option == null)
            {
                option = GameOption.Default;
            }
            for (int i = 0; i < playersId.Length; i++)
            {
                game.createPlayer(playersId[i], "玩家" + playersId[i], masters[i], decks[i]);
            }
            return(game);
        }
Beispiel #12
0
        public IEnumerator run_InitReplaceTest()
        {
            THHGame   game   = TestGameflow.initGameWithoutPlayers(null, GameOption.Default);
            THHPlayer player = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant>(), 30));

            game.createPlayer(2, "玩家2", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant>(), 30));
            AI ai = new AI(game, player);

            _ = game.run();
            yield return(new WaitForSeconds(.1f));

            game.players[1].cmdInitReplace(game);
            yield return(new WaitForSeconds(1f));

            Assert.True(game.triggers.getRecordedEvents().Any(e => e is THHGame.StartEventArg));
        }
Beispiel #13
0
        /// <summary>
        /// 初始化对局
        /// </summary>
        /// <typeparam name="T1">卡牌1</typeparam>
        /// <typeparam name="T2">卡牌2</typeparam>
        /// <param name="card1Count"></param>
        /// <param name="card2Count"></param>
        /// <returns></returns>
        public THHGame GameInitWithoutPlayer <T1, T2>(int card1Count, int card2Count) where T1 : CardDefine where T2 : CardDefine
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <T1>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <T2>(), 1)));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <T1>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <T2>(), 1)));
            game.run();
            game.sortedPlayers[0].cmdInitReplace(game);
            game.sortedPlayers[1].cmdInitReplace(game);
            return(game);
        }
        public void BeerFairyTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <BeerFairy>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <BeerFairy>() as CardDefine, 30));
            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 2);

            int handCardNum = game.sortedPlayers[0].hand.count;

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);
            Assert.AreEqual(handCardNum, game.sortedPlayers[0].hand.count);   //使用了一张牌后,又获得一张牌,手牌数没变
            Assert.True(game.sortedPlayers[0].hand[handCardNum - 1].GetType().IsSubclassOf(typeof(ServantCardDefine)));
        }
        public void LunaChildTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <LunaChild>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <LunaChild>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <DefaultServant>(), 1)));
            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 3);

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);
            Assert.False(game.sortedPlayers[0].field[0].isStealth());   //default随从一开始没有潜行
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 1, game.sortedPlayers[0].field[0]);
            Assert.True(game.sortedPlayers[0].field[0].isStealth());    //露娜出场后default随从变为潜行状态
        }
        public void drizzleFairyTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <DrizzleFairy>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <FantasySeal>(), 1)));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <DrizzleFairy>() as CardDefine, 29)
                              .Concat(Enumerable.Repeat(game.getCardDefine <FantasySeal>(), 1)));
            game.run();
            game.sortedPlayers[0].cmdInitReplace(game);
            game.sortedPlayers[1].cmdInitReplace(game);

            //第一回合
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 0);

            game.sortedPlayers[0].cmdTurnEnd(game);

            game.sortedPlayers[1].cmdUse(game, game.sortedPlayers[1].hand[1], 0);

            game.sortedPlayers[1].cmdTurnEnd(game);
            //第二回合
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 0);
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 0);

            game.sortedPlayers[0].cmdTurnEnd(game);
            game.sortedPlayers[1].cmdTurnEnd(game);
            //第三回合,共计4个妖精
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 0);

            game.sortedPlayers[0].cmdTurnEnd(game);
            game.sortedPlayers[1].cmdTurnEnd(game);
            //第四回合
            game.sortedPlayers[0].cmdTurnEnd(game);

            game.sortedPlayers[1].cmdUse(game, game.sortedPlayers[1].hand[0], 0);

            //对3个随从造成3点伤害
            THHCard.DamageEventArg damage = game.triggers.getRecordedEvents().LastOrDefault(e => e is THHCard.DamageEventArg) as THHCard.DamageEventArg;
            Assert.AreEqual(3, damage.cards.Length);
            Assert.AreEqual(3, damage.value);
            Assert.AreEqual(1, game.sortedPlayers[0].field.count);
        }
Beispiel #17
0
        public void mountainGaintTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <MountainGaint>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <MountainGaint>() as CardDefine, 30));

            game.skipTurnWhen(() => game.sortedPlayers[0].hand.count < 10);

            Assert.AreEqual(3, game.sortedPlayers[0].hand[0].getCost(game));
            int gemNow = game.sortedPlayers[0].gem;

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);
            Assert.AreEqual(gemNow - 3, game.sortedPlayers[0].gem);
        }
Beispiel #18
0
        public IEnumerator sorcererApprenticeTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster>(),
                              Enumerable.Repeat(game.getCardDefine <FireBall>(), 29).Cast <CardDefine>()
                              .Concat(Enumerable.Repeat(game.getCardDefine <SorcererApprentice>(), 1).Cast <CardDefine>()));
            game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(),
                              Enumerable.Repeat(game.getCardDefine <FireBall>(), 29).Cast <CardDefine>()
                              .Concat(Enumerable.Repeat(game.getCardDefine <SorcererApprentice>(), 1).Cast <CardDefine>()));

            game.skipTurnUntil(() =>
                               game.currentPlayer == game.players[0] &&
                               game.players[0].gem >= game.getCardDefine <SorcererApprentice>().cost&&
                               game.players[0].hand.Any(c => c.define is SorcererApprentice));
            Assert.True(game.players[0].hand.Where(c => c.define is FireBall).All(c => c.getCost(game) == 4)); //火球术全是4费
            var task = game.players[0].cmdUse(game, game.players[0].hand.getCard <SorcererApprentice>());      //使用哀绿

            yield return(TestHelper.waitTask(task));

            Assert.True(game.players[0].field.Any(c => c.define is SorcererApprentice));
            Assert.True(game.players[0].hand.Where(c => c.define is FireBall).All(c => c.getCost(game) == 3)); //火球术全是3费
            task = game.players[0].draw(game);                                                                 //抽一张火球
            yield return(TestHelper.waitTask(task));

            Card card = game.players[0].hand.right;

            Assert.AreEqual(3, card.getCost(game));
            task = card.pile.moveTo(game, card, game.players[0].grave);//把火球送入墓地
            yield return(TestHelper.waitTask(task));

            Assert.AreEqual(4, card.getCost(game));
            yield return(game.players[0].field[0].die(game).wait());//杀死哀绿

            Assert.True(game.players[0].hand.getCards <FireBall>().All(c => c.getCost(game) == 4));
            yield return(game.players[0].draw(game).wait());//再抽一张火球术

            Assert.True(game.players[0].hand.getCards <FireBall>().All(c => c.getCost(game) == 4));
        }
        public void PatchouliSilentSeleneTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });
            THHPlayer defaultPlayer = game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <MissingSpecter>() as CardDefine, 30));
            THHPlayer elusivePlayer = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <SilentSelene>() as CardDefine, 28)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <BestMagic>(), 2)));

            game.skipTurnUntil(() => game.currentPlayer == defaultPlayer && defaultPlayer.gem >= game.getCardDefine <MissingSpecter>().cost);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.getCard <MissingSpecter>());

            game.skipTurnUntil(() => game.currentPlayer == elusivePlayer && elusivePlayer.gem >= 10);
            elusivePlayer.cmdUse(game, elusivePlayer.hand.getCard <BestMagic>());//使用秘藏魔法减费
            Assert.True(game.players[0].hand.Where(c => c.define is SilentSelene).All(c => c.getCost(game) == 7));
            elusivePlayer.cmdUse(game, elusivePlayer.hand.getCard <SilentSelene>());

            game.Dispose();
        }
        public void BeerFairyTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <BeerFairy>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <BeerFairy>() as CardDefine, 30));
            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 4);

            var s = game.sortedPlayers[0].hand[0];

            game.sortedPlayers[0].cmdUse(game, s, 0);
            Assert.True(game.sortedPlayers[0].field.Contains(s));
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0, game.sortedPlayers[0].field[0]);
            Assert.True(game.sortedPlayers[0].hand.Contains(s));
            //TODO:落叶,这里就只有两个小熊猫相互测试,还不够。
            //还要测试手牌满了的情况下,小熊猫被挤死了
        }
Beispiel #21
0
        public IEnumerator fireBallTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <FireBall>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <FireBall>() as CardDefine, 30));

            game.skipTurnUntil(() => game.players[0].hand.count > 0);
            Assert.False(game.players[0].hand[0].isUsable(game, game.players[0], out _));
            game.skipTurnUntil(() => game.players[0].gem == 4);
            Assert.True(game.players[0].hand[0].isUsable(game, game.players[0], out _));
            Assert.True(game.players[0].hand[0].isValidTarget(game, game.players[1].master));
            game.players[0].cmdUse(game, game.players[0].hand[0], 0, game.players[1].master);
            yield return(new WaitUntil(() => game.triggers.getRecordedEvents().Any(e => e is THHCard.DamageEventArg)));

            Assert.NotNull(game.triggers.getRecordedEvents().OfType <THHCard.DamageEventArg>().Last());
        }
Beispiel #22
0
        public static void createGame(out THHGame game, out THHPlayer you, out THHPlayer oppo, GameOption option, params KeyValuePair <int, int>[] yourDeck)
        {
            game = initGameWithoutPlayers(null, option);
            IEnumerable <CardDefine> yourTrueDeck = yourDeck.Length > 0 ?
                                                    Enumerable.Repeat(game.getCardDefine(yourDeck[0].Key), yourDeck[0].Value) :
                                                    Enumerable.Repeat(game.getCardDefine(DefaultServant.ID), 30);

            for (int i = 1; i < yourDeck.Length; i++)
            {
                yourTrueDeck = yourTrueDeck.Concat(Enumerable.Repeat(game.getCardDefine(yourDeck[i].Key), yourDeck[i].Value));
            }
            int count = yourTrueDeck.Count();

            if (count < 30)
            {
                yourTrueDeck = yourTrueDeck.Concat(Enumerable.Repeat(game.getCardDefine <DefaultServant>(), 30 - count));
            }
            yourTrueDeck = yourTrueDeck.Reverse();
            you          = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), yourTrueDeck);
            oppo         = game.createPlayer(2, "玩家2", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 30));
        }
        public IEnumerator effectRegisterTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, GameOption.Default);

            game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant_TurnEndEffect>(), 30));
            game.createPlayer(2, "玩家2", game.getCardDefine <TestMaster>(), Enumerable.Repeat(game.getCardDefine <TestServant_TurnEndEffect>(), 30));
            _ = game.run();
            yield return(new WaitForSeconds(.1f));

            game.players[0].cmdInitReplace(game);
            game.players[1].cmdInitReplace(game);
            yield return(new WaitForSeconds(.1f));

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0);
            yield return(new WaitForSeconds(.1f));

            game.sortedPlayers[0].cmdTurnEnd(game);
            yield return(new WaitForSeconds(.1f));

            Assert.True(game.sortedPlayers[0].field[0].getProp <bool>("TestResult"));
        }
Beispiel #24
0
        public void startGame()
        {
            game = new THHGame(_option, getManager <CardManager>().GetCardDefines())
            {
                answers  = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(),
                triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(),
                logger   = new UnityLogger()
            };
            (game.answers as AnswerManager).game = game;
            THHPlayer localPlayer = game.createPlayer(1, "本地玩家", game.getCardDefine(_deck[0]) as MasterCardDefine,
                                                      _deck.Skip(1).Select(id => game.getCardDefine(id)));
            THHPlayer aiPlayer = game.createPlayer(2, "AI", game.getCardDefine(_deck[0]) as MasterCardDefine,
                                                   _deck.Skip(1).Select(id => game.getCardDefine(id)));

            //本地玩家用UI
            _ui.display(_ui.Game);
            _ui.Game.Table.setGame(game, localPlayer);
            //AI玩家用AI
            new AI(game, aiPlayer);
            game.triggers.onEventAfter += onEventAfter;
            gameTask = game.run();
        }
        public void PatchouliTrilithonShakeTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });
            THHPlayer defaultPlayer = game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 30));
            THHPlayer elusivePlayer = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 28)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <RockElement>(), 2)));

            defaultPlayer.cmdTurnEnd(game);

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <RockElement>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.hand.First(c => c.define.id == RockElement.ID), 0);

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == DefaultServant.ID), 0);

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <TrilithonShake>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdAttack(game, elusivePlayer.field[0], defaultPlayer.field[0]);
            game.Dispose();
        }
        public void StarSphereTest()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });

            game.createPlayer(0, "玩家0", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <LunaChild>() as CardDefine, 30));
            game.createPlayer(1, "玩家1", game.getCardDefine <Reimu>(), Enumerable.Repeat(game.getCardDefine <LunaChild>() as CardDefine, 28)
                              .Concat(Enumerable.Repeat(game.getCardDefine <SunnyMilk>(), 1))
                              .Concat(Enumerable.Repeat(game.getCardDefine <LunaChild>(), 1))
                              .Concat(Enumerable.Repeat(game.getCardDefine <DefaultServant>(), 1)));
            game.skipTurnWhen(() => game.sortedPlayers[0].gem < 9);

            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 0); //default
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[3], 1); //斯塔
            Assert.False(game.sortedPlayers[0].field[0].isStealth());             //没有桑尼和露娜,光环没起效
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[1], 2); //桑尼
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 3); //露娜
            game.sortedPlayers[0].cmdUse(game, game.sortedPlayers[0].hand[0], 4);
            Assert.True(game.sortedPlayers[0].field[2].isStealth());              //露娜和桑尼在场,光环起效
        }
        public void startGame()
        {
            game = new THHGame(_option, getManager <CardManager>().GetCardDefines())
            {
                answers  = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(),
                triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(),
                time     = new GameObject(nameof(TimeManager)).AddComponent <TimeManager>(),
                logger   = new UnityLogger()
            };
            (game.answers as AnswerManager).game = game;

            //检查卡组合法性
            if (game.getCardDefine(_deck[0]) == null)
            {
                UberDebug.LogError("非法角色ID" + _deck[0] + "被替换为灵梦");
                _deck[0] = game.getCardDefine <Reimu>().id;
            }
            for (int i = 1; i < _deck.Length; i++)
            {
                if (game.getCardDefine(_deck[i]) == null)
                {
                    UberDebug.LogError("非法随从ID" + _deck[i] + "被替换为小野菊");
                    _deck[i] = game.getCardDefine <RashFairy>().id;
                }
            }

            THHPlayer localPlayer = game.createPlayer(1, "本地玩家", game.getCardDefine(_deck[0]) as MasterCardDefine,
                                                      _deck.Skip(1).Select(id => game.getCardDefine(id)));
            THHPlayer aiPlayer = game.createPlayer(2, "AI", game.getCardDefine(_deck[0]) as MasterCardDefine,
                                                   _deck.Skip(1).Select(id => game.getCardDefine(id)));

            //本地玩家用UI
            _ui.display(_ui.Game);
            _ui.Game.Table.setGame(game, localPlayer);
            //AI玩家用AI
            new AI(game, aiPlayer);
            game.triggers.onEventAfter += onEventAfter;
            gameTask = game.run();
        }
Beispiel #28
0
        public void poisiousTest_ServantEffect()
        {
            THHGame game = TestGameflow.initGameWithoutPlayers(null, new GameOption()
            {
                shuffle = false
            });
            THHPlayer defaultPlayer = game.createPlayer(0, "玩家0", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 30));
            THHPlayer elusivePlayer = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster2>(), Enumerable.Repeat(game.getCardDefine <DefaultServant>() as CardDefine, 28)
                                                        .Concat(Enumerable.Repeat(game.getCardDefine <Priestess>(), 2)));

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == DefaultServant.ID), 0);
            //玩家0拍白板一张

            game.skipTurnUntil(() => elusivePlayer.gem >= game.getCardDefine <Priestess>().cost&& game.currentPlayer == elusivePlayer);
            elusivePlayer.cmdUse(game, elusivePlayer.hand.First(c => c.define.id == Priestess.ID), 0);
            //玩家1拍女祭司

            game.skipTurnUntil(() => defaultPlayer.gem >= game.getCardDefine <DefaultServant>().cost&& game.currentPlayer == defaultPlayer);
            defaultPlayer.cmdUse(game, defaultPlayer.hand.First(c => c.define.id == DefaultServant.ID), 1);

            game.Dispose();
        }
Beispiel #29
0
 public static void createGameWithoutDeck(out THHGame game, out THHPlayer you, out THHPlayer oppo, GameOption option = null)
 {
     game = initGameWithoutPlayers(null, option);
     you  = game.createPlayer(1, "玩家1", game.getCardDefine <TestMaster>(), null);
     oppo = game.createPlayer(2, "玩家2", game.getCardDefine <TestMaster>(), null);
 }
Beispiel #30
0
        public IEnumerator remotePVPSimulTest()
        {
            UnityLogger logger = new UnityLogger();
            HostManager host   = new GameObject(nameof(HostManager)).AddComponent <HostManager>();

            host.logger = logger;
            ClientManager local = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            local.logger = logger;
            //开房,打开Host,自己加入自己,房间应该有Option
            RoomInfo roomInfo = new RoomInfo();

            roomInfo.setOption(new GameOption());
            THHGame localGame = null;

            local.onConnected += () =>
            {
                //发送玩家信息
                RoomPlayerInfo playerInfo = new RoomPlayerInfo()
                {
                    id   = local.id,
                    name = "玩家" + local.id,
                };
                playerInfo.setDeck(new int[] { Reimu.ID }.Concat(Enumerable.Repeat(DrizzleFairy.ID, 30)).ToArray());
                return(local.send(playerInfo));
            };
            local.onReceive += (id, obj) =>
            {
                if (obj is RoomPlayerInfo newPlayerInfo)
                {
                    //收到玩家信息
                    RoomInfo newRoomInfo = new RoomInfo()
                    {
                        playerList = new List <RoomPlayerInfo>(roomInfo.playerList)
                    };
                    newRoomInfo.setOption(roomInfo.getOption());
                    newRoomInfo.playerList.Add(newPlayerInfo);
                    //发送房间信息
                    return(local.send(newRoomInfo));
                }
                else if (obj is RoomInfo newRoomInfo)
                {
                    roomInfo = newRoomInfo;
                    //收到房间信息
                    if (newRoomInfo.playerList.Count > 1)
                    {
                        localGame = TestGameflow.initGameWithoutPlayers("本地游戏", newRoomInfo.getOption());
                        (localGame.answers as AnswerManager).client = local;
                        foreach (var playerInfo in newRoomInfo.playerList)
                        {
                            localGame.createPlayer(playerInfo.id, "玩家" + playerInfo.id, localGame.getCardDefine <MasterCardDefine>(playerInfo.getDeck()[0]), playerInfo.getDeck().Skip(1).Select(did => localGame.getCardDefine(did)));
                        }
                        localGame.run();
                    }
                }
                return(Task.CompletedTask);
            };
            host.start();
            local.start();
            yield return(local.join(host.ip, host.port).wait());

            Assert.AreEqual(1, roomInfo.playerList.Count);

            ClientManager remote = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            remote.logger = logger;
            THHGame remoteGame = null;

            remote.onConnected += () =>
            {
                //发送玩家信息
                RoomPlayerInfo playerInfo = new RoomPlayerInfo()
                {
                    id   = remote.id,
                    name = "玩家" + remote.id
                };
                playerInfo.setDeck(new int[] { Reimu.ID }.Concat(Enumerable.Repeat(DrizzleFairy.ID, 30)).ToArray());
                return(remote.send(playerInfo));
            };
            remote.onReceive += (id, obj) =>
            {
                if (obj is RoomInfo newRoomInfo)
                {
                    //收到房间信息
                    if (newRoomInfo.playerList.Count > 1)
                    {
                        remoteGame = TestGameflow.initGameWithoutPlayers("远端游戏", newRoomInfo.getOption());
                        (remoteGame.answers as AnswerManager).client = remote;
                        foreach (var playerInfo in newRoomInfo.playerList)
                        {
                            remoteGame.createPlayer(playerInfo.id, "玩家" + playerInfo.id, remoteGame.getCardDefine <MasterCardDefine>(playerInfo.getDeck()[0]), playerInfo.getDeck().Skip(1).Select(did => remoteGame.getCardDefine(did)));
                        }
                        remoteGame.run();
                    }
                }
                return(Task.CompletedTask);
            };
            //加入房间
            remote.start();
            yield return(remote.join(host.ip, host.port).wait());

            //连接了,远程玩家把玩家信息发给本地,本地更新房间信息发给远端和开始游戏。
            yield return(new WaitUntil(() => localGame != null && remoteGame != null));

            Assert.True(localGame.isRunning);
            Assert.AreEqual(local.id, localGame.players[0].id);
            Assert.AreEqual(remote.id, localGame.players[1].id);
            Assert.True(remoteGame.isRunning);
            Assert.AreEqual(local.id, remoteGame.players[0].id);
            Assert.AreEqual(remote.id, remoteGame.players[1].id);

            THHPlayer localPlayer = localGame.getPlayer(local.id);

            Assert.AreEqual(0, localPlayer.id);
            yield return(new WaitUntil(() => localGame.answers.getRequests(localPlayer.id).FirstOrDefault() is InitReplaceRequest));

            Assert.Greater(localPlayer.init.count, 0);
            localPlayer.cmdInitReplace(localGame);
            yield return(new WaitUntil(() => localGame.answers.getResponse(localPlayer.id, localGame.answers.getRequests(localPlayer.id).FirstOrDefault()) is InitReplaceResponse));

            THHPlayer remotePlayer = remoteGame.getPlayer(remote.id);

            Assert.AreEqual(1, remotePlayer.id);
            yield return(new WaitUntil(() => remoteGame.answers.getRequests(remotePlayer.id).FirstOrDefault() is InitReplaceRequest));

            Assert.Greater(remotePlayer.init.count, 0);
            remotePlayer.cmdInitReplace(remoteGame);
            yield return(new WaitUntil(() => remoteGame.triggers.getRecordedEvents().Any(e => e is THHGame.StartEventArg)));

            //拍怪
            if (localGame.sortedPlayers[0] == localPlayer)
            {
                yield return(new WaitUntil(() => localGame.answers.getRequests(localPlayer.id).FirstOrDefault() is FreeActRequest));

                localPlayer.cmdUse(localGame, localPlayer.hand[0], 0);
                yield return(new WaitUntil(() => localPlayer.field.count > 0));

                localPlayer.cmdTurnEnd(localGame);
                yield return(new WaitUntil(() => localGame.currentPlayer != localPlayer));
            }
            yield return(new WaitUntil(() => remoteGame.answers.getRequests(remotePlayer.id).FirstOrDefault() is FreeActRequest));

            remotePlayer.cmdUse(remoteGame, remotePlayer.hand[0], 0);
            yield return(new WaitUntil(() => remotePlayer.field.count > 0));

            remotePlayer.cmdTurnEnd(remoteGame);
            yield return(new WaitUntil(() => remoteGame.currentPlayer != remotePlayer));

            if (localGame.sortedPlayers[0] != localPlayer)
            {
                yield return(new WaitUntil(() => localGame.answers.getRequests(localPlayer.id).FirstOrDefault() is FreeActRequest));

                localPlayer.cmdUse(localGame, localPlayer.hand[0], 0);
                yield return(new WaitUntil(() => localPlayer.field.count > 0));

                localPlayer.cmdTurnEnd(localGame);
                yield return(new WaitUntil(() => localGame.currentPlayer != localPlayer));
            }
            do
            {
                yield return(new WaitUntil(() => localGame.currentPlayer == localPlayer || remoteGame.currentPlayer == remotePlayer));

                if (localGame.currentPlayer == localPlayer)
                {
                    localPlayer.cmdAttack(localGame, localPlayer.field[0], localGame.getOpponent(localPlayer).master);
                    yield return(new WaitUntil(() => localPlayer.field[0].getAttackTimes(localGame) > 0));

                    localPlayer.cmdTurnEnd(localGame);
                    yield return(new WaitUntil(() => localGame.currentPlayer != localPlayer));
                }
                else if (remoteGame.currentPlayer == remotePlayer)
                {
                    remotePlayer.cmdAttack(remoteGame, remotePlayer.field[0], remoteGame.getOpponent(remotePlayer).master);
                    yield return(new WaitUntil(() => remotePlayer.field[0].getAttackTimes(remoteGame) > 0));

                    remotePlayer.cmdTurnEnd(remoteGame);
                    yield return(new WaitUntil(() => remoteGame.currentPlayer != remotePlayer));
                }
            }while (localGame.isRunning && remoteGame.isRunning);

            local.disconnect();
            remote.disconnect();
            yield break;
        }