- Unblocked attackers are now set during the declare blockers step

- First strike combat damage should now be skipped if the step isn't needed.
This commit is contained in:
jendave
2011-08-06 19:01:32 +00:00
parent 9c1df7ff5a
commit 4e603492c6
3 changed files with 41 additions and 18 deletions

View File

@@ -222,7 +222,8 @@ public class Combat {
}
public void setDefendingFirstStrikeDamage() {
public boolean setDefendingFirstStrikeDamage() {
boolean needsFirstStrike = false;
defendingDamageMap.clear();
CardList att = new CardList(getAttackers());
// sum unblocked attackers' power
@@ -235,10 +236,13 @@ public class Combat {
// if the creature has first strike or double strike do damage in the first strike combat phase
if (att.get(i).hasFirstStrike() || att.get(i).hasDoubleStrike()) {
addDefendingDamage(damageDealt, att.get(i));
needsFirstStrike = true;
}
}
}
} // for
return needsFirstStrike;
}
@@ -412,16 +416,28 @@ public class Combat {
removeFromCombat(all.get(i));
}// verifyCreaturesInPlay()
public void setUnblocked(){
CardList attacking = new CardList(getAttackers());
for (Card attacker : attacking) {
CardList block = getBlockers(attacker);
if (block.size() == 0){
// this damage is assigned to a player by setPlayerDamage()
addUnblockedAttacker(attacker);
}
}
}
// set Card.setAssignedDamage() for all creatures in combat
// also assigns player damage by setPlayerDamage()
public void setAssignedFirstStrikeDamage() {
public boolean setAssignedFirstStrikeDamage() {
setDefendingFirstStrikeDamage();
boolean needFirstStrike = setDefendingFirstStrikeDamage();
CardList block;
CardList attacking = new CardList(getAttackers());
for (int i = 0; i < attacking.size(); i++) {
Card attacker = attacking.get(i);
@@ -433,28 +449,29 @@ public class Combat {
for (Card b : block) {
if (b.hasFirstStrike() || b.hasDoubleStrike()) {
needFirstStrike = true;
int attack = b.getNetCombatDamage();
attacker.addAssignedDamage(attack, b);
}
}
if (block.size() == 0){
// this damage is assigned to a player by setPlayerDamage()
addUnblockedAttacker(attacker);
// this damage is assigned to a player by setDefendingFirstStrikeDamage()
}
else if (attacker.hasFirstStrike() || attacker.hasDoubleStrike()) {
needFirstStrike = true;
if (getAttackingPlayer().isHuman()) {// human attacks
if (attacker.getKeyword().contains("Trample") || block.size() > 1)
AllZone.Display.assignDamage(attacker, block, damageDealt);
else block.get(0).addAssignedDamage(damageDealt, attacking.get(i));
}
else {// computer attacks
distributeAIDamage(attacker, block, damageDealt);
distributeAIDamage(attacker, block, damageDealt);
}
}// if(hasFirstStrike || doubleStrike)
}// for
return needFirstStrike;
}// setAssignedFirstStrikeDamage()
/*
@@ -506,8 +523,7 @@ public class Combat {
}
if (block.size() == 0){
// this damage is assigned to a player by setPlayerDamage()
addUnblockedAttacker(attacker);
// this damage is assigned to a player by setDefendingDamage()
}
else if (!attacker.hasFirstStrike() || attacker.hasDoubleStrike()) {

View File

@@ -239,13 +239,17 @@ public class Phase extends MyObservable
else{
AllZone.Combat.verifyCreaturesInPlay();
AllZone.Combat.setAssignedFirstStrikeDamage();
// no first strikers, skip this step
if (!AllZone.Combat.setAssignedFirstStrikeDamage())
AllZone.Phase.setNeedToNextPhase(true);
if (!AllZone.GameInfo.isPreventCombatDamageThisTurn())
Combat.dealAssignedDamage();
AllZone.GameAction.checkStateEffects();
CombatUtil.showCombat();
else{
if (!AllZone.GameInfo.isPreventCombatDamageThisTurn())
Combat.dealAssignedDamage();
AllZone.GameAction.checkStateEffects();
CombatUtil.showCombat();
}
}
}

View File

@@ -417,6 +417,9 @@ public class PhaseUtil {
verifyCombat();
AllZone.Stack.freezeStack();
AllZone.Combat.setUnblocked();
CardList list = new CardList();
list.addAll(AllZone.Combat.getAllBlockers().toArray());