From 63df0a55c1502fda7ebf93c7be889a26df08cf3f Mon Sep 17 00:00:00 2001 From: melvin Date: Wed, 29 Jun 2011 11:20:01 +0800 Subject: [PATCH] improved readability --- .../MagicDeclareBlockersResultBuilder.java | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/magic/model/choice/MagicDeclareBlockersResultBuilder.java b/src/magic/model/choice/MagicDeclareBlockersResultBuilder.java index 3d9026f5d3..47db12d8ff 100644 --- a/src/magic/model/choice/MagicDeclareBlockersResultBuilder.java +++ b/src/magic/model/choice/MagicDeclareBlockersResultBuilder.java @@ -16,7 +16,8 @@ import magic.model.score.MagicSingleScoreRanking; public class MagicDeclareBlockersResultBuilder { - private static final Collection EMPTY_RESULT=Collections.singletonList(new MagicDeclareBlockersResult(0,0)); + private static final Collection EMPTY_RESULT = + Collections.singletonList(new MagicDeclareBlockersResult(0,0)); private static final int MAX_RESULTS=12; private static final int MAX_ATTACKERS=3; private static final int MAX_TURN=1; @@ -33,7 +34,6 @@ public class MagicDeclareBlockersResultBuilder { private int position; public MagicDeclareBlockersResultBuilder(final MagicGame game,final MagicPlayer defendingPlayer,final boolean fast) { - this.game=game; this.defendingPlayer=defendingPlayer; this.attackingPlayer=game.getOpponent(defendingPlayer); @@ -56,7 +56,6 @@ public class MagicDeclareBlockersResultBuilder { final MagicCombatCreature candidateBlockers[]=new MagicCombatCreature[attacker.candidateBlockers.length]; int blockersSize=0; for (MagicCombatCreature blocker : attacker.candidateBlockers) { - if (blockers.contains(blocker)) { candidateBlockers[blockersSize++]=blocker; } @@ -66,13 +65,13 @@ public class MagicDeclareBlockersResultBuilder { result.addLast(new MagicCombatCreature[]{attacker}); buildAttacker(index+1); result.removeLast(); - if (blockersSize==0) { + if (blockersSize == 0) { return; } // One blocker. - if (blockersSize==1) { - final MagicCombatCreature blocker=candidateBlockers[0]; + if (blockersSize == 1) { + final MagicCombatCreature blocker = candidateBlockers[0]; blockers.remove(blocker); result.addLast(new MagicCombatCreature[]{attacker,blocker}); buildAttacker(index+1); @@ -82,11 +81,10 @@ public class MagicDeclareBlockersResultBuilder { } // Single blocker which does not deal lethal damage to the attacker. - int lethalDamage=attacker.lethalDamage; - for (int blockerIndex=0;blockerIndex=0) { - + while (blockerIndex >= 0) { switch (blockerSteps[blockerIndex]++) { case 0: - blocker=candidateBlockers[blockerIndex]; + blocker = candidateBlockers[blockerIndex]; blockers.remove(blocker); - lethalDamage-=blocker.power; - creatures[size++]=blocker; + lethalDamage -= blocker.power; + creatures[size++] = blocker; // Lethal blocking combination. - if (lethalDamage<=0) { + if (lethalDamage <= 0) { result.addLast(Arrays.copyOf(creatures,size)); buildAttacker(index+1); result.removeLast(); - } else if (blockerIndex