Alchemy Incorporate (#4763)

* Alchemy Incorporate

* Tweaks for Volrath's Shapeshifter
This commit is contained in:
Northmoc
2024-03-02 08:44:11 -05:00
committed by GitHub
parent 013eb894b9
commit ae6c020065
4 changed files with 72 additions and 13 deletions

View File

@@ -31,6 +31,7 @@ import forge.card.ColorSet;
import forge.card.RemoveType; import forge.card.RemoveType;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostParser; import forge.card.mana.ManaCostParser;
import forge.game.cost.Cost;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
@@ -81,6 +82,28 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
source.addRemembered(c); source.addRemembered(c);
} }
// Alchemy "incorporate" cost
ColorSet incColors = null;
if (sa.hasParam("Incorporate")) {
final String incorporate = sa.getParam("Incorporate");
Map <String, Object> params = new HashMap<>();
params.put("Incorporate", incorporate);
params.put("Timestamp", timestamp);
params.put("Category", "Incorporate");
c.addPerpetual(params);
final ManaCost incMCost = new ManaCost(new ManaCostParser(incorporate));
incColors = ColorSet.fromMask(incMCost.getColorProfile());
final ManaCost newCost = ManaCost.combine(c.getManaCost(), incMCost);
c.addChangedManaCost(newCost, timestamp, 0);
c.updateManaCostForView();
if (c.getFirstSpellAbility() != null) {
c.getFirstSpellAbility().getPayCosts().add(new Cost(incorporate, false));
}
}
if (!addType.isEmpty() || !removeType.isEmpty() || addAllCreatureTypes || !remove.isEmpty()) { if (!addType.isEmpty() || !removeType.isEmpty() || addAllCreatureTypes || !remove.isEmpty()) {
if (perpetual) { if (perpetual) {
Map <String, Object> params = new HashMap<>(); Map <String, Object> params = new HashMap<>();
@@ -129,15 +152,10 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
if (colors != null) { if (colors != null) {
final boolean overwrite = sa.hasParam("OverwriteColors"); final boolean overwrite = sa.hasParam("OverwriteColors");
if (perpetual) { handleColors(c, colors, timestamp, overwrite, perpetual);
Map <String, Object> params = new HashMap<>(); }
params.put("Colors", colors); if (incColors != null) {
params.put("Overwrite", overwrite); handleColors(c, incColors, timestamp, false, perpetual);
params.put("Timestamp", timestamp);
params.put("Category", "Colors");
c.addPerpetual(params);
}
c.addColor(colors, !overwrite, timestamp, 0, false);
} }
if (sa.hasParam("LeaveBattlefield")) { if (sa.hasParam("LeaveBattlefield")) {
@@ -273,4 +291,17 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
c.removeHiddenExtrinsicKeywords(timestamp, 0); c.removeHiddenExtrinsicKeywords(timestamp, 0);
} }
static void handleColors(final Card c, final ColorSet colors, final long timestamp, final boolean overwrite,
final boolean perpetual) {
if (perpetual) {
Map <String, Object> params = new HashMap<>();
params.put("Colors", colors);
params.put("Overwrite", overwrite);
params.put("Timestamp", timestamp);
params.put("Category", "Colors");
c.addPerpetual(params);
}
c.addColor(colors, !overwrite, timestamp, 0, false);
}
} }

View File

@@ -592,6 +592,10 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
//view.getCurrentState().updateAbilityText(this, getCurrentState()); //view.getCurrentState().updateAbilityText(this, getCurrentState());
} }
public void updateManaCostForView() {
currentState.getView().updateManaCost(this);
}
public final void updatePowerToughnessForView() { public final void updatePowerToughnessForView() {
view.updateCounters(this); view.updateCounters(this);
} }
@@ -4451,15 +4455,14 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
private int intensity = 0; private int intensity = 0;
public final void addIntensity(final int n) { public final void addIntensity(final int n) {
intensity = intensity + n; intensity += n;
view.updateIntensity(this); view.updateIntensity(this);
} }
public final int getIntensity(boolean total) { public final int getIntensity(boolean total) {
if (total && hasKeyword(Keyword.STARTING_INTENSITY)) { if (total && hasKeyword(Keyword.STARTING_INTENSITY)) {
return getKeywordMagnitude(Keyword.STARTING_INTENSITY) + intensity; return getKeywordMagnitude(Keyword.STARTING_INTENSITY) + intensity;
} else {
return intensity;
} }
return intensity;
} }
public final void setIntensity(final int n) { intensity = n; } public final void setIntensity(final int n) { intensity = n; }
public final boolean hasIntensity() { public final boolean hasIntensity() {
@@ -4520,6 +4523,15 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
long timestamp = (long) p.get("Timestamp"); long timestamp = (long) p.get("Timestamp");
CardTraitChanges ctc = oldCard.getChangedCardTraits().get(timestamp, (long) 0).copy(this, false); CardTraitChanges ctc = oldCard.getChangedCardTraits().get(timestamp, (long) 0).copy(this, false);
addChangedCardTraits(ctc, timestamp, (long) 0); addChangedCardTraits(ctc, timestamp, (long) 0);
} else if (p.get("Category").equals("Incorporate")) {
long ts = (long) p.get("Timestamp");
final ManaCost cCMC = oldCard.changedCardManaCost.get(ts, (long) 0);
addChangedManaCost(cCMC, ts, (long) 0);
updateManaCostForView();
if (getFirstSpellAbility() != null) {
getFirstSpellAbility().getPayCosts().add(new Cost((String) p.get("Incorporate"), false));
}
} else executePerpetual(p); } else executePerpetual(p);
} }
} }
@@ -5191,6 +5203,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
getView().updateChangedColorWords(this); getView().updateChangedColorWords(this);
getView().updateChangedTypes(this); getView().updateChangedTypes(this);
updateManaCostForView();
currentState.getView().updateAbilityText(this, currentState); currentState.getView().updateAbilityText(this, currentState);
view.updateNonAbilityText(this); view.updateNonAbilityText(this);

View File

@@ -1007,7 +1007,8 @@ public class CardView extends GameEntityView {
// update the color only while in Game // update the color only while in Game
if (c.getGame() != null) { if (c.getGame() != null) {
currentStateView.updateColors(currentState); if (c.hasPerpetual()) currentStateView.updateColors(c);
else currentStateView.updateColors(currentState);
currentStateView.updateHasChangeColors(!Iterables.isEmpty(c.getChangedCardColors())); currentStateView.updateHasChangeColors(!Iterables.isEmpty(c.getChangedCardColors()));
} }
} else { } else {
@@ -1288,6 +1289,9 @@ public class CardView extends GameEntityView {
void updateManaCost(CardState c) { void updateManaCost(CardState c) {
set(TrackableProperty.ManaCost, c.getManaCost()); set(TrackableProperty.ManaCost, c.getManaCost());
} }
void updateManaCost(Card c) {
set(TrackableProperty.ManaCost, c.getManaCost());
}
public String getOracleText() { public String getOracleText() {
return get(TrackableProperty.OracleText); return get(TrackableProperty.OracleText);

View File

@@ -0,0 +1,11 @@
Name:Guildpact Greenwalker
ManaCost:2 G
Types:Creature Plant Rhino
PT:4/4
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigChoose | TriggerDescription$ When CARDNAME enters the battlefield, you may choose a creature card in your hand. If you do, that card perpetually incorporates {1}{G} and gets +4/+4.
SVar:TrigChoose:DB$ ChooseCard | ChoiceZone$ Hand | Choices$ Creature.YouOwn | ChoiceTitle$ You may choose a creature card in your hand | SubAbility$ DBAnimate
SVar:DBAnimate:DB$ Animate | Defined$ ChosenCard | Incorporate$ 1 G | Duration$ Perpetual | SubAbility$ DBPump
SVar:DBPump:DB$ Pump | PumpZone$ Hand | Defined$ ChosenCard | Duration$ Perpetual | NumAtt$ 4 | NumDef$ 4 | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearChosenCard$ True
S:Mode$ Continuous | Affected$ Creature.MultiColor+YouCtrl | AddKeyword$ Ward:2 | Description$ Multicolored creatures you control have ward {2}.
Oracle:When Guildpact Greenwalker enters the battlefield, you may choose a creature card in your hand. If you do, that card perpetually incorporates {1}{G} and gets +4/+4.\nMulticolored creatures you control have ward {2}.