Skip to content

Commit

Permalink
Merge pull request #42 from SWE2024/lastminute
Browse files Browse the repository at this point in the history
last minute final build
  • Loading branch information
LewisRye authored May 2, 2024
2 parents 1417049 + c205630 commit b931603
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions Assets/Scripts/AIPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
Expand Down
14 changes: 8 additions & 6 deletions Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Canvas>().enabled = false;
GameObject.Find("RenameCountryFrom").GetComponent<TMP_InputField>().text = "";
GameObject.Find("RenameCountryTo").GetComponent<TMP_InputField>().text = "";
Expand All @@ -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<Canvas>().enabled = false;
Expand Down Expand Up @@ -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;
Expand All @@ -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())
{
Expand Down
12 changes: 6 additions & 6 deletions Assets/Scripts/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Country>();
Expand Down Expand Up @@ -92,12 +90,11 @@ public void ChangeNumberOfTroops(int difference)
/// </summary>
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<Image>().enabled = true;
if (this is not AIPlayer) GameObject.Find("CardNotification").GetComponent<Image>().enabled = true;

int index = UnityEngine.Random.Range(0, GameController.ListOfCards.Count);
Card card = GameController.ListOfCards[index];
GameController.ListOfCards.RemoveAt(index);
Expand Down Expand Up @@ -241,6 +238,8 @@ public void Cancel()
/// </summary>
public bool Trade()
{
if (trade.Count < 3) return false; // stops the player from being able to trade in less than 3 cards

HashSet<string> types = new HashSet<string>();
foreach (Card card in trade) types.Add(card.GetCardType());
foreach (string s in types) Debug.Log(s);
Expand All @@ -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();
Expand Down

0 comments on commit b931603

Please sign in to comment.