Add round number to BattleState

This commit is contained in:
henriquenakashima 2020-09-30 22:18:55 -04:00
parent b654419966
commit 8a86423e7d
2 changed files with 21 additions and 7 deletions

View file

@ -177,18 +177,19 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
} }
private IEnumerator RunBattleRound() { private IEnumerator RunBattleRound() {
this.state.HeroTurn = true; this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn); this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
heroEnergy.Replenish(); heroEnergy.Replenish();
monsterEnergy.Replenish(); monsterEnergy.Replenish();
this.heroDeck.DrawHand(); this.heroDeck.DrawHand();
this.monsterDeck.DrawHand(); this.monsterDeck.DrawHand();
yield return RunHeroTurn(); yield return RunHeroTurn();
this.state.HeroTurn = false; this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
yield return RunMonsterTurn(); yield return RunMonsterTurn();
} }

View file

@ -9,6 +9,7 @@ public class BattleState
// public event BattleStateChangedAction OnBattleStateChanged; // public event BattleStateChangedAction OnBattleStateChanged;
private bool heroTurn; private bool heroTurn;
private bool playedEmotion; private bool playedEmotion;
private int round = 0;
public bool IsTeamsTurn(TeamChoice team) { public bool IsTeamsTurn(TeamChoice team) {
if (team == TeamChoice.Heroes) { if (team == TeamChoice.Heroes) {
@ -31,11 +32,23 @@ public class BattleState
this.playedEmotion = true; this.playedEmotion = true;
} }
public bool HeroTurn { public bool HeroTurn {get => this.heroTurn;}
get => this.heroTurn;
set { public int Round {get => this.round;}
this.heroTurn = value;
this.playedEmotion = false; 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;
} }
} }