Finish merging BattleClock and BattleState

This commit is contained in:
henriquenakashima 2020-10-13 00:25:55 -04:00
parent 658978682b
commit 5962ea9fd6
4 changed files with 17 additions and 25 deletions

View file

@ -154,7 +154,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private IEnumerator RunBattleRound() {
this.state.Clock.AdvanceRound();
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
@ -162,7 +161,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
monsterEnergy.Replenish();
if (STABLE_HAND_STYLE) {
if (this.state.Round > 1) {
if (this.state.Clock.Now.RoundNumber > 1) {
this.heroDeck.DrawCards(3);
this.monsterDeck.DrawCards(3);
}
@ -173,7 +172,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
yield return RunHeroTurn();
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
yield return RunMonsterTurn();
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
@ -183,6 +181,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private IEnumerator RunHeroTurn() {
// Start of hero turn
this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
this.state.ClearEmotionPlayed();
OnBattleStateChanged();
this.monsterIntentions.ResumeIntentions();
@ -224,15 +223,16 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
private IEnumerator RunMonsterTurn() {
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
OnBattleStateChanged();
yield return new WaitForSeconds(0.5f);
// Start of monster turn
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
this.state.ClearEmotionPlayed();
foreach (BattleMonster monster in this.monsters) {
monster.ResetBlock();
}
OnBattleStateChanged();
yield return new WaitForSeconds(0.5f);
// Monsters play an emotion
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();

View file

@ -5,9 +5,7 @@ using UnityEngine;
public class BattleState
{
private TeamChoice mTeamsTurn = TeamChoice.Monsters;
private bool mPlayedEmotion;
private int mRound = 0;
private bool playedEmotion;
private BattleClock clock;
private BuffManager buffManager;
@ -16,12 +14,16 @@ public class BattleState
this.buffManager = new BuffManager(this.clock);
}
public bool IsTeamsTurn(TeamChoice team) {
return team == mTeamsTurn;
public bool IsTeamsTurnToPlay(TeamChoice team) {
if (team == TeamChoice.Heroes) {
return this.clock.Now.RoundStep == RoundStep.StartOfHeroTurn;
} else {
return this.clock.Now.RoundStep == RoundStep.StartOfMonsterTurn;
}
}
public bool CanPlayEmotion(TeamChoice team) {
return !mPlayedEmotion && IsTeamsTurn(team);
return !playedEmotion && IsTeamsTurnToPlay(team);
}
public void NotifyPlayedEmotion(TeamChoice team) {
@ -30,20 +32,11 @@ public class BattleState
+ "cannot play emotion");
}
mPlayedEmotion = true;
playedEmotion = true;
}
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) {
mRound++;
}
public void ClearEmotionPlayed() {
this.playedEmotion = false;
}
public BattleClock Clock {get => this.clock;}

View file

@ -65,7 +65,7 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
continue;
}
bool canPlayNow = this.battleState.IsTeamsTurn(this.team);
bool canPlayNow = this.battleState.IsTeamsTurnToPlay(this.team);
if (card.Type == CardType.Emotion) {
canPlayNow = canPlayNow && this.battleState.CanPlayEmotion(this.team);
} else {

View file

@ -11,7 +11,6 @@ Battle
- Make Enchantments be dropped as an effect like Defaults
- No need to start coroutine for targeting
- Indicate which Default is triggering
- Merge BattleClock with BattleState
Story
- Make dialogue show letter by letter.