mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Restructured and improved performance of getExternalZoneActivationCards.
This commit is contained in:
@@ -2409,7 +2409,7 @@ public class CardFactoryUtil {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getGraveyardActivationCards.
|
||||
* getExternalZoneActivationCards.
|
||||
* </p>
|
||||
*
|
||||
* @param player
|
||||
@@ -2417,44 +2417,41 @@ public class CardFactoryUtil {
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public static CardList getExternalZoneActivationCards(final Player player) {
|
||||
CardList cl = new CardList();
|
||||
|
||||
cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Graveyard), player));
|
||||
cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Exile), player));
|
||||
cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Library), player));
|
||||
cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Command), player));
|
||||
|
||||
final List<Zone> sb = new ArrayList<Constant.Zone>(3);
|
||||
sb.add(Constant.Zone.Graveyard);
|
||||
sb.add(Constant.Zone.Exile);
|
||||
sb.add(Constant.Zone.Library);
|
||||
sb.add(Constant.Zone.Command);
|
||||
CardList cl = player.getCardsIn(sb);
|
||||
cl.addAll(AllZone.getStackZone().getCards());
|
||||
cl = cl.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return CardFactoryUtil.activateFromExternalZones(c, player);
|
||||
}
|
||||
});
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* activateFromGrave.
|
||||
* getActivateablesFromZone.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* @param zone
|
||||
* a PlayerZone object.
|
||||
* @param player
|
||||
* a {@link forge.Player} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean activateFromExternalZones(final Card c, final Player player) {
|
||||
final PlayerZone zone = AllZone.getZoneOf(c);
|
||||
public static CardList getActivateablesFromZone(final PlayerZone zone, final Player player) {
|
||||
|
||||
CardList cl = new CardList(zone.getCards());
|
||||
|
||||
cl = cl.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
if (zone.is(Constant.Zone.Graveyard)) {
|
||||
if (c.hasUnearth()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (c.isLand() && !zone.is(Constant.Zone.Battlefield) && c.hasKeyword("May be played")) {
|
||||
if (c.isLand() && c.hasKeyword("May be played")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2465,15 +2462,16 @@ public class CardFactoryUtil {
|
||||
}
|
||||
|
||||
if (sa.isSpell()
|
||||
&& !zone.is(Zone.Battlefield)
|
||||
&& (c.hasKeyword("May be played") || (c.hasStartOfKeyword("Flashback") && zone
|
||||
.is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user