mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Fix RememberCostMana
This commit is contained in:
@@ -1627,7 +1627,25 @@ public class AbilityUtils {
|
||||
|
||||
if (sa.hasParam("RememberCostMana")) {
|
||||
host.clearRemembered();
|
||||
host.addRemembered(sa.getPayingMana());
|
||||
ManaCostBeingPaid activationMana = new ManaCostBeingPaid(sa.getPayCosts().getTotalMana());
|
||||
if (sa.getXManaCostPaid() != null) {
|
||||
activationMana.setXManaCostPaid(sa.getXManaCostPaid(), null);
|
||||
}
|
||||
int activationShards = activationMana.getConvertedManaCost();
|
||||
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());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int nMana = 0;
|
||||
for (Mana m : activationPaid) {
|
||||
if (nMana > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(m.toString());
|
||||
nMana++;
|
||||
}
|
||||
host.addRemembered(sb.toString());
|
||||
}
|
||||
|
||||
if (sa.hasParam("RememberCostCards") && !sa.getPaidHash().isEmpty()) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
@@ -170,10 +169,7 @@ public class ManaEffect extends SpellAbilityEffect {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
int nMana = 0;
|
||||
for (Object o : card.getRemembered()) {
|
||||
if (o instanceof Mana) {
|
||||
if (nMana > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
if (o instanceof String) {
|
||||
sb.append(o.toString());
|
||||
nMana++;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import forge.game.player.Player;
|
||||
import forge.game.spellability.OptionalCost;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityPredicates;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -714,11 +715,14 @@ public class CardProperty {
|
||||
}
|
||||
break;
|
||||
case "ActivationColor":
|
||||
SpellAbility castSA = source.getCastSA();
|
||||
SpellAbilityStackInstance castSA = game.getStack().getInstanceFromSpellAbility((SpellAbility) spellAbility);
|
||||
if (castSA == null) {
|
||||
return false;
|
||||
}
|
||||
if (!card.getColor().hasAnyColor(castSA.getPayingColors().getColor())) {
|
||||
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 (!card.getColor().hasAnyColor(payingMana.get(payingMana.size() - 1).getColor())) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -594,6 +594,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public List<Mana> getPayingMana() {
|
||||
return payingMana;
|
||||
}
|
||||
public void setPayingMana(List<Mana> paying) {
|
||||
payingMana = Lists.newArrayList(paying);
|
||||
}
|
||||
public final void clearManaPaid() {
|
||||
payingMana.clear();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@@ -35,6 +36,7 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.IHasCardView;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.trigger.WrappedAbility;
|
||||
@@ -78,9 +80,8 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
// private String adjustedManaCost = "";
|
||||
|
||||
// Paid Mana Cost
|
||||
// private ArrayList<Mana> payingMana = new ArrayList<Mana>();
|
||||
// private ArrayList<AbilityMana> paidAbilities = new
|
||||
// ArrayList<AbilityMana>();
|
||||
private List<Mana> payingMana;
|
||||
// private ArrayList<AbilityMana> paidAbilities = new ArrayList<AbilityMana>();
|
||||
private Integer xManaPaid = null;
|
||||
|
||||
// Other Paid things
|
||||
@@ -112,6 +113,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
splicedCards = sa.getSplicedCards();
|
||||
|
||||
xManaPaid = sa.getXManaCostPaid();
|
||||
payingMana = Lists.newArrayList(sa.getPayingMana());
|
||||
|
||||
// Triggering info
|
||||
triggeringObjects = sa.getTriggeringObjects();
|
||||
@@ -181,6 +183,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
ability.setPaidHash(paidHash);
|
||||
ability.setSplicedCards(splicedCards);
|
||||
ability.setXManaCostPaid(xManaPaid);
|
||||
ability.setPayingMana(payingMana);
|
||||
|
||||
// Triggered
|
||||
ability.setTriggeringObjects(triggeringObjects);
|
||||
@@ -345,6 +348,10 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
view.updateActivatingPlayer(this);
|
||||
}
|
||||
|
||||
public List<Mana> getPayingMana() {
|
||||
return payingMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return TextUtil.concatNoSpace(getSourceCard().toString(), "->", getStackDescription());
|
||||
|
||||
Reference in New Issue
Block a user