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