add etbLoseLife keyword as (K:etbLoseLife:3); The AI is built into Spell_Permanent so Compy won't do anything stupid.

-convert Serpent Warrior as an example.
This commit is contained in:
jendave
2011-08-06 14:45:44 +00:00
parent 72aee47cde
commit a88bc65c88
5 changed files with 55 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ ManaCost:2 B
Types:Creature Snake Warrior
Text:When CARDNAME enters the battlefield, you lose 3 life.
PT:3/3
K:etbLoseLife:3
SVar:Rarity:Common
SVar:Picture:http://resources.wizards.com/magic/cards/9ed/en-us/card83364.jpg
SetInfo:8ED|Common|http://magiccards.info/scans/en/8e/161.jpg

View File

@@ -1112,6 +1112,13 @@ public class Card extends MyObservable {
manaAbility.clear();
}
public Spell_Permanent getSpellPermanent() {
for(SpellAbility sa:spellAbility) {
if(sa instanceof Spell_Permanent) return (Spell_Permanent)sa;
}
return null;
}
public void clearSpellKeepManaAbility() {
spellAbility.clear();
}

View File

@@ -2938,6 +2938,42 @@ public class CardFactory implements NewConstants {
card.addComesIntoPlayCommand(etbGainLife);
} // etbGainLife
// Generic enters the battlefield lose life
// there is also code in Spell_Permanent canPlayAI to handle that part
if (hasKeyword(card, "etbLoseLife") != -1) {
int n = hasKeyword(card, "etbLoseLife");
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
String k[] = parse.split(":");
final int num = Integer.parseInt(k[1]);
card.getSpellPermanent().setLoseLifeAmount(num);
// performs the gain
final SpellAbility etbLoseLifeAbility = new Ability(card, "0") {
@Override
public void resolve() {
card.getController().loseLife(num, card);
}
};
// when the card enters the battlefield
Command etbLoseLife = new Command() {
private static final long serialVersionUID = -6797619430597211329L;
public void execute() {
StringBuilder sb = new StringBuilder();
sb.append(card.getController()).append(" loses "+num+" life");
etbLoseLifeAbility.setStackDescription(sb.toString());
AllZone.Stack.add(etbLoseLifeAbility);
}
};
card.addComesIntoPlayCommand(etbLoseLife);
} // etbLoseLife
// Generic destroy all card
/* Cards converted to AF_DestroyAll

View File

@@ -1551,7 +1551,7 @@ public class CardFactory_Creatures {
card.addComesIntoPlayCommand(intoPlay);
}//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Serpent Warrior")) {
SpellAbility summoningSpell = new Spell_Permanent(card) {
@@ -1586,7 +1586,7 @@ public class CardFactory_Creatures {
};
card.addComesIntoPlayCommand(intoPlay);
}//*************** END ************ END **************************
*/
//*************** START *********** START **************************
else if(cardName.equals("Eviscerator")) {

View File

@@ -7,6 +7,11 @@ public class Spell_Permanent extends Spell {
private boolean willChampion = false;
private String championType = null;
private int loseLifeAmount;
public void setLoseLifeAmount(int a) {
loseLifeAmount = a;
}
/////////////////////
///////
@@ -187,6 +192,10 @@ public class Spell_Permanent extends Spell {
return false;
}
if(!(AllZone.ComputerPlayer.getLife() > (loseLifeAmount+3))) {
return false;
}
return super.canPlayAI();
}//canPlayAI()