/// <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; } }