- AI support for Polukranos, World Eater

This commit is contained in:
excessum
2014-03-27 13:52:03 +00:00
parent a629f4c42a
commit 2371d52c9d
3 changed files with 49 additions and 3 deletions

View File

@@ -127,6 +127,21 @@ public class CountersPutAi extends SpellAbilityAi {
amount = ComputerUtilMana.determineLeftoverMana(sa, ai);
source.setSVar("PayX", Integer.toString(amount));
}
if ("Polukranos".equals(sa.getParam("AILogic"))) {
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
//TODO how to grab target restrictions from subsequent triggered ability?
if (!humCreatures.isEmpty()){
boolean canSurvive = false;
for (Card humanCreature : humCreatures) {
if (!FightAi.canKill(humanCreature, source, 0)){
canSurvive = true;
}
}
if (!canSurvive){
return false;
}
}
}
// don't use it if no counters to add
if (amount <= 0) {

View File

@@ -2,6 +2,7 @@ package forge.ai.ability;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import forge.ai.*;
import forge.game.Game;
import forge.game.GameObject;
@@ -254,6 +255,37 @@ public class DamageDealAi extends DamageAiBase {
return false;
}
if ("Polukranos".equals(sa.getParam("AILogic"))) {
int dmgTaken = 0;
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
Card lastTgt = null;
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
ComputerUtilCard.sortByEvaluateCreature(humCreatures);
for (Card humanCreature : humCreatures) {
if (FightAi.canKill(humanCreature, source, dmgTaken)) {
continue;
}
final int assignedDamage = ComputerUtilCombat.getEnoughDamageToKill(humanCreature, dmg, source, false, noPrevention);
if (assignedDamage <= dmg) {
tcs.add(humanCreature);
tgt.addDividedAllocation(humanCreature, assignedDamage);
lastTgt = humanCreature;
}
dmg -= assignedDamage;
if (!source.hasProtectionFrom(humanCreature)) {
dmgTaken += humanCreature.getNetAttack();
}
if (dmg <= 0) {
break;
}
}
if (dmg > 0 && lastTgt != null) {
tgt.addDividedAllocation(lastTgt, tgt.getDividedValue(lastTgt) + dmg);
dmg = 0;
return true;
}
//fall back into generic targeting due to failure to restrict targets in CountersPutAi or change in board state
}
while (tcs.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
if (oppTargetsChoice && sa.getActivatingPlayer().equals(ai) && !sa.isTrigger()) {
// canPlayAI (sa activated by ai)

View File

@@ -2,15 +2,14 @@ Name:Polukranos, World Eater
ManaCost:2 G G
Types:Legendary Creature Hydra
PT:5/5
K:Monstrosity X:X X G
K:Monstrosity X:X X G | AILogic$ Polukranos
T:Mode$ BecomeMonstrous | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigDmg | TriggerDescription$ When CARDNAME becomes monstrous, it deals X damage divided as you choose among any number of target creatures your opponents control. Each of those creatures deals damage equal to its power to CARDNAME.
SVar:TrigDmg:AB$ DealDamage | Cost$ 0 | ValidTgts$ Creature.OppCtrl | TgtPrompt$ Select target creature your opponents control distribute damage to | NumDmg$ MonstrosityX | TargetMin$ 1 | TargetMax$ MaxTgts | DividedAsYouChoose$ MonstrosityX | References$ MonstrosityX,MaxTgts | SubAbility$ DBDmg
SVar:TrigDmg:AB$ DealDamage | Cost$ 0 | ValidTgts$ Creature.OppCtrl | AILogic$ Polukranos | TgtPrompt$ Select target creature your opponents control distribute damage to | NumDmg$ MonstrosityX | TargetMin$ 1 | TargetMax$ MaxTgts | DividedAsYouChoose$ MonstrosityX | References$ MonstrosityX,MaxTgts | SubAbility$ DBDmg
SVar:DBDmg:DB$ RepeatEach | RepeatSubAbility$ PolukranosFight | UseImprinted$ True | DefinedCards$ Targeted | StackDescription$ None
SVar:PolukranosFight:DB$ DealDamage | DamageSource$ Imprinted | NumDmg$ Y | References$ Y | Defined$ Self | StackDescription$ None
SVar:X:Count$xPaid
SVar:Y:Imprinted$CardPower
SVar:MonstrosityX:Count$MonstrosityMagnitude
SVar:MaxTgts:Count$Valid Creature.OppCtrl
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/polukranos_world_eater.jpg
Oracle:{X}{X}{G}: Monstrosity X. (If this creature isn't monstrous, put X +1/+1 counters on it and it becomes monstrous.) When Polukranos, World Eater becomes monstrous, it deals X damage divided as you choose among any number of target creatures your opponents control. Each of those creatures deals damage equal to its power to Polukranos.