CardDamageHistory & Combat: add logic so it does register CombatDamage dealt between creatures

Card: add dealtCombatDamageThisTurn <valid> for better checking if Card dealt combat damage to something this turn
This commit is contained in:
Hanmac
2016-08-10 14:11:43 +00:00
parent e9588c1c0e
commit a0678fc944
3 changed files with 22 additions and 1 deletions

View File

@@ -4717,6 +4717,19 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!hasDealtDamageToOpponentThisTurn()) {
return false;
}
} else if (property.startsWith("dealtCombatDamageThisTurn ")) {
final String v = property.split(" ")[1];
final List<GameEntity> list = getDamageHistory().getThisTurnCombatDamaged();
boolean found = false;
for (final GameEntity e : list) {
if (e.isValid(v, sourceController, source, spellAbility)) {
found = true;
break;
}
}
if (!found) {
return false;
}
} else if (property.startsWith("controllerWasDealtCombatDamageByThisTurn")) {
if (!source.getDamageHistory().getThisTurnCombatDamaged().contains(controller)) {
return false;

View File

@@ -4,7 +4,6 @@ package forge.game.card;
import forge.game.GameEntity;
import forge.game.player.Player;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
@@ -316,9 +315,15 @@ public class CardDamageHistory {
* TODO: Write javadoc for this method.
*/
public void newTurn() {
damagedThisCombat.clear();
damagedThisTurnInCombat.clear();
damagedThisTurn.clear();
}
public void endCombat() {
damagedThisCombat.clear();
}
/**
* TODO: Write javadoc for this method.
* @param player

View File

@@ -101,9 +101,11 @@ public class Combat {
//update view for all attackers and blockers
for (Card c : attackers) {
c.getDamageHistory().endCombat();
c.updateAttackingForView();
}
for (Card c : blockers) {
c.getDamageHistory().endCombat();
c.updateBlockingForView();
}
}
@@ -736,6 +738,7 @@ public class Combat {
for (final Entry<Card, Integer> entry : assignedDamageMap.entrySet()) {
final Card crd = entry.getKey();
c.getDamageHistory().registerCombatDamage(crd);
damageMap.put(crd, entry.getValue());
if (entry.getValue() > 0) {
if (damageDealtThisCombat.containsKey(crd)) {