From 8a86423e7de28eabad44264be0008079887d1629 Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Wed, 30 Sep 2020 22:18:55 -0400 Subject: [PATCH] Add round number to BattleState --- Assets/Battle/BattleController.cs | 5 +++-- Assets/Battle/BattleState.cs | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 74ed3e8..cf1460e 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -177,18 +177,19 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe } private IEnumerator RunBattleRound() { - this.state.HeroTurn = true; + this.state.AdvanceToTeamTurn(TeamChoice.Heroes); this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn); heroEnergy.Replenish(); monsterEnergy.Replenish(); + this.heroDeck.DrawHand(); this.monsterDeck.DrawHand(); yield return RunHeroTurn(); - this.state.HeroTurn = false; + this.state.AdvanceToTeamTurn(TeamChoice.Monsters); yield return RunMonsterTurn(); } diff --git a/Assets/Battle/BattleState.cs b/Assets/Battle/BattleState.cs index 22ab7e9..126fdbb 100644 --- a/Assets/Battle/BattleState.cs +++ b/Assets/Battle/BattleState.cs @@ -9,6 +9,7 @@ public class BattleState // public event BattleStateChangedAction OnBattleStateChanged; private bool heroTurn; private bool playedEmotion; + private int round = 0; public bool IsTeamsTurn(TeamChoice team) { if (team == TeamChoice.Heroes) { @@ -31,11 +32,23 @@ public class BattleState this.playedEmotion = true; } - public bool HeroTurn { - get => this.heroTurn; - set { - this.heroTurn = value; - this.playedEmotion = false; + public bool HeroTurn {get => this.heroTurn;} + + public int Round {get => this.round;} + + public void AdvanceToTeamTurn(TeamChoice team) { + if (team == TeamChoice.Heroes) { + if (this.heroTurn) { + throw new System.InvalidOperationException("Already in hero turn"); + } + this.heroTurn = true; + this.round++; + } else { + if (!this.heroTurn) { + throw new System.InvalidOperationException("Already in monster turn"); + } + this.heroTurn = false; } + this.playedEmotion = false; } }