cheats: added default commands to take and remove control over another player (related to #12878)

This commit is contained in:
Oleg Agafonov 2025-01-07 19:47:25 +04:00
parent c076f4925f
commit 5626c5f932
4 changed files with 46 additions and 4 deletions

View file

@ -248,7 +248,6 @@ public class Turn implements Serializable {
// 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());
}

View file

@ -62,6 +62,14 @@ public class TurnMods extends ArrayList<TurnMod> implements Serializable, Copyab
}
public TurnMod useNextNewController(UUID playerId) {
// 720.1a
// Multiple player-controlling effects that affect the same player overwrite each other.
// The last one to be created is the one that works.
//
// 720.1b
// If a turn is skipped, any pending player-controlling effects wait until the player
// who would be affected actually takes a turn.
TurnMod lastNewControllerMod = null;
// find last/actual mod

View file

@ -1380,7 +1380,7 @@ public final class CardUtil {
public static void takeControlUnderPlayerEnd(Game game, Ability source, Player controller, Player playerUnderControl) {
playerUnderControl.setGameUnderYourControl(true, false);
if (!playerUnderControl.getTurnControlledBy().equals(controller.getId())) {
game.informPlayers(controller + " return control of the turn to " + playerUnderControl.getLogName() + CardUtil.getSourceLogName(game, source));
game.informPlayers(controller.getLogName() + " return control of the turn to " + playerUnderControl.getLogName() + CardUtil.getSourceLogName(game, source));
controller.getPlayersUnderYourControl().remove(playerUnderControl.getId());
}
}