mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Implemented AI for Harnessed Lightning
This commit is contained in:
@@ -1493,6 +1493,7 @@ public class AiController {
|
||||
}
|
||||
|
||||
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||
final Card source = sa.getHostCard();
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if ("GainLife".equals(logic)) {
|
||||
if (player.getLife() < 5 || player.getCardsIn(ZoneType.Hand).size() >= player.getMaxHandSize()) {
|
||||
@@ -1528,6 +1529,8 @@ public class AiController {
|
||||
return MyRandom.getRandom().nextInt(Math.min(player.getLife() / 3, player.getOpponent().getLife())) + 1;
|
||||
} else if ("HighestGetCounter".equals(logic)) {
|
||||
return MyRandom.getRandom().nextInt(3);
|
||||
} else if (source.hasSVar("EnergyToPay")) {
|
||||
return AbilityUtils.calculateAmount(source, source.getSVar("EnergyToPay"), sa);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if ("Never".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("PayEnergy".equals(sa.getParam("AILogic"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getConditions() != null && !sa.getConditions().areMet(sa) && sa.getSubAbility() == null) {
|
||||
return false;
|
||||
|
||||
@@ -31,8 +31,28 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
final Card source = sa.getHostCard();
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$ChosenNumber")) {
|
||||
int energy = source.getCounters(CounterType.ENERGY);
|
||||
for (SpellAbility s : source.getSpellAbilities()) {
|
||||
if ("PayEnergy".equals(s.getParam("AILogic"))) {
|
||||
energy += AbilityUtils.calculateAmount(source, s.getParam("CounterNum"), sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; energy > 0; energy--) {
|
||||
if (this.damageTargetAI(ai, sa, energy, false)) {
|
||||
dmg = ComputerUtilCombat.getEnoughDamageToKill(sa.getTargetCard(), energy, source, false, false);
|
||||
if (dmg > energy || dmg < 1) {
|
||||
continue; // in case the calculation gets messed up somewhere
|
||||
}
|
||||
source.setSVar("EnergyToPay", "Number$" + dmg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
|
||||
Reference in New Issue
Block a user