Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

Commit

Permalink
Support for Tournament mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Skeen committed Mar 18, 2014
1 parent aa73f60 commit adbf033
Showing 1 changed file with 57 additions and 11 deletions.
68 changes: 57 additions & 11 deletions projects/Bot/src/AIBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
Expand All @@ -292,6 +332,7 @@ private void update()

// Login screen
case SceneMgr.Mode.LOGIN:
Delay(500);
// Click through quests
login_mode();
break;
Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit adbf033

Please sign in to comment.