mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
@@ -54,33 +54,29 @@ public class LifeExchangeEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
final int life1 = p1.getLife();
|
final int life1 = p1.getLife();
|
||||||
final int life2 = p2.getLife();
|
final int life2 = p2.getLife();
|
||||||
|
final int diff = Math.abs(life1 - life2);
|
||||||
|
|
||||||
if (sa.hasParam("RememberDifference")) {
|
if (life2 > life1) {
|
||||||
final int diff = life1 - life2;
|
// swap players
|
||||||
source.addRemembered(diff);
|
Player tmp = p2;
|
||||||
|
p2 = p1;
|
||||||
|
p1 = tmp;
|
||||||
}
|
}
|
||||||
|
if (diff > 0 && p1.canLoseLife() && p2.canGainLife()) {
|
||||||
final Map<Player, Integer> lossMap = Maps.newHashMap();
|
|
||||||
if ((life1 > life2) && p1.canLoseLife() && p2.canGainLife()) {
|
|
||||||
final int diff = life1 - life2;
|
|
||||||
final int lost = p1.loseLife(diff, false, false);
|
final int lost = p1.loseLife(diff, false, false);
|
||||||
p2.gainLife(diff, source, sa);
|
p2.gainLife(diff, source, sa);
|
||||||
if (lost > 0) {
|
if (lost > 0) {
|
||||||
|
final Map<Player, Integer> lossMap = Maps.newHashMap();
|
||||||
lossMap.put(p1, lost);
|
lossMap.put(p1, lost);
|
||||||
|
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPIMap(lossMap);
|
||||||
|
source.getGame().getTriggerHandler().runTrigger(TriggerType.LifeLostAll, runParams, false);
|
||||||
|
if (sa.hasParam("RememberOwnLoss") && p1.equals(sa.getActivatingPlayer())) {
|
||||||
|
source.addRemembered(lost);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ((life2 > life1) && p2.canLoseLife() && p1.canGainLife()) {
|
|
||||||
final int diff = life2 - life1;
|
|
||||||
final int lost = p2.loseLife(diff, false, false);
|
|
||||||
p1.gainLife(diff, source, sa);
|
|
||||||
if (lost > 0) {
|
|
||||||
lossMap.put(p2, lost);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// they are equal or can't be exchanged, so nothing to do
|
|
||||||
}
|
}
|
||||||
if (!lossMap.isEmpty()) { // Run triggers if any player actually lost life
|
if (sa.hasParam("RememberDifference")) {
|
||||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPIMap(lossMap);
|
source.addRemembered(p1.getLife() - p2.getLife());
|
||||||
source.getGame().getTriggerHandler().runTrigger(TriggerType.LifeLostAll, runParams, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,7 +455,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run any applicable replacement effects.
|
|
||||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
|
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
|
||||||
repParams.put(AbilityKey.LifeGained, lifeGain);
|
repParams.put(AbilityKey.LifeGained, lifeGain);
|
||||||
repParams.put(AbilityKey.SourceSA, sa);
|
repParams.put(AbilityKey.SourceSA, sa);
|
||||||
@@ -521,7 +520,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int oldLife = life;
|
int oldLife = life;
|
||||||
// Run applicable replacement effects
|
|
||||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
|
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
|
||||||
repParams.put(AbilityKey.Amount, toLose);
|
repParams.put(AbilityKey.Amount, toLose);
|
||||||
repParams.put(AbilityKey.IsDamage, damage);
|
repParams.put(AbilityKey.IsDamage, damage);
|
||||||
@@ -554,7 +553,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean firstLost = lifeLostThisTurn == 0;
|
boolean firstLost = lifeLostThisTurn == 0;
|
||||||
|
|
||||||
lifeLostThisTurn += toLose;
|
lifeLostThisTurn += toLose;
|
||||||
|
|
||||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
|
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user