mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
add ReplacePayLife
This commit is contained in:
@@ -625,11 +625,21 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ashiok Exile instead of paying life
|
// Replacement only matters when life payment is greater than 0
|
||||||
if (hasKeyword("Exile library instead of pay life") && lifePayment <= getZone(ZoneType.Library).size()) {
|
if (lifePayment > 0) {
|
||||||
// TODO is cause always set or not? if not then the ChangeZoneTable needs to trigger differently?
|
Map<AbilityKey, Object> replaceParams = AbilityKey.mapFromAffected(this);
|
||||||
getGame().getAction().exile(getTopXCardsFromLibrary(lifePayment), cause, null);
|
replaceParams.put(AbilityKey.Amount, lifePayment);
|
||||||
return true;
|
replaceParams.put(AbilityKey.Cause, cause);
|
||||||
|
replaceParams.put(AbilityKey.EffectOnly, effect);
|
||||||
|
switch (getGame().getReplacementHandler().run(ReplacementType.PayLife, replaceParams)) {
|
||||||
|
case Replaced:
|
||||||
|
return true;
|
||||||
|
case Prevented:
|
||||||
|
case Skipped:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
final int lost = loseLife(lifePayment, false, false);
|
final int lost = loseLife(lifePayment, false, false);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package forge.game.replacement;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import forge.game.ability.AbilityKey;
|
||||||
|
import forge.game.card.Card;
|
||||||
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.util.Expressions;
|
||||||
|
|
||||||
|
public class ReplacePayLife extends ReplacementEffect {
|
||||||
|
|
||||||
|
public ReplacePayLife(Map<String, String> map, Card host, boolean intrinsic) {
|
||||||
|
super(map, host, intrinsic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReplace(Map<AbilityKey, Object> runParams) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (!matchesValidParam("ValidPlayer", runParams.get(AbilityKey.Affected))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasParam("Amount")) {
|
||||||
|
final int n = (Integer)runParams.get(AbilityKey.Amount);
|
||||||
|
String comparator = getParam("Amount");
|
||||||
|
final String operator = comparator.substring(0, 2);
|
||||||
|
final int operandValue = Integer.parseInt(comparator.substring(2));
|
||||||
|
if (!Expressions.compare(n, operator, operandValue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setReplacingObjects(Map<AbilityKey, Object> runParams, SpellAbility sa) {
|
||||||
|
sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected));
|
||||||
|
sa.setReplacingObjectsFrom(runParams, AbilityKey.Amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ public enum ReplacementType {
|
|||||||
LoseMana(ReplaceLoseMana.class),
|
LoseMana(ReplaceLoseMana.class),
|
||||||
Mill(ReplaceMill.class),
|
Mill(ReplaceMill.class),
|
||||||
Moved(ReplaceMoved.class),
|
Moved(ReplaceMoved.class),
|
||||||
|
PayLife(ReplacePayLife.class),
|
||||||
PlanarDiceResult(ReplacePlanarDiceResult.class),
|
PlanarDiceResult(ReplacePlanarDiceResult.class),
|
||||||
ProduceMana(ReplaceProduceMana.class),
|
ProduceMana(ReplaceProduceMana.class),
|
||||||
Proliferate(ReplaceProliferate.class),
|
Proliferate(ReplaceProliferate.class),
|
||||||
|
|||||||
Reference in New Issue
Block a user