Remove hero/monster CardDatabase from BattleController

This commit is contained in:
henriquenakashima 2020-10-13 23:13:53 -04:00
parent db92332783
commit 04d00ebede
2 changed files with 20 additions and 26 deletions

View file

@ -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<HeroCard> heroDeck, BattleDeck<MonsterCard> 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<HeroCard>(
new HeroCardDatabase(), parameters.HCardIds.Cast<int>().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<MonsterCard>(
new MonsterCardDatabase(), parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
}
public bool IsTeamsTurnToPlay(TeamChoice team) {