Use VampireFangs instead of flat 2 damage

This commit is contained in:
henriquenakashima 2020-09-19 23:35:47 -04:00
parent cce0b2891c
commit c34b065ff5
6 changed files with 22 additions and 13 deletions

View file

@ -92,7 +92,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
DecideEnemyTarget();
StartHeroTurn(); StartHeroTurn();
} }
@ -128,19 +127,12 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
monster.ResetBlock(); monster.ResetBlock();
} }
DealDamageEffect damageEffect = new DealDamageEffect(heroes[this.enemyTarget], 2); MonsterCard card = MonsterCardDatabase.CreateCard(MCardId.VampireFangs, this.monsters[0]);
this.Apply(damageEffect); StartCoroutine(UseMonsterCard(card));
DecideEnemyTarget();
StartHeroTurn(); StartHeroTurn();
} }
private int enemyTarget;
private void DecideEnemyTarget() {
this.enemyTarget = Random.Range(0, 3);
Debug.Log("Will attack " + this.heroes[this.enemyTarget].GetDisplayName());
}
public void NotifyHeroCardUsed(HeroCard card) { public void NotifyHeroCardUsed(HeroCard card) {
if (!CanUseHeroCard(card)) { if (!CanUseHeroCard(card)) {
throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName()); throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName());
@ -159,6 +151,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
} }
} }
public IEnumerator UseMonsterCard(MonsterCard card) {
yield return card.Use(this, this);
// TODO: Manage monster deck.
}
public void NotifyHeroTurnPassed() { public void NotifyHeroTurnPassed() {
if (this.heroTurn) { if (this.heroTurn) {
StartEnemyTurn(); StartEnemyTurn();

View file

@ -20,7 +20,7 @@ public class CardDatabase
{CardId.Thunderstorm, HeroId.Shaman}, {CardId.Thunderstorm, HeroId.Shaman},
}; };
public static BaseCard CreateCard(CardId id, BattleParticipant owner) { public static HeroCard CreateCard(CardId id, BattleParticipant owner) {
switch (id) switch (id)
{ {
case CardId.CrashingPunch: case CardId.CrashingPunch:

View file

@ -2,9 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class MCardVampireFangs : MonsterCard public class VampireFangsMCard : MonsterCard
{ {
public MCardVampireFangs(BattleParticipant owner) public VampireFangsMCard(BattleParticipant owner)
: base(owner, MCardId.VampireFangs, "VampireFangs", 2, CardType.Attack, : base(owner, MCardId.VampireFangs, "VampireFangs", 2, CardType.Attack,
"Steals 2 HP from target.") { "Steals 2 HP from target.") {
} }

View file

@ -8,4 +8,13 @@ public enum MCardId {
public static class MonsterCardDatabase public static class MonsterCardDatabase
{ {
public static MonsterCard CreateCard(MCardId id, BattleParticipant owner) {
switch (id)
{
case MCardId.VampireFangs:
return new VampireFangsMCard(owner);
default:
throw new System.ArgumentException("MCardId unknown", "id");
}
}
} }

View file

@ -1 +1,4 @@
- Make API of IBattleEffectResolver take in effects instead of params - Make API of IBattleEffectResolver take in effects instead of params
- Make VampireFangs hit hero with highest HP
- Control flow of battle with state machine or coroutines
- Make battle end