crown_of_empires - uses a common variable, not a custom condition to check for M12 empire parts.

Removed special conditions from spellability/SpellAbilityCondition.java
adjusted visibility for a few methods
Zone: cotains(predicate<Card>) method added, still don't know if it's correct to put it there.
This commit is contained in:
Maxmtg
2013-05-18 22:38:36 +00:00
parent 323fbcfb92
commit ccf9fd4600
10 changed files with 18 additions and 119 deletions

View File

@@ -1,10 +1,11 @@
Name:Crown of Empires
ManaCost:2
Types:Artifact
A:AB$ Tap | Cost$ 3 T | ValidTgts$ Creature | TgtPrompt$ Select target creature | ConditionNotAllM12Empires$ True | SubAbility$ DBControl | SpellDescription$ Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
SVar:DBControl:DB$ GainControl | Defined$ Targeted | ConditionAllM12Empires$ True
A:AB$ Tap | Cost$ 3 T | ValidTgts$ Creature | TgtPrompt$ Select target creature | ConditionCheckSVar$ M12Complete | ConditionSVarCompare$ EQ0 | SubAbility$ DBControl | SpellDescription$ Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
SVar:DBControl:DB$ GainControl | Defined$ Targeted | ConditionCheckSVar$ M12Complete
SVar:RemRandomDeck:True
DeckHints:Name$Scepter of Empires|Throne of Empires
SVar:M12Complete:Count$AllM12Empires.1.0
SVar:Picture:http://www.wizards.com/global/images/magic/general/crown_of_empires.jpg
Oracle:{3}, {T}: Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
SetInfo:M12 Uncommon

View File

@@ -1452,9 +1452,7 @@ public class CardFactoryUtil {
// Count$M12Empires.<numIf>.<numIfNot>
if (sq[0].contains("AllM12Empires")) {
boolean has = c.getController().isCardInPlay("Crown of Empires");
has &= c.getController().isCardInPlay("Scepter of Empires");
has &= c.getController().isCardInPlay("Throne of Empires");
boolean has = cc.isCardInPlay("Crown of Empires") && cc.isCardInPlay("Scepter of Empires") && cc.isCardInPlay("Throne of Empires");
return doXMath(Integer.parseInt(sq[has ? 1 : 2]), m, c);
}

View File

@@ -116,13 +116,6 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
this.setPhases(PhaseType.parseRange(params.get("ConditionPhases")));
}
if (params.containsKey("ConditionAllM12Empires")) {
this.setAllM12Empires(true);
}
if (params.containsKey("ConditionNotAllM12Empires")) {
this.setNotAllM12Empires(true);
}
if (params.containsKey("ConditionChosenColor")) {
this.setColorToCheck(params.get("ConditionChosenColor"));
}
@@ -233,25 +226,6 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
}
}
if (this.isAllM12Empires()) {
final Player p = sa.getSourceCard().getController();
boolean has = p.isCardInPlay("Crown of Empires");
has &= p.isCardInPlay("Scepter of Empires");
has &= p.isCardInPlay("Throne of Empires");
if (!has) {
return false;
}
}
if (this.isNotAllM12Empires()) {
final Player p = sa.getSourceCard().getController();
boolean has = p.isCardInPlay("Crown of Empires");
has &= p.isCardInPlay("Scepter of Empires");
has &= p.isCardInPlay("Throne of Empires");
if (has) {
return false;
}
}
if (this.getCardsInHand() != -1) {
// Can handle Library of Alexandria, or Hellbent
if (activator.getCardsIn(ZoneType.Hand).size() != this.getCardsInHand()) {

View File

@@ -82,8 +82,6 @@ public class SpellAbilityVariables {
this.lifeAmount = sav.getLifeAmount();
this.manaSpent = sav.getManaSpent();
this.pwAbility = sav.isPwAbility();
this.allM12Empires = sav.isAllM12Empires();
this.notAllM12Empires = sav.isNotAllM12Empires();
}
// default values for Sorcery speed abilities
@@ -174,63 +172,10 @@ public class SpellAbilityVariables {
/** The pw ability. */
private boolean pwAbility = false;
/** The all m12 empires. */
private boolean allM12Empires = false;
/** The not all m12 empires. */
private boolean notAllM12Empires = false;
/** The chosen colors string. */
private String chosenColors = null;
/**
* <p>
* Setter for the field <code>notAllM12Empires</code>.
* </p>
*
* @param b
* a boolean
*/
public final void setNotAllM12Empires(final boolean b) {
this.notAllM12Empires = b;
}
/**
* <p>
* Getter for the field <code>notAllM12Empires</code>.
* </p>
*
* @return a boolean
*/
public final boolean getNotAllM12Empires() {
return this.isNotAllM12Empires();
}
/**
* <p>
* Setter for the field <code>allM12Empires</code>.
* </p>
*
* @param b
* a boolean
*/
public final void setAllM12Empires(final boolean b) {
this.allM12Empires = b;
}
/**
* <p>
* Getter for the field <code>allM12Empires</code>.
* </p>
*
* @return a boolean
*/
public final boolean getAllM12Empires() {
return this.isAllM12Empires();
}
/**
* <p>
* Setter for the field <code>manaSpent</code>.
@@ -819,25 +764,6 @@ public class SpellAbilityVariables {
public final String getPresentDefined() {
return this.presentDefined;
}
/**
* Checks if is all m12 empires.
*
* @return the allM12Empires
*/
public final boolean isAllM12Empires() {
return this.allM12Empires;
}
/**
* Checks if is not all m12 empires.
*
* @return the notAllM12Empires
*/
public final boolean isNotAllM12Empires() {
return this.notAllM12Empires;
}
/**
* Gets the s var operand.
*

View File

@@ -84,7 +84,7 @@ public class AiController {
game = game0;
}
public final SpellAbility getSpellAbilityToPlay() {
private final SpellAbility getSpellAbilityToPlay() {
// if top of stack is owned by me
if (!game.getStack().isEmpty() && game.getStack().peekAbility().getActivatingPlayer().equals(player)) {
// probably should let my stuff resolve

View File

@@ -2771,11 +2771,11 @@ public class Player extends GameEntity implements Comparable<Player> {
return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.LANDS);
}
public boolean isCardInPlay(final String cardName) {
return Iterables.any(getZone(ZoneType.Battlefield), CardPredicates.nameEquals(cardName));
return getZone(ZoneType.Battlefield).contains(CardPredicates.nameEquals(cardName));
}
public boolean isCardInCommand(final String cardName) {
return Iterables.any(getZone(ZoneType.Command), CardPredicates.nameEquals(cardName));
return getZone(ZoneType.Command).contains(CardPredicates.nameEquals(cardName));
}
public List<Card> getColoredCardsInPlay(final String color) {

View File

@@ -19,6 +19,8 @@ package forge.game.zone;
import java.util.List;
import com.google.common.base.Predicate;
import forge.Card;
/**
@@ -121,6 +123,7 @@ interface IZone {
* @return true, if successful
*/
boolean contains(Card c);
boolean contains(final Predicate<Card> condition);
/**
* isEmpty returns true if given zone contains no cards.
*

View File

@@ -25,6 +25,9 @@ import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.CopyOnWriteArrayList;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.Card;
import forge.game.player.Player;
import forge.util.MyObservable;
@@ -171,6 +174,10 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
return this.cardList.contains(c);
}
public final boolean contains(final Predicate<Card> condition) {
return Iterables.any(this.cardList, condition);
}
public final int getPosition(final Card c) {
return this.cardList.indexOf(c);
}

View File

@@ -412,7 +412,7 @@ public final class GuiDisplayUtil {
* a {@link forge.game.player.Player} object.
* @return a {@link forge.CardList} object.
*/
public static List<Card> devProcessCardsForZone(final String[] data, final Player player) {
private static List<Card> devProcessCardsForZone(final String[] data, final Player player) {
final List<Card> cl = new ArrayList<Card>();
for (final String element : data) {
final String[] cardinfo = element.trim().split("\\|");

View File

@@ -54,14 +54,4 @@ public class MyRandom {
public static Random getRandom() {
return MyRandom.random;
}
/**
* Sets the random.
*
* @param random0
* the random to set
*/
public static void setRandom(final Random random0) {
MyRandom.random = random0;
}
}