- First step towards the player keyword "Spells and abilities your opponents control can't cause you to sacrifice permanents."

This commit is contained in:
Sloth
2012-04-28 21:02:51 +00:00
parent 6011413b0c
commit a06cd1bb5a
19 changed files with 65 additions and 66 deletions

View File

@@ -1275,7 +1275,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
if (hasVanish && AllZoneUtil.isCardInPlay(this)) {
Singletons.getModel().getGameAction().sacrifice(this);
Singletons.getModel().getGameAction().sacrifice(this, null);
}
if (this.hasSuspend() && AllZoneUtil.isCardExiled(this)) {

View File

@@ -1176,7 +1176,7 @@ public class GameAction {
* a {@link forge.Card} object.
* @return a boolean.
*/
public final boolean sacrifice(final Card c) {
public final boolean sacrifice(final Card c, final SpellAbility source) {
if (c.isImmutable()) {
System.out.println("Trying to sacrifice immutables: " + c);
return false;

View File

@@ -459,7 +459,7 @@ public final class AbilityFactoryCopy {
if (params.get("AtEOT").equals("Sacrifice")) {
// maybe do a setSacrificeAtEOT, but
// probably not.
Singletons.getModel().getGameAction().sacrifice(target[index]);
Singletons.getModel().getGameAction().sacrifice(target[index], sa);
} else if (params.get("AtEOT").equals("Exile")) {
Singletons.getModel().getGameAction().exile(target[index]);
}

View File

@@ -552,7 +552,7 @@ public class AbilityFactoryDestroy {
for (final Card tgtC : tgtCards) {
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
if (sac) {
Singletons.getModel().getGameAction().sacrifice(tgtC);
Singletons.getModel().getGameAction().sacrifice(tgtC, sa);
} else if (noRegen) {
Singletons.getModel().getGameAction().destroyNoRegeneration(tgtC);
} else {
@@ -566,7 +566,7 @@ public class AbilityFactoryDestroy {
for (final Card unTgtC : untargetedCards) {
if (AllZoneUtil.isCardInPlay(unTgtC)) {
if (sac) {
Singletons.getModel().getGameAction().sacrifice(unTgtC);
Singletons.getModel().getGameAction().sacrifice(unTgtC, sa);
} else if (noRegen) {
Singletons.getModel().getGameAction().destroyNoRegeneration(unTgtC);
} else {

View File

@@ -369,7 +369,7 @@ public class AbilityFactoryMana {
final int num = card.getCounters(Counters.getType(deplete));
if (num == 0) {
abMana.setUndoable(false);
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
}

View File

@@ -452,8 +452,7 @@ public class AbilityFactorySacrifice {
if (valid.equals("Self")) {
if (AllZone.getZoneOf(card).is(ZoneType.Battlefield)) {
Singletons.getModel().getGameAction().sacrifice(card);
if (remSacrificed) {
if (Singletons.getModel().getGameAction().sacrifice(card, sa) && remSacrificed) {
card.addRemembered(card);
}
}
@@ -543,7 +542,7 @@ public class AbilityFactorySacrifice {
sacList.add(c);
}
} else {
if (Singletons.getModel().getGameAction().sacrifice(c)) {
if (Singletons.getModel().getGameAction().sacrifice(c, sa)) {
sacList.add(c);
}
}
@@ -836,7 +835,7 @@ public class AbilityFactorySacrifice {
list = AbilityFactory.filterListByType(list, valid, sa);
for (int i = 0; i < list.size(); i++) {
if (Singletons.getModel().getGameAction().sacrifice(list.get(i)) && remSacrificed) {
if (Singletons.getModel().getGameAction().sacrifice(list.get(i), sa) && remSacrificed) {
card.addRemembered(list.get(i));
}
}

View File

@@ -154,7 +154,7 @@ class CardFactoryArtifacts {
AllZone.getHumanPlayer().discard(c, null);
this.stop();
} else if (c.equals(card)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
}
@@ -165,7 +165,7 @@ class CardFactoryArtifacts {
public void resolve() {
if (card.getController().isHuman()) {
if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).isEmpty()) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
} else {
AllZone.getInputControl().setInput(discard);
}

View File

@@ -480,7 +480,7 @@ class CardFactoryAuras {
if (!grave.is(ZoneType.Graveyard)) {
// Animated Creature got removed before ability resolved
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
return;
}
@@ -496,7 +496,7 @@ class CardFactoryAuras {
if (CardFactoryUtil.hasProtectionFrom(card, animated)) {
// Animated a creature with protection
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
return;
}
@@ -534,7 +534,7 @@ class CardFactoryAuras {
final PlayerZone play = card.getController().getZone(ZoneType.Battlefield);
if (play.contains(c)) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
}
}; // Detach

View File

@@ -209,7 +209,7 @@ public class CardFactoryCreatures {
public void resolve() {
final CardList hand = card.getController().getCardsIn(ZoneType.Hand);
if (hand.size() == 0) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
} else {
card.getController().discardRandom(this);
}
@@ -547,7 +547,7 @@ public class CardFactoryCreatures {
@Override
public void execute() {
if (AllZoneUtil.isCardInPlay(card)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
}
});
@@ -1587,7 +1587,7 @@ public class CardFactoryCreatures {
@Override
public void selectButtonCancel() {
toSac.clear();
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
@@ -1603,10 +1603,10 @@ public class CardFactoryCreatures {
private void done() {
if (getTotalPower() >= 12) {
for (final Card sac : toSac) {
Singletons.getModel().getGameAction().sacrifice(sac);
Singletons.getModel().getGameAction().sacrifice(sac, null);
}
} else {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
toSac.clear();
this.stop();

View File

@@ -213,14 +213,14 @@ class CardFactoryLands {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
@Override
public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(ZoneType.Battlefield) && c.isUntapped()) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
if (paid[0] < 1) {
paid[0]++;
final StringBuilder sb = new StringBuilder();
@@ -234,7 +234,7 @@ class CardFactoryLands {
}; // Input
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
.size() < 2)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
return;
} else {
AllZone.getInputControl().setInput(target);
@@ -283,12 +283,12 @@ class CardFactoryLands {
// if any are tapped, sacrifice it
// else sacrifice random
if (tappedLand.size() > 0) {
Singletons.getModel().getGameAction().sacrifice(tappedLand.get(0));
Singletons.getModel().getGameAction().sacrifice(tappedLand.get(0), null);
} else {
Singletons.getModel().getGameAction().sacrifice(land.get(0));
Singletons.getModel().getGameAction().sacrifice(land.get(0), null);
}
} else {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
} else { // this is the human resolution
final Input target = new Input() {
@@ -303,14 +303,14 @@ class CardFactoryLands {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
@Override
public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(ZoneType.Battlefield) && land.contains(c)) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
this.stop();
}
} // selectCard()
@@ -342,7 +342,7 @@ class CardFactoryLands {
if (land.size() > 0) {
for (final Card c : land) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
}
}
@@ -367,21 +367,21 @@ class CardFactoryLands {
CardList tappedPlains = new CardList(plains);
tappedPlains = tappedPlains.getType("Basic");
for (final Card c : tappedPlains) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
for (int i = 0; i < tappedPlains.size(); i++) {
Singletons.getModel().getGameAction().sacrifice(plains.get(i));
Singletons.getModel().getGameAction().sacrifice(plains.get(i), null);
}
// if any are tapped, sacrifice it
// else sacrifice random
} else {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
} else { // this is the human resolution
final int[] paid = { 0 };
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
.size() < 2)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
return;
}
final Input target = new Input() {
@@ -396,14 +396,14 @@ class CardFactoryLands {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
@Override
public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(ZoneType.Battlefield) && c.isUntapped()) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
if (paid[0] < 1) {
paid[0]++;
CMatchUI.SINGLETON_INSTANCE.showMessage(
@@ -659,7 +659,7 @@ class CardFactoryLands {
Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(land));
}
} else {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
} else { // this is the human resolution
final Input target = new Input() {
@@ -676,7 +676,7 @@ class CardFactoryLands {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}
@@ -728,7 +728,7 @@ class CardFactoryLands {
final Card c = CardFactoryUtil.getWorstLand(land);
Singletons.getModel().getGameAction().moveToHand(c);
} else {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
} else { // this is the human resolution
final Input target = new Input() {
@@ -745,7 +745,7 @@ class CardFactoryLands {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.stop();
}

View File

@@ -506,7 +506,7 @@ public class CardFactorySorceries {
// selected are sacrificed.
for (int i = 0; i < target.size(); i++) {
if (AllZoneUtil.isCardInPlay(target.get(i)) && !saveList.contains(target.get(i))) {
Singletons.getModel().getGameAction().sacrifice(target.get(i));
Singletons.getModel().getGameAction().sacrifice(target.get(i), this);
}
}
} // resolve()
@@ -738,7 +738,7 @@ public class CardFactorySorceries {
if (compLand.size() > humLand.size()) {
compLand.shuffle();
for (int i = 0; i < (compLand.size() - humLand.size()); i++) {
Singletons.getModel().getGameAction().sacrifice(compLand.get(i));
Singletons.getModel().getGameAction().sacrifice(compLand.get(i), this);
}
} else if (humLand.size() > compLand.size()) {
final int diff = humLand.size() - compLand.size();
@@ -765,7 +765,7 @@ public class CardFactorySorceries {
CardListUtil.sortCMC(compCreats);
compCreats.reverse();
for (int i = 0; i < (compCreats.size() - humCreats.size()); i++) {
Singletons.getModel().getGameAction().sacrifice(compCreats.get(i));
Singletons.getModel().getGameAction().sacrifice(compCreats.get(i), this);
}
} else if (humCreats.size() > compCreats.size()) {
final int diff = humCreats.size() - compCreats.size();
@@ -1895,7 +1895,7 @@ public class CardFactorySorceries {
if (toSac != null) {
final Card c = (Card) toSac;
baseCMC = CardUtil.getConvertedManaCost(c);
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, this);
} else {
return;
}

View File

@@ -1816,7 +1816,7 @@ public class CardFactoryUtil {
@Override
public void selectButtonCancel() {
Singletons.getModel().getGameAction().sacrifice(crd);
Singletons.getModel().getGameAction().sacrifice(crd, null);
this.stop();
}
@@ -1824,7 +1824,7 @@ public class CardFactoryUtil {
public void selectCard(final Card card, final PlayerZone zone) {
if (choices.contains(card)) {
if (card == spell.getSourceCard()) {
Singletons.getModel().getGameAction().sacrifice(spell.getSourceCard());
Singletons.getModel().getGameAction().sacrifice(spell.getSourceCard(), null);
this.stop();
} else {
spell.getSourceCard().setChampionedCard(card);
@@ -5179,7 +5179,7 @@ public class CardFactoryUtil {
numCreatures[0] = selection.size();
for (int m = 0; m < selection.size(); m++) {
card.addDevoured(selection.get(m));
Singletons.getModel().getGameAction().sacrifice(selection.get(m));
Singletons.getModel().getGameAction().sacrifice(selection.get(m), null);
}
}
@@ -5190,7 +5190,7 @@ public class CardFactoryUtil {
final Card c = creats.get(i);
if ((c.getNetAttack() <= 1) && ((c.getNetAttack() + c.getNetDefense()) <= 3)) {
card.addDevoured(c);
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
count++;
}
// is this needed?

View File

@@ -138,7 +138,7 @@ public class CostSacrifice extends CostPartWithList {
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
this.addListToHash(ability, "Sacrificed");
for (final Card c : this.getList()) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, ability);
}
}
@@ -247,7 +247,7 @@ public class CostSacrifice extends CostPartWithList {
// TODO Ask First
for (final Card card : typeList) {
payment.getAbility().addCostToHashList(card, "Sacrificed");
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, sa);
}
payment.setPaidManaPart(part, true);
@@ -304,7 +304,7 @@ public class CostSacrifice extends CostPartWithList {
if (typeList.contains(card)) {
this.nSacrifices++;
part.addToList(card);
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, sa);
typeList.remove(card);
// in case nothing else to sacrifice
if (this.nSacrifices == nNeeded) {
@@ -365,7 +365,7 @@ public class CostSacrifice extends CostPartWithList {
if (choice.equals(0)) {
part.addToList(card);
part.addListToHash(sa, "Sacrificed");
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, sa);
this.stop();
payment.paidCost(part);
} else {

View File

@@ -91,7 +91,7 @@ public class SpellPermanent extends Spell {
final CardList creature = (CardList) SpellPermanent.this.championGetCreature.execute();
if (creature.size() == 0) {
Singletons.getModel().getGameAction().sacrifice(source);
Singletons.getModel().getGameAction().sacrifice(source, null);
return;
} else if (controller.isHuman()) {
AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes);
@@ -114,7 +114,7 @@ public class SpellPermanent extends Spell {
runParams.put("Championed", source.getChampionedCard());
AllZone.getTriggerHandler().runTrigger(TriggerType.Championed, runParams);
} else {
Singletons.getModel().getGameAction().sacrifice(this.getSourceCard());
Singletons.getModel().getGameAction().sacrifice(this.getSourceCard(), null);
}
} // computer
} // resolve()

View File

@@ -73,7 +73,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override
public void resolve() {
if (AllZoneUtil.isCardInPlay(card)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
}
}
};

View File

@@ -145,7 +145,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
} else if (GameActionUtil.showYesNoDialog(c, sb.toString())) {
abMana.produceMana();
} else {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
}
@@ -182,7 +182,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void execute() {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
};
@@ -201,7 +201,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (ComputerUtil.canPayCost(aiPaid)) {
ComputerUtil.playNoStack(aiPaid);
} else {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
}
}
@@ -360,7 +360,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void execute() {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
};
@@ -378,7 +378,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (ComputerUtil.canPayCost(aiPaid)) {
ComputerUtil.playNoStack(aiPaid);
} else {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
}
}
}
@@ -582,7 +582,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
// probably need to restrict by controller also
if (artifact.isArtifact() && zone.is(ZoneType.Battlefield)
&& zone.getPlayer().isHuman()) {
Singletons.getModel().getGameAction().sacrifice(artifact);
Singletons.getModel().getGameAction().sacrifice(artifact, null);
this.stop();
}
} // selectCard()
@@ -592,7 +592,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (null == target) {
this.tapAndDamage(player);
} else {
Singletons.getModel().getGameAction().sacrifice(target);
Singletons.getModel().getGameAction().sacrifice(target, null);
}
}
} // resolve
@@ -722,7 +722,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
} else {
final Card target = CardFactoryUtil.getBestLandAI(playerLand);
Singletons.getModel().getGameAction().sacrifice(target);
Singletons.getModel().getGameAction().sacrifice(target, null);
}
} // end resolve()
}; // end noPay ability
@@ -1982,7 +1982,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
public void resolve() {
final int fadeCounters = card.getCounters(Counters.FADE);
if (fadeCounters <= 0) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
} else {
card.subtractCounter(Counters.FADE, 1);
}

View File

@@ -1762,7 +1762,7 @@ public class ComputerUtil {
continue;
}
} else {
if (!Singletons.getModel().getGameAction().sacrifice(c)) {
if (!Singletons.getModel().getGameAction().sacrifice(c, null)) {
continue;
}
}

View File

@@ -296,7 +296,7 @@ public final class PlayerUtil {
@Override
public void selectCard(final Card card, final PlayerZone zone) {
if (zone.equals(AllZone.getHumanPlayer().getZone(ZoneType.Battlefield)) && list.contains(card)) {
Singletons.getModel().getGameAction().sacrifice(card);
Singletons.getModel().getGameAction().sacrifice(card, null);
this.n++;
list.remove(card);

View File

@@ -781,7 +781,7 @@ public class MagicStack extends MyObservable {
@Override
public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(ZoneType.Battlefield) && c.getController().isHuman() && c.isLand()) {
Singletons.getModel().getGameAction().sacrifice(c);
Singletons.getModel().getGameAction().sacrifice(c, null);
this.stop();
}
}