mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'master' into master2
This commit is contained in:
@@ -26,71 +26,74 @@ public abstract class ManifestBaseEffect extends SpellAbilityEffect {
|
|||||||
final Game game = source.getGame();
|
final Game game = source.getGame();
|
||||||
// Usually a number leaving possibility for X, Sacrifice X land: Manifest X creatures.
|
// Usually a number leaving possibility for X, Sacrifice X land: Manifest X creatures.
|
||||||
final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(source, sa.getParam("Amount"), sa) : 1;
|
final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(source, sa.getParam("Amount"), sa) : 1;
|
||||||
|
final int times = sa.hasParam("Times") ? AbilityUtils.calculateAmount(source, sa.getParam("Times"), sa) : 1;
|
||||||
|
|
||||||
for (final Player p : getTargetPlayers(sa, "DefinedPlayer")) {
|
for (int i = 0; i < times; i++) {
|
||||||
CardCollection tgtCards;
|
for (final Player p : getTargetPlayers(sa, "DefinedPlayer")) {
|
||||||
Card toGrave = null;
|
CardCollection tgtCards;
|
||||||
boolean fromLibrary = false;
|
Card toGrave = null;
|
||||||
if (sa.hasParam("Choices") || sa.hasParam("ChoiceZone")) {
|
boolean fromLibrary = false;
|
||||||
ZoneType choiceZone = ZoneType.Hand;
|
if (sa.hasParam("Choices") || sa.hasParam("ChoiceZone")) {
|
||||||
if (sa.hasParam("ChoiceZone")) {
|
ZoneType choiceZone = ZoneType.Hand;
|
||||||
choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone"));
|
if (sa.hasParam("ChoiceZone")) {
|
||||||
fromLibrary = choiceZone.equals(ZoneType.Library);
|
choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone"));
|
||||||
}
|
fromLibrary = choiceZone.equals(ZoneType.Library);
|
||||||
CardCollectionView choices = p.getCardsIn(choiceZone);
|
}
|
||||||
if (sa.hasParam("Choices")) {
|
CardCollectionView choices = p.getCardsIn(choiceZone);
|
||||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), activator, source, sa);
|
if (sa.hasParam("Choices")) {
|
||||||
}
|
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), activator, source, sa);
|
||||||
if (choices.isEmpty()) {
|
}
|
||||||
continue;
|
if (choices.isEmpty()) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : getDefaultMessage() + " ";
|
String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : getDefaultMessage() + " ";
|
||||||
|
|
||||||
tgtCards = new CardCollection(p.getController().chooseCardsForEffect(choices, sa, title, amount, amount, false, null));
|
tgtCards = new CardCollection(p.getController().chooseCardsForEffect(choices, sa, title, amount, amount, false, null));
|
||||||
} else if (sa.hasParam("Dread")) {
|
} else if (sa.hasParam("Dread")) {
|
||||||
tgtCards = p.getTopXCardsFromLibrary(2);
|
tgtCards = p.getTopXCardsFromLibrary(2);
|
||||||
if (!tgtCards.isEmpty()) {
|
if (!tgtCards.isEmpty()) {
|
||||||
Card manifest = p.getController().chooseSingleEntityForEffect(tgtCards, sa, getDefaultMessage(), null);
|
Card manifest = p.getController().chooseSingleEntityForEffect(tgtCards, sa, getDefaultMessage(), null);
|
||||||
tgtCards.remove(manifest);
|
tgtCards.remove(manifest);
|
||||||
toGrave = tgtCards.isEmpty() ? null : tgtCards.getFirst();
|
toGrave = tgtCards.isEmpty() ? null : tgtCards.getFirst();
|
||||||
tgtCards = new CardCollection(manifest);
|
tgtCards = new CardCollection(manifest);
|
||||||
}
|
}
|
||||||
fromLibrary = true;
|
|
||||||
} else if ("TopOfLibrary".equals(sa.getParamOrDefault("Defined", "TopOfLibrary"))) {
|
|
||||||
tgtCards = p.getTopXCardsFromLibrary(amount);
|
|
||||||
fromLibrary = true;
|
|
||||||
} else {
|
|
||||||
tgtCards = getTargetCards(sa);
|
|
||||||
if (Iterables.all(tgtCards, CardPredicates.inZone(ZoneType.Library))) {
|
|
||||||
fromLibrary = true;
|
fromLibrary = true;
|
||||||
|
} else if ("TopOfLibrary".equals(sa.getParamOrDefault("Defined", "TopOfLibrary"))) {
|
||||||
|
tgtCards = p.getTopXCardsFromLibrary(amount);
|
||||||
|
fromLibrary = true;
|
||||||
|
} else {
|
||||||
|
tgtCards = getTargetCards(sa);
|
||||||
|
if (Iterables.all(tgtCards, CardPredicates.inZone(ZoneType.Library))) {
|
||||||
|
fromLibrary = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (sa.hasParam("Shuffle")) {
|
if (sa.hasParam("Shuffle")) {
|
||||||
CardLists.shuffle(tgtCards);
|
CardLists.shuffle(tgtCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromLibrary) {
|
if (fromLibrary) {
|
||||||
for (Card c : tgtCards) {
|
for (Card c : tgtCards) {
|
||||||
// CR 701.34d If an effect instructs a player to manifest multiple cards from their library, those cards are manifested one at a time.
|
// CR 701.34d If an effect instructs a player to manifest multiple cards from their library, those cards are manifested one at a time.
|
||||||
|
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
|
||||||
|
CardZoneTable triggerList = AbilityKey.addCardZoneTableParams(moveParams, sa);
|
||||||
|
internalEffect(c, p, sa, moveParams);
|
||||||
|
if (sa.hasParam("Dread") && toGrave != null) {
|
||||||
|
game.getAction().moveToGraveyard(toGrave, sa, moveParams);
|
||||||
|
toGrave = null;
|
||||||
|
}
|
||||||
|
triggerList.triggerChangesZoneAll(game, sa);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// manifest from other zones should be done at the same time
|
||||||
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
|
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
|
||||||
CardZoneTable triggerList = AbilityKey.addCardZoneTableParams(moveParams, sa);
|
CardZoneTable triggerList = AbilityKey.addCardZoneTableParams(moveParams, sa);
|
||||||
internalEffect(c, p, sa, moveParams);
|
for (Card c : tgtCards) {
|
||||||
if (sa.hasParam("Dread") && toGrave != null) {
|
internalEffect(c, p, sa, moveParams);
|
||||||
game.getAction().moveToGraveyard(toGrave, sa, moveParams);
|
|
||||||
toGrave = null;
|
|
||||||
}
|
}
|
||||||
triggerList.triggerChangesZoneAll(game, sa);
|
triggerList.triggerChangesZoneAll(game, sa);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// manifest from other zones should be done at the same time
|
|
||||||
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
|
|
||||||
CardZoneTable triggerList = AbilityKey.addCardZoneTableParams(moveParams, sa);
|
|
||||||
for (Card c : tgtCards) {
|
|
||||||
internalEffect(c, p, sa, moveParams);
|
|
||||||
}
|
|
||||||
triggerList.triggerChangesZoneAll(game, sa);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user