当前位置: 首页>>代码示例>>C#>>正文


C# IGame.NewArenaCard方法代码示例

本文整理汇总了C#中IGame.NewArenaCard方法的典型用法代码示例。如果您正苦于以下问题:C# IGame.NewArenaCard方法的具体用法?C# IGame.NewArenaCard怎么用?C# IGame.NewArenaCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGame的用法示例。


在下文中一共展示了IGame.NewArenaCard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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


注:本文中的IGame.NewArenaCard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。