- Added AI and some functionality to the spike keyword.

This commit is contained in:
jendave
2011-08-06 05:43:54 +00:00
parent d094feb64a
commit ea63ff5e25

View File

@@ -4019,6 +4019,7 @@ public class CardFactory implements NewConstants {
}//while shouldModular }//while shouldModular
int spike = hasKeyword(card, "Spike"); int spike = hasKeyword(card, "Spike");
if(spike != -1) { if(spike != -1) {
String parse = card.getKeyword().get(spike).toString(); String parse = card.getKeyword().get(spike).toString();
@@ -4032,30 +4033,16 @@ public class CardFactory implements NewConstants {
+ " (This enters the battlefield with " + " (This enters the battlefield with "
+ m + m
+ " +1/+1 counters on it.)"); + " +1/+1 counters on it.)");
card.addComesIntoPlayCommand(new Command() { card.addComesIntoPlayCommand(new Command() {
private static final long serialVersionUID = -2292898970576123040L; private static final long serialVersionUID = -2292898970576123040L;
public void execute() { public void execute() {
card.addCounter(Counters.P1P1, m); card.addCounter(Counters.P1P1, m);
} }
}); });//ComesIntoPlayCommand
final SpellAbility ability = new Ability(card, "2") { final SpellAbility ability = new Ability(card, "2") {
@Override
public void resolve() {
if(card.getController().equals(Constant.Player.Computer)) {
CardList choices = new CardList(AllZone.Computer_Play.getCards()).filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature();
}
});
if(choices.size() != 0) CardFactoryUtil.AI_getBestCreature(choices).addCounter(
Counters.P1P1, 1);
} else {
Card c = getTargetCard();
c.addCounter(Counters.P1P1, 1);
}
}//resolve()
@Override @Override
public boolean canPlay() { public boolean canPlay() {
@@ -4066,9 +4053,44 @@ public class CardFactory implements NewConstants {
if (sa.getSourceCard().equals(card)) return false; if (sa.getSourceCard().equals(card)) return false;
} }
return (card.getCounters(Counters.P1P1) > 0); return (card.getCounters(Counters.P1P1) > 0);
} }//canPlay()
@Override
public boolean canPlayAI() {
return getCreature().size() != 0
&& card.getCounters(Counters.P1P1) > 0
&& !CardFactoryUtil.AI_doesCreatureAttack(card);
}//canPlayAI()
@Override
public void chooseTargetAI() {
Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
setTargetCard(best);
card.subtractCounter(Counters.P1P1, 1);
}//chooseTargetAI()
CardList getCreature() {
CardList list = new CardList(AllZone.Computer_Play.getCards());
list = list.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature()
&& CardFactoryUtil.canTarget(card, c)
&& c.getNetAttack() > card.getNetAttack()
&& c != card;
}
});
return list;
}//getCreature()
@Override
public void resolve() {
if (AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
getTargetCard().addCounter(Counters.P1P1, 1);
}
}//resolve()
};//SpellAbility
};
Input target = new Input() { Input target = new Input() {
private static final long serialVersionUID = 903928778649052032L; private static final long serialVersionUID = 903928778649052032L;
@@ -4085,7 +4107,7 @@ public class CardFactory implements NewConstants {
@Override @Override
public void selectCard(Card target, PlayerZone zone) { public void selectCard(Card target, PlayerZone zone) {
// Choose a legal target, then sacrifice a creature // Choose a legal target, then remove a counter
if (!CardFactoryUtil.canTarget(ability, target)) { if (!CardFactoryUtil.canTarget(ability, target)) {
AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?)."); AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
} else if (target.isCreature() && zone.is(Constant.Zone.Play)) { } else if (target.isCreature() && zone.is(Constant.Zone.Play)) {
@@ -4095,11 +4117,13 @@ public class CardFactory implements NewConstants {
AllZone.GameAction.checkStateEffects(); AllZone.GameAction.checkStateEffects();
stop(); stop();
} }
} }//selectCard()
};//Input };//Input()
ability.setAfterPayMana(target); ability.setAfterPayMana(target);
ability.setStackDescription("Put a +1/+1 counter from " + card + " on target creature."); StringBuffer sb = new StringBuffer();
sb.append("Put a +1/+1 counter from ").append(card.getName()).append(" on target creature.");
ability.setStackDescription(sb.toString());
ability.setDescription("2, Remove a +1/+1 counter: Add a +1/+1 counter to target creature"); ability.setDescription("2, Remove a +1/+1 counter: Add a +1/+1 counter to target creature");
card.addSpellAbility(ability); card.addSpellAbility(ability);
} // if Spike } // if Spike