Move PlayArea into BattleState

This commit is contained in:
henriquenakashima 2020-10-13 01:00:49 -04:00
parent 12eb97084f
commit cb88ae78b6
2 changed files with 8 additions and 7 deletions

View file

@ -19,7 +19,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
// Private // Private
private HeroCardDatabase heroCardDatabase; private HeroCardDatabase heroCardDatabase;
private MonsterCardDatabase monsterCardDatabase; private MonsterCardDatabase monsterCardDatabase;
private PlayArea playArea;
private BattleHero[] heroes; private BattleHero[] heroes;
@ -87,7 +86,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.monsterCardDatabase, parameters.MCardIds.Cast<int>().ToArray(), mCardOwners); this.monsterCardDatabase, parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
this.state.SetDecks(heroDeck, monsterDeck); this.state.SetDecks(heroDeck, monsterDeck);
this.participantActivity = new ParticipantActivity(); this.participantActivity = new ParticipantActivity();
this.playArea = new PlayArea();
this.heroHandPlayability = new HandPlayability<HeroCard>( this.heroHandPlayability = new HandPlayability<HeroCard>(
this.state, this.state.HeroEnergy, TeamChoice.Heroes, this.state.HeroDeck); this.state, this.state.HeroEnergy, TeamChoice.Heroes, this.state.HeroDeck);
@ -100,7 +98,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.state.MonsterDeck, this.state.MonsterEnergy, this.monsterHandPlayability); this.state.MonsterDeck, this.state.MonsterEnergy, this.monsterHandPlayability);
this.battlePlayerControls.Init( this.battlePlayerControls.Init(
this.state.HeroDeck, this.state.MonsterDeck, this.playArea, this.insightLevel, this.state.HeroDeck, this.state.MonsterDeck, this.state.PlayArea, this.insightLevel,
this.heroHandPlayability, this.monsterHandPlayability, this.monsterIntentions, this.heroHandPlayability, this.monsterHandPlayability, this.monsterIntentions,
this.uiCanvas.transform.localScale.x); this.uiCanvas.transform.localScale.x);
this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged; this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged;
@ -198,7 +196,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
} }
// End of hero turn // End of hero turn
yield return this.playArea.UseHeroDefaults(this.heroes, this.participantActivity, UseHeroDefault); yield return this.state.PlayArea.UseHeroDefaults(this.heroes, this.participantActivity, UseHeroDefault);
if (STABLE_HAND_STYLE) { if (STABLE_HAND_STYLE) {
this.state.HeroDeck.DiscardInExcessOf(3); this.state.HeroDeck.DiscardInExcessOf(3);
} else { } else {
@ -286,7 +284,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
if (card.Type == CardType.Default) { if (card.Type == CardType.Default) {
// Already added to playArea by effect // Already added to playArea by effect
} else if (card.IsPermanent()) { } else if (card.IsPermanent()) {
this.playArea.AddPlayedHeroPermanent(card); this.state.PlayArea.AddPlayedHeroPermanent(card);
} else if (card.IsEphemeral()) { } else if (card.IsEphemeral()) {
this.state.HeroDeck.MoveCardToOblivion(card); this.state.HeroDeck.MoveCardToOblivion(card);
} else { } else {
@ -313,7 +311,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.state.MonsterDeck.RemoveCardFromHand(card); this.state.MonsterDeck.RemoveCardFromHand(card);
yield return card.Use(this, this); yield return card.Use(this, this);
if (card.IsPermanent()) { if (card.IsPermanent()) {
this.playArea.AddPlayedMonsterPermanent(card); this.state.PlayArea.AddPlayedMonsterPermanent(card);
} else if (card.IsEphemeral()) { } else if (card.IsEphemeral()) {
this.state.MonsterDeck.MoveCardToOblivion(card); this.state.MonsterDeck.MoveCardToOblivion(card);
} else { } else {
@ -574,7 +572,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
} }
public void SetupDefault(DefaultEffect effect) { public void SetupDefault(DefaultEffect effect) {
DefaultHeroCard previousDefault = this.playArea.SetupDefault(effect); DefaultHeroCard previousDefault = this.state.PlayArea.SetupDefault(effect);
if (previousDefault != null) { if (previousDefault != null) {
this.state.HeroDeck.MoveCardToDiscard(previousDefault); this.state.HeroDeck.MoveCardToDiscard(previousDefault);
} }

View file

@ -12,12 +12,14 @@ public class BattleState
private EnergyPool monsterEnergy; private EnergyPool monsterEnergy;
private BattleDeck<HeroCard> heroDeck; private BattleDeck<HeroCard> heroDeck;
private BattleDeck<MonsterCard> monsterDeck; private BattleDeck<MonsterCard> monsterDeck;
private PlayArea playArea;
public BattleState() { public BattleState() {
this.clock = new BattleClock(); this.clock = new BattleClock();
this.buffManager = new BuffManager(this.clock); this.buffManager = new BuffManager(this.clock);
this.heroEnergy = new EnergyPool(); this.heroEnergy = new EnergyPool();
this.monsterEnergy = new EnergyPool(); this.monsterEnergy = new EnergyPool();
this.playArea = new PlayArea();
} }
public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) { public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) {
@ -57,4 +59,5 @@ public class BattleState
public EnergyPool MonsterEnergy {get => this.monsterEnergy;} public EnergyPool MonsterEnergy {get => this.monsterEnergy;}
public BattleDeck<HeroCard> HeroDeck {get => this.heroDeck;} public BattleDeck<HeroCard> HeroDeck {get => this.heroDeck;}
public BattleDeck<MonsterCard> MonsterDeck {get => this.monsterDeck;} public BattleDeck<MonsterCard> MonsterDeck {get => this.monsterDeck;}
public PlayArea PlayArea {get => this.playArea;}
} }