本文整理汇总了C#中IHsGameState类的典型用法代码示例。如果您正苦于以下问题:C# IHsGameState类的具体用法?C# IHsGameState怎么用?C# IHsGameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHsGameState类属于命名空间,在下文中一共展示了IHsGameState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if (logLine[9] != 'R' && logLine[16] != 'r') // [Bob] ---Register
return;
if (logLine.Length == 29 && logLine[23] == 'B' && logLine[25] == 'x') // ---RegisterScreenBox---
{
if (game.CurrentGameMode == GameMode.Spectator)
gameState.GameEnd();
}
else if (logLine.Length == 31 && logLine[23] == 'F' && logLine[27] == 'e') // ---RegisterScreenForge---
{
gameState.GameHandler.SetGameMode(GameMode.Arena);
game.ResetArenaCards();
}
else if (logLine.Length == 34)
{
if (logLine[23] == 'P' && logLine[30] == 'e') // ---RegisterScreenPractice---
gameState.GameHandler.SetGameMode(GameMode.Practice);
else if (logLine[23] == 'T' && logLine[30] == 's') // ---RegisterScreenTourneys---
gameState.GameHandler.SetGameMode(GameMode.Casual);
else if (logLine[23] == 'F' && logLine[30] == 'y') // ---RegisterScreenFriendly---
gameState.GameHandler.SetGameMode(GameMode.Friendly);
else if (logLine[23] == 'e' && logLine[24] == 'N' && logLine[30] == 's') // RegisterProfileNotices
gameState.GameLoaded = true;
}
else if (logLine.Length == 35 && logLine[17] == 'F' && logLine[22] == 'd' && logLine[23] == 'C') // RegisterFriendChallenge
{
gameState.GameHandler.HandleInMenu();
}
else if (logLine.Length == 43 && logLine[23] == 'C' && logLine[32] == 'n' && logLine[33] == 'M' && logLine[39] == 'r')// ---RegisterScreenCollectionManager---
gameState.GameHandler.ResetConstructedImporting();
}
示例2: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if (HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
{
var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
if (game.CurrentGameMode == GameMode.Arena)
gameState.GameHandler.HandlePossibleArenaCard(id);
else
gameState.GameHandler.HandlePossibleConstructedCard(id, false);
}
else if (HsLogReaderConstants.GoldProgressRegex.IsMatch(logLine)
&& (DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
&& game.CurrentGameMode != GameMode.Spectator)
{
int wins;
var rawWins = HsLogReaderConstants.GoldProgressRegex.Match(logLine).Groups["wins"].Value;
if (int.TryParse(rawWins, out wins))
{
TimeZoneInfo timeZone = null;
switch (game.CurrentRegion)
{
case Region.EU:
timeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
break;
case Region.US:
timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
break;
case Region.ASIA:
timeZone = TimeZoneInfo.FindSystemTimeZoneById("Korea Standard Time");
break;
}
if (timeZone != null)
{
var region = (int)game.CurrentRegion - 1;
var date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZone).Date;
if (Config.Instance.GoldProgressLastReset[region].Date != date)
{
Config.Instance.GoldProgressTotal[region] = 0;
Config.Instance.GoldProgressLastReset[region] = date;
}
Config.Instance.GoldProgress[region] = wins == 3 ? 0 : wins;
if (wins == 3)
Config.Instance.GoldProgressTotal[region] += 10;
Config.Save();
}
}
}
else if (HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
{
int amount;
if (int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
gameState.GameHandler.HandleDustReward(amount);
}
else if (HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
{
int amount;
if (int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
gameState.GameHandler.HandleGoldReward(amount);
}
}
示例3: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if(HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
{
var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
if(game.CurrentGameMode == GameMode.Arena)
gameState.GameHandler.HandlePossibleArenaCard(id);
else
gameState.GameHandler.HandlePossibleConstructedCard(id, false);
}
else if(HsLogReaderConstants.GoldProgressRegex.IsMatch(logLine) && (DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
&& game.CurrentGameMode != GameMode.Spectator)
{
int wins;
var rawWins = HsLogReaderConstants.GoldProgressRegex.Match(logLine).Groups["wins"].Value;
if(int.TryParse(rawWins, out wins))
{
var timeZone = GetTimeZoneInfo(game.CurrentRegion);
if(timeZone != null)
UpdateGoldProgress(wins, game, timeZone);
}
}
else if(HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
{
int amount;
if(int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
gameState.GameHandler.HandleDustReward(amount);
}
else if(HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
{
int amount;
if(int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
gameState.GameHandler.HandleGoldReward(amount);
}
}
示例4: StateChange
private void StateChange(int value, IHsGameState gameState)
{
if(value != (int)State.COMPLETE)
return;
gameState.GameHandler.HandleGameEnd();
gameState.GameEnded = true;
}
示例5: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if (gameState.AwaitingRankedDetection)
{
gameState.LastAssetUnload = DateTime.Now;
gameState.WaitingForFirstAssetUnload = false;
}
if (logLine.Contains("Medal_Ranked_"))
{
var match = Regex.Match(logLine, "Medal_Ranked_(?<rank>(\\d+))");
if (match.Success)
{
int rank;
if (int.TryParse(match.Groups["rank"].Value, out rank))
gameState.GameHandler.SetRank(rank);
}
}
else if (logLine.Contains("rank_window"))
{
gameState.FoundRanked = true;
gameState.GameHandler.SetGameMode(GameMode.Ranked);
}
else if (HsLogReaderConstants.UnloadCardRegex.IsMatch(logLine))
{
var id = HsLogReaderConstants.UnloadCardRegex.Match(logLine).Groups["id"].Value;
if (game.CurrentGameMode == GameMode.Arena)
gameState.GameHandler.HandlePossibleArenaCard(id);
else
gameState.GameHandler.HandlePossibleConstructedCard(id, true);
}
}
示例6: TagChange
public void TagChange(IHsGameState gameState, GameTag tag, int id, int value, IGame game, bool isCreationTag = false)
{
if(gameState.LastId != id)
{
if(gameState.ProposedKeyPoint != null)
{
ReplayMaker.Generate(gameState.ProposedKeyPoint.Type, gameState.ProposedKeyPoint.Id, gameState.ProposedKeyPoint.Player, game);
gameState.ProposedKeyPoint = null;
}
}
gameState.LastId = id;
if(id > gameState.MaxId)
gameState.MaxId = id;
if(!game.Entities.ContainsKey(id))
game.Entities.Add(id, new Entity(id));
if(!gameState.DeterminedPlayers)
{
var entity = game.Entities[id];
if(tag == CONTROLLER && entity.IsInHand && string.IsNullOrEmpty(entity.CardId))
DeterminePlayers(gameState, game, value);
}
var prevValue = game.Entities[id].GetTag(tag);
game.Entities[id].SetTag(tag, value);
if(isCreationTag)
{
var action = _tagChangeActions.FindAction(tag, game, gameState, id, value, prevValue);
if(action != null)
_creationTagActionQueue.Enqueue(new Tuple<int, Action>(id, action));
}
else
_tagChangeActions.FindAction(tag, game, gameState, id, value, prevValue)?.Invoke();
}
示例7: DeterminePlayers
internal void DeterminePlayers(IHsGameState gameState, IGame game, int playerId, bool isOpponentId = true)
{
if(isOpponentId)
{
game.Entities.FirstOrDefault(e => e.Value.GetTag(PLAYER_ID) == 1).Value?.SetPlayer(playerId != 1);
game.Entities.FirstOrDefault(e => e.Value.GetTag(PLAYER_ID) == 2).Value?.SetPlayer(playerId == 1);
game.Player.Id = playerId % 2 + 1;
game.Opponent.Id = playerId;
}
else
{
game.Entities.FirstOrDefault(e => e.Value.GetTag(PLAYER_ID) == 1).Value?.SetPlayer(playerId == 1);
game.Entities.FirstOrDefault(e => e.Value.GetTag(PLAYER_ID) == 2).Value?.SetPlayer(playerId != 1);
game.Player.Id = playerId;
game.Opponent.Id = playerId % 2 + 1;
}
if(gameState.WasInProgress)
{
var playerName = game.GetStoredPlayerName(game.Player.Id);
if(!string.IsNullOrEmpty(playerName))
game.Player.Name = playerName;
var opponentName = game.GetStoredPlayerName(game.Opponent.Id);
if(!string.IsNullOrEmpty(opponentName))
game.Opponent.Name = opponentName;
}
gameState.DeterminedPlayers = game.PlayerEntity != null;
}
示例8: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if(!logLine.Contains("---Register"))
return;
if(logLine.Contains("---RegisterScreenBox---"))
{
if(game.CurrentGameMode == GameMode.Spectator)
gameState.GameEnd();
}
else if(logLine.Contains("---RegisterScreenForge---"))
{
gameState.GameHandler.SetGameMode(GameMode.Arena);
game.ResetArenaCards();
}
else if(logLine.Contains("---RegisterScreenPractice---"))
gameState.GameHandler.SetGameMode(GameMode.Practice);
else if(logLine.Contains("---RegisterScreenTourneys---"))
gameState.GameHandler.SetGameMode(GameMode.Casual);
else if(logLine.Contains("---RegisterScreenFriendly---"))
gameState.GameHandler.SetGameMode(GameMode.Friendly);
else if(logLine.Contains("---RegisterProfileNotices---"))
gameState.GameLoaded = true;
else if(logLine.Contains("---RegisterFriendChallenge---"))
{
gameState.GameHandler.HandleInMenu();
}
else if(logLine.Contains("---RegisterScreenCollectionManager---"))
gameState.GameHandler.ResetConstructedImporting();
}
示例9: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if (HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
{
var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
if (game.CurrentGameMode == GameMode.Arena)
gameState.GameHandler.HandlePossibleArenaCard(id);
else
gameState.GameHandler.HandlePossibleConstructedCard(id, false);
}
else if ((DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
&& game.CurrentGameMode != GameMode.Spectator)
{
GoldTracking(logLine, game);
}
else if (HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
{
int amount;
if (int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value,
out amount))
gameState.GameHandler.HandleDustReward(amount);
}
else if (HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
{
int amount;
if (int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value,
out amount))
gameState.GameHandler.HandleGoldReward(amount);
}
}
示例10: SetUp
public void SetUp()
{
_game = MockRepository.GenerateMock<IGame>();
_gameHandler = MockRepository.GenerateMock<IGameHandler>();
_gameState = MockRepository.GenerateMock<IHsGameState>();
_gameState.Stub(x => x.GameHandler).Return(_gameHandler);
_arenaHandler = new ArenaHandler();
}
示例11: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if(!UnloadCardRegex.IsMatch(logLine))
return;
var id = UnloadCardRegex.Match(logLine).Groups["id"].Value;
if(game.CurrentMode == Mode.DRAFT && game.PreviousMode == Mode.HUB)
gameState.GameHandler.HandlePossibleArenaCard(id);
else if((game.CurrentMode == Mode.COLLECTIONMANAGER || game.CurrentMode == Mode.TAVERN_BRAWL) && game.PreviousMode == Mode.HUB)
gameState.GameHandler.HandlePossibleConstructedCard(id, true);
}
示例12: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if(!UnloadCardRegex.IsMatch(logLine))
return;
var id = UnloadCardRegex.Match(logLine).Groups["id"].Value;
if(game.CurrentGameMode == GameMode.Arena)
gameState.GameHandler.HandlePossibleArenaCard(id);
else
gameState.GameHandler.HandlePossibleConstructedCard(id, true);
}
示例13: Handle
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;
}
}
示例14: TurnChange
private void TurnChange(IHsGameState gameState, IGame game)
{
if(!gameState.SetupDone || game.PlayerEntity == null)
return;
var activePlayer = game.PlayerEntity.HasTag(CURRENT_PLAYER) ? ActivePlayer.Player : ActivePlayer.Opponent;
if(activePlayer == ActivePlayer.Player)
gameState.PlayerUsedHeroPower = false;
else
gameState.OpponentUsedHeroPower = false;
}
示例15: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
var match = HsLogReaderConstants.ExistingHeroRegex.Match(logLine);
if(match.Success)
game.NewArenaDeck(match.Groups["id"].Value);
else
{
match = HsLogReaderConstants.ExistingCardRegex.Match(logLine);
if(match.Success)
{
try
{
game.NewArenaCard(match.Groups["id"].Value);
}
catch(Exception ex)
{
Logger.WriteLine("Error adding arena card: " + ex, "ArenaHandler");
}
}
else
{
match = HsLogReaderConstants.NewChoiceRegex.Match(logLine);
if(match.Success)
{
if(Database.GetHeroNameFromId(match.Groups["id"].Value, false) != null)
game.NewArenaDeck(match.Groups["id"].Value);
else
{
var cardId = match.Groups["id"].Value;
var timeSinceLastChoice = DateTime.Now.Subtract(_lastChoice).Milliseconds;
if(_lastChoiceId == cardId && timeSinceLastChoice < 1000)
{
Logger.WriteLine(string.Format("Card with the same ID ({0}) was chosen less {1} ms ago. Ignoring.", cardId, timeSinceLastChoice));
return;
}
try
{
game.NewArenaCard(cardId);
}
catch(Exception ex)
{
Logger.WriteLine("Error adding arena card: " + ex, "ArenaHandler");
}
_lastChoice = DateTime.Now;
_lastChoiceId = cardId;
}
}
}
}
}