Some cleanup (#9056)

This commit is contained in:
tool4ever
2025-11-01 15:44:47 +01:00
committed by GitHub
parent 1445fc2621
commit 54b8094211
9 changed files with 39 additions and 54 deletions

View File

@@ -487,14 +487,14 @@ public class ComputerUtilMana {
String originalProduced = manaProduced.toString();
if (originalProduced.isEmpty()) {
return manaProduced.toString();
return originalProduced;
}
// Run triggers like Nissa
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(hostCard);
runParams.put(AbilityKey.Activator, ai); // assuming AI would only ever gives itself mana
runParams.put(AbilityKey.AbilityMana, saPayment);
runParams.put(AbilityKey.Produced, manaProduced.toString());
runParams.put(AbilityKey.Produced, originalProduced);
for (Trigger tr : ai.getGame().getTriggerHandler().getActiveTrigger(TriggerType.TapsForMana, runParams)) {
SpellAbility trSA = tr.ensureAbility();
if (trSA == null) {
@@ -1292,11 +1292,11 @@ public class ComputerUtilMana {
* @return ManaCost
*/
public static ManaCostBeingPaid calculateManaCost(final Cost cost, final SpellAbility sa, final boolean test, final int extraMana, final boolean effect) {
Card card = sa.getHostCard();
Card host = sa.getHostCard();
Zone castFromBackup = null;
if (test && sa.isSpell() && !card.isInZone(ZoneType.Stack)) {
castFromBackup = card.getCastFrom();
card.setCastFrom(card.getZone() != null ? card.getZone() : null);
if (test && sa.isSpell() && !host.isInZone(ZoneType.Stack)) {
castFromBackup = host.getCastFrom();
host.setCastFrom(host.getZone() != null ? host.getZone() : null);
}
Cost payCosts;
@@ -1319,7 +1319,7 @@ public class ComputerUtilMana {
final int multiplicator = Math.max(xCounter, 1);
manaToAdd = extraMana * multiplicator;
} else {
manaToAdd = AbilityUtils.calculateAmount(card, sa.getParamOrDefault("XAlternative", "X"), sa) * xCounter;
manaToAdd = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("XAlternative", "X"), sa) * xCounter;
}
if (manaToAdd < 1 && payCosts != null && payCosts.getCostMana().getXMin() > 0) {
@@ -1331,7 +1331,7 @@ public class ComputerUtilMana {
if (xColor == null) {
xColor = "1";
}
if (card.hasKeyword("Spend only colored mana on X. No more than one mana of each color may be spent this way.")) {
if (host.hasKeyword("Spend only colored mana on X. No more than one mana of each color may be spent this way.")) {
xColor = "WUBRGX";
}
if (xCounter > 0) {
@@ -1356,14 +1356,14 @@ public class ComputerUtilMana {
mCost = ManaCost.combine(mCost, mkCost);
ManaCostBeingPaid mcbp = new ManaCostBeingPaid(mCost);
if (!canPayManaCost(mcbp, sa, sa.getActivatingPlayer(), true)) {
sa.getHostCard().setSVar("NumTimes", "Number$" + i);
host.setSVar("NumTimes", "Number$" + i);
break;
}
}
}
if (test && sa.isSpell()) {
sa.getHostCard().setCastFrom(castFromBackup);
if (test && sa.isSpell() && !host.isInZone(ZoneType.Stack)) {
host.setCastFrom(castFromBackup);
}
return manaCost;
@@ -1596,6 +1596,7 @@ public class ComputerUtilMana {
}
// don't use abilities with dangerous drawbacks
// TODO this has already been checked earlier
AbilitySub sub = m.getSubAbility();
if (sub != null && !SpellApiToAi.Converter.get(sub).chkDrawbackWithSubs(ai, sub).willingToPlay()) {
continue;

View File

@@ -411,15 +411,13 @@ public class AnimateAi extends SpellAbilityAi {
}
if (logic.equals("ValuableAttackerOrBlocker")) {
if (ph.inCombat()) {
final Combat combat = ph.getCombat();
for (Card c : list) {
Card animated = becomeAnimated(c, sa);
boolean isValuableAttacker = ph.is(PhaseType.MAIN1, ai) && ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, animated);
boolean isValuableBlocker = combat != null && combat.getDefendingPlayers().contains(ai) && ComputerUtilCard.doesSpecifiedCreatureBlock(ai, animated);
if (isValuableAttacker || isValuableBlocker)
return new AiAbilityDecision(100, AiPlayDecision.WillPlay);
}
final Combat combat = ph.getCombat();
for (Card c : list) {
Card animated = becomeAnimated(c, sa);
boolean isValuableAttacker = ph.is(PhaseType.COMBAT_BEGIN, ai) && ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, animated);
boolean isValuableBlocker = combat != null && combat.getDefendingPlayers().contains(ai) && ComputerUtilCard.doesSpecifiedCreatureBlock(ai, animated);
if (isValuableAttacker || isValuableBlocker)
return new AiAbilityDecision(100, AiPlayDecision.WillPlay);
}
}

View File

@@ -879,14 +879,12 @@ public final class GameActionUtil {
} else if (abMana.isComboMana()) {
// amount is already taken care of in resolve method for combination mana, just append baseMana
sb.append(baseMana);
} else if (StringUtils.isNumeric(baseMana)) {
sb.append(amount * Integer.parseInt(baseMana));
} else {
if (StringUtils.isNumeric(baseMana)) {
sb.append(amount * Integer.parseInt(baseMana));
} else {
sb.append(baseMana);
for (int i = 1; i < amount; i++) {
sb.append(" ").append(baseMana);
}
sb.append(baseMana);
for (int i = 1; i < amount; i++) {
sb.append(" ").append(baseMana);
}
}
return sb.toString();

View File

@@ -3419,7 +3419,6 @@ public class AbilityUtils {
}
public static int playerXProperty(final Player player, final String s, final Card source, CardTraitBase ctb) {
final String[] l = s.split("/");
final String m = CardFactoryUtil.extractOperators(s);

View File

@@ -103,12 +103,10 @@ public class ManaReflectedEffect extends SpellAbilityEffect {
return "0";
} else if (colors.size() == 1) {
baseMana = MagicColor.toShortString(colors.iterator().next());
} else if (colors.contains("colorless")) {
baseMana = MagicColor.toShortString(player.getController().chooseColorAllowColorless(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa.getHostCard(), ColorSet.fromNames(colors)));
} else {
if (colors.contains("colorless")) {
baseMana = MagicColor.toShortString(player.getController().chooseColorAllowColorless(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa.getHostCard(), ColorSet.fromNames(colors)));
} else {
baseMana = MagicColor.toShortString(player.getController().chooseColor(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa, ColorSet.fromNames(colors)));
}
baseMana = MagicColor.toShortString(player.getController().chooseColor(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa, ColorSet.fromNames(colors)));
}
} else {
colorMenu = ColorSet.fromMask(mask);
@@ -122,19 +120,16 @@ public class ManaReflectedEffect extends SpellAbilityEffect {
if (amount == 0) {
sb.append("0");
} else if (StringUtils.isNumeric(baseMana)) {
// if baseMana is an integer(colorless), just multiply amount and baseMana
final int base = Integer.parseInt(baseMana);
sb.append(base * amount);
} else {
if (StringUtils.isNumeric(baseMana)) {
// if baseMana is an integer(colorless), just multiply amount
// and baseMana
final int base = Integer.parseInt(baseMana);
sb.append(base * amount);
} else {
for (int i = 0; i < amount; i++) {
if (i != 0) {
sb.append(" ");
}
sb.append(baseMana);
for (int i = 0; i < amount; i++) {
if (i != 0) {
sb.append(" ");
}
sb.append(baseMana);
}
}
return sb.toString();

View File

@@ -192,10 +192,8 @@ public class AbilityManaPart implements java.io.Serializable {
}
}
// add the mana produced to the mana pool
manaPool.add(this.lastManaProduced);
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(source);
runParams.put(AbilityKey.Player, player);
runParams.put(AbilityKey.Produced, afterReplace);
@@ -512,7 +510,7 @@ public class AbilityManaPart implements java.io.Serializable {
* @return a {@link java.lang.String} object.
*/
public final String mana(SpellAbility sa) {
if (isComboMana()) { // when asking combo, just go there
if (isComboMana()) {
return getComboColors(sa);
}
String produced = this.getOrigProduced();

View File

@@ -58,10 +58,6 @@ public class TriggerHandler {
game = gameState;
}
public final boolean hasDelayedTriggers() {
return !delayedTriggers.isEmpty();
}
public final void registerDelayedTrigger(final Trigger trig) {
delayedTriggers.add(trig);
}

View File

@@ -2,7 +2,7 @@ Name:General Kreat, the Boltbringer
ManaCost:2 R
Types:Legendary Creature Goblin Soldier
PT:2/2
T:Mode$ AttackersDeclared | ValidAttackers$ Goblin.YouCtrl | Execute$ TrigToken | TriggerZones$ Battlefield | ActivationLimit$ 1 | TriggerDescription$ Whenever one or more Goblins you control attack, create a 1/1 red Goblin creature token that's tapped and attacking.
T:Mode$ AttackersDeclared | ValidAttackers$ Goblin.YouCtrl | Execute$ TrigToken | TriggerZones$ Battlefield | TriggerDescription$ Whenever one or more Goblins you control attack, create a 1/1 red Goblin creature token that's tapped and attacking.
SVar:TrigToken:DB$ Token | TokenAmount$ 1 | TokenScript$ r_1_1_goblin | TokenOwner$ You | TokenTapped$ True | TokenAttacking$ True
T:Mode$ ChangesZone | ValidCard$ Creature.Other+YouCtrl | Destination$ Battlefield | TriggerZones$ Battlefield | Execute$ TrigDealDamage | TriggerDescription$ Whenever another creature you control enters, CARDNAME deals 1 damage to each opponent.
SVar:TrigDealDamage:DB$ DealDamage | Defined$ Player.Opponent | NumDmg$ 1

View File

@@ -1,7 +1,7 @@
Name:Synchronized Eviction
ManaCost:4 U
Types:Instant
S:Mode$ ReduceCost | ValidCard$ Card.Self | Type$ Spell | Amount$ 2 | EffectZone$ All | CheckSVar$ X | SVarCompare$ GE2 | Description$ This spell costs {2} less to cast if you control two at least two creatures that share a creature type.
S:Mode$ ReduceCost | ValidCard$ Card.Self | Type$ Spell | Amount$ 2 | EffectZone$ All | CheckSVar$ X | SVarCompare$ GE2 | Description$ This spell costs {2} less to cast if you control at least two creatures that share a creature type.
SVar:X:Count$MostProminentCreatureType Creature.YouCtrl
A:SP$ ChangeZone | Origin$ Battlefield | Destination$ Library | ValidTgts$ Permanent.nonLand | TgtPrompt$ Select target nonland permanent | LibraryPosition$ 1 | SpellDescription$ Put target nonland permanent into its owner's library second from the top.
Oracle:This spell costs {2} less to cast if you control two at least two creatures that share a creature type.\nPut target nonland permanent into its owner's library second from the top.
Oracle:This spell costs {2} less to cast if you control at least two creatures that share a creature type.\nPut target nonland permanent into its owner's library second from the top.