diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index dfc009f96fb..65c2c8da653 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -556,7 +556,7 @@ public final int loseLife(int toLose, final boolean damage, final boolean manaBu int oldLife = life; // Run applicable replacement effects final Map repParams = AbilityKey.mapFromAffected(this); - repParams.put(AbilityKey.Result, oldLife-toLose); + repParams.put(AbilityKey.Amount, toLose); repParams.put(AbilityKey.IsDamage, damage); switch (getGame().getReplacementHandler().run(ReplacementType.LifeReduced, repParams)) { @@ -565,8 +565,7 @@ public final int loseLife(int toLose, final boolean damage, final boolean manaBu case Updated: // check if this is still the affected player if (this.equals(repParams.get(AbilityKey.Affected))) { - int result = (int) repParams.get(AbilityKey.Result); - toLose = oldLife - result; + toLose = (int) repParams.get(AbilityKey.Amount); // there is nothing that changes lifegain into lifeloss this way if (toLose <= 0) { return 0; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceLifeReduced.java b/forge-game/src/main/java/forge/game/replacement/ReplaceLifeReduced.java index 97560963f9e..c4501dd2e06 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceLifeReduced.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceLifeReduced.java @@ -4,6 +4,8 @@ import forge.game.ability.AbilityKey; import forge.game.card.Card; +import forge.game.player.Player; +import forge.game.spellability.SpellAbility; import forge.util.Expressions; /** @@ -27,7 +29,13 @@ public ReplaceLifeReduced(Map map, Card host, boolean intrinsic) */ @Override public boolean canReplace(Map runParams) { - if (!matchesValidParam("ValidPlayer", runParams.get(AbilityKey.Affected))) { + int amount = (int)runParams.get(AbilityKey.Amount); + Player affected = (Player) runParams.get(AbilityKey.Affected); + if (amount <= 0) { + return false; + } + + if (!matchesValidParam("ValidPlayer", affected)) { return false; } @@ -36,8 +44,9 @@ public boolean canReplace(Map runParams) { return false; } } + if (hasParam("Result")) { - final int n = (Integer)runParams.get(AbilityKey.Result); + final int n = affected.getLife() - amount; String comparator = getParam("Result"); final String operator = comparator.substring(0, 2); final int operandValue = Integer.parseInt(comparator.substring(2)); @@ -47,4 +56,10 @@ public boolean canReplace(Map runParams) { } return true; } + + @Override + public void setReplacingObjects(Map runParams, SpellAbility sa) { + sa.setReplacingObjectsFrom(runParams, AbilityKey.Amount); + sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected)); + } } diff --git a/forge-gui/res/cardsfolder/a/ali_from_cairo.txt b/forge-gui/res/cardsfolder/a/ali_from_cairo.txt index aacf2a9adbc..b5cf5641612 100644 --- a/forge-gui/res/cardsfolder/a/ali_from_cairo.txt +++ b/forge-gui/res/cardsfolder/a/ali_from_cairo.txt @@ -2,8 +2,8 @@ Name:Ali from Cairo ManaCost:2 R R Types:Creature Human PT:0/1 -R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 Oracle:Damage that would reduce your life total to less than 1 reduces it to 1 instead. diff --git a/forge-gui/res/cardsfolder/a/angel_of_grace.txt b/forge-gui/res/cardsfolder/a/angel_of_grace.txt index ab3dd9356a0..6da7712664e 100644 --- a/forge-gui/res/cardsfolder/a/angel_of_grace.txt +++ b/forge-gui/res/cardsfolder/a/angel_of_grace.txt @@ -6,10 +6,10 @@ K:Flash K:Flying T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigEffect | TriggerDescription$ When CARDNAME enters the battlefield, until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. SVar:TrigEffect:DB$ Effect | Name$ Angel of Grace Effect | ReplacementEffects$ SelflessDamage | Description$ Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:SelflessDamage:Event$ LifeReduced | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | ReplaceWith$ ReduceLoss | Description$ Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +SVar:SelflessDamage:Event$ LifeReduced | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 A:AB$ SetLife | Cost$ 4 W W ExileFromGrave<1/CARDNAME> | Defined$ You | ActivationZone$ Graveyard | LifeAmount$ 10 | SpellDescription$ Your life total becomes 10. AI:RemoveDeck:Random Oracle:Flash\nFlying\nWhen Angel of Grace enters the battlefield, until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead.\n{4}{W}{W}, Exile Angel of Grace from your graveyard: Your life total becomes 10. diff --git a/forge-gui/res/cardsfolder/a/angels_grace.txt b/forge-gui/res/cardsfolder/a/angels_grace.txt index 03fd5b4a27c..630ee855288 100644 --- a/forge-gui/res/cardsfolder/a/angels_grace.txt +++ b/forge-gui/res/cardsfolder/a/angels_grace.txt @@ -4,8 +4,8 @@ Types:Instant K:Split second A:SP$ Effect | StaticAbilities$ STCantLose | ReplacementEffects$ SelflessDamage | AILogic$ Fog | SpellDescription$ You can't lose the game this turn and your opponents can't win the game this turn. Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. SVar:STCantLose:Mode$ Continuous | Affected$ You | AddKeyword$ You can't lose the game. & Your opponents can't win the game. | Description$ You can't lose the game. Your opponents can't win the game. -SVar:SelflessDamage:Event$ LifeReduced | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | ReplaceWith$ ReduceLoss | Description$ Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +SVar:SelflessDamage:Event$ LifeReduced | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 Oracle:Split second (As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities.)\nYou can't lose the game this turn and your opponents can't win the game this turn. Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead. diff --git a/forge-gui/res/cardsfolder/e/elderscale_wurm.txt b/forge-gui/res/cardsfolder/e/elderscale_wurm.txt index 3df78eb1612..51710c9bfb3 100644 --- a/forge-gui/res/cardsfolder/e/elderscale_wurm.txt +++ b/forge-gui/res/cardsfolder/e/elderscale_wurm.txt @@ -3,10 +3,11 @@ ManaCost:4 G G G Types:Creature Wurm PT:7/7 K:Trample -T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigLife | CheckSVar$ ElderscaleCondition | SVarCompare$ LT7 | TriggerDescription$ When CARDNAME enters the battlefield, if your life total is less than 7, your life total becomes 7. +T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigLife | CheckSVar$ YourLife | SVarCompare$ LT7 | TriggerDescription$ When CARDNAME enters the battlefield, if your life total is less than 7, your life total becomes 7. SVar:TrigLife:DB$ SetLife | Defined$ You | LifeAmount$ 7 -R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You | Result$ LT7 | IsDamage$ True | CheckSVar$ ElderscaleCondition | SVarCompare$ GE7 | ReplaceWith$ ReduceLoss | Description$ As long as you have 7 or more life, damage that would reduce your life total to less than 7 reduces it to 7 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.7 -SVar:ElderscaleCondition:Count$YourLifeTotal +R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You.lifeGE7 | Result$ LT7 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ As long as you have 7 or more life, damage that would reduce your life total to less than 7 reduces it to 7 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.7 +SVar:YourLife:Count$YourLifeTotal Oracle:Trample\nWhen Elderscale Wurm enters the battlefield, if your life total is less than 7, your life total becomes 7.\nAs long as you have 7 or more life, damage that would reduce your life total to less than 7 reduces it to 7 instead. diff --git a/forge-gui/res/cardsfolder/f/fortune_thief.txt b/forge-gui/res/cardsfolder/f/fortune_thief.txt index a6b915c684f..779693e8a37 100644 --- a/forge-gui/res/cardsfolder/f/fortune_thief.txt +++ b/forge-gui/res/cardsfolder/f/fortune_thief.txt @@ -3,8 +3,8 @@ ManaCost:4 R Types:Creature Human Rogue PT:0/1 K:Morph:R R -R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 Oracle:Damage that would reduce your life total to less than 1 reduces it to 1 instead.\nMorph {R}{R} (You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.) diff --git a/forge-gui/res/cardsfolder/s/serra_the_benevolent.txt b/forge-gui/res/cardsfolder/s/serra_the_benevolent.txt index 10299fb5c9c..2c01c7de3d9 100644 --- a/forge-gui/res/cardsfolder/s/serra_the_benevolent.txt +++ b/forge-gui/res/cardsfolder/s/serra_the_benevolent.txt @@ -5,9 +5,9 @@ Loyalty:4 A:AB$ PumpAll | Cost$ AddCounter<2/LOYALTY> | Planeswalker$ True | ValidCards$ Creature.withFlying+YouCtrl | NumAtt$ +1 | NumDef$ +1 | SpellDescription$ Creatures you control with flying get +1/+1 until end of turn. A:AB$ Token | Cost$ SubCounter<3/LOYALTY> | Planeswalker$ True | TokenScript$ w_4_4_angel_flying_vigilance | TokenOwner$ You | SpellDescription$ Create a 4/4 white Angel creature token with flying and vigilance. A:AB$ Effect | Cost$ SubCounter<6/LOYALTY> | Name$ Emblem - Serra the Benevolent | Image$ emblem_serra_the_benevolent | ReplacementEffects$ STWorship | Planeswalker$ True | Ultimate$ True | Stackable$ False | Duration$ Permanent | AILogic$ Always | SpellDescription$ You get an emblem with "If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead." -SVar:STWorship:Event$ LifeReduced | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | IsPresent$ Creature.YouCtrl | ReplaceWith$ ReduceLoss | Description$ If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +SVar:STWorship:Event$ LifeReduced | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | IsPresent$ Creature.YouCtrl | ReplaceWith$ ReduceLoss | Description$ If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 DeckHas:Ability$Token Oracle:[+2]: Creatures you control with flying get +1/+1 until end of turn.\n[-3]: Create a 4/4 white Angel creature token with flying and vigilance.\n[-6]: You get an emblem with "If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead." diff --git a/forge-gui/res/cardsfolder/s/sustaining_spirit.txt b/forge-gui/res/cardsfolder/s/sustaining_spirit.txt index cbced08a0ff..06f6141e3f3 100644 --- a/forge-gui/res/cardsfolder/s/sustaining_spirit.txt +++ b/forge-gui/res/cardsfolder/s/sustaining_spirit.txt @@ -3,8 +3,8 @@ ManaCost:1 W Types:Creature Angel Spirit PT:0/3 K:Cumulative upkeep:1 W -R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | ReplaceWith$ ReduceLoss | Description$ Damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 Oracle:Cumulative upkeep {1}{W} (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.)\nDamage that would reduce your life total to less than 1 reduces it to 1 instead. diff --git a/forge-gui/res/cardsfolder/upcoming/bloodletter_of_aclazotz.txt b/forge-gui/res/cardsfolder/upcoming/bloodletter_of_aclazotz.txt new file mode 100644 index 00000000000..95c6f192519 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/bloodletter_of_aclazotz.txt @@ -0,0 +1,8 @@ +Name:Bloodletter of Aclazotz +ManaCost:1 B B B +Types:Creature Vampire Demon +PT:2/4 +K:Flying +R:Event$ LifeReduced | ValidPlayer$ Opponent | PlayerTurn$ True | ReplaceWith$ LoseTwice | ActiveZones$ Battlefield | Description$ If an opponent would lose life during your turn, they lose twice that much life instead. (Damage causes loss of life.) +SVar:LoseTwice:DB$ ReplaceEffect | VarName$ Amount | VarValue$ ReplaceCount$Amount/Twice +Oracle:Flying\nIf an opponent would lose life during your turn, they lose twice that much life instead. (Damage causes loss of life.) diff --git a/forge-gui/res/cardsfolder/w/worship.txt b/forge-gui/res/cardsfolder/w/worship.txt index 29e901aa74f..35346983510 100644 --- a/forge-gui/res/cardsfolder/w/worship.txt +++ b/forge-gui/res/cardsfolder/w/worship.txt @@ -1,8 +1,8 @@ Name:Worship ManaCost:3 W Types:Enchantment -R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You | Result$ LT1 | IsDamage$ True | CheckSVar$ YourLife | SVarCompare$ GE1 | IsPresent$ Creature.YouCtrl | ReplaceWith$ ReduceLoss | Description$ If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead. -SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Result | VarValue$ X -SVar:X:ReplaceCount$Result/NMinus.1 -SVar:YourLife:Count$YourLifeTotal +R:Event$ LifeReduced | ActiveZones$ Battlefield | ValidPlayer$ You.lifeGE1 | Result$ LT1 | IsDamage$ True | IsPresent$ Creature.YouCtrl | ReplaceWith$ ReduceLoss | Description$ If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead. +SVar:ReduceLoss:DB$ ReplaceEffect | VarName$ Amount | VarValue$ X +SVar:X:ReplaceCount$Amount/LimitMax.Difference +SVar:Difference:Count$YourLifeTotal/Minus.1 Oracle:If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead.