From adbf033ef1bd1bb2758a45e0f6f20e6ed9c06049 Mon Sep 17 00:00:00 2001 From: HearthstoneBot Date: Tue, 18 Mar 2014 12:45:58 +0100 Subject: [PATCH] Support for Tournament mode --- projects/Bot/src/AIBot.cs | 68 ++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/projects/Bot/src/AIBot.cs b/projects/Bot/src/AIBot.cs index a8bc8ab..b3609d7 100644 --- a/projects/Bot/src/AIBot.cs +++ b/projects/Bot/src/AIBot.cs @@ -50,7 +50,7 @@ public void tick() return; } // Delay has been waited out, when we get here - Delay(500); + //Delay(500); // Try to run the main loop try @@ -142,6 +142,49 @@ private void login_mode() } } + private void tournament_mode(bool ranked) + { + // Don't do this, if we're currently in a game, or matching a game + // TODO: Change to an assertion + if (SceneMgr.Get().IsInGame() || Network.IsMatching()) + { + return; + } + // Delay 5 seconds for loading and such + // TODO: Smarter delaying + Delay(5000); + + Log.log("Joining game in tournament mode, ranked = " + ranked); + + // Get the ID of the current Deck + long selectedDeckID = DeckPickerTrayDisplay.Get().GetSelectedDeckID(); + // We want to play vs other players + MissionID missionID = MissionID.MULTIPLAYER_1v1; + // Ranked or unranked? + GameMode mode = ranked ? GameMode.RANKED_PLAY : GameMode.UNRANKED_PLAY; + // Setup up the game + GameMgr.Get().SetNextGame(mode, missionID); + // Do network join + if(ranked) + { + Network.TrackClient(Network.TrackLevel.LEVEL_INFO, + Network.TrackWhat.TRACK_PLAY_TOURNAMENT_WITH_CUSTOM_DECK); + Network.RankedMatch(selectedDeckID); + } + else + { + Network.TrackClient(Network.TrackLevel.LEVEL_INFO, + Network.TrackWhat.TRACK_PLAY_CASUAL_WITH_CUSTOM_DECK); + Network.UnrankedMatch(selectedDeckID); + } + // Set status + FriendChallengeMgr.Get().OnEnteredMatchmakerQueue(); + PresenceMgr.Get().SetStatus(new Enum[] + { + PresenceStatus.PLAY_QUEUE + }); + } + // Play against AI private void pratice_mode(bool expert) { @@ -151,15 +194,18 @@ private void pratice_mode(bool expert) { return; } + // Delay 5 seconds for loading and such + // TODO: Smarter delaying + Delay(5000); + + Log.log("Joining game in practice mode, expert = " + expert); + // Get the ID of the current Deck long selectedDeckID = DeckPickerTrayDisplay.Get().GetSelectedDeckID(); // Get a random mission, of selected difficulty MissionID missionID = getRandomAIMissionID(expert); // Start up the game GameMgr.Get().StartGame(GameMode.PRACTICE, missionID, selectedDeckID); - // Delay 5 seconds for loading and such - // TODO: Smarter delaying - Delay(5000); } // Called when a game is in mulligan state @@ -248,12 +294,7 @@ private void gameplay_mode() game_over(); } // If it's not our turn - else if (gs.IsLocalPlayerTurn() == false) - { - // Simply return - return; - } - else + else if (gs.IsLocalPlayerTurn() == true) { run_ai(); } @@ -274,7 +315,6 @@ private void update() case SceneMgr.Mode.FRIENDLY: case SceneMgr.Mode.DRAFT: case SceneMgr.Mode.CREDITS: - case SceneMgr.Mode.TOURNAMENT: // (Play SubMenu) // Enter MainMenu SceneMgr.Get().SetNextMode(SceneMgr.Mode.HUB); // Delay 5 seconds for loading and such @@ -292,6 +332,7 @@ private void update() // Login screen case SceneMgr.Mode.LOGIN: + Delay(500); // Click through quests login_mode(); break; @@ -316,6 +357,11 @@ private void update() // Play against non-expert AI pratice_mode(false); break; + + // In Play Sub Menu + case SceneMgr.Mode.TOURNAMENT: + tournament_mode(false); + break; } } }