mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Added partial RememberSacrificed support to Sacrifice. Cannot remember Human choices because of game actions in GUI
This commit is contained in:
@@ -1185,7 +1185,8 @@ public class ComputerUtil {
|
|||||||
* @param amount a int.
|
* @param amount a int.
|
||||||
* @param list a {@link forge.CardList} object.
|
* @param list a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
static public void sacrificePermanents(int amount, CardList list) {
|
static public CardList sacrificePermanents(int amount, CardList list) {
|
||||||
|
CardList sacList = new CardList();
|
||||||
// used in Annihilator and AF_Sacrifice
|
// used in Annihilator and AF_Sacrifice
|
||||||
int max = list.size();
|
int max = list.size();
|
||||||
if (max > amount)
|
if (max > amount)
|
||||||
@@ -1220,8 +1221,10 @@ public class ComputerUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
|
sacList.add(c);
|
||||||
AllZone.getGameAction().sacrifice(c);
|
AllZone.getGameAction().sacrifice(c);
|
||||||
}
|
}
|
||||||
|
return sacList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
if (tgt != null)
|
if (tgt != null)
|
||||||
tgts = tgt.getTargetPlayers();
|
tgts = tgt.getTargetPlayers();
|
||||||
else
|
else
|
||||||
tgts = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgts = AbilityFactory.getDefinedPlayers(card, params.get("Defined"), sa);
|
||||||
|
|
||||||
String valid = params.get("SacValid");
|
String valid = params.get("SacValid");
|
||||||
if (valid == null)
|
if (valid == null)
|
||||||
@@ -351,30 +351,57 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
msg = "Sacrifice a " + msg;
|
msg = "Sacrifice a " + msg;
|
||||||
|
|
||||||
|
boolean remSacrificed = params.containsKey("RememberSacrificed");
|
||||||
|
if (remSacrificed)
|
||||||
|
card.clearRemembered();
|
||||||
|
|
||||||
if (valid.equals("Self")) {
|
if (valid.equals("Self")) {
|
||||||
if (AllZone.getZoneOf(sa.getSourceCard()).is(Constant.Zone.Battlefield))
|
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield))
|
||||||
AllZone.getGameAction().sacrifice(sa.getSourceCard());
|
AllZone.getGameAction().sacrifice(card);
|
||||||
|
if (remSacrificed) {
|
||||||
|
card.addRemembered(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//TODO - maybe this can be done smarter...
|
//TODO - maybe this can be done smarter...
|
||||||
else if (valid.equals("Card.AttachedBy")) {
|
else if (valid.equals("Card.AttachedBy")) {
|
||||||
Card toSac = sa.getSourceCard().getEnchantingCard();
|
Card toSac = card.getEnchantingCard();
|
||||||
if (AllZone.getZoneOf(sa.getSourceCard()).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
|
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
|
||||||
AllZone.getGameAction().sacrifice(toSac);
|
AllZone.getGameAction().sacrifice(toSac);
|
||||||
|
if (remSacrificed) {
|
||||||
|
card.addRemembered(toSac);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (valid.equals("TriggeredCard")) {
|
} else if (valid.equals("TriggeredCard")) {
|
||||||
Card equipee = (Card) sa.getTriggeringObject("Card");
|
Card equipee = (Card) sa.getTriggeringObject("Card");
|
||||||
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
|
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
|
||||||
AllZone.getGameAction().sacrifice(equipee);
|
AllZone.getGameAction().sacrifice(equipee);
|
||||||
|
if (remSacrificed) {
|
||||||
|
card.addRemembered(equipee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
CardList sacList = null;
|
||||||
for (Player p : tgts) {
|
for (Player p : tgts) {
|
||||||
|
|
||||||
if (p.isComputer())
|
//TODO - Can only add cards computer sacrificed to remembered list because
|
||||||
sacrificeAI(p, amount, valid, sa);
|
// human sacrifice choices are buried in a Input. Why is this hardcoded
|
||||||
|
// into the GUI!?! A better approach would be to have two different methods
|
||||||
|
// that return the sacrifice choices for the AI and the human respectively,
|
||||||
|
// then actually sacrifice the cards in this resolve method. (ArsenalNut 09/20/2011)
|
||||||
|
if (p.isComputer()) {
|
||||||
|
sacList = sacrificeAI(p, amount, valid, sa);
|
||||||
|
if (remSacrificed) {
|
||||||
|
for (int i = 0; i < sacList.size(); i++) {
|
||||||
|
card.addRemembered(sacList.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sacrificeHuman(p, amount, valid, sa, msg);
|
sacrificeHuman(p, amount, valid, sa, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -386,11 +413,13 @@ public class AbilityFactory_Sacrifice {
|
|||||||
* @param valid a {@link java.lang.String} object.
|
* @param valid a {@link java.lang.String} object.
|
||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void sacrificeAI(Player p, int amount, String valid, SpellAbility sa) {
|
private static CardList sacrificeAI(Player p, int amount, String valid, SpellAbility sa) {
|
||||||
CardList list = p.getCardsIn(Zone.Battlefield);
|
CardList list = p.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
ComputerUtil.sacrificePermanents(amount, list);
|
CardList sacList = ComputerUtil.sacrificePermanents(amount, list);
|
||||||
|
|
||||||
|
return sacList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user