public override void MulliganUpdate() { switch (mulliganPhase) { case "begin": Card[] cards = GameState.Get().GetPlayer(0).GetHandZone().GetCards().ToArray(); foreach (Card card in cards) { if (card.GetEntity().GetCardId() == "GAME_005") { continue; } ZConsole.LogLog(card.GetEntity().GetName()); if (card.GetEntity().GetCost() > 3) { HearthGem.ClickCard(card); } } mulliganPhase = "click"; break; case "click": MulliganManager.Get().GetMulliganButton().TriggerRelease(); mulliganPhase = "end"; break; case "end": break; } }
void TurnAI() { Player player = GameState.Get().GetPlayer(0); Player enemy = GameState.Get().GetPlayer(1); Card playerHero = player.GetHeroCard(); Card enemyHero = enemy.GetHeroCard(); int mana = player.GetNumAvailableResources(); List <Card> cards = player.GetHandZone().GetCards(); List <Card> playerMinions = player.GetBattlefieldZone().GetCards(); List <Card> enemyMinions = enemy.GetBattlefieldZone().GetCards(); Card heropower = player.GetHeroPowerCard(); Card coin = null; foreach (Card card in cards) { if (card.GetEntity().GetCardId() == "GAME_005") { coin = card; break; } } int minionsCount = playerMinions.Count; cards.Sort((a, b) => b.GetEntity().GetCost().CompareTo(a.GetEntity().GetCost())); foreach (Card card in cards) { if (card.GetEntity().GetCardId() == "GAME_005") { continue; } //if (card.GetEntity().IsSpell()) // continue; int cost = card.GetEntity().GetCost(); int extra = 0; if (coin != null) { extra = 1; } if (cost > mana + extra) { continue; } if (card.GetEntity().IsMinion()) { if (minionsCount >= 7) { continue; } minionsCount += 1; } if (cost > mana) { ZConsole.LogLog(coin.GetEntity().GetName()); actionQueue.Enqueue(new PlayAction().AddCard(coin)); mana += 1; } ZConsole.LogLog(card.GetEntity().GetName()); actionQueue.Enqueue(new PlayAction().AddCard(card)); mana -= cost; } if (mana >= 2 && canHeropower) { canHeropower = false; switch (player.GetHeroCard().GetEntity().GetClass()) { case TAG_CLASS.WARLOCK: if (cards.Count <= 8) { if (playerHero.GetEntity().GetRemainingHP() >= 12) { actionQueue.Enqueue(new PlayAction().AddCard(heropower)); } } break; case TAG_CLASS.SHAMAN: case TAG_CLASS.PALADIN: if (minionsCount < 7) { actionQueue.Enqueue(new PlayAction().AddCard(heropower)); } break; case TAG_CLASS.HUNTER: case TAG_CLASS.DRUID: case TAG_CLASS.ROGUE: case TAG_CLASS.WARRIOR: actionQueue.Enqueue(new PlayAction().AddCard(heropower)); break; case TAG_CLASS.PRIEST: actionQueue.Enqueue(new AttackAction().AddCard(heropower).AddCard(playerHero)); break; case TAG_CLASS.MAGE: actionQueue.Enqueue(new AttackAction().AddCard(heropower).AddCard(enemyHero)); break; default: break; } } List <Card> enemyTaunts = new List <Card>(); foreach (Card card in enemyMinions) { if (card.GetEntity().IsMinion() && card.GetEntity().HasTaunt()) { enemyTaunts.Add(card); } } if (actionQueue.Count < 1) { foreach (Card card in playerMinions) { if (card.GetEntity().CanAttack() && !card.GetEntity().IsExhausted() && !card.GetEntity().IsFrozen() && !card.GetEntity().IsAsleep() && card.GetEntity().GetATK() > 0) { if (enemyTaunts.Count > 0) { actionQueue.Enqueue(new AttackAction().AddCard(card).AddCard(enemyTaunts[0])); } else { actionQueue.Enqueue(new AttackAction().AddCard(card).AddCard(enemyHero)); } break; } } } if (actionQueue.Count < 1) { if (playerHero.GetEntity().CanAttack() && !playerHero.GetEntity().IsExhausted() && !playerHero.GetEntity().IsFrozen() && playerHero.GetEntity().GetATK() > 0) { ZConsole.LogLog("Hero Atk"); if (enemyTaunts.Count > 0) { actionQueue.Enqueue(new AttackAction().AddCard(playerHero).AddCard(enemyTaunts[0])); } else { actionQueue.Enqueue(new AttackAction().AddCard(playerHero).AddCard(enemyHero)); } } } if (actionQueue.Count > 0) { turnPhase = "action"; lastAction = DateTime.Now; } else { turnPhase = "end"; } }
void Update() { Reflection.SetField(InactivePlayerKicker.Get(), "m_activityDetected", true); SceneMgr.Mode mode = SceneMgr.Get().GetMode(); if (mode != lastmode) { if (lastmode != SceneMgr.Mode.GAMEPLAY && mode == SceneMgr.Mode.GAMEPLAY) { bot.Reset(); } lastmode = mode; ZConsole.Get().HandleLog(mode.ToString(), "SceneMode", LogType.Log); clickplaygame = false; } if (mode == SceneMgr.Mode.TOURNAMENT) { if (SceneMgr.Get().IsInGame() || DeckPickerTrayDisplay.Get() == null || DeckPickerTrayDisplay.Get().GetSelectedDeckID() == 0) { return; } if (!clickplaygame) { Reflection.InvokeMethod(DeckPickerTrayDisplay.Get(), "PlayGame"); clickplaygame = true; } } if (mode == SceneMgr.Mode.GAMEPLAY) { GameState state = GameState.Get(); string gamestate = "invalid"; if (state != null) { if (state.IsBlockingServer()) { return; } if (state.IsMulliganPhase()) { gamestate = "mulligan"; } //else if (state.IsLocalPlayerTurn()) // gamestate = "turn"; else if (state.IsGameOver()) { gamestate = "over"; } else { gamestate = "invalid"; } } if (gamestate != lastgamestate) { if (gamestate == "turn") { bot.TurnBegin(); } lastgamestate = gamestate; } ZConsole.LogLog(gamestate); switch (gamestate) { case "mulligan": if (GameState.Get().IsMulliganManagerActive() && MulliganManager.Get() != null && MulliganManager.Get().GetMulliganButton() != null && MulliganManager.Get().GetMulliganButton().IsEnabled() && (bool)Reflection.GetField(MulliganManager.Get(), "m_waitingForUserInput")) { bot.MulliganUpdate(); } break; case "turn": if (GameState.Get().IsMainPhase() && ((GameEntity)Reflection.GetField(GameState.Get(), "m_gameEntity")).GetTag <TAG_STEP>(GAME_TAG.STEP) == TAG_STEP.MAIN_ACTION) { bot.TurnUpdate(); } break; case "over": CleanUp(); break; case "invalid": //CleanUp(); break; } } }