mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +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;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
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);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
Name:Harnessed Lightning
|
||||
ManaCost:1 R
|
||||
Types:Instant
|
||||
A:SP$ PutCounter | Cost$ 1 R | Defined$ You | CounterType$ ENERGY | CounterNum$ 3 | SubAbility$ DBChooseNumber | SpellDescription$ Choose target creature. You get {E}{E}{E} (three energy counters), then you may pay any amount of {E}. Harnessed Lightning deals that much damage to that creature.
|
||||
A:SP$ PutCounter | Cost$ 1 R | Defined$ You | AILogic$ PayEnergy | CounterType$ ENERGY | CounterNum$ 3 | SubAbility$ DBChooseNumber | SpellDescription$ Choose target creature. You get {E}{E}{E} (three energy counters), then you may pay any amount of {E}. Harnessed Lightning deals that much damage to that creature.
|
||||
SVar:DBChooseNumber:DB$ ChooseNumber | Max$ Max | ListTitle$ Pay Energy for Damage | SubAbility$ DBDealDamage
|
||||
SVar:DBDealDamage:DB$ DealDamage | References$ X | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ X | UnlessCost$ PayEnergy<X> | UnlessPayer$ You | UnlessSwitched$ True
|
||||
SVar:Max:Count$YourCountersEnergy
|
||||
SVar:X:Count$ChosenNumber
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/harnessed_lightning.jpg
|
||||
Oracle:Choose target creature. You get {E}{E}{E} (three energy counters), then you may pay any amount of {E}. Harnessed Lightning deals that much damage to that creature.
|
||||
|
||||
Reference in New Issue
Block a user