mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
ReplaceLifeReduced: update for Bloodletter (#4197)
* ReplaceLifeReduced: update for Bloodletter * add Bloodletter of aclazotz
This commit is contained in:
@@ -556,7 +556,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
int oldLife = life;
|
||||
// Run applicable replacement effects
|
||||
final Map<AbilityKey, Object> 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 class Player extends GameEntity implements Comparable<Player> {
|
||||
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;
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.Map;
|
||||
|
||||
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 class ReplaceLifeReduced extends ReplacementEffect {
|
||||
*/
|
||||
@Override
|
||||
public boolean canReplace(Map<AbilityKey, Object> 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 class ReplaceLifeReduced extends ReplacementEffect {
|
||||
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 class ReplaceLifeReduced extends ReplacementEffect {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplacingObjects(Map<AbilityKey, Object> runParams, SpellAbility sa) {
|
||||
sa.setReplacingObjectsFrom(runParams, AbilityKey.Amount);
|
||||
sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user