private void OnGameFinished(object sender, GameResponse e) { progressTurns.Value = progressTurns.Maximum; //write result into log LogResult(e); Restart(); }
private void OnRequestCompleted(object sender, UploadStringCompletedEventArgs e) { if (_closed) { return; } if (e.Error != null) { if (e.Error.InnerException != null) { RequestFailed(this, e.Error.InnerException.Message); } else { RequestFailed(this, e.Error.Message); } } else { _gameState = Deserialize(e.Result); if (_gameState.game.finished) { GameFinished(this, _gameState); } else { MoveRequired(this, _gameState); } } }
private void LogResult(GameResponse e) { Log("***Game Over***"); int place = 1; foreach (var hero in e.game.heroes.OrderByDescending(h => h.gold)) { Log((place++) + ". " + hero.name + " with " + hero.gold + " gold."); } Debug.WriteLine("***************"); }
private void OnGameStarted(object sender, GameResponse e) { Log("Joined " + _con.GameState.viewUrl); progressTurns.Maximum = e.game.maxTurns; progressTurns.Value = e.game.turn; linkViewGame.Enabled = true; _con.MoveRequired -= OnGameStarted; //oneshot _con.MoveRequired += OnActionRequired; _knowledge = new Knowledge(e); _bot = Activator.CreateInstance(_account.Bot, _knowledge) as Bot; PlayMove(e); }
private void PlayMove(GameResponse rawData) { _knowledge.Update(rawData); Move action = _bot.Act(); _con.SendMove(action); pictureBoard.Image = KnowledgeRenderer.Render(_knowledge.Map, 4); var visRequests = _bot.Visualizaton.ToList(); int max = Math.Min(visRequests.Count, _visCtrls.Count); for (int i = 0; i < max; i++) { _visCtrls[i].Description.Text = visRequests[i].Description; _visCtrls[i].Image.Image = KnowledgeRenderer.Render(_knowledge[visRequests[i].ChartName], KnowledgeRenderer.GradientRedToGreen, 4); } for (int i = max; i < _visCtrls.Count; i++) { _visCtrls[i].Description.Text = "..."; _visCtrls[i].Image.Image = null; } }
private void OnActionRequired(object sender, GameResponse e) { progressTurns.Value = e.game.turn; textProgress.Text = e.game.turn + " / " + e.game.maxTurns; PlayMove(e); }