* Fix NPE

* Fix cards like Klinspire District that use two X SVar

* Clean up

---------

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.60>
This commit is contained in:
tool4ever
2023-12-09 00:33:41 +01:00
committed by GitHub
parent 4075685b8f
commit e8c17640a9
15 changed files with 29 additions and 43 deletions

View File

@@ -1106,7 +1106,7 @@ public class ComputerUtilMana {
// * pay hybrids
// * pay phyrexian, keep mana for colorless
// * pay generic
return cost.getShardToPayByPriority(cost.getDistinctShards(), ColorSet.ALL_COLORS.getColor());
return cost.getShardToPayByPriority(shardsToPay, ColorSet.ALL_COLORS.getColor());
}
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) {

View File

@@ -78,9 +78,9 @@ public abstract class SpellAbilityEffect {
// by typing "SpellDescription" they want to bypass the Effect's string builder
if ("SpellDescription".equalsIgnoreCase(stackDesc)) {
String rawSDesc = params.get("SpellDescription");
if (rawSDesc.contains(",,,,,,")) rawSDesc = rawSDesc.replaceAll(",,,,,,", " ");
if (rawSDesc.contains(",,,")) rawSDesc = rawSDesc.replaceAll(",,,", " ");
if (params.containsKey("SpellDescription")) {
if (rawSDesc.contains(",,,,,,")) rawSDesc = rawSDesc.replaceAll(",,,,,,", " ");
if (rawSDesc.contains(",,,")) rawSDesc = rawSDesc.replaceAll(",,,", " ");
String spellDesc = CardTranslation.translateSingleDescriptionText(rawSDesc,
sa.getHostCard().getName());

View File

@@ -24,7 +24,7 @@ public class PlaneswalkEffect extends SpellAbilityEffect {
return;
}
if (sa.hasParam("Optional") && !sa.getActivatingPlayer().getController().confirmAction(sa, null,
if (sa.hasParam("Optional") && !activator.getController().confirmAction(sa, null,
Localizer.getInstance().getMessage("lblWouldYouLikeToPlaneswalk"), null)) {
return;
}
@@ -43,9 +43,9 @@ public class PlaneswalkEffect extends SpellAbilityEffect {
}
if (sa.hasParam("Defined")) {
CardCollectionView destinations = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
sa.getActivatingPlayer().planeswalkTo(sa, destinations);
activator.planeswalkTo(sa, destinations);
} else {
sa.getActivatingPlayer().planeswalk(sa);
activator.planeswalk(sa);
}
}
}

View File

@@ -2127,11 +2127,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} else if (keyword.startsWith("Protection:") || keyword.startsWith("DeckLimit")) {
final String[] k = keyword.split(":");
sbLong.append(k[2]).append("\r\n");
} else if (keyword.startsWith("Creatures can't attack unless their controller pays")) {
final String[] k = keyword.split(":");
if (!k[3].equals("no text")) {
sbLong.append(k[3]).append("\r\n");
}
} else if (keyword.startsWith("Enchant")) {
String k = keyword;
k = TextUtil.fastReplace(k, "Curse", "");
@@ -2225,9 +2220,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} else if (keyword.startsWith("MayFlash")) {
// Pseudo keywords, only print Reminder
sbLong.append(inst.getReminderText()).append("\r\n");
} else if (keyword.contains("At the beginning of your upkeep, ")
&& keyword.contains(" unless you pay")) {
sbLong.append(keyword).append("\r\n");
} else if (keyword.startsWith("Strive") || keyword.startsWith("Escalate")
|| keyword.startsWith("ETBReplacement")
|| keyword.startsWith("Affinity")

View File

@@ -552,10 +552,7 @@ public class ReplacementHandler {
// Log the replacement effect
if (res != ReplacementResult.NotReplaced) {
String message = re.getDescription();
if ( !StringUtils.isEmpty(message)) {
if (re.getHostCard() != null) {
message = TextUtil.fastReplace(message, "CARDNAME", re.getHostCard().getName());
}
if (!StringUtils.isEmpty(message)) {
game.getGameLog().add(GameLogEntryType.EFFECT_REPLACED, message);
}
}

View File

@@ -895,8 +895,7 @@ public final class StaticAbilityContinuous {
}
// add Types
if (addTypes != null || removeTypes != null || addAllCreatureTypes
|| !remove.isEmpty()) {
if (addTypes != null || removeTypes != null || addAllCreatureTypes || !remove.isEmpty()) {
affectedCard.addChangedCardTypes(addTypes, removeTypes, addAllCreatureTypes, remove,
hostCard.getTimestamp(), stAb.getId(), true, stAb.hasParam("CharacteristicDefining"));
}

View File

@@ -6,11 +6,10 @@ K:MayEffectFromOpeningHand:RevealCard
K:Flying
K:Lifelink
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ DrainOnUpkeep | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, each opponent loses 3 life, then you gain life equal to the life lost this way.
SVar:DrainOnUpkeep:DB$ Effect | Triggers$ TrigDrain | Name$ Chancellor of the Dross effect
SVar:TrigDrain:Mode$ Phase | Phase$ Upkeep | Execute$ DrainLife | TriggerDescription$ At the beginning of the first upkeep, each opponent loses 3 life, then you gain life equal to the life lost this way.
SVar:DrainOnUpkeep:DB$ Effect | Triggers$ TrigDrain
SVar:TrigDrain:Mode$ Phase | Phase$ Upkeep | Execute$ DrainLife | OneOff$ True | TriggerDescription$ At the beginning of the first upkeep, each opponent loses 3 life, then you gain life equal to the life lost this way.
SVar:DrainLife:DB$ LoseLife | Defined$ Player.Opponent | LifeAmount$ 3 | SubAbility$ GainLife
SVar:GainLife:DB$ GainLife | Defined$ You | LifeAmount$ AFLifeLost | SubAbility$ RemoveMe
SVar:RemoveMe:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
SVar:GainLife:DB$ GainLife | Defined$ You | LifeAmount$ AFLifeLost
SVar:AFLifeLost:Number$0
#AFLifeLost will be set by LoseLife
Oracle:You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, each opponent loses 3 life, then you gain life equal to the life lost this way.\nFlying, lifelink

View File

@@ -7,9 +7,9 @@ SVar:EffMassToken:DB$ Token | TokenAmount$ X | TokenOwner$ You | TokenScript$ r_
SVar:X:Count$Valid Creature.YouCtrl
K:MayEffectFromOpeningHand:RevealCard
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ TokenOnUpkeep | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, create a 1/1 red Phyrexian Goblin creature token with haste.
SVar:TokenOnUpkeep:DB$ Effect | Triggers$ TrigToken | Name$ Chancellor of the Forge effect | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, create a 1/1 red Phyrexian Goblin creature token with haste.
SVar:TrigToken:Mode$ Phase | Phase$ Upkeep | Execute$ EffToken | TriggerDescription$ At the beginning of the first upkeep, create a 1/1 red Phyrexian Goblin creature token with haste.
SVar:EffToken:DB$ Token | TokenAmount$ 1 | TokenOwner$ You | TokenScript$ r_1_1_phyrexian_goblin_haste | SubAbility$ RemoveMe
SVar:RemoveMe:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
SVar:TokenOnUpkeep:DB$ Effect | Triggers$ TrigToken
SVar:TrigToken:Mode$ Phase | Phase$ Upkeep | Execute$ EffToken | OneOff$ True | TriggerDescription$ At the beginning of the first upkeep, create a 1/1 red Phyrexian Goblin creature token with haste.
SVar:EffToken:DB$ Token | TokenAmount$ 1 | TokenOwner$ You | TokenScript$ r_1_1_phyrexian_goblin_haste
SVar:PlayMain1:TRUE
DeckHas:Type$Goblin
Oracle:You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, create a 1/1 red Phyrexian Goblin creature token with haste.\nWhen Chancellor of the Forge enters the battlefield, create X 1/1 red Phyrexian Goblin creature tokens with haste, where X is the number of creatures you control.

View File

@@ -5,10 +5,10 @@ PT:5/7
K:MayEffectFromOpeningHand:RevealCard
K:Flying
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ DrainOnUpkeep | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, each opponent mills seven cards.
SVar:DrainOnUpkeep:DB$ Effect | Triggers$ TrigMill | Name$ Chancellor of the Spires effect
SVar:TrigMill:Mode$ Phase | Phase$ Upkeep | Execute$ Mill | TriggerDescription$ At the beginning of the first upkeep, each opponent mills seven cards.
SVar:Mill:DB$ Mill | NumCards$ 7 | Defined$ Player.Opponent | SubAbility$ RemoveMe
SVar:RemoveMe:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
SVar:DrainOnUpkeep:DB$ Effect | Triggers$ TrigMill
SVar:TrigMill:Mode$ Phase | Phase$ Upkeep | Execute$ Mill | OneOff$ True | TriggerDescription$ At the beginning of the first upkeep, each opponent mills seven cards.
SVar:Mill:DB$ Mill | NumCards$ 7 | Defined$ Player.Opponent
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigChangeZone | TriggerDescription$ When CARDNAME enters the battlefield, you may cast target instant or sorcery card from an opponent's graveyard without paying its mana cost.
SVar:TrigChangeZone:DB$ Play | TgtZone$ Graveyard | WithoutManaCost$ True | ValidTgts$ Instant.OppOwn,Sorcery.OppOwn | TgtPrompt$ Choose target instant or sorcery card from an opponent's graveyard | Optional$ True
DeckHas:Ability$Mill
Oracle:You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, each opponent mills seven cards.\nFlying\nWhen Chancellor of the Spires enters the battlefield, you may cast target instant or sorcery card from an opponent's graveyard without paying its mana cost.

View File

@@ -6,7 +6,7 @@ K:MayEffectFromOpeningHand:ManaOnMain
K:Vigilance
K:Reach
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ ManaOnMain | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of your first main phase, add {G}.
SVar:ManaOnMain:DB$ Effect | Triggers$ TrigMana | Duration$ Permanent | Name$ Chancellor of the Tangle effect
SVar:ManaOnMain:DB$ Effect | Triggers$ TrigMana | Duration$ Permanent
SVar:TrigMana:Mode$ Phase | Phase$ Main1 | ValidPlayer$ You | OneOff$ True | Execute$ EffMana | TriggerDescription$ At the beginning of your first main phase, add G.
SVar:EffMana:DB$ Mana | Produced$ G
Oracle:You may reveal this card from your opening hand. If you do, at the beginning of your first main phase, add {G}.\nVigilance, reach

View File

@@ -4,11 +4,11 @@ Types:Creature — Cat Warrior
PT:3/1
K:Flash
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigCharm | TriggerDescription$ When CARDNAME enters the battlefield, ABILITY
SVar:TrigCharm:DB$ Charm | Choices$ DBGainLife,DBExile
SVar:TrigCharm:DB$ Charm | Choices$ DBPutCounter,DBGainLife,DBExile
SVar:DBPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ X | SpellDescription$ Put a +1/+1 counter on CARDNAME for each creature that left the battlefield under your control this turn.
SVar:X:Count$LeftBattlefieldThisTurn Creature.YouCtrl
SVar:DBGainLife:DB$ GainLife | LifeAmount$ 3 | SubAbility$ DBScry | SpellDescription$ You gain 2 life and scry 2.
SVar:DBScry:DB$ Scry | ScryNum$ 2
SVar:DBExile:DB$ ChangeZoneAll | ValidTgts$ Player | Origin$ Graveyard | Destination$ Exile | ChangeType$ Card | IsCurse$ True
Oracle:Flash\nWhen Kutzils Flanker enters the battlefield, choose one —\n• Put a +1/+1 counter on Kutzils Flanker for each creature that left the battlefield under your control this turn.\n• You gain 2 life and scry 2.\n• Exile target players graveyard.
SVar:DBExile:DB$ ChangeZoneAll | ValidTgts$ Player | Origin$ Graveyard | Destination$ Exile | ChangeType$ Card | IsCurse$ True | SpellDescription$ Exile target player's graveyard.
Oracle:Flash\nWhen Kutzil's Flanker enters the battlefield, choose one —\n• Put a +1/+1 counter on Kutzil's Flanker for each creature that left the battlefield under your control this turn.\n• You gain 2 life and scry 2.\n• Exile target player's graveyard.

View File

@@ -3,9 +3,8 @@ ManaCost:5 W W
Types:Sorcery
K:MayEffectFromOpeningHand:RevealCard
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ SetLifeOnUpkeep | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, your life total becomes 26.
SVar:SetLifeOnUpkeep:DB$ Effect | Triggers$ TrigSetLife | Name$ Providence effect | SpellDescription$ You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, your life total becomes 26.
SVar:TrigSetLife:Mode$ Phase | Phase$ Upkeep | Execute$ EffSetLife | TriggerDescription$ At the beginning of the first upkeep, your life total becomes 26.
SVar:EffSetLife:DB$ SetLife | LifeAmount$ 26 | Defined$ You | SubAbility$ RemoveMe
SVar:RemoveMe:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
SVar:SetLifeOnUpkeep:DB$ Effect | Triggers$ TrigSetLife
SVar:TrigSetLife:Mode$ Phase | Phase$ Upkeep | Execute$ EffSetLife | OneOff$ True | TriggerDescription$ At the beginning of the first upkeep, your life total becomes 26.
SVar:EffSetLife:DB$ SetLife | LifeAmount$ 26 | Defined$ You
A:SP$ SetLife | Cost$ 5 W W | LifeAmount$ 26 | Defined$ You | SpellDescription$ Your life total becomes 26.
Oracle:You may reveal this card from your opening hand. If you do, at the beginning of the first upkeep, your life total becomes 26.\nYour life total becomes 26.

View File

@@ -7,7 +7,7 @@ SVar:TrigDamage:DB$ DealDamage | Defined$ Opponent | NumDmg$ 2 | SubAbility$ DBG
SVar:DBGainLife:DB$ GainLife | LifeAmount$ 2
A:AB$ Token | Cost$ AddCounter<1/LOYALTY> | Planeswalker$ True | TokenScript$ rw_3_2_spirit | SpellDescription$ Create a 3/2 red and white Spirit creature token.
A:AB$ Discover | Cost$ SubCounter<3/LOYALTY> | Planeswalker$ True | Num$ 4 | SpellDescription$ Discover 4.
A:AB$ ChangeZone | Cost$ SubCounter<6/LOYALTY> | Planeswalker$ True | Ultimate$ True | Origin$ Graveyard | Destination$ Exile | TargetMin$ 0 | TargetMax$ Yard | TgtPrompt$ Select any number of target cards in your graveyard | ValidTgts$ Card.YouOwn | RememberChanged$ True | StackDescription$ SpellDescription | SpellDescription$ Exile any number of target cards from your graveyard. Add {R} for each card exiled this way. You may play those cards this turn.
A:AB$ ChangeZone | Cost$ SubCounter<6/LOYALTY> | Planeswalker$ True | Ultimate$ True | Origin$ Graveyard | Destination$ Exile | TargetMin$ 0 | TargetMax$ Yard | TgtPrompt$ Select any number of target cards in your graveyard | ValidTgts$ Card.YouOwn | RememberChanged$ True | SubAbility$ DBMana | StackDescription$ SpellDescription | SpellDescription$ Exile any number of target cards from your graveyard. Add {R} for each card exiled this way. You may play those cards this turn.
SVar:DBMana:DB$ Mana | Produced$ R | Amount$ X | SubAbility$ DBEffect
SVar:DBEffect:DB$ Effect | RememberObjects$ Remembered | StaticAbilities$ STMayPlay | SubAbility$ DBCleanup | ForgetOnMoved$ Exile
SVar:STMayPlay:Mode$ Continuous | MayPlay$ True | EffectZone$ Command | Affected$ Card.IsRemembered | AffectedZone$ Exile | Description$ You may play those cards.

View File

@@ -4,7 +4,7 @@ Types:Creature Sphinx
PT:4/4
K:MayEffectFromOpeningHand:RevealCard
SVar:RevealCard:DB$ Reveal | RevealDefined$ Self | SubAbility$ ScryOnUpkeep | SpellDescription$ You may reveal this card from your opening hand. If you do, scry 3 at the beginning of your first upkeep.
SVar:ScryOnUpkeep:DB$ Effect | Triggers$ TrigOpenScry | Duration$ Permanent | SpellDescription$ You may reveal this card from your opening hand. If you do, scry 3 at the beginning of your first upkeep.
SVar:ScryOnUpkeep:DB$ Effect | Triggers$ TrigOpenScry | Duration$ Permanent
SVar:TrigOpenScry:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | OneOff$ True | Execute$ DBScry | TriggerDescription$ If you do, scry 3 at the beginning of your first upkeep.
SVar:DBScry:DB$ Scry | ScryNum$ 3
K:Flying

View File

@@ -569,7 +569,7 @@ public class HumanPlay {
final Card source = ability.getHostCard();
ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost);
String xInCard = source.getSVar("X");
String xInCard = ability.getSVar("X");
String xColor = ability.getXColor();
if (source.hasKeyword("Spend only colored mana on X. No more than one mana of each color may be spent this way.")) {
xColor = "WUBRGX";