From 6bf1a8672f6be7e70d30e516f9cae435b5f32d0e Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Wed, 30 Sep 2020 22:24:12 -0400 Subject: [PATCH] Cleanup BattleState --- Assets/Battle/BattleState.cs | 43 +++++++++++++----------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/Assets/Battle/BattleState.cs b/Assets/Battle/BattleState.cs index 126fdbb..c221879 100644 --- a/Assets/Battle/BattleState.cs +++ b/Assets/Battle/BattleState.cs @@ -5,50 +5,37 @@ using UnityEngine; public class BattleState { -// public delegate void BattleStateChangedAction(); -// public event BattleStateChangedAction OnBattleStateChanged; - private bool heroTurn; - private bool playedEmotion; - private int round = 0; + private TeamChoice mTeamsTurn = TeamChoice.Monsters; + private bool mPlayedEmotion; + private int mRound = 0; public bool IsTeamsTurn(TeamChoice team) { - if (team == TeamChoice.Heroes) { - return this.HeroTurn; - } else { - return !this.HeroTurn; - } + return team == mTeamsTurn; } public bool CanPlayEmotion(TeamChoice team) { - return !this.playedEmotion && IsTeamsTurn(team); + return !mPlayedEmotion && IsTeamsTurn(team); } public void NotifyPlayedEmotion(TeamChoice team) { - if (!this.CanPlayEmotion(team)) { + if (!CanPlayEmotion(team)) { throw new System.InvalidOperationException("BattleState received NotifyPlayedEmotion but " + "cannot play emotion"); } - this.playedEmotion = true; + mPlayedEmotion = true; } - public bool HeroTurn {get => this.heroTurn;} - - public int Round {get => this.round;} + public int Round {get => mRound;} 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; + if (team == mTeamsTurn) { + throw new System.InvalidOperationException("Already in turn of team " + team); + } + mTeamsTurn = team; + mPlayedEmotion = false; + if (team == TeamChoice.Heroes) { + mRound++; } - this.playedEmotion = false; } }