mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
Fix Lifelink so it triggers per source instead of per recipient in combat. (#6272)
* Fix Lifelink so it triggers once per source instead of once per recipient in combat. * Undo an import collapse. * Add more tests for lifelink.
This commit is contained in:
parent
fb82303b85
commit
29ce4b1ad4
4 changed files with 187 additions and 4 deletions
|
|
@ -132,6 +132,8 @@ public interface Permanent extends Card, Controllable {
|
|||
*/
|
||||
int markDamage(int damage, UUID sourceId, Game game, boolean preventable, boolean combat);
|
||||
|
||||
void markLifelink(int damage);
|
||||
|
||||
int applyDamage(Game game);
|
||||
|
||||
void removeAllDamage(Game game);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected List<UUID> bandedCards = new ArrayList<>();
|
||||
protected Counters counters;
|
||||
protected List<MarkedDamageInfo> markedDamage;
|
||||
protected int markedLifelink;
|
||||
protected int timesLoyaltyUsed = 0;
|
||||
protected Map<String, String> info;
|
||||
protected int createOrder;
|
||||
|
|
@ -133,6 +134,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
this.blocking = permanent.blocking;
|
||||
this.maxBlocks = permanent.maxBlocks;
|
||||
this.deathtouched = permanent.deathtouched;
|
||||
this.markedLifelink = permanent.markedLifelink;
|
||||
|
||||
for (Map.Entry<String, List<UUID>> entry : permanent.connectedCards.entrySet()) {
|
||||
this.connectedCards.put(entry.getKey(), entry.getValue());
|
||||
|
|
@ -886,8 +888,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
if (source != null && sourceAbilities != null) {
|
||||
if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) {
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
player.gainLife(damageDone, game, sourceId);
|
||||
if (markDamage) {
|
||||
game.getPermanent(sourceId).markLifelink(damageDone);
|
||||
} else {
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
player.gainLife(damageDone, game, sourceId);
|
||||
}
|
||||
}
|
||||
if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) {
|
||||
deathtouched = true;
|
||||
|
|
@ -912,6 +918,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return damageDone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markLifelink(int damage) {
|
||||
markedLifelink += damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int markDamage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat) {
|
||||
return damage(damageAmount, sourceId, game, preventable, combat, true, null);
|
||||
|
|
@ -919,6 +930,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|
||||
@Override
|
||||
public int applyDamage(Game game) {
|
||||
if (markedLifelink > 0) {
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
player.gainLife(markedLifelink, game, this.getId());
|
||||
markedLifelink = 0;
|
||||
}
|
||||
if (markedDamage == null) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2161,8 +2161,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
if (sourceAbilities != null && sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) {
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
player.gainLife(actualDamage, game, sourceId);
|
||||
if (combatDamage) {
|
||||
game.getPermanent(sourceId).markLifelink(actualDamage);
|
||||
} else {
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
player.gainLife(actualDamage, game, sourceId);
|
||||
}
|
||||
}
|
||||
// Unstable ability - Earl of Squirrel
|
||||
if (sourceAbilities != null && sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue