Cleanup BattleState

This commit is contained in:
henriquenakashima 2020-09-30 22:24:12 -04:00
parent 8a86423e7d
commit 6bf1a8672f

View file

@ -5,50 +5,37 @@ using UnityEngine;
public class BattleState public class BattleState
{ {
// public delegate void BattleStateChangedAction(); private TeamChoice mTeamsTurn = TeamChoice.Monsters;
// public event BattleStateChangedAction OnBattleStateChanged; private bool mPlayedEmotion;
private bool heroTurn; private int mRound = 0;
private bool playedEmotion;
private int round = 0;
public bool IsTeamsTurn(TeamChoice team) { public bool IsTeamsTurn(TeamChoice team) {
if (team == TeamChoice.Heroes) { return team == mTeamsTurn;
return this.HeroTurn;
} else {
return !this.HeroTurn;
}
} }
public bool CanPlayEmotion(TeamChoice team) { public bool CanPlayEmotion(TeamChoice team) {
return !this.playedEmotion && IsTeamsTurn(team); return !mPlayedEmotion && IsTeamsTurn(team);
} }
public void NotifyPlayedEmotion(TeamChoice team) { public void NotifyPlayedEmotion(TeamChoice team) {
if (!this.CanPlayEmotion(team)) { if (!CanPlayEmotion(team)) {
throw new System.InvalidOperationException("BattleState received NotifyPlayedEmotion but " throw new System.InvalidOperationException("BattleState received NotifyPlayedEmotion but "
+ "cannot play emotion"); + "cannot play emotion");
} }
this.playedEmotion = true; mPlayedEmotion = true;
} }
public bool HeroTurn {get => this.heroTurn;} public int Round {get => mRound;}
public int Round {get => this.round;}
public void AdvanceToTeamTurn(TeamChoice team) { public void AdvanceToTeamTurn(TeamChoice team) {
if (team == TeamChoice.Heroes) { if (team == mTeamsTurn) {
if (this.heroTurn) { throw new System.InvalidOperationException("Already in turn of team " + team);
throw new System.InvalidOperationException("Already in hero turn"); }
} mTeamsTurn = team;
this.heroTurn = true; mPlayedEmotion = false;
this.round++; if (team == TeamChoice.Heroes) {
} else { mRound++;
if (!this.heroTurn) {
throw new System.InvalidOperationException("Already in monster turn");
}
this.heroTurn = false;
} }
this.playedEmotion = false;
} }
} }