Enemies drop energy before, intentions are more accurate
This commit is contained in:
parent
94b3309bb7
commit
737a851283
6 changed files with 64 additions and 13 deletions
|
|
@ -6,8 +6,8 @@ using UnityEngine.SceneManagement;
|
|||
|
||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||
{
|
||||
private bool STABLE_HAND_STYLE = false;
|
||||
private int STARTING_INSIGHT = 1;
|
||||
private bool STABLE_HAND_STYLE = true;
|
||||
private int STARTING_INSIGHT = 3;
|
||||
|
||||
// Inspector public
|
||||
public HeroInfoUI heroUIPrefab;
|
||||
|
|
@ -139,7 +139,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
|
||||
|
||||
this.monsterIntentions = new TurnIntentions<MonsterCard>(
|
||||
this.monsterDeck, this.monsterEnergy);
|
||||
this.monsterDeck, this.monsterEnergy, this.monsterHandPlayability);
|
||||
|
||||
this.battlePlayerControls.Init(
|
||||
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
||||
|
|
@ -170,6 +170,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
cheat.OnInsightCode += delegate {
|
||||
this.insightLevel.Modify(+5);
|
||||
};
|
||||
cheat.OnOneHPCode += delegate {
|
||||
foreach (BattleMonster m in this.monsters) {
|
||||
if (m.IsAlive()) {
|
||||
m.DealDamage(m.GetHP() - 1);
|
||||
}
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
};
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
@ -260,13 +268,25 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
OnBattleStateChanged();
|
||||
|
||||
// Monsters act until they pass
|
||||
// Monsters play an emotion
|
||||
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
||||
for (int i = 0; i < monsterHand.Count; i++) {
|
||||
MonsterCard monsterCard = monsterHand[i];
|
||||
if (CanUseMonsterCard(monsterCard)) {
|
||||
if (monsterCard.Type == CardType.Emotion && CanUseMonsterCard(monsterCard)) {
|
||||
yield return UseMonsterCard(monsterCard);
|
||||
}
|
||||
}
|
||||
|
||||
// Monsters play as many actions from the top as possible
|
||||
bool anyCardPlayed = true;
|
||||
while (anyCardPlayed) {
|
||||
anyCardPlayed = false;
|
||||
|
||||
MonsterCard monsterCard = FirstMonsterActionToPlay();
|
||||
if (monsterCard != null) {
|
||||
yield return UseMonsterCard(monsterCard);
|
||||
OnBattleStateChanged();
|
||||
anyCardPlayed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +302,18 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
private MonsterCard FirstMonsterActionToPlay() {
|
||||
List<MonsterCard> monsterHand = monsterHand = this.monsterDeck.GetHandPile();
|
||||
|
||||
for (int i = 0; i < monsterHand.Count; i++) {
|
||||
MonsterCard monsterCard = monsterHand[i];
|
||||
if (monsterCard.Type != CardType.Emotion && CanUseMonsterCard(monsterCard)) {
|
||||
return monsterCard;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerator UseHeroCard(HeroCard card) {
|
||||
if (!CanUseHeroCard(card)) {
|
||||
throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName());
|
||||
|
|
@ -298,8 +330,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.heroDeck.MoveCardToDiscard(card);
|
||||
}
|
||||
|
||||
OnBattleStateChanged();
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||
|
|
@ -316,6 +348,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
public bool CanUseHeroCard(HeroCard card) {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class CheatBattle: MonoBehaviour
|
|||
public delegate void CheatAction();
|
||||
public event CheatAction OnWinCode;
|
||||
public event CheatAction OnInsightCode;
|
||||
public event CheatAction OnOneHPCode;
|
||||
|
||||
private string lastCommands = "";
|
||||
|
||||
|
|
@ -94,6 +95,9 @@ public class CheatBattle: MonoBehaviour
|
|||
} else if (this.lastCommands.EndsWith("insight")) {
|
||||
this.OnInsightCode();
|
||||
this.lastCommands = "";
|
||||
} else if (this.lastCommands.EndsWith("onehp")) {
|
||||
this.OnOneHPCode();
|
||||
this.lastCommands = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,11 +124,14 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
if (cardPlayability == PlayabilityState.PlayableImmediately
|
||||
|| cardPlayability == PlayabilityState.PlayableInOwnTurn) {
|
||||
if (this.intentions.WillUseCard(card)) {
|
||||
// Debug.Log("Display state of " + card.GetDisplayName() + " = IntendedToPlay");
|
||||
cardUI.State = PlayableState.IntendedToPlay;
|
||||
} else {
|
||||
// Debug.Log("Display state of " + card.GetDisplayName() + " = Playable");
|
||||
cardUI.State = PlayableState.Playable;
|
||||
}
|
||||
} else {
|
||||
// Debug.Log("Display state of " + card.GetDisplayName() + " = Unplayable");
|
||||
cardUI.State = PlayableState.Unplayable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,9 +61,10 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
|
|||
foreach (BaseCardT card in this.deck.GetHandPile()) {
|
||||
if (!card.Owner.CanUseCard(card)) {
|
||||
this.playable[card] = PlayabilityState.Unplayable;
|
||||
// Debug.Log("Playability of " + card.GetDisplayName() + " = Unplayable");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bool canPlayNow = this.battleState.IsTeamsTurn(this.team);
|
||||
if (card.Type == CardType.Emotion) {
|
||||
canPlayNow = canPlayNow && this.battleState.CanPlayEmotion(this.team);
|
||||
|
|
@ -72,8 +73,10 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
|
|||
}
|
||||
if (canPlayNow) {
|
||||
this.playable[card] = PlayabilityState.PlayableImmediately;
|
||||
// Debug.Log("Playability of " + card.GetDisplayName() + " = PlayableImmediately");
|
||||
} else {
|
||||
this.playable[card] = PlayabilityState.PlayableInOwnTurn;
|
||||
// Debug.Log("Playability of " + card.GetDisplayName() + " = PlayableInOwnTurn");
|
||||
}
|
||||
}
|
||||
TriggerOnPlayabilityChanged();
|
||||
|
|
|
|||
|
|
@ -12,13 +12,15 @@ public class TurnIntentions<BaseCardT> where BaseCardT: BaseCard
|
|||
private bool mActive;
|
||||
private List<BaseCardT> mCardsToUse = new List<BaseCardT>();
|
||||
|
||||
public TurnIntentions(BattleDeck<BaseCardT> deck, EnergyPool energyPool) {
|
||||
public TurnIntentions(BattleDeck<BaseCardT> deck, EnergyPool energyPool,
|
||||
HandPlayability<BaseCardT> playability) {
|
||||
mDeck = deck;
|
||||
mEnergyPool = energyPool;
|
||||
mActive = true;
|
||||
|
||||
mDeck.OnDrawPileChanged += OnDependencyChanged;
|
||||
mEnergyPool.OnEnergyChanged += OnDependencyChanged;
|
||||
playability.OnPlayabilityChanged += OnDependencyChanged;
|
||||
}
|
||||
|
||||
public void ResumeIntentions() {
|
||||
|
|
@ -46,14 +48,23 @@ public class TurnIntentions<BaseCardT> where BaseCardT: BaseCard
|
|||
|
||||
private void UpdateState() {
|
||||
int projectedEnergy = mEnergyPool.Energy;
|
||||
// TODO: Account for emotions
|
||||
|
||||
mCardsToUse.Clear();
|
||||
|
||||
List<BaseCardT> hand = mDeck.GetHandPile();
|
||||
|
||||
for (int i = 0; i < hand.Count; i++) {
|
||||
BaseCardT card = hand[i];
|
||||
if (card.Owner.CanUseCard(card)
|
||||
if (card.Type == CardType.Emotion && card.Owner.CanUseCard(card)) {
|
||||
projectedEnergy ++;
|
||||
mCardsToUse.Add(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < hand.Count; i++) {
|
||||
BaseCardT card = hand[i];
|
||||
if (card.Type != CardType.Emotion
|
||||
&& card.Owner.CanUseCard(card)
|
||||
&& projectedEnergy >= card.GetCost()) {
|
||||
projectedEnergy -= card.GetCost();
|
||||
mCardsToUse.Add(card);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue