- BNG: Added Ephara, God of the Polis

This commit is contained in:
swordshine
2014-01-13 09:56:21 +00:00
parent ee5187c7e7
commit 559c96412a
3 changed files with 92 additions and 3 deletions

View File

@@ -1169,7 +1169,7 @@ public class CardFactoryUtil {
}
// Count$Chroma.<mana letter>
if (sq[0].contains("Chroma") || sq[0].contains("Devotion")) {
if (sq[0].contains("Chroma") || sq[0].equals("Devotion")) {
ZoneType sourceZone = sq[0].contains("ChromaInGrave") ? ZoneType.Graveyard : ZoneType.Battlefield;
String colorAbb = sq[1];
if (colorAbb.contains("Chosen")) {
@@ -1192,6 +1192,19 @@ public class CardFactoryUtil {
}
return doXMath(colorOcurrencices, m, c);
}
if (sq[0].contains("DevotionDual")) {
int colorOcurrencices = 0;
byte color1 = MagicColor.fromName(sq[1]);
byte color2 = MagicColor.fromName(sq[2]);
for(Card c0 : cc.getCardsIn(ZoneType.Battlefield)) {
for (ManaCostShard sh : c0.getManaCost()) {
if (sh.canBePaidWithManaOfColor(color1) || sh.canBePaidWithManaOfColor(color2)) {
colorOcurrencices++;
}
}
}
return doXMath(colorOcurrencices, m, c);
}
if (sq[0].contains("Hellbent")) return doXMath(Integer.parseInt(sq[cc.hasHellbent() ? 1 : 2]), m, c);
if (sq[0].contains("Metalcraft")) return doXMath(Integer.parseInt(sq[cc.hasMetalcraft() ? 1 : 2]), m, c);
@@ -1297,6 +1310,19 @@ public class CardFactoryUtil {
return doXMath(res.size(), m, c);
}
// Count$LastTurnEntered <ZoneDestination> [from <ZoneOrigin>] <Valid>
if (sq[0].contains("LastTurnEntered")) {
final String[] workingCopy = l[0].split("_");
ZoneType destination = ZoneType.smartValueOf(workingCopy[1]);
final boolean hasFrom = workingCopy[2].equals("from");
ZoneType origin = hasFrom ? ZoneType.smartValueOf(workingCopy[3]) : null;
String validFilter = workingCopy[hasFrom ? 4 : 2] ;
final List<Card> res = CardUtil.getLastTurnEntered(destination, origin, validFilter, c);
return doXMath(res.size(), m, c);
}
// Count$AttackersDeclared
if (sq[0].contains("AttackersDeclared")) {
return doXMath(cc.getAttackersDeclaredThisTurn(), m, c);

View File

@@ -88,6 +88,31 @@ public final class CardUtil {
return res;
}
/**
* getLastTurnEntered.
*
* @param to zone going to
* @param from zone coming from
* @param valid a isValid expression
* @param src a Card object
* @return a List<Card> that matches the given criteria
*/
public static List<Card> getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
List<Card> res = new ArrayList<Card>();
final Game game = src.getGame();
if (to != ZoneType.Stack) {
for (Player p : game.getPlayers()) {
res.addAll(p.getZone(to).getCardsAddedLastTurn(from));
}
} else {
res.addAll(game.getStackZone().getCardsAddedLastTurn(from));
}
res = CardLists.getValidCards(res, valid, src.getController(), src);
return res;
}
public static List<Card> getThisTurnCast(final String valid, final Card src) {
List<Card> res = new ArrayList<Card>();
final Game game = src.getGame();

View File

@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.CopyOnWriteArrayList;
import com.google.common.base.Predicate;
@@ -56,6 +57,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
protected final Game game;
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
protected final transient MapOfLists<ZoneType, Card> cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
public Zone(final ZoneType zone, Game game) {
this.zoneType = zone;
@@ -177,6 +179,15 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
return cardsAddedThisTurn;
}
/**
* <p>
* Getter for the field <code>cardsAddedLastTurn</code>.
* </p>
*/
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn() {
return cardsAddedLastTurn;
}
/**
* <p>
* Getter for the field <code>cardsAddedThisTurn</code>.
@@ -188,14 +199,37 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
*/
public final List<Card> getCardsAddedThisTurn(final ZoneType origin) {
//System.out.print("Request cards put into " + this.getZoneType() + " from " + origin + ".Amount: ");
return getCardsAdded(cardsAddedThisTurn, origin);
}
/**
* <p>
* Getter for the field <code>getcardsAddedLastTurn</code>.
* </p>
*
* @param origin
* a {@link java.lang.String} object.
* @return a {@link forge.CardList} object.
*/
public final List<Card> getCardsAddedLastTurn(final ZoneType origin) {
//System.out.print("Last turn - Request cards put into " + this.getZoneType() + " from " + origin + ".Amount: ");
return getCardsAdded(cardsAddedLastTurn, origin);
}
/**
* <p>
* getCardsAdded.
* </p>
*/
private final List<Card> getCardsAdded(final MapOfLists<ZoneType, Card> cardsAdded, final ZoneType origin) {
if (origin != null) {
Collection<Card> cards = cardsAddedThisTurn.get(origin);
Collection<Card> cards = cardsAdded.get(origin);
return cards == null ? Lists.<Card>newArrayList() : Lists.newArrayList(cards);
}
// all cards if key == null
final List<Card> ret = new ArrayList<Card>();
for (Collection<Card> kv : cardsAddedThisTurn.values()) {
for (Collection<Card> kv : cardsAdded.values()) {
ret.addAll(kv);
}
return ret;
@@ -207,6 +241,10 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
* </p>
*/
public final void resetCardsAddedThisTurn() {
this.cardsAddedLastTurn.clear();
for (Entry<ZoneType, Collection<Card>> entry : this.cardsAddedThisTurn.entrySet()) {
this.cardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
}
this.cardsAddedThisTurn.clear();
}