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
|
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||||
{
|
{
|
||||||
private bool STABLE_HAND_STYLE = false;
|
private bool STABLE_HAND_STYLE = true;
|
||||||
private int STARTING_INSIGHT = 1;
|
private int STARTING_INSIGHT = 3;
|
||||||
|
|
||||||
// Inspector public
|
// Inspector public
|
||||||
public HeroInfoUI heroUIPrefab;
|
public HeroInfoUI heroUIPrefab;
|
||||||
|
|
@ -139,7 +139,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
|
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
|
||||||
|
|
||||||
this.monsterIntentions = new TurnIntentions<MonsterCard>(
|
this.monsterIntentions = new TurnIntentions<MonsterCard>(
|
||||||
this.monsterDeck, this.monsterEnergy);
|
this.monsterDeck, this.monsterEnergy, this.monsterHandPlayability);
|
||||||
|
|
||||||
this.battlePlayerControls.Init(
|
this.battlePlayerControls.Init(
|
||||||
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
||||||
|
|
@ -170,6 +170,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
cheat.OnInsightCode += delegate {
|
cheat.OnInsightCode += delegate {
|
||||||
this.insightLevel.Modify(+5);
|
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
|
// Update is called once per frame
|
||||||
|
|
@ -260,13 +268,25 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
|
|
||||||
// Monsters act until they pass
|
// Monsters play an emotion
|
||||||
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
||||||
for (int i = 0; i < monsterHand.Count; i++) {
|
for (int i = 0; i < monsterHand.Count; i++) {
|
||||||
MonsterCard monsterCard = monsterHand[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);
|
yield return UseMonsterCard(monsterCard);
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
|
anyCardPlayed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,6 +302,18 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
OnBattleStateChanged();
|
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) {
|
public IEnumerator UseHeroCard(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());
|
||||||
|
|
@ -298,8 +330,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.heroDeck.MoveCardToDiscard(card);
|
this.heroDeck.MoveCardToDiscard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnBattleStateChanged();
|
|
||||||
CheckState();
|
CheckState();
|
||||||
|
OnBattleStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||||
|
|
@ -316,6 +348,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
yield return new WaitForSeconds(0.5f);
|
yield return new WaitForSeconds(0.5f);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
OnBattleStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanUseHeroCard(HeroCard card) {
|
public bool CanUseHeroCard(HeroCard card) {
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public class CheatBattle: MonoBehaviour
|
||||||
public delegate void CheatAction();
|
public delegate void CheatAction();
|
||||||
public event CheatAction OnWinCode;
|
public event CheatAction OnWinCode;
|
||||||
public event CheatAction OnInsightCode;
|
public event CheatAction OnInsightCode;
|
||||||
|
public event CheatAction OnOneHPCode;
|
||||||
|
|
||||||
private string lastCommands = "";
|
private string lastCommands = "";
|
||||||
|
|
||||||
|
|
@ -94,6 +95,9 @@ public class CheatBattle: MonoBehaviour
|
||||||
} else if (this.lastCommands.EndsWith("insight")) {
|
} else if (this.lastCommands.EndsWith("insight")) {
|
||||||
this.OnInsightCode();
|
this.OnInsightCode();
|
||||||
this.lastCommands = "";
|
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
|
if (cardPlayability == PlayabilityState.PlayableImmediately
|
||||||
|| cardPlayability == PlayabilityState.PlayableInOwnTurn) {
|
|| cardPlayability == PlayabilityState.PlayableInOwnTurn) {
|
||||||
if (this.intentions.WillUseCard(card)) {
|
if (this.intentions.WillUseCard(card)) {
|
||||||
|
// Debug.Log("Display state of " + card.GetDisplayName() + " = IntendedToPlay");
|
||||||
cardUI.State = PlayableState.IntendedToPlay;
|
cardUI.State = PlayableState.IntendedToPlay;
|
||||||
} else {
|
} else {
|
||||||
|
// Debug.Log("Display state of " + card.GetDisplayName() + " = Playable");
|
||||||
cardUI.State = PlayableState.Playable;
|
cardUI.State = PlayableState.Playable;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Debug.Log("Display state of " + card.GetDisplayName() + " = Unplayable");
|
||||||
cardUI.State = PlayableState.Unplayable;
|
cardUI.State = PlayableState.Unplayable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
|
||||||
foreach (BaseCardT card in this.deck.GetHandPile()) {
|
foreach (BaseCardT card in this.deck.GetHandPile()) {
|
||||||
if (!card.Owner.CanUseCard(card)) {
|
if (!card.Owner.CanUseCard(card)) {
|
||||||
this.playable[card] = PlayabilityState.Unplayable;
|
this.playable[card] = PlayabilityState.Unplayable;
|
||||||
|
// Debug.Log("Playability of " + card.GetDisplayName() + " = Unplayable");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,8 +73,10 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
|
||||||
}
|
}
|
||||||
if (canPlayNow) {
|
if (canPlayNow) {
|
||||||
this.playable[card] = PlayabilityState.PlayableImmediately;
|
this.playable[card] = PlayabilityState.PlayableImmediately;
|
||||||
|
// Debug.Log("Playability of " + card.GetDisplayName() + " = PlayableImmediately");
|
||||||
} else {
|
} else {
|
||||||
this.playable[card] = PlayabilityState.PlayableInOwnTurn;
|
this.playable[card] = PlayabilityState.PlayableInOwnTurn;
|
||||||
|
// Debug.Log("Playability of " + card.GetDisplayName() + " = PlayableInOwnTurn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TriggerOnPlayabilityChanged();
|
TriggerOnPlayabilityChanged();
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,15 @@ public class TurnIntentions<BaseCardT> where BaseCardT: BaseCard
|
||||||
private bool mActive;
|
private bool mActive;
|
||||||
private List<BaseCardT> mCardsToUse = new List<BaseCardT>();
|
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;
|
mDeck = deck;
|
||||||
mEnergyPool = energyPool;
|
mEnergyPool = energyPool;
|
||||||
mActive = true;
|
mActive = true;
|
||||||
|
|
||||||
mDeck.OnDrawPileChanged += OnDependencyChanged;
|
mDeck.OnDrawPileChanged += OnDependencyChanged;
|
||||||
mEnergyPool.OnEnergyChanged += OnDependencyChanged;
|
mEnergyPool.OnEnergyChanged += OnDependencyChanged;
|
||||||
|
playability.OnPlayabilityChanged += OnDependencyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResumeIntentions() {
|
public void ResumeIntentions() {
|
||||||
|
|
@ -46,14 +48,23 @@ public class TurnIntentions<BaseCardT> where BaseCardT: BaseCard
|
||||||
|
|
||||||
private void UpdateState() {
|
private void UpdateState() {
|
||||||
int projectedEnergy = mEnergyPool.Energy;
|
int projectedEnergy = mEnergyPool.Energy;
|
||||||
// TODO: Account for emotions
|
|
||||||
|
|
||||||
mCardsToUse.Clear();
|
mCardsToUse.Clear();
|
||||||
|
|
||||||
List<BaseCardT> hand = mDeck.GetHandPile();
|
List<BaseCardT> hand = mDeck.GetHandPile();
|
||||||
|
|
||||||
for (int i = 0; i < hand.Count; i++) {
|
for (int i = 0; i < hand.Count; i++) {
|
||||||
BaseCardT card = hand[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()) {
|
||||||
projectedEnergy -= card.GetCost();
|
projectedEnergy -= card.GetCost();
|
||||||
mCardsToUse.Add(card);
|
mCardsToUse.Add(card);
|
||||||
|
|
|
||||||
3
TODO.txt
3
TODO.txt
|
|
@ -1,9 +1,6 @@
|
||||||
Battle
|
Battle
|
||||||
- Animate rearrange hand after card is used
|
- Animate rearrange hand after card is used
|
||||||
- Do not Highlight unusable cards
|
- Do not Highlight unusable cards
|
||||||
+ Make enemies play energy before anything else
|
|
||||||
+ Limit intentions to drop one energy
|
|
||||||
+ Account for one dropped energy in intentions
|
|
||||||
- Show on who enemies will use the cards
|
- Show on who enemies will use the cards
|
||||||
- Highlight which card is targeting
|
- Highlight which card is targeting
|
||||||
- Allow cancelling targeting
|
- Allow cancelling targeting
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue