mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'damage' into 'master'
Deal combat damage to players simultaneously Closes #2042 See merge request core-developers/forge!5960
This commit is contained in:
@@ -2268,6 +2268,14 @@ public class GameAction {
|
||||
}
|
||||
}
|
||||
|
||||
// lose life simultaneously
|
||||
if (isCombat) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
p.dealCombatDamage();
|
||||
}
|
||||
game.getTriggerHandler().runWaitingTriggers();
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
// Remember objects as needed
|
||||
final Card sourceLKI = game.getChangeZoneLKIInfo(cause.getHostCard());
|
||||
|
||||
@@ -808,9 +808,6 @@ public class AbilityUtils {
|
||||
if (parent != null) {
|
||||
list = parent.findTargetedCards();
|
||||
}
|
||||
else {
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
else if (calcX[0].startsWith("TriggerRemembered")) {
|
||||
final SpellAbility root = sa.getRootAbility();
|
||||
|
||||
@@ -5270,8 +5270,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
Log.debug(this + " - was assigned " + assignedDamage0 + " damage, by " + sourceCard);
|
||||
if (!assignedDamageMap.containsKey(sourceCard)) {
|
||||
assignedDamageMap.put(sourceCard, assignedDamage0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assignedDamageMap.put(sourceCard, assignedDamageMap.get(sourceCard) + assignedDamage0);
|
||||
}
|
||||
if (assignedDamage0 > 0) {
|
||||
@@ -5433,13 +5432,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
excess = damageIn + getDamage() - getLethal();
|
||||
}
|
||||
|
||||
GameEventCardDamaged.DamageType damageType = DamageType.Normal;
|
||||
DamageType damageType = DamageType.Normal;
|
||||
if (isPlaneswalker()) { // 120.3c
|
||||
subtractCounter(CounterType.get(CounterEnumType.LOYALTY), damageIn);
|
||||
}
|
||||
if (isCreature()) {
|
||||
boolean wither = (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||
|| source.hasKeyword(Keyword.WITHER) || source.hasKeyword(Keyword.INFECT));
|
||||
boolean wither = game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||
|| source.hasKeyword(Keyword.WITHER) || source.hasKeyword(Keyword.INFECT);
|
||||
|
||||
if (wither) { // 120.3d
|
||||
addCounter(CounterType.get(CounterEnumType.M1M1), damageIn, source.getController(), null, true, counterTable);
|
||||
@@ -5450,7 +5449,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
view.updateDamage(this);
|
||||
}
|
||||
|
||||
if (source.hasKeyword(Keyword.DEATHTOUCH) && isCreature()) {
|
||||
if (source.hasKeyword(Keyword.DEATHTOUCH)) {
|
||||
setHasBeenDealtDeathtouchDamage(true);
|
||||
damageType = DamageType.Deathtouch;
|
||||
}
|
||||
|
||||
@@ -175,6 +175,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
private int numForetoldThisTurn = 0;
|
||||
private int numCardsInHandStartedThisTurnWith = 0;
|
||||
|
||||
private int simultaneousDamage = 0;
|
||||
|
||||
private int lastTurnNr = 0;
|
||||
|
||||
private final Map<String, FCollection<String>> notes = Maps.newHashMap();
|
||||
@@ -662,7 +664,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
if (amount <= 0 || hasLost()) {
|
||||
return 0;
|
||||
}
|
||||
//String additionalLog = "";
|
||||
|
||||
boolean infect = source.hasKeyword(Keyword.INFECT)
|
||||
|| hasKeyword("All damage is dealt to you as though its source had infect.");
|
||||
@@ -672,7 +673,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
else if (!hasKeyword("Damage doesn't cause you to lose life.")) {
|
||||
// rule 118.2. Damage dealt to a player normally causes that player to lose that much life.
|
||||
loseLife(amount, true, false);
|
||||
if (isCombat) {
|
||||
// currently all abilities treat is as single event
|
||||
simultaneousDamage += amount;
|
||||
} else {
|
||||
loseLife(amount, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
//Oathbreaker, Tiny Leaders, and Brawl ignore commander damage rule
|
||||
@@ -711,7 +717,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
runParams.put(AbilityKey.IsCombatDamage, isCombat);
|
||||
// Defending player at the time the damage was dealt
|
||||
runParams.put(AbilityKey.DefendingPlayer, game.getCombat() != null ? game.getCombat().getDefendingPlayerRelatedTo(source) : null);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams, isCombat);
|
||||
|
||||
game.fireEvent(new GameEventPlayerDamaged(this, source, amount, isCombat, infect));
|
||||
|
||||
@@ -811,6 +817,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return restDamage;
|
||||
}
|
||||
|
||||
public final void dealCombatDamage() {
|
||||
loseLife(simultaneousDamage, true, false);
|
||||
simultaneousDamage = 0;
|
||||
}
|
||||
|
||||
public final void clearAssignedDamage() {
|
||||
assignedDamage.clear();
|
||||
assignedCombatDamage.clear();
|
||||
|
||||
Reference in New Issue
Block a user