forked from External/mage
Turn under control reworked:
- game: added support for human games (cards like Emrakul, the Promised End, #12878); - game: added support of 720.1. to reset control in the turn beginning instead cleanup step (related to #12115); - game: added game logs for priorities in cleanup step; - game: fixed game freezes and wrong skip settings usages (related to #12878); - gui: added playable and choose-able marks for controlling player's cards and permanents, including switched hands; - gui: added controlling player name in all choice dialogs; - info: control of computer players is it not yet supported;
This commit is contained in:
parent
75d241d541
commit
c076f4925f
17 changed files with 177 additions and 140 deletions
|
|
@ -107,12 +107,16 @@ public class Turn implements Serializable {
|
|||
));
|
||||
return true;
|
||||
}
|
||||
logStartOfTurn(game, activePlayer);
|
||||
|
||||
checkTurnIsControlledByOtherPlayer(game, activePlayer.getId());
|
||||
logStartOfTurn(game, activePlayer);
|
||||
resetCounts();
|
||||
|
||||
this.activePlayerId = activePlayer.getId();
|
||||
resetCounts();
|
||||
this.currentPhase = null;
|
||||
|
||||
// turn control must be called after potential turn skip due 720.1.
|
||||
checkTurnIsControlledByOtherPlayer(game, activePlayer.getId());
|
||||
|
||||
game.getPlayer(activePlayer.getId()).beginTurn(game);
|
||||
for (Phase phase : phases) {
|
||||
if (game.isPaused() || game.checkIfGameIsOver()) {
|
||||
|
|
@ -220,8 +224,31 @@ public class Turn implements Serializable {
|
|||
}
|
||||
|
||||
private void checkTurnIsControlledByOtherPlayer(Game game, UUID activePlayerId) {
|
||||
// 720.1.
|
||||
// Some cards allow a player to control another player during that player’s next turn.
|
||||
// This effect applies to the next turn that the affected player actually takes.
|
||||
// The affected player is controlled during the entire turn; the effect doesn’t end until
|
||||
// the beginning of the next turn.
|
||||
//
|
||||
// 720.1b
|
||||
// If a turn is skipped, any pending player-controlling effects wait until the player who would be
|
||||
// affected actually takes a turn.
|
||||
|
||||
// remove old under control
|
||||
game.getPlayers().values().forEach(player -> {
|
||||
if (player.isInGame() && !player.isGameUnderControl()) {
|
||||
Player controllingPlayer = game.getPlayer(player.getTurnControlledBy());
|
||||
if (player != controllingPlayer && controllingPlayer != null) {
|
||||
game.informPlayers(controllingPlayer.getLogName() + " lost control over " + player.getLogName());
|
||||
}
|
||||
player.setGameUnderYourControl(true);
|
||||
}
|
||||
});
|
||||
|
||||
// add new under control
|
||||
TurnMod newControllerMod = game.getState().getTurnMods().useNextNewController(activePlayerId);
|
||||
if (newControllerMod != null && !newControllerMod.getNewControllerId().equals(activePlayerId)) {
|
||||
// set player under new control
|
||||
// game logs added in child's call (controlPlayersTurn)
|
||||
game.getPlayer(newControllerMod.getNewControllerId()).controlPlayersTurn(game, activePlayerId, newControllerMod.getInfo());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue