- Implemented a part of the rule 119.7: a source can be a face-up card in the command zone.

This commit is contained in:
Agetian
2013-07-21 11:55:25 +00:00
parent a547bbc815
commit d5c9a9c34a

View File

@@ -48,11 +48,19 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
List<Card> permanentSources = new ArrayList<Card>(); List<Card> permanentSources = new ArrayList<Card>();
List<Card> stackSources = new ArrayList<Card>(); List<Card> stackSources = new ArrayList<Card>();
List<Card> referencedSources = new ArrayList<Card>(); List<Card> referencedSources = new ArrayList<Card>();
List<Card> commandZoneSources = new ArrayList<Card>();
List<Card> sourcesToChooseFrom = new ArrayList<Card>(); List<Card> sourcesToChooseFrom = new ArrayList<Card>();
// Get the list of permanent cards // Get the list of permanent cards
permanentSources = game.getCardsIn(ZoneType.Battlefield); permanentSources = game.getCardsIn(ZoneType.Battlefield);
// A source can be a face-up card in the command zone
commandZoneSources = new ArrayList<Card>();
for (Card c : game.getCardsIn(ZoneType.Command)) {
if (!c.isFaceDown()) {
commandZoneSources.add(c);
}
}
// Get the list of cards that produce effects on the stack // Get the list of cards that produce effects on the stack
@@ -91,32 +99,40 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
stackSources = CardLists.getValidCards(stackSources, sa.getParam("Choices"), host.getController(), host); stackSources = CardLists.getValidCards(stackSources, sa.getParam("Choices"), host.getController(), host);
referencedSources = CardLists.getValidCards(referencedSources, sa.getParam("Choices"), host.getController(), host); referencedSources = CardLists.getValidCards(referencedSources, sa.getParam("Choices"), host.getController(), host);
commandZoneSources = CardLists.getValidCards(commandZoneSources, sa.getParam("Choices"), host.getController(), host);
} }
if (sa.hasParam("TargetControls")) { if (sa.hasParam("TargetControls")) {
permanentSources = CardLists.filterControlledBy(permanentSources, tgtPlayers.get(0)); permanentSources = CardLists.filterControlledBy(permanentSources, tgtPlayers.get(0));
stackSources = CardLists.filterControlledBy(stackSources, tgtPlayers.get(0)); stackSources = CardLists.filterControlledBy(stackSources, tgtPlayers.get(0));
referencedSources = CardLists.filterControlledBy(referencedSources, tgtPlayers.get(0)); referencedSources = CardLists.filterControlledBy(referencedSources, tgtPlayers.get(0));
commandZoneSources = CardLists.filterControlledBy(commandZoneSources, tgtPlayers.get(0));
} }
Card divPermanentCards = new Card(); Card divPermanentSources = new Card();
divPermanentCards.setName("--PERMANENT SOURCES:--"); divPermanentSources.setName("--PERMANENT SOURCES:--");
Card divStackCards = new Card(); Card divStackSources = new Card();
divStackCards.setName("--SOURCES ON STACK:--"); divStackSources.setName("--SOURCES ON STACK:--");
Card divReferencedCards = new Card(); Card divReferencedSources = new Card();
divReferencedCards.setName("--SOURCES REFERENCED ON STACK:--"); divReferencedSources.setName("--SOURCES REFERENCED ON STACK:--");
Card divCommandZoneSources = new Card();
divCommandZoneSources.setName("--SOURCES IN COMMAND ZONE:--");
if (permanentSources.size() > 0) { if (permanentSources.size() > 0) {
sourcesToChooseFrom.add(divPermanentCards); sourcesToChooseFrom.add(divPermanentSources);
sourcesToChooseFrom.addAll(permanentSources); sourcesToChooseFrom.addAll(permanentSources);
} }
if (stackSources.size() > 0) { if (stackSources.size() > 0) {
sourcesToChooseFrom.add(divStackCards); sourcesToChooseFrom.add(divStackSources);
sourcesToChooseFrom.addAll(stackSources); sourcesToChooseFrom.addAll(stackSources);
} }
if (referencedSources.size() > 0) { if (referencedSources.size() > 0) {
sourcesToChooseFrom.add(divReferencedCards); sourcesToChooseFrom.add(divReferencedSources);
sourcesToChooseFrom.addAll(referencedSources); sourcesToChooseFrom.addAll(referencedSources);
} }
if (commandZoneSources.size() > 0) {
sourcesToChooseFrom.add(divCommandZoneSources);
sourcesToChooseFrom.addAll(commandZoneSources);
}
if (sourcesToChooseFrom.size() == 0) { if (sourcesToChooseFrom.size() == 0) {
return; return;
@@ -134,7 +150,7 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
Card o = null; Card o = null;
do { do {
o = GuiChoose.one(choiceTitle, sourcesToChooseFrom); o = GuiChoose.one(choiceTitle, sourcesToChooseFrom);
} while (o.equals(divPermanentCards) || o.equals(divStackCards) || o.equals(divReferencedCards)); } while (o.equals(divPermanentSources) || o.equals(divStackSources) || o.equals(divReferencedSources) || o.equals(divCommandZoneSources));
chosen.add(o); chosen.add(o);
sourcesToChooseFrom.remove(o); sourcesToChooseFrom.remove(o);