diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index b0f2c69..1b652ee 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -16,9 +16,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe public BattleSprites battleSprites; // Private - private HeroCardDatabase heroCardDatabase; - private MonsterCardDatabase monsterCardDatabase; - private BattleState state; private HandPlayability heroHandPlayability; private HandPlayability monsterHandPlayability; @@ -35,9 +32,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe parameters = CheatBattle.CreateParameters(); } - this.heroCardDatabase = new HeroCardDatabase(); - this.monsterCardDatabase = new MonsterCardDatabase(); - this.state = new BattleState(parameters); this.heroEnergyUI.Init(this.state.HeroEnergy); @@ -45,20 +39,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.battleSprites.Init(this.state.Heroes, this.state.Monsters, this.state); - BattleParticipant[] cardOwners = new BattleParticipant[parameters.HCardIds.Length]; - for (int i = 0; i < parameters.HCardIds.Length; i++) { - cardOwners[i] = this.state.Heroes[parameters.HCardOwnerIndexes[i]]; - } - BattleDeck heroDeck = new BattleDeck( - this.heroCardDatabase, parameters.HCardIds.Cast().ToArray(), cardOwners); - - BattleParticipant[] mCardOwners = new BattleParticipant[parameters.MCardIds.Length]; - for (int i = 0; i < parameters.MCardIds.Length; i++) { - mCardOwners[i] = this.state.Monsters[parameters.MCardOwnerIndexes[i]]; - } - BattleDeck monsterDeck = new BattleDeck( - this.monsterCardDatabase, parameters.MCardIds.Cast().ToArray(), mCardOwners); - this.state.SetDecks(heroDeck, monsterDeck); this.participantActivity = new ParticipantActivity(); this.heroHandPlayability = new HandPlayability( @@ -397,9 +377,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe if (effect.Participant == null) return; if (effect.Participant.Team == TeamChoice.Heroes) { - this.AcquireCardsTyped(effect, this.state.HeroDeck, this.heroCardDatabase); + this.AcquireCardsTyped(effect, this.state.HeroDeck, new HeroCardDatabase()); } else { - this.AcquireCardsTyped(effect, this.state.MonsterDeck, this.monsterCardDatabase); + this.AcquireCardsTyped(effect, this.state.MonsterDeck, new MonsterCardDatabase()); } } diff --git a/Assets/Battle/BattleState.cs b/Assets/Battle/BattleState.cs index f729f00..c164fcd 100644 --- a/Assets/Battle/BattleState.cs +++ b/Assets/Battle/BattleState.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; public class BattleState: MonsterViewpoint @@ -35,6 +36,10 @@ public class BattleState: MonsterViewpoint this.playArea = new PlayArea(); this.insightLevel = new InsightLevel(STARTING_INSIGHT); + InitHeroesAndMonsters(parameters); + } + + private void InitHeroesAndMonsters(BattleParameters parameters) { this.heroes = new BattleHero[parameters.HeroIds.Length]; for (int i = 0; i < this.heroes.Length; i++) { HeroId id = parameters.HeroIds[i]; @@ -52,11 +57,20 @@ public class BattleState: MonsterViewpoint monster.Init(); this.monsters[i] = monster; } - } - public void SetDecks(BattleDeck heroDeck, BattleDeck monsterDeck) { - this.heroDeck = heroDeck; - this.monsterDeck = monsterDeck; + BattleParticipant[] cardOwners = new BattleParticipant[parameters.HCardIds.Length]; + for (int i = 0; i < parameters.HCardIds.Length; i++) { + cardOwners[i] = this.heroes[parameters.HCardOwnerIndexes[i]]; + } + this.heroDeck = new BattleDeck( + new HeroCardDatabase(), parameters.HCardIds.Cast().ToArray(), cardOwners); + + BattleParticipant[] mCardOwners = new BattleParticipant[parameters.MCardIds.Length]; + for (int i = 0; i < parameters.MCardIds.Length; i++) { + mCardOwners[i] = this.monsters[parameters.MCardOwnerIndexes[i]]; + } + this.monsterDeck = new BattleDeck( + new MonsterCardDatabase(), parameters.MCardIds.Cast().ToArray(), mCardOwners); } public bool IsTeamsTurnToPlay(TeamChoice team) {