mirror of
https://github.com/correl/mage.git
synced 2025-04-03 09:18:59 -09:00
fixed issue 93
This commit is contained in:
parent
3351f402eb
commit
f2c44688d0
10 changed files with 117 additions and 26 deletions
Mage.Server.Plugins
Mage.Player.AI.MA/src/mage/player/ai
Mage.Player.AIMinimax/src/mage/player/ai
Mage.Server/plugins
Mage/src/mage/game/turn
|
@ -134,6 +134,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
|
|||
}
|
||||
break;
|
||||
case BEGIN_COMBAT:
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
case COMBAT_DAMAGE:
|
||||
case END_COMBAT:
|
||||
pass();
|
||||
|
@ -643,13 +644,13 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
|
|||
game.getPhase().setStep(new DeclareBlockersStep());
|
||||
break;
|
||||
case DECLARE_BLOCKERS:
|
||||
game.getPhase().setStep(new CombatDamageStep(true));
|
||||
game.getPhase().setStep(new FirstCombatDamageStep());
|
||||
break;
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
game.getPhase().setStep(new CombatDamageStep());
|
||||
break;
|
||||
case COMBAT_DAMAGE:
|
||||
if (((CombatDamageStep)currentPhase.getStep()).getFirst())
|
||||
game.getPhase().setStep(new CombatDamageStep(false));
|
||||
else
|
||||
game.getPhase().setStep(new EndOfCombatStep());
|
||||
game.getPhase().setStep(new EndOfCombatStep());
|
||||
break;
|
||||
case END_COMBAT:
|
||||
game.getTurn().setPhase(new PostCombatMainPhase());
|
||||
|
|
|
@ -119,6 +119,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player {
|
|||
pass();
|
||||
break;
|
||||
case DECLARE_BLOCKERS:
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
case COMBAT_DAMAGE:
|
||||
case END_COMBAT:
|
||||
pass();
|
||||
|
@ -502,8 +503,8 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player {
|
|||
logger.debug("interrupted");
|
||||
return;
|
||||
}
|
||||
simulateStep(game, new CombatDamageStep(true));
|
||||
simulateStep(game, new CombatDamageStep(false));
|
||||
simulateStep(game, new FirstCombatDamageStep());
|
||||
simulateStep(game, new CombatDamageStep());
|
||||
simulateStep(game, new EndOfCombatStep());
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ import mage.game.turn.DrawStep;
|
|||
import mage.game.turn.EndOfCombatStep;
|
||||
import mage.game.turn.EndPhase;
|
||||
import mage.game.turn.EndStep;
|
||||
import mage.game.turn.FirstCombatDamageStep;
|
||||
import mage.game.turn.Phase;
|
||||
import mage.game.turn.PostCombatMainPhase;
|
||||
import mage.game.turn.PostCombatMainStep;
|
||||
|
@ -148,6 +149,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
|
|||
case BEGIN_COMBAT:
|
||||
case DECLARE_ATTACKERS:
|
||||
case DECLARE_BLOCKERS:
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
case COMBAT_DAMAGE:
|
||||
case END_COMBAT:
|
||||
case POSTCOMBAT_MAIN:
|
||||
|
@ -599,13 +601,13 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
|
|||
game.getPhase().setStep(new DeclareBlockersStep());
|
||||
break;
|
||||
case DECLARE_BLOCKERS:
|
||||
game.getPhase().setStep(new CombatDamageStep(true));
|
||||
game.getPhase().setStep(new FirstCombatDamageStep());
|
||||
break;
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
game.getPhase().setStep(new CombatDamageStep());
|
||||
break;
|
||||
case COMBAT_DAMAGE:
|
||||
if (((CombatDamageStep)currentPhase.getStep()).getFirst())
|
||||
game.getPhase().setStep(new CombatDamageStep(false));
|
||||
else
|
||||
game.getPhase().setStep(new EndOfCombatStep());
|
||||
game.getPhase().setStep(new EndOfCombatStep());
|
||||
break;
|
||||
case END_COMBAT:
|
||||
game.getTurn().setPhase(new PostCombatMainPhase());
|
||||
|
|
|
@ -52,6 +52,7 @@ import mage.game.turn.DrawStep;
|
|||
import mage.game.turn.EndOfCombatStep;
|
||||
import mage.game.turn.EndPhase;
|
||||
import mage.game.turn.EndStep;
|
||||
import mage.game.turn.FirstCombatDamageStep;
|
||||
import mage.game.turn.PostCombatMainPhase;
|
||||
import mage.game.turn.PostCombatMainStep;
|
||||
import mage.game.turn.Step;
|
||||
|
@ -129,6 +130,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
|||
pass();
|
||||
break;
|
||||
case DECLARE_BLOCKERS:
|
||||
case FIRST_COMBAT_DAMAGE:
|
||||
case COMBAT_DAMAGE:
|
||||
case END_COMBAT:
|
||||
pass();
|
||||
|
@ -516,8 +518,8 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
|||
logger.debug("interrupted");
|
||||
return;
|
||||
}
|
||||
simulateStep(game, new CombatDamageStep(true));
|
||||
simulateStep(game, new CombatDamageStep(false));
|
||||
simulateStep(game, new FirstCombatDamageStep());
|
||||
simulateStep(game, new CombatDamageStep());
|
||||
simulateStep(game, new EndOfCombatStep());
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -40,11 +40,8 @@ import mage.game.events.GameEvent.EventType;
|
|||
*/
|
||||
public class CombatDamageStep extends Step<CombatDamageStep> {
|
||||
|
||||
private boolean first;
|
||||
|
||||
public CombatDamageStep(boolean first) {
|
||||
public CombatDamageStep() {
|
||||
super(PhaseStep.COMBAT_DAMAGE, true);
|
||||
this.first = first;
|
||||
this.stepEvent = EventType.COMBAT_DAMAGE_STEP;
|
||||
this.preStepEvent = EventType.COMBAT_DAMAGE_STEP_PRE;
|
||||
this.postStepEvent = EventType.COMBAT_DAMAGE_STEP_POST;
|
||||
|
@ -52,15 +49,12 @@ public class CombatDamageStep extends Step<CombatDamageStep> {
|
|||
|
||||
public CombatDamageStep(final CombatDamageStep step) {
|
||||
super(step);
|
||||
this.first = step.first;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skipStep(Game game, UUID activePlayerId) {
|
||||
if (game.getCombat().noAttackers())
|
||||
return true;
|
||||
if (first && !game.getCombat().hasFirstOrDoubleStrike(game))
|
||||
return true;
|
||||
return super.skipStep(game, activePlayerId);
|
||||
}
|
||||
|
||||
|
@ -68,10 +62,10 @@ public class CombatDamageStep extends Step<CombatDamageStep> {
|
|||
public void beginStep(Game game, UUID activePlayerId) {
|
||||
super.beginStep(game, activePlayerId);
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
group.assignDamageToBlockers(first, game);
|
||||
group.assignDamageToBlockers(false, game);
|
||||
}
|
||||
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
|
||||
group.assignDamageToAttackers(first, game);
|
||||
group.assignDamageToAttackers(false, game);
|
||||
}
|
||||
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
|
@ -84,7 +78,7 @@ public class CombatDamageStep extends Step<CombatDamageStep> {
|
|||
}
|
||||
|
||||
public boolean getFirst() {
|
||||
return first;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,8 +45,8 @@ public class CombatPhase extends Phase<CombatPhase> {
|
|||
this.steps.add(new BeginCombatStep());
|
||||
this.steps.add(new DeclareAttackersStep());
|
||||
this.steps.add(new DeclareBlockersStep());
|
||||
this.steps.add(new CombatDamageStep(true));
|
||||
this.steps.add(new CombatDamageStep(false));
|
||||
this.steps.add(new FirstCombatDamageStep());
|
||||
this.steps.add(new CombatDamageStep());
|
||||
this.steps.add(new EndOfCombatStep());
|
||||
}
|
||||
|
||||
|
|
91
Mage/src/mage/game/turn/FirstCombatDamageStep.java
Normal file
91
Mage/src/mage/game/turn/FirstCombatDamageStep.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game.turn;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class FirstCombatDamageStep extends Step<FirstCombatDamageStep> {
|
||||
|
||||
public FirstCombatDamageStep() {
|
||||
super(PhaseStep.FIRST_COMBAT_DAMAGE, true);
|
||||
this.stepEvent = EventType.COMBAT_DAMAGE_STEP;
|
||||
this.preStepEvent = EventType.COMBAT_DAMAGE_STEP_PRE;
|
||||
this.postStepEvent = EventType.COMBAT_DAMAGE_STEP_POST;
|
||||
}
|
||||
|
||||
public FirstCombatDamageStep(final FirstCombatDamageStep step) {
|
||||
super(step);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skipStep(Game game, UUID activePlayerId) {
|
||||
if (game.getCombat().noAttackers())
|
||||
return true;
|
||||
if (!game.getCombat().hasFirstOrDoubleStrike(game))
|
||||
return true;
|
||||
return super.skipStep(game, activePlayerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginStep(Game game, UUID activePlayerId) {
|
||||
super.beginStep(game, activePlayerId);
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
group.assignDamageToBlockers(true, game);
|
||||
}
|
||||
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
|
||||
group.assignDamageToAttackers(true, game);
|
||||
}
|
||||
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
group.applyDamage(game);
|
||||
}
|
||||
|
||||
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
|
||||
group.applyDamage(game);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFirst() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirstCombatDamageStep copy() {
|
||||
return new FirstCombatDamageStep(this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue