mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
game.endTurn
This commit is contained in:
parent
9a791c0d5b
commit
a00701c756
9 changed files with 41 additions and 13 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -278,6 +278,9 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
case GRAVEYARD:
|
case GRAVEYARD:
|
||||||
game.getPlayer(ownerId).removeFromGraveyard(this, game);
|
game.getPlayer(ownerId).removeFromGraveyard(this, game);
|
||||||
break;
|
break;
|
||||||
|
case HAND:
|
||||||
|
game.getPlayer(ownerId).removeFromHand(this, game);
|
||||||
|
break;
|
||||||
case LIBRARY:
|
case LIBRARY:
|
||||||
game.getPlayer(ownerId).removeFromLibrary(this, game);
|
game.getPlayer(ownerId).removeFromLibrary(this, game);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -154,6 +154,7 @@ public interface Game extends MageItem, Serializable {
|
||||||
public void applyEffects();
|
public void applyEffects();
|
||||||
public boolean checkStateAndTriggered();
|
public boolean checkStateAndTriggered();
|
||||||
public void playPriority(UUID activePlayerId);
|
public void playPriority(UUID activePlayerId);
|
||||||
|
public boolean endTurn(UUID playerId);
|
||||||
|
|
||||||
//game transaction methods
|
//game transaction methods
|
||||||
public void saveState();
|
public void saveState();
|
||||||
|
|
|
@ -1172,6 +1172,15 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean endTurn(UUID playerId) {
|
||||||
|
if (!getActivePlayerId().equals(playerId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
getTurn().endTurn(this, getActivePlayerId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getStartTime() {
|
public Date getStartTime() {
|
||||||
return startTime;
|
return startTime;
|
||||||
|
|
|
@ -35,6 +35,7 @@ import java.util.UUID;
|
||||||
import mage.Constants.PhaseStep;
|
import mage.Constants.PhaseStep;
|
||||||
import mage.Constants.TurnPhase;
|
import mage.Constants.TurnPhase;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -124,6 +125,8 @@ public class Turn implements Serializable {
|
||||||
playExtraPhases(game, phase.getType());
|
playExtraPhases(game, phase.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!currentPhase.equals(phase)) // phase was changed from the card
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//20091005 - 500.7
|
//20091005 - 500.7
|
||||||
playExtraTurns(game);
|
playExtraTurns(game);
|
||||||
|
@ -173,6 +176,30 @@ public class Turn implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void endTurn(Game game, UUID activePlayerId) {
|
||||||
|
// Exile all spells and abilities on the stack
|
||||||
|
game.getStack().clear();
|
||||||
|
|
||||||
|
// Discard down to your maximum hand size.
|
||||||
|
Player activePlayer = game.getPlayer(activePlayerId);
|
||||||
|
game.getState().setPriorityPlayerId(activePlayer.getId());
|
||||||
|
//20091005 - 514.1
|
||||||
|
if (!activePlayer.hasLeft() && !activePlayer.hasLost()) {
|
||||||
|
activePlayer.discardToMax(game);
|
||||||
|
activePlayer.setGameUnderYourControl(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Damage wears off.
|
||||||
|
//20100423 - 514.2
|
||||||
|
game.getBattlefield().endOfTurn(activePlayerId, game);
|
||||||
|
game.getState().removeEotEffects(game);
|
||||||
|
|
||||||
|
Phase phase = new EndPhase();
|
||||||
|
phase.setStep(new CleanupStep());
|
||||||
|
currentPhase = phase;
|
||||||
|
//phase.play(game, activePlayerId);
|
||||||
|
}
|
||||||
|
|
||||||
public Turn copy() {
|
public Turn copy() {
|
||||||
return new Turn(this);
|
return new Turn(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,20 +440,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId))) {
|
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId))) {
|
||||||
int bookmark = game.bookmarkState();
|
int bookmark = game.bookmarkState();
|
||||||
card.cast(game, game.getZone(card.getId()), ability, playerId);
|
|
||||||
|
|
||||||
Zone zone = game.getZone(card.getId());
|
card.cast(game, game.getZone(card.getId()), ability, playerId);
|
||||||
switch (zone) {
|
|
||||||
case HAND:
|
|
||||||
removeFromHand(card, game);
|
|
||||||
break;
|
|
||||||
case LIBRARY:
|
|
||||||
removeFromLibrary(card, game);
|
|
||||||
break;
|
|
||||||
case GRAVEYARD:
|
|
||||||
removeFromGraveyard(card, game);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ability spellAbility = game.getStack().getSpell(ability.getId()).getSpellAbility();
|
Ability spellAbility = game.getStack().getSpell(ability.getId()).getSpellAbility();
|
||||||
if (spellAbility.activate(game, noMana)) {
|
if (spellAbility.activate(game, noMana)) {
|
||||||
|
|
Loading…
Reference in a new issue