mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
SpellAbility: moved ManaSpent from Card into CastSA
This commit is contained in:
@@ -623,13 +623,6 @@ public class ComputerUtilMana {
|
||||
}
|
||||
}
|
||||
|
||||
// Note: manaSpentToPay shouldn't be cleared here, since it needs to remain
|
||||
// on the SpellAbility in order for effects that check mana spent cost to work.
|
||||
|
||||
sa.getHostCard().setColorsPaid(cost.getColorsPaid());
|
||||
// if (sa instanceof Spell_Permanent) // should probably add this
|
||||
sa.getHostCard().setSunburstValue(cost.getSunburst());
|
||||
|
||||
if (test) {
|
||||
refundMana(manaSpentToPay, ai, sa);
|
||||
resetPayment(paymentList);
|
||||
|
||||
@@ -387,15 +387,18 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
}
|
||||
|
||||
if (params.containsKey("ManaSpent")) {
|
||||
byte spent = ManaAtom.fromName(params.get("ManaSpent"));
|
||||
if ( 0 == (this.getHostCard().getColorsPaid() & spent)) {
|
||||
SpellAbility castSA = getHostCard().getCastSA();
|
||||
if (castSA == null) {
|
||||
return false;
|
||||
}
|
||||
if (!castSA.getPayingColors().hasAllColors(ManaAtom.fromName(params.get("ManaSpent")))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ManaNotSpent")) {
|
||||
byte spent = ManaAtom.fromName(params.get("ManaNotSpent"));
|
||||
if ( 0 != (this.getHostCard().getColorsPaid() & spent)) {
|
||||
SpellAbility castSA = getHostCard().getCastSA();
|
||||
if (castSA != null && castSA.getPayingColors().hasAllColors(ManaAtom.fromName(params.get("ManaNotSpent")))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,9 +220,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
private Map<String, Integer> xManaCostPaidByColor;
|
||||
|
||||
private int sunburstValue = 0;
|
||||
private byte colorsPaid = 0;
|
||||
|
||||
private Player owner = null;
|
||||
private Player controller = null;
|
||||
private long controllerTimestamp = 0;
|
||||
@@ -1055,20 +1052,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
|
||||
public final int getSunburstValue() {
|
||||
return sunburstValue;
|
||||
}
|
||||
public final void setSunburstValue(final int valueIn) {
|
||||
sunburstValue = valueIn;
|
||||
}
|
||||
|
||||
public final byte getColorsPaid() {
|
||||
return colorsPaid;
|
||||
}
|
||||
public final void setColorsPaid(final byte s) {
|
||||
colorsPaid |= s;
|
||||
}
|
||||
|
||||
public final int getXManaCostPaid() {
|
||||
if (getCastSA() != null) {
|
||||
Integer paid = getCastSA().getXManaCostPaid();
|
||||
@@ -6434,7 +6417,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
removeSVar("PayX"); // Temporary AI X announcement variable
|
||||
removeSVar("IsCastFromPlayEffect"); // Temporary SVar indicating that the spell is cast indirectly via AF Play
|
||||
setSunburstValue(0); // Sunburst
|
||||
setXManaCostPaidByColor(null);
|
||||
setKickerMagnitude(0);
|
||||
setPseudoMultiKickerMagnitude(0);
|
||||
|
||||
@@ -95,7 +95,6 @@ public class CardFactory {
|
||||
out.setAttachedCards(in.getAttachedCards());
|
||||
out.setEntityAttachedTo(in.getEntityAttachedTo());
|
||||
|
||||
out.setCastSA(in.getCastSA());
|
||||
for (final Object o : in.getRemembered()) {
|
||||
out.addRemembered(o);
|
||||
}
|
||||
|
||||
@@ -1546,7 +1546,8 @@ public class CardFactoryUtil {
|
||||
}
|
||||
// Count$Converge
|
||||
if (sq[0].contains("Converge")) {
|
||||
return doXMath(c.getSunburstValue(), m, c);
|
||||
SpellAbility castSA = c.getCastSA();
|
||||
return doXMath(castSA == null ? 0 : castSA.getPayingColors().countColors(), m, c);
|
||||
}
|
||||
// Count$ColoredCreatures *a DOMAIN for creatures*
|
||||
if (sq[0].contains("ColoredCreatures")) {
|
||||
|
||||
@@ -722,8 +722,11 @@ public class CardProperty {
|
||||
}
|
||||
break;
|
||||
case "ActivationColor":
|
||||
byte manaSpent = source.getColorsPaid();
|
||||
if (!CardUtil.getColors(card).hasAnyColor(manaSpent)) {
|
||||
SpellAbility castSA = source.getCastSA();
|
||||
if (castSA == null) {
|
||||
return false;
|
||||
}
|
||||
if (!CardUtil.getColors(card).hasAnyColor(castSA.getPayingColors().getColor())) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.card.CardStateName;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.*;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
@@ -128,8 +129,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
|
||||
protected ApiType api = null;
|
||||
|
||||
private final List<Mana> payingMana = Lists.newArrayList();
|
||||
private final List<SpellAbility> paidAbilities = Lists.newArrayList();
|
||||
private List<Mana> payingMana = Lists.newArrayList();
|
||||
private List<SpellAbility> paidAbilities = Lists.newArrayList();
|
||||
private Integer xManaCostPaid = null;
|
||||
|
||||
private HashMap<String, CardCollection> paidLists = Maps.newHashMap();
|
||||
@@ -476,6 +477,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
payingMana.clear();
|
||||
}
|
||||
|
||||
public ColorSet getPayingColors() {
|
||||
byte colors = 0;
|
||||
for (Mana m : payingMana) {
|
||||
colors |= m.getColor();
|
||||
}
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
|
||||
public List<SpellAbility> getPayingManaAbilities() {
|
||||
return paidAbilities;
|
||||
}
|
||||
@@ -879,6 +888,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
clone.changeZoneTable.putAll(changeZoneTable);
|
||||
}
|
||||
|
||||
clone.payingMana = Lists.newArrayList(payingMana);
|
||||
clone.paidAbilities = Lists.newArrayList();
|
||||
clone.setPaidHash(Maps.newHashMap(getPaidHash()));
|
||||
|
||||
if (usesTargeting()) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
package forge.game.spellability;
|
||||
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ColorSet;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameType;
|
||||
@@ -430,18 +430,17 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(getManaSpent())) {
|
||||
for (String s : getManaSpent().split(" ")) {
|
||||
byte manaSpent = MagicColor.fromName(s);
|
||||
if( 0 == (manaSpent & sa.getHostCard().getColorsPaid())) // no match of colors
|
||||
return false;
|
||||
SpellAbility castSa = sa.getHostCard().getCastSA();
|
||||
if (castSa == null) {
|
||||
return false;
|
||||
}
|
||||
if (!castSa.getPayingColors().hasAllColors(ColorSet.fromNames(getManaSpent().split(" ")).getColor())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(getManaNotSpent())) {
|
||||
byte toPay = 0;
|
||||
for (String s : getManaNotSpent().split(" ")) {
|
||||
toPay |= MagicColor.fromName(s);
|
||||
}
|
||||
if (toPay == (toPay & sa.getHostCard().getColorsPaid())) {
|
||||
SpellAbility castSa = sa.getHostCard().getCastSA();
|
||||
if (castSa != null && castSa.getPayingColors().hasAllColors(ColorSet.fromNames(getManaNotSpent().split(" ")).getColor())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,8 +766,6 @@ public class HumanPlay {
|
||||
}
|
||||
|
||||
source.setXManaCostPaidByColor(toPay.getXManaCostPaidByColor());
|
||||
source.setColorsPaid(toPay.getColorsPaid());
|
||||
source.setSunburstValue(toPay.getSunburst());
|
||||
}
|
||||
|
||||
// Handle convoke and offerings
|
||||
|
||||
Reference in New Issue
Block a user