/// <summary> /// Display the last move played on the board. /// </summary> /// <param name="move">The last move.</param> public void SetLastMove(AIManager.Choice move) { string cardName = "Discard"; CardColor cardColor = CardColor.white; string[] symbols = null; int[] symbolsValue = null; if (move.Action == AIManager.Action.BUILD_CITY) { cardName = move.CardToPlay.Name; cardColor = this.GetCardColor(move.CardToPlay); symbols = this.GetSymbolNames(move.CardToPlay); symbolsValue = this.GetSymbolsValue(move.CardToPlay); } else if (move.Action == AIManager.Action.BUILD_WONDER) { cardName = "Wonder"; Step builtStep = this.Player.WonderManager.GetPreviousStep(); if (builtStep != null) { symbols = this.GetSymbolNames(builtStep); symbolsValue = this.GetSymbolsValue(builtStep); } } this.PlayerBoard.SetLastMove(cardName, cardColor.ToString(), symbols, symbolsValue); }
/// <summary> /// Update last player move on corresponding board. /// </summary> /// <param name="player">The player who did the move.</param> /// <param name="move">The last move.</param> public void SetLastMove(Player player, AIManager.Choice move) { if (player == this.LeftPlayer.Player) { this.LeftPlayer.SetLastMove(move); } else if (player == this.RightPlayer.Player) { this.RightPlayer.SetLastMove(move); } else if (this.GameManager.GetDistantPlayers().Contains(player)) { this.DistantPlayers.Where(dp => dp.Player == player).First().SetLastMove(move); } }
/// <summary> /// Perform all end turn game actions. /// </summary> /// <param name="gc">Current game controller.</param> public void EndTurn(GameController gc) { bool skipRotating = false; foreach (Player p in Players) { if (!p.IsHuman && p.Hand.Count > 0) { AIManager.Choice choice = p.AI.Play(); this.ApplyAIChoice(p, choice); gc.RefreshAIBoards(); gc.SetLastMove(p, choice); } if (p.Hand.Count == 1) { if (p.WonderManager.HasExtraBuildBonus()) { skipRotating = true; } else { if (!p.IsHuman) { DiscardPile.Add(Playable.GetPlayable(p.Hand[0].ID, p.Hand[0].Type)); } p.Hand.RemoveAt(0); } } else if (p.Hand.Count < 1) { p.Hand = new List <Card>(); } p.City.TradeResources = new Dictionary <CityManager.TradeLocation, Dictionary <ResourceType, int> > { { CityManager.TradeLocation.EAST, new Dictionary <ResourceType, int>() }, { CityManager.TradeLocation.WEST, new Dictionary <ResourceType, int>() } }; } Players.ForEach(p => p.City.IsLastCardResource = false); if (!skipRotating) { this.RotateHands(); } }
/// <summary> /// Perform the move decided by the AI. /// </summary> /// <param name="choice">Move chosen by the AI.</param> public void ApplyAIChoice(Player player, AIManager.Choice choice) { switch (choice.Action) { case AIManager.Action.BUILD_CITY: player.City.Build(choice.CardToPlay, false); break; case AIManager.Action.BUILD_WONDER: // Hack: TEMP AI action to perform is not taken into account. player.WonderManager.BuildWonder(choice.CardToPlay.ID); break; case AIManager.Action.DISCARD: player.City.Discard(choice.CardToPlay.ID); DiscardPile.Add(Playable.GetPlayable(choice.CardToPlay.ID, choice.CardToPlay.Type)); break; } }