Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,20 +642,22 @@ private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbil
List<SpellAbility> paymentList = Lists.newArrayList();
final ManaPool manapool = ai.getManaPool();

// Apply the color/type conversion matrix if necessary
manapool.restoreColorReplacements();
CardPlayOption mayPlay = sa.getMayPlayOption();
if (!effect) {
if (sa.isSpell() && mayPlay != null) {
mayPlay.applyManaConvert(manapool);
} else if (sa.isActivatedAbility() && sa.getGrantorStatic() != null && sa.getGrantorStatic().hasParam("ManaConversion")) {
AbilityUtils.applyManaColorConversion(manapool, sa.getGrantorStatic().getParam("ManaConversion"));
// Apply color/type conversion matrix if necessary (already done via autopay)
if (ai.getControllingPlayer() == null) {
manapool.restoreColorReplacements();
CardPlayOption mayPlay = sa.getMayPlayOption();
if (!effect) {
if (sa.isSpell() && mayPlay != null) {
mayPlay.applyManaConvert(manapool);
} else if (sa.isActivatedAbility() && sa.getGrantorStatic() != null && sa.getGrantorStatic().hasParam("ManaConversion")) {
AbilityUtils.applyManaColorConversion(manapool, sa.getGrantorStatic().getParam("ManaConversion"));
}
}
if (sa.hasParam("ManaConversion")) {
AbilityUtils.applyManaColorConversion(manapool, sa.getParam("ManaConversion"));
}
StaticAbilityManaConvert.manaConvert(manapool, ai, sa.getHostCard(), effect && !sa.isCastFromPlayEffect() ? null : sa);
}
if (sa.hasParam("ManaConversion")) {
AbilityUtils.applyManaColorConversion(manapool, sa.getParam("ManaConversion"));
}
StaticAbilityManaConvert.manaConvert(manapool, ai, sa.getHostCard(), effect && !sa.isCastFromPlayEffect() ? null : sa);

if (manapool.payManaCostFromPool(cost, sa, test, manaSpentToPay)) {
CostPayment.handleOfferings(sa, test, cost.isPaid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ protected String getStackDescription(SpellAbility sa) {
@SuppressWarnings("serial")
@Override
public void resolve(SpellAbility sa) {
final Player activator = sa.getActivatingPlayer();
final Game game = activator.getGame();
final Player controller = sa.hasParam("Controller") ? AbilityUtils.getDefinedPlayers(
sa.getHostCard(), sa.getParam("Controller"), sa).get(0) : activator;
final Player controller = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Controller"), sa).get(0);
final Game game = controller.getGame();

for (final Player pTarget: getTargetPlayers(sa)) {
// before next untap gain control
Expand Down
16 changes: 0 additions & 16 deletions forge-game/src/main/java/forge/game/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public class Player extends GameEntity implements Comparable<Player> {
private CardCollection gainedOwnership = new CardCollection();

private ManaPool manaPool = new ManaPool(this);
private int numManaConversion = 0;
// The SA currently being paid for
private Deque<SpellAbility> paidForStack = new ArrayDeque<>();

Expand Down Expand Up @@ -2228,20 +2227,6 @@ public final void incLibrarySearched() {
numLibrarySearchedOwn++;
}

public final void setNumManaConversion(final int l) {
numManaConversion = l;
}
public final boolean hasManaConversion() {
return numManaConversion < getAmountOfKeyword("You may spend mana as though"
+ " it were mana of any type to cast a spell this turn.");
}
public final void incNumManaConversion() {
numManaConversion++;
}
public final void decNumManaConversion() {
numManaConversion--;
}

@Override
public final boolean isValid(final String restriction, final Player sourceController, final Card source, CardTraitBase spellAbility) {
final String[] incR = restriction.split("\\.", 2);
Expand Down Expand Up @@ -2587,7 +2572,6 @@ public void onCleanupPhase() {
lifeGainedByTeamThisTurn = 0;
setLifeStartedThisTurnWith(getLife());
setLibrarySearched(0);
setNumManaConversion(0);

setCommitedCrimeThisTurn(0);
diceRollsThisTurn = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public static boolean checkManaConvert(StaticAbility stAb, Player p, Card card,
if (!stAb.matchesValidParam("ValidSA", sa)) {
return false;
}

if (stAb.hasParam("Optional")) {
stAb.getHostCard().clearRemembered();
if (!p.getController().confirmStaticApplication(card, null, "Do you want to spend mana as though it were mana of any type to pay the cost?", null)) {
return false;
}
stAb.getHostCard().addRemembered(sa.getHostCard());
}

return true;
}
}
3 changes: 2 additions & 1 deletion forge-gui/res/cardsfolder/n/north_star.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Name:North Star
ManaCost:4
Types:Artifact
A:AB$ Pump | Cost$ 4 T | Defined$ You | KW$ You may spend mana as though it were mana of any type to cast a spell this turn. | SpellDescription$ For one spell this turn, you may spend mana as though it were mana of any type to pay that spell's mana cost. (Additional costs are still paid normally.)
A:AB$ Effect | Cost$ 4 T | ForgetOnCast$ Card.IsRemembered | StaticAbilities$ Convert | SpellDescription$ For one spell this turn, you may spend mana as though it were mana of any type to pay that spell's mana cost. (Additional costs are still paid normally.)
SVar:Convert:Mode$ ManaConvert | ValidPlayer$ You | ValidSA$ Spell | Optional$ True | ManaConversion$ AnyType->AnyType | Description$ For one spell this turn, you may spend mana as though it were mana of any type to pay that spell's mana cost.
AI:RemoveDeck:All
Oracle:{4}, {T}: For one spell this turn, you may spend mana as though it were mana of any type to pay that spell's mana cost. (Additional costs are still paid normally.)
15 changes: 2 additions & 13 deletions forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.collect.Iterables;
import forge.card.CardType;
import forge.card.MagicColor;
import forge.game.Game;
import forge.game.GameActionUtil;
import forge.game.GameObject;
Expand Down Expand Up @@ -116,8 +115,6 @@ public final boolean playAbility(final boolean mayChooseTargets, final boolean i
Cost abCost = ability.getPayCosts();
CostPayment payment = new CostPayment(abCost, ability);

final boolean playerManaConversion = human.hasManaConversion()
&& human.getController().confirmStaticApplication(c, null, "Do you want to spend mana as though it were mana of any type to pay the cost?", null);
boolean manaColorConversion = false;

if (!ability.isCopied()) {
Expand All @@ -141,16 +138,11 @@ public final boolean playAbility(final boolean mayChooseTargets, final boolean i
}

if (ability.hasParam("ManaConversion")) {
AbilityUtils.applyManaColorConversion(manapool, ability.getParam("ManaConversion"));
AbilityUtils.applyManaColorConversion(payment, ability.getParam("ManaConversion"));
manaColorConversion = true;
}
}

if (playerManaConversion) {
AbilityUtils.applyManaColorConversion(payment, MagicColor.Constant.ANY_TYPE_CONVERSION);
human.incNumManaConversion();
}

// reset is also done early here, because if an ability is canceled from targeting it might otherwise lead to refunding mana from earlier cast
ability.clearManaPaid();
ability.getPayingManaAbilities().clear();
Expand Down Expand Up @@ -195,10 +187,7 @@ public final boolean playAbility(final boolean mayChooseTargets, final boolean i
if (manaColorConversion) {
manapool.restoreColorReplacements();
}
if (playerManaConversion) {
manapool.restoreColorReplacements();
human.decNumManaConversion();
}

return false;
}

Expand Down