- Convert Kaervek's Spite to script (we should probably add code in LoseLife to handle this card if we expect the AI to use it)

This commit is contained in:
jendave
2011-08-07 00:33:42 +00:00
parent 9b4cc5555f
commit 96a7da5130
6 changed files with 43 additions and 138 deletions

View File

@@ -1722,48 +1722,7 @@ public class CardFactory implements NewConstants {
});
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Kaervek's Spite")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -6259614160639535500L;
@Override
public boolean canPlayAI() {
if(AllZone.HumanPlayer.getLife() <= 5) return true;
CardList playList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
CardList libList = AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer);
playList = playList.getName("Academy Rector");
libList = libList.getName("Barren Glory");
return (AllZone.HumanPlayer.getLife() <= 5) || (playList.size() == 1 && libList.size() >= 1);
}
@Override
public void resolve() {
CardList play = AllZoneUtil.getPlayerCardsInPlay(card.getController());
for(Card c:play) {
AllZone.GameAction.sacrifice(c);
}
card.getController().discardHand(this);
getTargetPlayer().loseLife(5, card);
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
// Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Goblin Charbelcher")) {
Cost abCost = new Cost("3 T", cardName, true);

View File

@@ -932,7 +932,8 @@ class CardFactory_Auras {
prevController[0] = c.getController();
AllZone.GameAction.moveToPlay(card);
c.attachCard(card);
card.enchantCard(c);
//c.attachCard(card);
AllZone.GameAction.changeController(new CardList(c), c.getController(), card.getController());
if(cardName.equals("Volition Reins")) {
if(c.isTapped()) c.untap();

View File

@@ -1248,93 +1248,7 @@ public class CardFactory_Instants {
spell.setStackDescription("Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way");
card.addSpellAbility(spell);
}//*************** END ************ END **************************
/*
//*************** START ********** START *************************
else if(cardName.equals("Mana Drain"))//NOTE: The AI can't cast this spell due to inability to use a manapool, but provisions are still made for it for if/when we get to that point.
{
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 6139754377230333678L;
@Override
public void resolve() {
SpellAbility sa = AllZone.Stack.pop();
if(card.getController().isHuman())
{
Phase.getManaDrain_BonusMana_Human().add(CardUtil.getConvertedManaCost(sa.getSourceCard()));
Phase.getManaDrain_Source_Human().add(card);
}
else if(card.getController().isComputer())
{
Phase.getManaDrain_BonusMana_AI().add(CardUtil.getConvertedManaCost(sa.getSourceCard()));
Phase.getManaDrain_Source_AI().add(card);
}
}
@Override
public boolean canPlayAI()
{
return false;
}
@Override
public boolean canPlay() {
if(AllZone.Stack.size() != 0)
{
return AllZone.Stack.peek().isSpell();
}
else
{
return false;
}
}
};
// Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
*/
//*************** START *********** START **************************
else if(cardName.equals("Kaervek's Spite")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -6259614160639535500L;
@Override
public boolean canPlayAI() {
if(AllZone.HumanPlayer.getLife() <= 5) return true;
CardList playList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
CardList libList = AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer);
playList = playList.getName("Academy Rector");
libList = libList.getName("Barren Glory");
return playList.size() == 1 && libList.size() >= 1;
}
@Override
public void resolve() {
CardList list = AllZoneUtil.getPlayerCardsInPlay(card.getController());
for(Card c:list) {
AllZone.GameAction.sacrifice(c);
}
card.getController().discardHand(this);
getTargetPlayer().loseLife(5, card);
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
// Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if( cardName.equals("Siren's Call") ) {
@@ -1489,7 +1403,6 @@ public class CardFactory_Instants {
String phase = AllZone.Phase.buildActivateString(Constant.Phase.Upkeep, Constant.Phase.Combat_Declare_Blockers_InstantAbility);
spell.getRestrictions().setActivatePhases(phase);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
}//*************** END ************ END **************************

View File

@@ -20,6 +20,8 @@ public class Cost {
public int getSacAmount() { return sacAmount; }
private boolean sacX = false;
public boolean isSacX() { return sacX; }
private boolean sacAll = false;
public boolean isSacAll() { return sacAll; }
private boolean exileCost = false;
public boolean getExileCost() { return exileCost; }
@@ -206,6 +208,7 @@ public class Cost {
parse = abUpdateParse(parse, sacStr);
if(splitStr[0].equals("X")) sacX = true;
else if(splitStr[0].equals("All")) sacAll = true;
else sacAmount = Integer.parseInt(splitStr[0]);
sacType = splitStr[1];
sacThis = (sacType.equals("CARDNAME"));
@@ -762,4 +765,4 @@ public class Cost {
return sb.toString();
}
}
}

View File

@@ -164,8 +164,11 @@ public class Cost_Payment {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
CardList typeList = new CardList(play.getCards());
typeList = typeList.getValidCards(cost.getSacType().split(";"),ability.getActivatingPlayer() ,ability.getSourceCard());
if (typeList.size() < cost.getSacAmount())
typeList = typeList.getValidCards(cost.getSacType().split(";"),ability.getActivatingPlayer() ,ability.getSourceCard());
int amount = cost.isSacAll() ? typeList.size() : cost.getSacAmount();
if (typeList.size() < amount)
return false;
}
else if (!AllZoneUtil.isCardInPlay(card))
@@ -375,7 +378,10 @@ public class Cost_Payment {
if (!paySac && cost.getSacCost()){ // sacrifice stuff here
if (cost.getSacThis())
setInput(sacrificeThis(ability, this));
else if(cost.isSacX()) setInput(sacrificeXType(ability, cost.getSacType(), this));
else if (cost.isSacAll())
sacrificeAllType(ability, cost.getSacType(), this);
else if (cost.isSacX())
setInput(sacrificeXType(ability, cost.getSacType(), this));
else
setInput(sacrificeType(ability, cost.getSacType(), this));
return false;
@@ -499,13 +505,19 @@ public class Cost_Payment {
// double check if something can be sacrificed here. Real check is in ComputerUtil.canPayAdditionalCosts()
if (cost.getSacCost()){
int amount = cost.getSacAmount();
if (cost.getSacThis())
sacCard.add(card);
else if (cost.isSacAll()){
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
typeList = typeList.getValidCards(cost.getSacType().split(","), card.getController(), card);
sacCard.add(typeList);
amount = sacCard.size();
}
else
sacCard = ComputerUtil.chooseSacrificeType(cost.getSacType(), card, ability.getTargetCard(), cost.getSacAmount());
if (sacCard.size() != cost.getSacAmount()){
if (sacCard.size() != amount){
System.out.println("Couldn't find a valid card to sacrifice for: "+card.getName());
return;
}
@@ -1023,6 +1035,22 @@ public class Cost_Payment {
return target;
}//sacrificeType()
public static void sacrificeAllType(final SpellAbility sa, final String type, final Cost_Payment payment){
// TODO Ask First
CardList typeList;
typeList = AllZoneUtil.getPlayerCardsInPlay(sa.getActivatingPlayer());
typeList = typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(), sa.getSourceCard());
for(Card card : typeList){
payment.getAbility().addSacrificedCost(card);
AllZone.GameAction.sacrifice(card);
}
payment.setPaySac(true);
payment.payCost();
}
public static Input sacrificeXType(final SpellAbility sa, final String type, final Cost_Payment payment){
Input target = new Input() {
private static final long serialVersionUID = -4496270321029213839L;