mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
HumanPlay: add ChangesZoneAll trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package forge.player;
|
package forge.player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -58,6 +60,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.player.PlayerView;
|
import forge.game.player.PlayerView;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.match.input.InputPayMana;
|
import forge.match.input.InputPayMana;
|
||||||
import forge.match.input.InputPayManaOfCostPayment;
|
import forge.match.input.InputPayManaOfCostPayment;
|
||||||
@@ -500,6 +503,8 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (part instanceof CostExile) {
|
else if (part instanceof CostExile) {
|
||||||
|
final CardCollection exiledList = new CardCollection();
|
||||||
|
ZoneType from = ZoneType.Graveyard;
|
||||||
if ("All".equals(part.getType())) {
|
if ("All".equals(part.getType())) {
|
||||||
if (!p.getController().confirmPayment(part, "Do you want to exile all cards in your graveyard?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to exile all cards in your graveyard?")) {
|
||||||
return false;
|
return false;
|
||||||
@@ -507,12 +512,12 @@ public class HumanPlay {
|
|||||||
|
|
||||||
CardCollection cards = new CardCollection(p.getCardsIn(ZoneType.Graveyard));
|
CardCollection cards = new CardCollection(p.getCardsIn(ZoneType.Graveyard));
|
||||||
for (final Card card : cards) {
|
for (final Card card : cards) {
|
||||||
p.getGame().getAction().exile(card);
|
exiledList.add(p.getGame().getAction().exile(card));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CostExile costExile = (CostExile) part;
|
CostExile costExile = (CostExile) part;
|
||||||
ZoneType from = costExile.getFrom();
|
from = costExile.getFrom();
|
||||||
List<Card> list = CardLists.getValidCards(p.getCardsIn(from), part.getType().split(";"), p, source, sourceAbility);
|
List<Card> list = CardLists.getValidCards(p.getCardsIn(from), part.getType().split(";"), p, source, sourceAbility);
|
||||||
final int nNeeded = getAmountFromPart(costPart, source, sourceAbility);
|
final int nNeeded = getAmountFromPart(costPart, source, sourceAbility);
|
||||||
if (list.size() < nNeeded) {
|
if (list.size() < nNeeded) {
|
||||||
@@ -527,19 +532,28 @@ public class HumanPlay {
|
|||||||
for (Card c : list) {
|
for (Card c : list) {
|
||||||
p.getGame().getAction().exile(c);
|
p.getGame().getAction().exile(c);
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
}
|
// replace this with input
|
||||||
// replace this with input
|
for (int i = 0; i < nNeeded; i++) {
|
||||||
for (int i = 0; i < nNeeded; i++) {
|
final Card c = p.getGame().getCard(SGuiChoose.oneOrNone("Exile from " + from, CardView.getCollection(list)));
|
||||||
final Card c = p.getGame().getCard(SGuiChoose.oneOrNone("Exile from " + from, CardView.getCollection(list)));
|
if (c == null) {
|
||||||
if (c == null) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
p.getGame().getAction().exile(c);
|
exiledList.add(p.getGame().getAction().exile(c));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!exiledList.isEmpty()) {
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
|
triggerList.put(from, exiledList);
|
||||||
|
runParams.put("Cards", triggerList);
|
||||||
|
runParams.put("Destination", ZoneType.Exile);
|
||||||
|
p.getGame().getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (part instanceof CostPutCardToLib) {
|
else if (part instanceof CostPutCardToLib) {
|
||||||
int amount = Integer.parseInt(((CostPutCardToLib) part).getAmount());
|
int amount = Integer.parseInt(((CostPutCardToLib) part).getAmount());
|
||||||
@@ -708,9 +722,22 @@ public class HumanPlay {
|
|||||||
private static boolean handleOfferingConvokeAndDelve(final SpellAbility ability, CardCollection cardsToDelve, boolean manaInputCancelled) {
|
private static boolean handleOfferingConvokeAndDelve(final SpellAbility ability, CardCollection cardsToDelve, boolean manaInputCancelled) {
|
||||||
if (!manaInputCancelled && !cardsToDelve.isEmpty()) {
|
if (!manaInputCancelled && !cardsToDelve.isEmpty()) {
|
||||||
Card hostCard = ability.getHostCard();
|
Card hostCard = ability.getHostCard();
|
||||||
|
final Game game = hostCard.getGame();
|
||||||
|
|
||||||
|
final CardCollection delved = new CardCollection();
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
|
|
||||||
for (final Card c : cardsToDelve) {
|
for (final Card c : cardsToDelve) {
|
||||||
hostCard.addDelved(c);
|
hostCard.addDelved(c);
|
||||||
hostCard.getGame().getAction().exile(c);
|
delved.add(game.getAction().exile(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!delved.isEmpty()) {
|
||||||
|
triggerList.put(ZoneType.Graveyard, delved);
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Cards", triggerList);
|
||||||
|
runParams.put("Destination", ZoneType.Exile);
|
||||||
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.isOffering() && ability.getSacrificedAsOffering() != null) {
|
if (ability.isOffering() && ability.getSacrificedAsOffering() != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user