forked from HearthSim/Hearthstone-Deck-Tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement game mode detection (except ranked and spectator) via Loadi…
…ngScreen log (HearthSim#1653)
- Loading branch information
Alexander Zeier
committed
Nov 23, 2015
1 parent
493d930
commit f3a5975
Showing
8 changed files
with
67 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Hearthstone Deck Tracker/LogReader/Handlers/LoadingScreenHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#region | ||
|
||
using Hearthstone_Deck_Tracker.Enums; | ||
using Hearthstone_Deck_Tracker.Hearthstone; | ||
using Hearthstone_Deck_Tracker.LogReader.Interfaces; | ||
|
||
#endregion | ||
|
||
namespace Hearthstone_Deck_Tracker.LogReader.Handlers | ||
{ | ||
class LoadingScreenHandler | ||
{ | ||
public void Handle(string logLine, IHsGameState gameState, IGame game) | ||
{ | ||
var match = HsLogReaderConstants.GameModeRegex.Match(logLine); | ||
if(match.Success) | ||
{ | ||
var newMode = GetGameMode(match.Groups["curr"].Value) ?? GetGameMode(match.Groups["prev"].Value); | ||
if(newMode.HasValue && !(game.CurrentGameMode == GameMode.Ranked && newMode.Value == GameMode.Casual)) | ||
game.CurrentGameMode = newMode.Value; | ||
} | ||
} | ||
|
||
private GameMode? GetGameMode(string mode) | ||
{ | ||
switch(mode) | ||
{ | ||
case "ADVENTURE": | ||
return GameMode.Practice; | ||
case "TAVERN_BRAWL": | ||
return GameMode.Brawl; | ||
case "TOURNAMENT": | ||
return GameMode.Casual; | ||
case "DRAFT": | ||
return GameMode.Arena; | ||
case "FRIENDLY": | ||
return GameMode.Friendly; | ||
default: | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters