mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Fix so MultiKicker is announced before mana paid
This commit is contained in:
@@ -2136,9 +2136,10 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
final SpellAbility sa = card.getFirstSpellAbility();
|
final SpellAbility sa = card.getFirstSpellAbility();
|
||||||
sa.setMultiKickerManaCost(new ManaCost(new ManaCostParser(k[1])));
|
sa.setMultiKickerManaCost(new ManaCost(new ManaCostParser(k[1])));
|
||||||
|
sa.addAnnounceVar("Multikicker");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasKeyword(card, "Fuse") != -1) {
|
if (hasKeyword(card, "Fuse") != -1) {
|
||||||
card.getState(CardCharacteristicName.Original).getSpellAbility().add(AbilityFactory.buildFusedAbility(card));
|
card.getState(CardCharacteristicName.Original).getSpellAbility().add(AbilityFactory.buildFusedAbility(card));
|
||||||
}
|
}
|
||||||
@@ -2732,7 +2733,7 @@ public class CardFactoryUtil {
|
|||||||
// instantiate attach ability
|
// instantiate attach ability
|
||||||
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
|
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
|
||||||
card.addSpellAbility(sa);
|
card.addSpellAbility(sa);
|
||||||
// add ability to instrinic strings so copies/clones create the ability also
|
// add ability to intrinsic strings so copies/clones create the ability also
|
||||||
card.getUnparsedAbilities().add(abilityStr.toString());
|
card.getUnparsedAbilities().add(abilityStr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -302,18 +302,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
public boolean isSpell() { return false; }
|
public boolean isSpell() { return false; }
|
||||||
public boolean isAbility() { return true; }
|
public boolean isAbility() { return true; }
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isMultiKicker.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public boolean isMultiKicker() {
|
|
||||||
return this.multiKickerManaCost != null && !this.isAnnouncing("Multikicker");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* setIsMorphUp.
|
* setIsMorphUp.
|
||||||
@@ -384,14 +372,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getParamOrDefault(String key, String defaultValue) {
|
public String getParamOrDefault(String key, String defaultValue) {
|
||||||
return mapParams == null || !mapParams.containsKey(key) ? defaultValue : mapParams.get(key);
|
return mapParams.containsKey(key) ? mapParams.get(key) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParam(String key) {
|
public String getParam(String key) {
|
||||||
return mapParams == null ? null : mapParams.get(key);
|
return mapParams.get(key);
|
||||||
}
|
}
|
||||||
public boolean hasParam(String key) {
|
public boolean hasParam(String key) {
|
||||||
return mapParams == null ? false : mapParams.containsKey(key);
|
return mapParams.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -399,9 +387,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
* @param mapParams
|
* @param mapParams
|
||||||
*/
|
*/
|
||||||
public void copyParamsToMap(Map<String, String> mapParams) {
|
public void copyParamsToMap(Map<String, String> mapParams) {
|
||||||
if (null != this.mapParams) {
|
mapParams.putAll(this.mapParams);
|
||||||
mapParams.putAll(this.mapParams);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is not null, then ability was made in a factory
|
// If this is not null, then ability was made in a factory
|
||||||
@@ -1355,7 +1341,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
*/
|
*/
|
||||||
public boolean isAnnouncing(String variable) {
|
public boolean isAnnouncing(String variable) {
|
||||||
String announce = getParam("Announce");
|
String announce = getParam("Announce");
|
||||||
if (StringUtils.isBlank(announce)) return false;
|
if (StringUtils.isBlank(announce)) { return false; }
|
||||||
|
|
||||||
String[] announcedOnes = TextUtil.split(announce, ',');
|
String[] announcedOnes = TextUtil.split(announce, ',');
|
||||||
for (String a : announcedOnes) {
|
for (String a : announcedOnes) {
|
||||||
if (a.trim().equalsIgnoreCase(variable)) {
|
if (a.trim().equalsIgnoreCase(variable)) {
|
||||||
@@ -1365,6 +1352,21 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAnnounceVar(String variable) {
|
||||||
|
String announce = getParam("Announce");
|
||||||
|
if (StringUtils.isBlank(announce)) {
|
||||||
|
mapParams.put("Announce", variable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] announcedOnes = TextUtil.split(announce, ',');
|
||||||
|
for (String a : announcedOnes) {
|
||||||
|
if (a.trim().equalsIgnoreCase(variable)) {
|
||||||
|
return; //don't add announce variable that already exists
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapParams.put("Announce", announce + ";" + variable);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isXCost() {
|
public boolean isXCost() {
|
||||||
CostPartMana cm = payCosts != null ? getPayCosts().getCostMana() : null;
|
CostPartMana cm = payCosts != null ? getPayCosts().getCostMana() : null;
|
||||||
return cm != null && cm.getAmountOfX() > 0;
|
return cm != null && cm.getAmountOfX() > 0;
|
||||||
|
|||||||
@@ -243,11 +243,6 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
return sa.isFlashBackAbility();
|
return sa.isFlashBackAbility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMultiKicker() {
|
|
||||||
return sa.isMultiKicker();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSpell() {
|
public boolean isSpell() {
|
||||||
return sa.isSpell();
|
return sa.isSpell();
|
||||||
|
|||||||
@@ -340,20 +340,6 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
si = this.push(sp);
|
si = this.push(sp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sp.isMultiKicker()) {
|
|
||||||
final Cost costMultikicker = new Cost(sp.getMultiKickerManaCost(), false);
|
|
||||||
boolean hasPaid = false;
|
|
||||||
do {
|
|
||||||
int mkMagnitude = source.getKickerMagnitude();
|
|
||||||
String prompt = String.format("Multikicker for %s\r\nTimes Kicked: %d\r\n", source, mkMagnitude );
|
|
||||||
hasPaid = activator.getController().payManaOptional(source, costMultikicker, sp, prompt, ManaPaymentPurpose.Multikicker);
|
|
||||||
if (hasPaid) {
|
|
||||||
source.addMultiKickerMagnitude(1);
|
|
||||||
totManaSpent += sp.getPayingMana().size();
|
|
||||||
// TODO: paying mana is replaced by multikicker cost, this should be fixed in the future
|
|
||||||
}
|
|
||||||
} while( hasPaid );
|
|
||||||
}
|
|
||||||
if (sp.isSpell() && source.isCreature() && Iterables.any(activator.getCardsIn(ZoneType.Battlefield),
|
if (sp.isSpell() && source.isCreature() && Iterables.any(activator.getCardsIn(ZoneType.Battlefield),
|
||||||
CardPredicates.hasKeyword("As an additional cost to cast creature spells," +
|
CardPredicates.hasKeyword("As an additional cost to cast creature spells," +
|
||||||
" you may pay any amount of mana. If you do, that creature enters " +
|
" you may pay any amount of mana. If you do, that creature enters " +
|
||||||
|
|||||||
@@ -198,24 +198,27 @@ public class HumanPlaySpellAbility {
|
|||||||
// SA Params as comma delimited list
|
// SA Params as comma delimited list
|
||||||
String announce = ability.getParam("Announce");
|
String announce = ability.getParam("Announce");
|
||||||
if (announce != null) {
|
if (announce != null) {
|
||||||
|
PlayerController controller = ability.getActivatingPlayer().getController();
|
||||||
|
Card card = ability.getHostCard();
|
||||||
|
boolean allowZero = !ability.hasParam("XCantBe0");
|
||||||
|
CostPartMana manaCost = ability.getPayCosts().getCostMana();
|
||||||
|
|
||||||
for (String aVar : announce.split(",")) {
|
for (String aVar : announce.split(",")) {
|
||||||
String varName = aVar.trim();
|
String varName = aVar.trim();
|
||||||
|
|
||||||
boolean isX = "X".equalsIgnoreCase(varName);
|
boolean isX = "X".equalsIgnoreCase(varName);
|
||||||
CostPartMana manaCost = ability.getPayCosts().getCostMana();
|
|
||||||
boolean allowZero = !ability.hasParam("XCantBe0") && (!isX || manaCost == null || manaCost.canXbe0());
|
|
||||||
|
|
||||||
Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, varName, allowZero);
|
Integer value = controller.announceRequirements(ability, varName, allowZero && (!isX || manaCost == null || manaCost.canXbe0()));
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ability.setSVar(varName, value.toString());
|
ability.setSVar(varName, value.toString());
|
||||||
if ("Multikicker".equals(varName)) {
|
if ("Multikicker".equals(varName)) {
|
||||||
ability.getHostCard().setKickerMagnitude(value);
|
card.setKickerMagnitude(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ability.getHostCard().setSVar(varName, value.toString());
|
card.setSVar(varName, value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user