Convert HeroDeck into BattleDeck<HeroCard>

This commit is contained in:
henriquenakashima 2020-09-20 12:17:04 -04:00
parent c2e8b526b6
commit de072a80f7
8 changed files with 93 additions and 67 deletions

View file

@ -12,7 +12,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
public GameObject uiCanvas;
public BattlePlayerControls battlePlayerControls;
private HeroDeck heroDeck;
private HeroCardDatabase heroCardDatabase;
private MonsterCardDatabase monsterCardDatabase;
private BattleDeck<HeroCard> heroDeck;
private PlayArea playArea;
public BattleHero[] heroes;
@ -28,6 +30,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private int energy;
void Awake() {
this.heroCardDatabase = new HeroCardDatabase();
this.monsterCardDatabase = new MonsterCardDatabase();
heroes = new BattleHero[3];
heroSprites = new GameObject[3];
heroUIs = new HeroInfoUI[3];
@ -70,9 +75,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
BattleParticipant[] cardOwners = new BattleParticipant[this.cardIds.Length];
for (int i = 0; i < this.cardIds.Length; i++) {
cardOwners[i] = FindHeroByClass(CardDatabase.GetHeroIdOfCard(this.cardIds[i]));
cardOwners[i] = FindHeroByClass(HeroCardDatabase.GetHeroIdOfCard(this.cardIds[i]));
}
this.heroDeck = new HeroDeck(this.cardIds, cardOwners);
this.heroDeck = new BattleDeck<HeroCard>(this.heroCardDatabase, this.cardIds, cardOwners);
this.playArea = new PlayArea();
@ -127,7 +132,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
monster.ResetBlock();
}
MonsterCard card = MonsterCardDatabase.CreateCard(MCardId.VampireFangs, this.monsters[0]);
MonsterCard card = this.monsterCardDatabase.CreateCard((int) MCardId.VampireFangs, this.monsters[0]);
StartCoroutine(UseMonsterCard(card));
StartHeroTurn();
@ -178,7 +183,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
return this.maxEnergy;
}
public HeroDeck GetHeroDeck() {
public BattleDeck<HeroCard> GetHeroDeck() {
return this.heroDeck;
}
@ -217,10 +222,10 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
public void AcquireHeroCards(AcquireCardsEffect effect) {
BattleHero hero = (BattleHero) effect.Participant;
foreach (CardId cardId in effect.CardIds) {
BaseCard acquiredCard = CardDatabase.CreateCard(cardId, hero);
HeroCard acquiredCard = this.heroCardDatabase.CreateCard((int) cardId, hero);
switch (effect.Zone) {
case BattleZone.DrawPile:
this.GetHeroDeck().PutCardOnTopOfDrawPile(acquiredCard);
this.heroDeck.PutCardOnTopOfDrawPile(acquiredCard);
break;
default:
throw new System.NotImplementedException();
@ -228,7 +233,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
if (effect.Zone == BattleZone.DrawPile) {
this.GetHeroDeck().ShuffleDrawPile();
this.heroDeck.ShuffleDrawPile();
}
}