mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
Turn under control reworked:
- game: fixed game freezes when computer try to take control over another computer or human (added game logs, related to #12878); - cheats: improved take and give control commands, now you can give control under yourself to another player; - cheats: improved take and give control commands, now you can return control to computer in the same priority; - cheats: deleted useless and unused command to activate opponent's ability;
This commit is contained in:
parent
a5c354f960
commit
1f1d1088a1
6 changed files with 50 additions and 73 deletions
|
|
@ -341,8 +341,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param game
|
||||
* @param playerUnderControlId
|
||||
* @param info additional info to show in game logs like source
|
||||
* @return false on failed taken control, e.g. on unsupported player type
|
||||
*/
|
||||
void controlPlayersTurn(Game game, UUID playerUnderControlId, String info);
|
||||
boolean controlPlayersTurn(Game game, UUID playerUnderControlId, String info);
|
||||
|
||||
/**
|
||||
* Sets player {@link UUID} who controls this player's turn.
|
||||
|
|
|
|||
|
|
@ -598,8 +598,17 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void controlPlayersTurn(Game game, UUID playerUnderControlId, String info) {
|
||||
public boolean controlPlayersTurn(Game game, UUID playerUnderControlId, String info) {
|
||||
Player playerUnderControl = game.getPlayer(playerUnderControlId);
|
||||
|
||||
// TODO: add support computer over computer
|
||||
// TODO: add support computer over human
|
||||
if (this.isComputer()) {
|
||||
// not supported yet
|
||||
game.informPlayers(getLogName() + " is AI and can't take control over " + playerUnderControl.getLogName() + info);
|
||||
return false;
|
||||
}
|
||||
|
||||
playerUnderControl.setTurnControlledBy(this.getId());
|
||||
game.informPlayers(getLogName() + " taken turn control of " + playerUnderControl.getLogName() + info);
|
||||
if (!playerUnderControlId.equals(this.getId())) {
|
||||
|
|
@ -609,6 +618,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
// control will reset on start of the turn
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -777,10 +788,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
// if this method was called from a replacement event, pass the number of cards back through
|
||||
// (uncomment conditions if correct ruling is to only count cards drawn by the same player)
|
||||
if (event instanceof DrawCardEvent /* && event.getPlayerId().equals(getId()) */ ) {
|
||||
if (event instanceof DrawCardEvent /* && event.getPlayerId().equals(getId()) */) {
|
||||
((DrawCardEvent) event).incrementCardsDrawn(numDrawn);
|
||||
}
|
||||
if (event instanceof DrawTwoOrMoreCardsEvent /* && event.getPlayerId().equals(getId()) */ ) {
|
||||
if (event instanceof DrawTwoOrMoreCardsEvent /* && event.getPlayerId().equals(getId()) */) {
|
||||
((DrawTwoOrMoreCardsEvent) event).incrementCardsDrawn(numDrawn);
|
||||
}
|
||||
return numDrawn;
|
||||
|
|
|
|||
|
|
@ -1358,7 +1358,11 @@ public final class CardUtil {
|
|||
*/
|
||||
public static void takeControlUnderPlayerStart(Game game, Ability source, Player controller, Player playerUnderControl, boolean givePauseForResponse) {
|
||||
// game logs added in child's call
|
||||
controller.controlPlayersTurn(game, playerUnderControl.getId(), CardUtil.getSourceLogName(game, source));
|
||||
if (!controller.controlPlayersTurn(game, playerUnderControl.getId(), CardUtil.getSourceLogName(game, source))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// give pause, so new controller can look around battlefield and hands before finish controlling choose dialog
|
||||
if (givePauseForResponse) {
|
||||
while (controller.canRespond()) {
|
||||
if (controller.chooseUse(Outcome.Benefit, "You got control of " + playerUnderControl.getLogName()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue