public void startRemoteGame(ClientManager client, GameOption option, RoomPlayerInfo[] players) { _ui.Game.GameResultDialog.hide(); 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.getDeck()); THHPlayer player = game.createPlayer(info.id, info.name, game.getCardDefine(info.getDeck()[0]) as MasterCardDefine, info.getDeck().Skip(1).Select(id => game.getCardDefine(id))); if (client.id == info.id) { displayGameUI(player); } } gameTask = game.run(); }
/// <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))); }
static async Task effect(THHGame game, Card card) { for (int i = 0; i < 2; i++) { await card.getOwner().createToken(game, game.getCardDefine <LavaElement>()); } await Patchouli.tryMix(game, card); }
static async Task effect(THHGame game, Card card) { await game.getAllServants().silence(game); await card.getOwner().createToken(game, game.getCardDefine <FloodElement>()); await Patchouli.tryMix(game, card); }
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); }
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(); }
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); }
static async Task effect(THHGame game, Card card) { THHPlayer opponent = game.getOpponent(card.getOwner()); for (int i = 0; i < opponent.field.count; i++) { await card.getOwner().createToken(game, game.getCardDefine <DustElement>()); } await Patchouli.tryMix(game, card); }
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 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()); }
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:落叶,这里就只有两个小熊猫相互测试,还不够。 //还要测试手牌满了的情况下,小熊猫被挤死了 }
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")); }
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>(), 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 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(); }
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 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 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 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(); }
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); }
public static void skipUntilCanUse <T>(this THHGame game, THHPlayer you) where T : CardDefine { game.skipTurnUntil(() => game.currentPlayer == you && you.gem >= game.getCardDefine <T>().getProp <int>(nameof(ServantCardDefine.cost))); }
static async Task effect(THHGame game, Card card) { await card.getOwner().createToken(game, game.getCardDefine <GemSpear>(), card.getOwner().field.count); await Patchouli.tryMix(game, card); }
static async Task effect(THHGame game, Card card) { await card.getOwner().createToken(game, game.getOpponent(card.getOwner()).field.count, game.getCardDefine <DustElement>()); await Patchouli.tryMix(game, card); }
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; }