- Fixed Karakas AI targeting code.

- Removed Corrupt from CardFactory_Creatures and readded it into CardFactory.
This commit is contained in:
jendave
2011-08-06 02:49:51 +00:00
parent 3674e5c873
commit c4d75273f0
4 changed files with 93 additions and 94 deletions

View File

@@ -1,6 +1,6 @@
program/mail=mtgerror@yahoo.com
program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26
program/version=MTG Forge -- official beta: 09/11/02, SVN revision: 90
program/version=MTG Forge -- official beta: 09/11/02, SVN revision: 92
tokens--file=AllTokens.txt

View File

@@ -16957,6 +16957,81 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase();
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
}//*************** END ************ END **************************
//*************** START *********** START **************************
if(cardName.equals("Corrupt"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 335838994716307031L;
Card check;
public boolean canPlayAI()
{
if(AllZone.Human_Life.getLife() <= countSwamps(card))
return true;
check = getFlying();
return check != null;
}
public int countSwamps(Card c)
{
PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
CardList swamps = new CardList(play.getCards());
swamps = swamps.getType("Swamp");
return swamps.size();
}
public void chooseTargetAI()
{
if(AllZone.Human_Life.getLife() <= 12) //12? mebbe 15?
{
setTargetPlayer(Constant.Player.Human);
return;
}
Card c = getFlying();
if((c == null) || (! check.equals(c)))
throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
setTargetCard(c);
}//chooseTargetAI()
//uses "damage" variable
Card getFlying()
{
CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
for(int i = 0; i < flying.size(); i++)
if(flying.get(i).getNetDefense() <= countSwamps(card))
return flying.get(i);
return null;
}
public void resolve()
{
int damage = countSwamps(card);
if(getTargetCard() != null)
{
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{
Card c = getTargetCard();
c.addDamage(damage);
AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
}
}
else {
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
}
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
}//*************** END ************ END **************************
// Cards with Cycling abilities

View File

@@ -10553,84 +10553,7 @@ public class CardFactory_Creatures {
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Corrupt"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 335838994716307031L;
Card check;
public boolean canPlayAI()
{
if(AllZone.Human_Life.getLife() <= countSwamps(card))
return true;
check = getFlying();
return check != null;
}
public int countSwamps(Card c)
{
PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
CardList swamps = new CardList(play.getCards());
swamps = swamps.getType("Swamp");
return swamps.size();
}
public void chooseTargetAI()
{
if(AllZone.Human_Life.getLife() <= 12) //12? mebbe 15?
{
setTargetPlayer(Constant.Player.Human);
return;
}
Card c = getFlying();
if((c == null) || (! check.equals(c)))
throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
setTargetCard(c);
}//chooseTargetAI()
//uses "damage" variable
Card getFlying()
{
CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
for(int i = 0; i < flying.size(); i++)
if(flying.get(i).getNetDefense() <= countSwamps(card))
return flying.get(i);
return null;
}
public void resolve()
{
int damage = countSwamps(card);
if(getTargetCard() != null)
{
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{
Card c = getTargetCard();
c.addDamage(damage);
AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
}
}
else {
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
}
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
}//*************** END ************ END **************************
//*************** START *********** START **************************
//*************** START *********** START **************************
else if(cardName.equals("Serra Avatar"))
{
Command leavesPlay = new Command()

View File

@@ -868,22 +868,23 @@ class CardFactory_Lands {
final Ability_Tap ability = new Ability_Tap(card, "0")
{
private static final long serialVersionUID = -6589125907956046586L;
private static final long serialVersionUID = -6589125907956046586L;
public boolean canPlayAI()
{
CardList list = new CardList(AllZone.Human_Play.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isCreature() && c.getKeyword().contains("Legendary");
}
});
setTargetCard(CardFactoryUtil.AI_getBestCreature(list, card));
return list.size() > 0;
}
public boolean canPlayAI()
{
CardList list = new CardList(AllZone.Human_Play.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isCreature() && c.getKeyword().contains("Legendary");
}
});
if (list.size() > 0)
setTargetCard(CardFactoryUtil.AI_getBestCreature(list, card));
return list.size() > 0;
}
public void resolve()
{