2013-04-12 19:32:25 -07:00
|
|
|
package magic.model.phase;
|
|
|
|
|
|
|
|
import magic.model.MagicGame;
|
|
|
|
import magic.model.MagicPlayer;
|
2015-04-14 03:39:30 -07:00
|
|
|
import magic.model.action.DrawAction;
|
2013-04-12 19:32:25 -07:00
|
|
|
import magic.model.event.MagicExcludeEvent;
|
2013-06-07 17:59:09 -07:00
|
|
|
import magic.model.trigger.MagicTriggerType;
|
2013-04-12 19:32:25 -07:00
|
|
|
|
|
|
|
public class MagicDrawPhase extends MagicPhase {
|
|
|
|
|
|
|
|
private static final MagicPhase INSTANCE=new MagicDrawPhase();
|
|
|
|
|
|
|
|
public MagicDrawPhase() {
|
|
|
|
super(MagicPhaseType.Draw);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public static MagicPhase getInstance() {
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void executeBeginStep(final MagicGame game) {
|
|
|
|
//skip draw phase for first turn
|
|
|
|
if (game.getTurn() == 1) {
|
|
|
|
game.setStep(MagicStep.NextPhase);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final MagicPlayer player=game.getTurnPlayer();
|
2015-04-14 03:39:30 -07:00
|
|
|
game.doAction(new DrawAction(player));
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-06-07 17:59:09 -07:00
|
|
|
game.executeTrigger(MagicTriggerType.AtDraw,game.getTurnPlayer());
|
2013-06-23 18:33:35 -07:00
|
|
|
|
|
|
|
game.setStep(game.canSkip() ?
|
|
|
|
MagicStep.NextPhase :
|
2013-06-07 17:59:09 -07:00
|
|
|
MagicStep.ActivePlayer
|
|
|
|
);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
|
|
|
// Determines what the purpose is for permanents that can attack,
|
|
|
|
// block or produce mana. Do this after draw, could be a land card.
|
2015-04-05 01:34:40 -07:00
|
|
|
if (player.isArtificial()) {
|
2013-04-12 19:32:25 -07:00
|
|
|
game.addEvent(new MagicExcludeEvent(player));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|