Fix getLethalDamage

This commit is contained in:
tool4EvEr
2022-01-06 15:43:44 +01:00
parent 76232624bc
commit c09301bcea
3 changed files with 11 additions and 7 deletions

View File

@@ -5199,6 +5199,12 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
// this is the minimal damage a trampling creature has to assign to a blocker // this is the minimal damage a trampling creature has to assign to a blocker
public final int getLethalDamage() { public final int getLethalDamage() {
// CR 702.2c
for (Card c : getAssignedDamageMap().keySet()) {
if (c.hasKeyword(Keyword.DEATHTOUCH)) {
return 0;
}
}
return getLethal() - getDamage() - getTotalAssignedDamage(); return getLethal() - getDamage() - getTotalAssignedDamage();
} }
@@ -5224,8 +5230,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
public final void addAssignedDamage(int assignedDamage0, final Card sourceCard) { public final void addAssignedDamage(int assignedDamage0, final Card sourceCard) {
if (assignedDamage0 < 0) { // 510.1a Creatures that would assign 0 or less damage dont assign combat damage at all.
assignedDamage0 = 0; if (assignedDamage0 <= 0) {
return;
} }
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)) {

View File

@@ -1056,7 +1056,6 @@ public final class CMatchUI
return result.get(); return result.get();
} }
@Override @Override
public void openView(final TrackableCollection<PlayerView> myPlayers) { public void openView(final TrackableCollection<PlayerView> myPlayers) {
final GameView gameView = getGameView(); final GameView gameView = getGameView();

View File

@@ -283,7 +283,7 @@ public class VAssignCombatDamage {
* @param isLMB * @param isLMB
*/ */
private void assignDamageTo(CardView source, final boolean meta, final boolean isAdding) { private void assignDamageTo(CardView source, final boolean meta, final boolean isAdding) {
if ( !damage.containsKey(source) ) if (!damage.containsKey(source))
source = null; source = null;
// If trying to assign to the defender, follow the normal assignment rules // If trying to assign to the defender, follow the normal assignment rules
@@ -391,7 +391,6 @@ public class VAssignCombatDamage {
dt.damage = Math.max(0, addedDamage + dt.damage); dt.damage = Math.max(0, addedDamage + dt.damage);
} }
/** /**
* TODO: Write javadoc for this method. * TODO: Write javadoc for this method.
* @return * @return
@@ -410,8 +409,7 @@ public class VAssignCombatDamage {
int damageLeft = totalDamageToAssign; int damageLeft = totalDamageToAssign;
boolean allHaveLethal = true; boolean allHaveLethal = true;
for (DamageTarget dt : defenders) for (DamageTarget dt : defenders) {
{
int dmg = dt.damage; int dmg = dt.damage;
damageLeft -= dmg; damageLeft -= dmg;
int lethal = getDamageToKill(dt.card); int lethal = getDamageToKill(dt.card);