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 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 == mTeamsTurn) {
throw new System.InvalidOperationException("Already in turn of team " + team);
}
mTeamsTurn = team;
mPlayedEmotion = false;
if (team == TeamChoice.Heroes) {
if (this.heroTurn) {
throw new System.InvalidOperationException("Already in hero turn");
mRound++;
}
this.heroTurn = true;
this.round++;
} else {
if (!this.heroTurn) {
throw new System.InvalidOperationException("Already in monster turn");
}
this.heroTurn = false;
}
this.playedEmotion = false;
}
}