本文整理汇总了C#中IHsGameState类的典型用法代码示例。如果您正苦于以下问题:C# IHsGameState类的具体用法?C# IHsGameState怎么用?C# IHsGameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHsGameState类属于命名空间,在下文中一共展示了IHsGameState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:radoraykov,项目名称:Hearthstone-Deck-Tracker,代码行数:33,代码来源:BobHandler.cs
示例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);
}
}
开发者ID:radoraykov,项目名称:Hearthstone-Deck-Tracker,代码行数:60,代码来源:RachelleHandler.cs
示例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);
}
}
开发者ID:joshuaduffy,项目名称:Hearthstone-Deck-Tracker,代码行数:35,代码来源:RachelleHandler.cs
示例4: StateChange
private void StateChange(int value, IHsGameState gameState)
{
if(value != (int)State.COMPLETE)
return;
gameState.GameHandler.HandleGameEnd();
gameState.GameEnded = true;
}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:7,代码来源:TagChangeActions.cs
示例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);
}
}
开发者ID:karimsah,项目名称:Hearthstone-Deck-Tracker,代码行数:31,代码来源:AssetHandler.cs
示例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();
}
开发者ID:clemgaut,项目名称:Hearthstone-Deck-Tracker,代码行数:35,代码来源:TagChangeHandler.cs
示例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;
}
开发者ID:clemgaut,项目名称:Hearthstone-Deck-Tracker,代码行数:27,代码来源:TagChangeHandler.cs
示例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();
}
开发者ID:nikolasferreira,项目名称:Hearthstone-Deck-Tracker,代码行数:30,代码来源:BobHandler.cs
示例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);
}
}
开发者ID:graydon-armstrong,项目名称:Hearthstone-Deck-Tracker,代码行数:30,代码来源:RachelleHandler.cs
示例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();
}
开发者ID:nikolasferreira,项目名称:Hearthstone-Deck-Tracker,代码行数:8,代码来源:ArenaHandlerTest.cs
示例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);
}
开发者ID:JDurman,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:AssetHandler.cs
示例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);
}
开发者ID:Rob2K2,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:AssetHandler.cs
示例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;
}
}
开发者ID:karimsah,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:LoadingScreenHandler.cs
示例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;
}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:10,代码来源:TagChangeActions.cs
示例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;
}
}
}
}
}
开发者ID:joshuaduffy,项目名称:Hearthstone-Deck-Tracker,代码行数:53,代码来源:ArenaHandler.cs
示例16: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
var match = HsLogReaderConstants.GameModeRegex.Match(logLine);
if(!match.Success)
return;
var prev = match.Groups["prev"].Value;
var newMode = GetGameMode(match.Groups["curr"].Value) ?? GetGameMode(prev);
if(newMode.HasValue && !(game.CurrentGameMode == Ranked && newMode.Value == Casual))
game.CurrentGameMode = newMode.Value;
if(prev == "GAMEPLAY")
gameState.GameHandler.HandleInMenu();
}
开发者ID:Rob2K2,项目名称:Hearthstone-Deck-Tracker,代码行数:12,代码来源:LoadingScreenHandler.cs
示例17: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
var match = ExistingHeroRegex.Match(logLine);
if(match.Success)
game.NewArenaDeck(match.Groups["id"].Value);
else
{
match = ExistingCardRegex.Match(logLine);
if(match.Success)
{
try
{
game.NewArenaCard(match.Groups["id"].Value);
}
catch(Exception ex)
{
Log.Error("Error adding arena card: " + ex);
}
}
else
{
match = NewChoiceRegex.Match(logLine);
if(!match.Success)
return;
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).TotalMilliseconds;
if(_lastChoiceId == cardId && timeSinceLastChoice < 1000)
{
Log.Warn($"Card with the same ID ({cardId}) was chosen less {timeSinceLastChoice} ms ago. Ignoring.");
return;
}
try
{
game.NewArenaCard(cardId);
}
catch(Exception ex)
{
Log.Error("Error adding arena card: " + ex);
}
_lastChoice = DateTime.Now;
_lastChoiceId = cardId;
}
}
}
}
开发者ID:JDurman,项目名称:Hearthstone-Deck-Tracker,代码行数:52,代码来源:ArenaHandler.cs
示例18: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
if ((logLine.Contains("Begin Spectating") || logLine.Contains("Start Spectator") || gameState.FoundSpectatorStart) && game.IsInMenu)
{
gameState.GameHandler.SetGameMode(GameMode.Spectator);
gameState.FoundSpectatorStart = false;
}
else if (logLine.Contains("End Spectator"))
{
gameState.GameHandler.SetGameMode(GameMode.Spectator);
gameState.GameHandler.HandleGameEnd();
}
}
开发者ID:radoraykov,项目名称:Hearthstone-Deck-Tracker,代码行数:13,代码来源:PowerHandler.cs
示例19: Handle
public void Handle(string logLine, IHsGameState gameState, IGame game)
{
var match = HsLogReaderConstants.ConnectionRegex.Match(logLine);
if(match.Success)
{
game.MetaData.ServerAddress = match.Groups["address"].Value.Trim();
game.MetaData.ClientId = match.Groups["client"].Value.Trim();
game.MetaData.GameId = match.Groups["game"].Value.Trim();
game.MetaData.SpectateKey = match.Groups["spectateKey"].Value.Trim();
gameState.Reset();
gameState.GameHandler.HandleGameStart();
}
}
开发者ID:JDurman,项目名称:Hearthstone-Deck-Tracker,代码行数:14,代码来源:NetHandler.cs
示例20: FindAction
public Action FindAction(GameTag tag, IGame game, IHsGameState gameState, int id, int value, int prevValue)
{
switch(tag)
{
case ZONE:
return () => ZoneChange(gameState, id, game, value, prevValue);
case PLAYSTATE:
return () => PlaystateChange(gameState, id, game, value);
case CARDTYPE:
return () => CardTypeChange(gameState, id, game, value);
case LAST_CARD_PLAYED:
return () => LastCardPlayedChange(gameState, value);
case DEFENDING:
return () => DefendingChange(gameState, id, game, value);
case ATTACKING:
return () => AttackingChange(gameState, id, game, value);
case PROPOSED_DEFENDER:
return () => ProposedDefenderChange(game, value);
case PROPOSED_ATTACKER:
return () => ProposedAttackerChange(game, value);
case NUM_MINIONS_PLAYED_THIS_TURN:
return () => NumMinionsPlayedThisTurnChange(gameState, game, value);
case PREDAMAGE:
return () => PredamageChange(gameState, id, game, value);
case NUM_TURNS_IN_PLAY:
return () => NumTurnsInPlayChange(gameState, id, game, value);
case NUM_ATTACKS_THIS_TURN:
return () => NumAttacksThisTurnChange(gameState, id, game, value);
case ZONE_POSITION:
return () => ZonePositionChange(gameState, id, game);
case CARD_TARGET:
return () => CardTargetChange(gameState, id, game, value);
case WEAPON:
return () => EquippedWeaponChange(gameState, id, game, value);
case EXHAUSTED:
return () => ExhaustedChange(gameState, id, game, value);
case CONTROLLER:
return () => ControllerChange(gameState, id, game, prevValue, value);
case FATIGUE:
return () => FatigueChange(gameState, value, game, id);
case STEP:
return () => StepChange(gameState, game);
case TURN:
return () => TurnChange(gameState, game);
case STATE:
return () => StateChange(value, gameState);
}
return null;
}
开发者ID:irufus,项目名称:Hearthstone-Deck-Tracker,代码行数:49,代码来源:TagChangeActions.cs
注:本文中的IHsGameState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论