adding Zuran Orb. Includes a couple helper functions in CardFactoryUtil.java:

1) public static Card getWorstLand(String player);
2) public static CardList getLandsInPlay(String player);
This commit is contained in:
jendave
2011-08-06 03:58:48 +00:00
parent 87908a9ecf
commit d1d55be8a1
4 changed files with 129 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene
snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg
snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
zuran_orb.jpg http://www.wizards.com/global/images/magic/general/zuran_orb.jpg
storm_seeker.jpg http://www.wizards.com/global/images/magic/general/storm_seeker.jpg storm_seeker.jpg http://www.wizards.com/global/images/magic/general/storm_seeker.jpg
twiddle.jpg http://www.wizards.com/global/images/magic/general/twiddle.jpg twiddle.jpg http://www.wizards.com/global/images/magic/general/twiddle.jpg
kor_duelist.jpg http://www.wizards.com/global/images/magic/general/kor_duelist.jpg kor_duelist.jpg http://www.wizards.com/global/images/magic/general/kor_duelist.jpg

View File

@@ -1,3 +1,8 @@
Zuran Orb
0
Artifact
0: Sacrifice a land to gain 2 life.
Storm Seeker Storm Seeker
3 G 3 G
Instant Instant

View File

@@ -18142,6 +18142,51 @@ public class CardFactory implements NewConstants {
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START **************************
if(cardName.equals("Zuran Orb")) {
final SpellAbility ability = new Ability_Activated(card,"0") {
private static final long serialVersionUID = 6349074098650435648L;
public boolean canPlayAI() {
if( CardFactoryUtil.getLandsInPlay(Constant.Player.Computer).size() > 0 ) {
if( AllZone.GameAction.getPlayerLife(Constant.Player.Computer).getLife() < 5 ) {
return true;
}
else {
return false;
}
}
else return false;
}
public void chooseTargetAI() {
Card target = null;
target = CardFactoryUtil.getWorstLand(Constant.Player.Computer);
setTargetCard(target);
}//chooseTargetAI()
public void resolve() {
AllZone.GameAction.getPlayerLife(card.getController()).addLife(2);
AllZone.GameAction.sacrifice(getTargetCard());
}
};//SpellAbility
Input runtime = new Input() {
private static final long serialVersionUID = -64941510699003443L;
public void showMessage() {
ability.setStackDescription(card +" - Sacrifice a land to gain 2 life.");
PlayerZone play = AllZone.getZone(Constant.Zone.Play,card.getController());
CardList choice = new CardList(play.getCards());
choice = choice.getType("Land");
stopSetNext(CardFactoryUtil.input_sacrifice(ability,choice,"Select a land to sacrifice."));
}
};
ability.setStackDescription("Zuran Orb - Gain 2 life.");
card.addSpellAbility(ability);
ability.setBeforePayMana(runtime);
}//*************** END ************ END **************************
// Cards with Cycling abilities // Cards with Cycling abilities

View File

@@ -3539,6 +3539,84 @@ public class CardFactoryUtil {
*/ */
/**
* getWorstLand(String)
*
* This function finds the worst land a player has in play based on:
* worst
* 1. tapped, basic land
* 2. tapped, non-basic land
* 3. untapped, basic land
* 4. untapped, non-basic land
* best
*
* This is useful when the AI needs to find one of its lands to sacrifice
*
* @param player - Constant.Player.Human or Constant.Player.Computer
* @return the worst land found based on the description above
*/
public static Card getWorstLand(String player) {
Card worstLand = null;
CardList lands = CardFactoryUtil.getLandsInPlay(player);
//first, check for tapped, basic lands
for( int i = 0; i < lands.size(); i++ ) {
Card tmp = lands.get(i);
if(tmp.isTapped() && tmp.isBasicLand()) {
worstLand = tmp;
}
}
//next, check for tapped, non-basic lands
if(worstLand == null) {
for( int i = 0; i < lands.size(); i++ ) {
Card tmp = lands.get(i);
if(tmp.isTapped()) {
worstLand = tmp;
}
}
}
//next, untapped, basic lands
if(worstLand == null) {
for( int i = 0; i < lands.size(); i++ ) {
Card tmp = lands.get(i);
if(tmp.isUntapped() && tmp.isBasicLand()) {
worstLand = tmp;
}
}
}
//next, untapped, non-basic lands
if(worstLand == null) {
for( int i = 0; i < lands.size(); i++ ) {
Card tmp = lands.get(i);
if(tmp.isUntapped()) {
worstLand = tmp;
}
}
}
return worstLand;
}//end getWorstLand
/**
* getLandsInPlay(String)
*
* This function returns a CardList of all lands that the given
* player has in Constant.Zone.Play
*
* @param player - Constant.Player.Human or Constant.Player.Computer
* @return a CardList of that players lands
*/
public static CardList getLandsInPlay(String player) {
PlayerZone compBattlezone = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList(compBattlezone.getCards());
list = list.filter(new CardListFilter() {
public boolean addCard(Card c) {
if(c.isLand()) return true;
else return false;
}
});
return list;
}
//may return null //may return null
static public Card getRandomCard(CardList list) { static public Card getRandomCard(CardList list) {
if(list.size() == 0) return null; if(list.size() == 0) return null;