Move BattleClock and BuffManager into BattleState

This commit is contained in:
henriquenakashima 2020-10-13 00:03:40 -04:00
parent f212d73515
commit 658978682b
2 changed files with 14 additions and 15 deletions

View file

@ -34,8 +34,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private HandPlayability<HeroCard> heroHandPlayability;
private HandPlayability<MonsterCard> monsterHandPlayability;
private TurnIntentions<MonsterCard> monsterIntentions;
private BattleClock clock;
private BuffManager buffManager;
private ParticipantActivity participantActivity;
private delegate void BattleStateChangedAction();
@ -51,9 +49,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.heroCardDatabase = new HeroCardDatabase();
this.monsterCardDatabase = new MonsterCardDatabase();
this.clock = new BattleClock();
this.buffManager = new BuffManager(this.clock);
this.state = new BattleState(this.buffManager);
this.state = new BattleState();
this.heroEnergy = new EnergyPool();
this.heroEnergyUI.Init(this.heroEnergy);
@ -157,7 +153,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
private IEnumerator RunBattleRound() {
this.clock.AdvanceRound();
this.state.Clock.AdvanceRound();
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
@ -180,13 +176,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
yield return RunMonsterTurn();
this.clock.AdvanceToStep(RoundStep.EndOfRound);
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
this.participantActivity.NextRound();
}
private IEnumerator RunHeroTurn() {
// Start of hero turn
this.clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
OnBattleStateChanged();
this.monsterIntentions.ResumeIntentions();
@ -221,14 +217,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
hero.TickStatuses();
}
this.clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
this.state.Clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
OnBattleStateChanged();
this.monsterIntentions.PauseIntentions();
}
private IEnumerator RunMonsterTurn() {
this.clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
OnBattleStateChanged();
yield return new WaitForSeconds(0.5f);
@ -270,7 +266,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
monster.TickStatuses();
}
this.clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
this.state.Clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
OnBattleStateChanged();
}
@ -478,7 +474,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
int amount = effect.Amount;
if (effect.Source != null) {
amount += this.buffManager.GetTotalBuffAmountOfType(effect.Source, BuffType.Power);
amount += this.state.BuffManager.GetTotalBuffAmountOfType(effect.Source, BuffType.Power);
}
int damageDealt = effect.Target.DealDamage(amount);
foreach (DamageTrigger dt in this.damageTriggers) {
@ -536,7 +532,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
public void BuffParticipant(BuffParticipantEffect effect) {
this.buffManager.AddBuff(effect, this.clock.Now);
this.state.BuffManager.AddBuff(effect, this.state.Clock.Now);
}
public void Rotate(RotateEffect effect) {