mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Remove some obsolete stuff (#2685)
* Remove obsolete code * Fix uncounterable being invisible * Fix CantHappen requiring choice
This commit is contained in:
@@ -590,7 +590,7 @@ public class ComputerUtilMana {
|
||||
final Mana mana = CostPayment.getMana(ai, part, sa, cost.getSourceRestriction(), (byte) -1, cost.getXManaCostPaidByColor());
|
||||
if (mana != null) {
|
||||
if (ai.getManaPool().tryPayCostWithMana(sa, cost, mana, false)) {
|
||||
manaSpentToPay.add(0, mana);
|
||||
manaSpentToPay.add(mana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Set;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.util.CardTranslation;
|
||||
import forge.util.ComparableOp;
|
||||
@@ -185,7 +184,7 @@ public final class CardRulesPredicates {
|
||||
return new Predicate<CardRules>() {
|
||||
@Override
|
||||
public boolean apply(final CardRules card) {
|
||||
return Iterables.contains(card.getMainPart().getKeywords(), keyword);
|
||||
return card.hasKeyword(keyword);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1580,7 +1580,7 @@ public class AbilityUtils {
|
||||
List<Mana> payingMana = sa.getPayingMana();
|
||||
// even if the cost was raised, we only care about mana from activation part
|
||||
// let's just assume the first shards spent are that for easy handling
|
||||
List<Mana> activationPaid = payingMana.subList(payingMana.size() - activationShards, payingMana.size());
|
||||
List<Mana> activationPaid = payingMana.subList(0, activationShards);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int nMana = 0;
|
||||
for (Mana m : activationPaid) {
|
||||
|
||||
@@ -287,9 +287,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
game.getStack().remove(si);
|
||||
|
||||
// if the target card on stack was a spell with Bestow, then unbestow it
|
||||
if (c.isBestowed()) {
|
||||
c.unanimateBestow(true);
|
||||
}
|
||||
c.unanimateBestow();
|
||||
|
||||
Map<AbilityKey, Object> params = AbilityKey.newMap();
|
||||
params.put(AbilityKey.StackSa, tgtSA);
|
||||
|
||||
@@ -199,8 +199,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
private Card copiedPermanent;
|
||||
private boolean copiedSpell = false;
|
||||
|
||||
private boolean canCounter = true;
|
||||
|
||||
private boolean unearthed;
|
||||
|
||||
private boolean monstrous;
|
||||
@@ -2927,7 +2925,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
|
||||
public final SpellAbility getFirstSpellAbility() {
|
||||
return currentState.getNonManaAbilities().isEmpty() ? null : currentState.getNonManaAbilities().getFirst();
|
||||
return Iterables.getFirst(currentState.getNonManaAbilities(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3247,13 +3245,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
flipped = value;
|
||||
}
|
||||
|
||||
public final void setCanCounter(final boolean b) {
|
||||
canCounter = b;
|
||||
}
|
||||
public final boolean getCanCounter() {
|
||||
return canCounter;
|
||||
}
|
||||
|
||||
public final void addLeavesPlayCommand(final GameCommand c) {
|
||||
leavePlayCommandList.add(c);
|
||||
}
|
||||
@@ -3669,9 +3660,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
entity.removeAttachedCard(this);
|
||||
|
||||
// Handle Bestowed Aura part
|
||||
if (isBestowed()) {
|
||||
unanimateBestow();
|
||||
}
|
||||
|
||||
getGame().fireEvent(new GameEventCardAttachment(this, entity, null));
|
||||
|
||||
// Run triggers
|
||||
|
||||
@@ -60,6 +60,7 @@ import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.replacement.ReplacementHandler;
|
||||
import forge.game.replacement.ReplacementLayer;
|
||||
import forge.game.replacement.ReplacementType;
|
||||
import forge.game.spellability.AbilityStatic;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.AlternativeCost;
|
||||
@@ -258,8 +259,13 @@ public class CardFactoryUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean isCounterable(final Card c) {
|
||||
return !(c.hasKeyword("CARDNAME can't be countered.") || c.hasKeyword("This spell can't be countered."))
|
||||
&& c.getCanCounter();
|
||||
if (c.hasKeyword("CARDNAME can't be countered.") || c.hasKeyword("This spell can't be countered.")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(c);
|
||||
List<ReplacementEffect> list = c.getGame().getReplacementHandler().getReplacementList(ReplacementType.Counter, repParams, ReplacementLayer.CantHappen);
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -695,7 +695,7 @@ public class CardProperty {
|
||||
List<Mana> payingMana = castSA.getPayingMana();
|
||||
// even if the cost was raised, we only care about mana from activation part
|
||||
// since this can only be 1 currently with Protective Sphere, let's just assume it's the first shard spent for easy handling
|
||||
if (payingMana.isEmpty() || !card.getColor().hasAnyColor(payingMana.get(payingMana.size() - 1).getColor())) {
|
||||
if (payingMana.isEmpty() || !card.getColor().hasAnyColor(payingMana.get(0).getColor())) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
||||
for (AbilityManaPart mp : saPayment.getAllManaParts()) {
|
||||
for (final Mana mana : mp.getLastManaProduced()) {
|
||||
if (tryPayCostWithMana(saPaidFor, manaCost, mana, false)) {
|
||||
saPaidFor.getPayingMana().add(0, mana);
|
||||
saPaidFor.getPayingMana().add(mana);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
||||
}
|
||||
|
||||
if (manaFound != null && tryPayCostWithMana(saPaidFor, manaCost, manaFound, false)) {
|
||||
manaSpentToPay.add(0, manaFound);
|
||||
manaSpentToPay.add(manaFound);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -300,9 +300,6 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
||||
}
|
||||
|
||||
public static void refundMana(List<Mana> manaSpent, Player player, SpellAbility sa) {
|
||||
if (sa.getHostCard() != null) {
|
||||
sa.getHostCard().setCanCounter(true);
|
||||
}
|
||||
player.getManaPool().add(manaSpent);
|
||||
manaSpent.clear();
|
||||
}
|
||||
@@ -383,7 +380,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
||||
final Mana mana = CostPayment.getMana(player, part, sa, cost.getSourceRestriction(), hasConverge ? cost.getColorsPaid() : -1, cost.getXManaCostPaidByColor());
|
||||
if (mana != null) {
|
||||
if (player.getManaPool().tryPayCostWithMana(sa, cost, mana, test)) {
|
||||
manaSpentToPay.add(0, mana);
|
||||
manaSpentToPay.add(mana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,13 @@ public class ReplacementHandler {
|
||||
return ReplacementResult.NotReplaced;
|
||||
}
|
||||
|
||||
ReplacementEffect chosenRE = decider.getController().chooseSingleReplacementEffect(Localizer.getInstance().getMessage("lblChooseFirstApplyReplacementEffect"), possibleReplacers);
|
||||
ReplacementEffect chosenRE;
|
||||
// "can't" is never a choice
|
||||
if (layer == ReplacementLayer.CantHappen) {
|
||||
chosenRE = possibleReplacers.get(0);
|
||||
} else {
|
||||
chosenRE = decider.getController().chooseSingleReplacementEffect(Localizer.getInstance().getMessage("lblChooseFirstApplyReplacementEffect"), possibleReplacers);
|
||||
}
|
||||
|
||||
possibleReplacers.remove(chosenRE);
|
||||
|
||||
|
||||
@@ -33,11 +33,14 @@ import forge.game.GameActionUtil;
|
||||
import forge.game.IHasSVars;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaPool;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.replacement.ReplacementHandler;
|
||||
import forge.game.replacement.ReplacementLayer;
|
||||
import forge.game.replacement.ReplacementType;
|
||||
import forge.game.trigger.Trigger;
|
||||
@@ -223,6 +226,32 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
return source.isValid(cannotCounterSpell, sourceCard.getController(), sourceCard, null);
|
||||
}
|
||||
|
||||
public void addNoCounterEffect(SpellAbility saBeingPaid) {
|
||||
final Game game = sourceCard.getGame();
|
||||
final Card eff = new Card(game.nextCardId(), game);
|
||||
eff.setTimestamp(game.getNextTimestamp());
|
||||
eff.setName(sourceCard + "'s Effect");
|
||||
eff.setOwner(sourceCard.getController());
|
||||
|
||||
eff.setImageKey(sourceCard.getImageKey());
|
||||
eff.setColor(MagicColor.COLORLESS);
|
||||
eff.setImmutable(true);
|
||||
|
||||
String cantcounterstr = "Event$ Counter | ValidCard$ Card.IsRemembered | Description$ That spell can't be countered.";
|
||||
ReplacementEffect re = ReplacementHandler.parseReplacement(cantcounterstr, eff, true);
|
||||
re.setLayer(ReplacementLayer.CantHappen);
|
||||
eff.addReplacementEffect(re);
|
||||
|
||||
eff.addRemembered(saBeingPaid.getHostCard());
|
||||
|
||||
SpellAbilityEffect.addForgetOnMovedTrigger(eff, "Stack");
|
||||
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
game.getAction().moveTo(ZoneType.Command, eff, null, null);
|
||||
eff.updateStateForView();
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* addKeywords.
|
||||
|
||||
@@ -645,8 +645,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
mana.getManaAbility().createETBCounters(host, getActivatingPlayer());
|
||||
}
|
||||
|
||||
if (mana.addsNoCounterMagic(this) && host != null) {
|
||||
host.setCanCounter(false);
|
||||
if (mana.addsNoCounterMagic(this)) {
|
||||
mana.getManaAbility().addNoCounterEffect(this);
|
||||
}
|
||||
|
||||
if (isSpell() && host != null) {
|
||||
|
||||
@@ -219,11 +219,9 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
cp = CardUtil.getLKICopy(c);
|
||||
}
|
||||
|
||||
if (!cp.isBestowed()) {
|
||||
cp.animateBestow(!cp.isLKI());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cardZone == null || this.getZone() == null || !cardZone.is(this.getZone())) {
|
||||
// If Card is not in the default activating zone, do some additional checks
|
||||
|
||||
@@ -572,11 +572,6 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
|
||||
curResolvingCard = null;
|
||||
|
||||
// TODO: this is a huge hack. Why is this necessary?
|
||||
// hostCard in AF is not the same object that's on the battlefield
|
||||
// verified by System.identityHashCode(card);
|
||||
final Card tmp = sa.getHostCard();
|
||||
if (!(sa instanceof WrappedAbility && sa.isTrigger())) { tmp.setCanCounter(true); } // reset mana pumped counter magic flag
|
||||
// xManaCostPaid will reset when cast the spell, comment out to fix Venarian Gold
|
||||
// sa.getHostCard().setXManaCostPaid(0);
|
||||
}
|
||||
|
||||
@@ -113,4 +113,4 @@ public class CField implements ICDoc {
|
||||
public void update() {
|
||||
}
|
||||
|
||||
} // End class CField
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
}
|
||||
|
||||
if (restrictionsMet) {
|
||||
player.getManaPool().payManaFromAbility(saPaidFor, InputPayMana.this.manaCost, chosen);
|
||||
player.getManaPool().payManaFromAbility(saPaidFor, manaCost, chosen);
|
||||
}
|
||||
onManaAbilityPaid();
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class HumanPlaySpellAbility {
|
||||
|
||||
if (isFree || payment.isFullyPaid()) {
|
||||
//track when planeswalker ultimates are activated
|
||||
ability.getActivatingPlayer().getAchievementTracker().onSpellAbilityPlayed(ability);
|
||||
human.getAchievementTracker().onSpellAbilityPlayed(ability);
|
||||
|
||||
if (skipStack) {
|
||||
AbilityUtils.resolve(ability);
|
||||
|
||||
Reference in New Issue
Block a user