replace lifelink with generic damage trigger, and do lifelink there

git-svn-id: http://svn.slightlymagic.net/forge/trunk@35746 269b9781-a132-4a9b-9d4e-f004f1b56b58
This commit is contained in:
Hanmac 2017-09-25 05:21:06 +00:00
parent 777610c38b
commit 2f1b5904ab
8 changed files with 14 additions and 24 deletions

View File

@ -111,7 +111,7 @@ public class DamageAllEffect extends DamageBaseEffect {
}
preventMap.triggerPreventDamage(false);
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
replaceDying(sa);
}

View File

@ -159,7 +159,7 @@ public class DamageDealEffect extends DamageBaseEffect {
} else {
preventMap.triggerPreventDamage(false);
// non combat damage cause lifegain there
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
replaceDying(sa);
}
return;

View File

@ -121,7 +121,7 @@ public class DamageEachEffect extends DamageBaseEffect {
}
preventMap.triggerPreventDamage(false);
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
replaceDying(sa);
}

View File

@ -67,7 +67,7 @@ public class FightEffect extends DamageBaseEffect {
dealDamage(fighters.get(1), fighters.get(0), dmg2, damageMap, preventMap);
preventMap.triggerPreventDamage(false);
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
replaceDying(sa);

View File

@ -16,20 +16,6 @@ import forge.game.trigger.TriggerType;
public class CardDamageMap extends ForwardingTable<Card, GameEntity, Integer> {
private Table<Card, GameEntity, Integer> dataMap = HashBasedTable.create();
// common function to gain life for lifelink
public void dealLifelinkDamage() {
for (Map.Entry<Card, Map<GameEntity, Integer>> e : this.rowMap().entrySet()) {
final Card sourceLKI = e.getKey();
int damageSum = 0;
for (final Integer i : e.getValue().values()) {
damageSum += i;
}
if (damageSum > 0 && sourceLKI.hasKeyword("Lifelink")) {
sourceLKI.getController().gainLife(damageSum, sourceLKI);
}
}
}
public void triggerPreventDamage(boolean isCombat) {
for (Map.Entry<GameEntity, Map<Card, Integer>> e : this.columnMap().entrySet()) {
@ -52,19 +38,23 @@ public class CardDamageMap extends ForwardingTable<Card, GameEntity, Integer> {
public void triggerDamageDoneOnce(boolean isCombat) {
// Source -> Targets
for (Map.Entry<Card, Map<GameEntity, Integer>> e : this.rowMap().entrySet()) {
final Card sourceLKI = e.getKey();
int sum = 0;
for (final Integer i : e.getValue().values()) {
sum += i;
}
if (sum > 0) {
final GameEntity ge = e.getKey();
final Map<String, Object> runParams = Maps.newHashMap();
runParams.put("DamageSource", ge);
runParams.put("DamageSource", sourceLKI);
runParams.put("DamageTargets", Sets.newHashSet(e.getValue().keySet()));
runParams.put("DamageAmount", sum);
runParams.put("IsCombatDamage", isCombat);
ge.getGame().getTriggerHandler().runTrigger(TriggerType.DamageDealtOnce, runParams, false);
sourceLKI.getGame().getTriggerHandler().runTrigger(TriggerType.DamageDealtOnce, runParams, false);
if (sourceLKI.hasKeyword("Lifelink")) {
sourceLKI.getController().gainLife(sum, sourceLKI);
}
}
}
// Targets -> Source

View File

@ -830,7 +830,7 @@ public class Combat {
// This was deeper before, but that resulted in the stack entry acting like before.
// LifeLink for Combat Damage at this place
dealtDamageTo.dealLifelinkDamage();
dealtDamageTo.triggerDamageDoneOnce(true);
// when ... deals combat damage to one or more
for (final Card damageSource : dealtDamageTo.rowKeySet()) {

View File

@ -67,7 +67,7 @@ public class CostDamage extends CostPart {
payer.addDamage(decision.c, source, damageMap, preventMap);
preventMap.triggerPreventDamage(false);
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
return decision.c > 0;
}

View File

@ -427,7 +427,7 @@ public class HumanPlay {
p.addDamage(amount, source, damageMap, preventMap);
preventMap.triggerPreventDamage(false);
damageMap.dealLifelinkDamage();
damageMap.triggerDamageDoneOnce(false);
}
else if (part instanceof CostPutCounter) {
CounterType counterType = ((CostPutCounter) part).getCounter();