diff --git a/Assets/Scripts/AIPlayer.cs b/Assets/Scripts/AIPlayer.cs index 7806427..2c6c7c7 100644 --- a/Assets/Scripts/AIPlayer.cs +++ b/Assets/Scripts/AIPlayer.cs @@ -189,6 +189,7 @@ override public void TakeTurn() GameController.Get().HandleObjectClick = GameController.Get().DraftPhase; GameController.Get().NextTurn(); GameController.Get().turnPlayer.GetNewTroopsAndCards(); + GameController.Get().turnPlayer.InitializeSlot(); }); } } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 2a5c472..86152d2 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -717,7 +717,7 @@ public void HandleRenameClick(GameObject selectedObj) i++; if (to.ToLower().Equals(name.ToLower())) { - Killfeed.Update($"Country '{to}' already exists"); + Killfeed.Update($"Error: Country '{to}' already exists"); GameObject.Find("RenameCountry").GetComponent().enabled = false; GameObject.Find("RenameCountryFrom").GetComponent().text = ""; GameObject.Find("RenameCountryTo").GetComponent().text = ""; @@ -730,11 +730,11 @@ public void HandleRenameClick(GameObject selectedObj) if (foundCountry != null) { foundCountry.SetName(to); - Killfeed.Update($"'{from}' was renamed to '{to}'"); + Killfeed.Update($"Success: '{from}' was renamed to '{to}'"); } else { - Killfeed.Update($"Country '{from}' does not exist"); + Killfeed.Update($"Error: Country '{from}' does not exist"); } GameObject.Find("RenameCountry").GetComponent().enabled = false; @@ -763,8 +763,8 @@ private void HandleAttackClick(GameObject selectedObj) { case "Confirm": this.AttackCanvas.enabled = false; - - if (this.defender.GetTroops() > 1) + + if (this.defender.GetTroops() > 1 && this.defender.GetOwner() is not AIPlayer) { numberOfTroops.text = "1"; AttackCanvas.enabled = false; @@ -773,7 +773,9 @@ private void HandleAttackClick(GameObject selectedObj) return; } - if (!this.Attack(attacker, defender, attacker_num, 1)) return; + int defender_num = (this.defender.GetTroops() > 1 && this.defender.GetOwner() is AIPlayer) ? UnityEngine.Random.Range(1, 3) : 1; + + if (!this.Attack(attacker, defender, attacker_num, defender_num)) return; if (attacker.GetOwner() == defender.GetOwner()) { diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 92ccfad..fec4ac2 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -28,9 +28,7 @@ public Player(string name, Color color) case 5: this.numberOfTroops = 25; break; case 6: this.numberOfTroops = 20; break; } - - // this.numberOfTroops = 3; // for debugging - + this.name = name; this.color = color; ownedCountries = new List(); @@ -92,12 +90,11 @@ public void ChangeNumberOfTroops(int difference) /// public void GetNewTroopsAndCards() { - // if (color != new Color(0.95f, 0.3f, 0.3f, 1f)) return; // for debugging - this.numberOfTroops = Math.Max(this.ownedCountries.Count / 3, 3); // you need to receive at least 3 armies if (gain_card) { - GameObject.Find("CardNotification").GetComponent().enabled = true; + if (this is not AIPlayer) GameObject.Find("CardNotification").GetComponent().enabled = true; + int index = UnityEngine.Random.Range(0, GameController.ListOfCards.Count); Card card = GameController.ListOfCards[index]; GameController.ListOfCards.RemoveAt(index); @@ -241,6 +238,8 @@ public void Cancel() /// public bool Trade() { + if (trade.Count < 3) return false; // stops the player from being able to trade in less than 3 cards + HashSet types = new HashSet(); foreach (Card card in trade) types.Add(card.GetCardType()); foreach (string s in types) Debug.Log(s); @@ -254,6 +253,7 @@ public bool Trade() return false; } ChangeNumberOfTroops(6); + Killfeed.Update($"{this.GetName()}: traded in for 6 troops"); foreach (Card card in trade) ownedCards.Remove(card); trade.Clear(); LoadTrade();