mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +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) {
|
if (cause != null) {
|
||||||
// Remember objects as needed
|
// Remember objects as needed
|
||||||
final Card sourceLKI = game.getChangeZoneLKIInfo(cause.getHostCard());
|
final Card sourceLKI = game.getChangeZoneLKIInfo(cause.getHostCard());
|
||||||
|
|||||||
@@ -808,9 +808,6 @@ public class AbilityUtils {
|
|||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
list = parent.findTargetedCards();
|
list = parent.findTargetedCards();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
list = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (calcX[0].startsWith("TriggerRemembered")) {
|
else if (calcX[0].startsWith("TriggerRemembered")) {
|
||||||
final SpellAbility root = sa.getRootAbility();
|
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);
|
Log.debug(this + " - was assigned " + assignedDamage0 + " damage, by " + sourceCard);
|
||||||
if (!assignedDamageMap.containsKey(sourceCard)) {
|
if (!assignedDamageMap.containsKey(sourceCard)) {
|
||||||
assignedDamageMap.put(sourceCard, assignedDamage0);
|
assignedDamageMap.put(sourceCard, assignedDamage0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assignedDamageMap.put(sourceCard, assignedDamageMap.get(sourceCard) + assignedDamage0);
|
assignedDamageMap.put(sourceCard, assignedDamageMap.get(sourceCard) + assignedDamage0);
|
||||||
}
|
}
|
||||||
if (assignedDamage0 > 0) {
|
if (assignedDamage0 > 0) {
|
||||||
@@ -5433,13 +5432,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
excess = damageIn + getDamage() - getLethal();
|
excess = damageIn + getDamage() - getLethal();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameEventCardDamaged.DamageType damageType = DamageType.Normal;
|
DamageType damageType = DamageType.Normal;
|
||||||
if (isPlaneswalker()) { // 120.3c
|
if (isPlaneswalker()) { // 120.3c
|
||||||
subtractCounter(CounterType.get(CounterEnumType.LOYALTY), damageIn);
|
subtractCounter(CounterType.get(CounterEnumType.LOYALTY), damageIn);
|
||||||
}
|
}
|
||||||
if (isCreature()) {
|
if (isCreature()) {
|
||||||
boolean wither = (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
boolean wither = game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||||
|| source.hasKeyword(Keyword.WITHER) || source.hasKeyword(Keyword.INFECT));
|
|| source.hasKeyword(Keyword.WITHER) || source.hasKeyword(Keyword.INFECT);
|
||||||
|
|
||||||
if (wither) { // 120.3d
|
if (wither) { // 120.3d
|
||||||
addCounter(CounterType.get(CounterEnumType.M1M1), damageIn, source.getController(), null, true, counterTable);
|
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);
|
view.updateDamage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.hasKeyword(Keyword.DEATHTOUCH) && isCreature()) {
|
if (source.hasKeyword(Keyword.DEATHTOUCH)) {
|
||||||
setHasBeenDealtDeathtouchDamage(true);
|
setHasBeenDealtDeathtouchDamage(true);
|
||||||
damageType = DamageType.Deathtouch;
|
damageType = DamageType.Deathtouch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
private int numForetoldThisTurn = 0;
|
private int numForetoldThisTurn = 0;
|
||||||
private int numCardsInHandStartedThisTurnWith = 0;
|
private int numCardsInHandStartedThisTurnWith = 0;
|
||||||
|
|
||||||
|
private int simultaneousDamage = 0;
|
||||||
|
|
||||||
private int lastTurnNr = 0;
|
private int lastTurnNr = 0;
|
||||||
|
|
||||||
private final Map<String, FCollection<String>> notes = Maps.newHashMap();
|
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()) {
|
if (amount <= 0 || hasLost()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//String additionalLog = "";
|
|
||||||
|
|
||||||
boolean infect = source.hasKeyword(Keyword.INFECT)
|
boolean infect = source.hasKeyword(Keyword.INFECT)
|
||||||
|| hasKeyword("All damage is dealt to you as though its source had 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.")) {
|
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.
|
// 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
|
//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);
|
runParams.put(AbilityKey.IsCombatDamage, isCombat);
|
||||||
// Defending player at the time the damage was dealt
|
// Defending player at the time the damage was dealt
|
||||||
runParams.put(AbilityKey.DefendingPlayer, game.getCombat() != null ? game.getCombat().getDefendingPlayerRelatedTo(source) : null);
|
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));
|
game.fireEvent(new GameEventPlayerDamaged(this, source, amount, isCombat, infect));
|
||||||
|
|
||||||
@@ -811,6 +817,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return restDamage;
|
return restDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void dealCombatDamage() {
|
||||||
|
loseLife(simultaneousDamage, true, false);
|
||||||
|
simultaneousDamage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public final void clearAssignedDamage() {
|
public final void clearAssignedDamage() {
|
||||||
assignedDamage.clear();
|
assignedDamage.clear();
|
||||||
assignedCombatDamage.clear();
|
assignedCombatDamage.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user