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,6 +2136,7 @@ public class CardFactoryUtil {
|
||||
|
||||
final SpellAbility sa = card.getFirstSpellAbility();
|
||||
sa.setMultiKickerManaCost(new ManaCost(new ManaCostParser(k[1])));
|
||||
sa.addAnnounceVar("Multikicker");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2732,7 +2733,7 @@ public class CardFactoryUtil {
|
||||
// instantiate attach ability
|
||||
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -302,18 +302,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public boolean isSpell() { return false; }
|
||||
public boolean isAbility() { return true; }
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isMultiKicker.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isMultiKicker() {
|
||||
return this.multiKickerManaCost != null && !this.isAnnouncing("Multikicker");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setIsMorphUp.
|
||||
@@ -384,14 +372,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
|
||||
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) {
|
||||
return mapParams == null ? null : mapParams.get(key);
|
||||
return mapParams.get(key);
|
||||
}
|
||||
public boolean hasParam(String key) {
|
||||
return mapParams == null ? false : mapParams.containsKey(key);
|
||||
return mapParams.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,10 +387,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
* @param mapParams
|
||||
*/
|
||||
public void copyParamsToMap(Map<String, String> mapParams) {
|
||||
if (null != this.mapParams) {
|
||||
mapParams.putAll(this.mapParams);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is not null, then ability was made in a factory
|
||||
public ApiType getApi() {
|
||||
@@ -1355,7 +1341,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
*/
|
||||
public boolean isAnnouncing(String variable) {
|
||||
String announce = getParam("Announce");
|
||||
if (StringUtils.isBlank(announce)) return false;
|
||||
if (StringUtils.isBlank(announce)) { return false; }
|
||||
|
||||
String[] announcedOnes = TextUtil.split(announce, ',');
|
||||
for (String a : announcedOnes) {
|
||||
if (a.trim().equalsIgnoreCase(variable)) {
|
||||
@@ -1365,6 +1352,21 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
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() {
|
||||
CostPartMana cm = payCosts != null ? getPayCosts().getCostMana() : null;
|
||||
return cm != null && cm.getAmountOfX() > 0;
|
||||
|
||||
@@ -243,11 +243,6 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
||||
return sa.isFlashBackAbility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiKicker() {
|
||||
return sa.isMultiKicker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpell() {
|
||||
return sa.isSpell();
|
||||
|
||||
@@ -340,20 +340,6 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
si = this.push(sp);
|
||||
}
|
||||
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),
|
||||
CardPredicates.hasKeyword("As an additional cost to cast creature spells," +
|
||||
" 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
|
||||
String announce = ability.getParam("Announce");
|
||||
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(",")) {
|
||||
String varName = aVar.trim();
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ability.setSVar(varName, value.toString());
|
||||
if ("Multikicker".equals(varName)) {
|
||||
ability.getHostCard().setKickerMagnitude(value);
|
||||
card.setKickerMagnitude(value);
|
||||
}
|
||||
else {
|
||||
ability.getHostCard().setSVar(varName, value.toString());
|
||||
card.setSVar(varName, value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user