mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Karn Liberated - fixed that after using its -14 ability the game does not properly set the starting player of the new game (fixes #3786).
This commit is contained in:
parent
3a52ce609d
commit
a3e7aa6230
3 changed files with 51 additions and 35 deletions
|
@ -157,6 +157,7 @@ class KarnLiberatedEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
game.addDelayedTriggeredAbility(new KarnLiberatedDelayedTriggeredAbility(exileId), source);
|
||||
game.setStartingPlayerId(source.getControllerId());
|
||||
game.start(null);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -442,6 +442,8 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
UUID getStartingPlayerId();
|
||||
|
||||
void setStartingPlayerId(UUID startingPlayerId);
|
||||
|
||||
void saveRollBackGameState();
|
||||
|
||||
boolean canRollbackTurns(int turnsToRollback);
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
*/
|
||||
package mage.game;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.MageException;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
|
@ -92,11 +96,6 @@ import mage.watchers.Watchers;
|
|||
import mage.watchers.common.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public abstract class GameImpl implements Game, Serializable {
|
||||
|
||||
private static final int ROLLBACK_TURNS_MAX = 4;
|
||||
|
@ -855,31 +854,33 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
//20091005 - 103.2
|
||||
TargetPlayer targetPlayer = new TargetPlayer();
|
||||
targetPlayer.setTargetName("starting player");
|
||||
Player choosingPlayer = null;
|
||||
if (choosingPlayerId != null) {
|
||||
choosingPlayer = this.getPlayer(choosingPlayerId);
|
||||
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
|
||||
choosingPlayer = null;
|
||||
if (startingPlayerId == null) {
|
||||
TargetPlayer targetPlayer = new TargetPlayer();
|
||||
targetPlayer.setTargetName("starting player");
|
||||
if (choosingPlayerId != null) {
|
||||
choosingPlayer = this.getPlayer(choosingPlayerId);
|
||||
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
|
||||
choosingPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choosingPlayer == null) {
|
||||
choosingPlayerId = pickChoosingPlayer();
|
||||
if (choosingPlayerId == null) {
|
||||
if (choosingPlayer == null) {
|
||||
choosingPlayerId = pickChoosingPlayer();
|
||||
if (choosingPlayerId == null) {
|
||||
return;
|
||||
}
|
||||
choosingPlayer = getPlayer(choosingPlayerId);
|
||||
}
|
||||
if (choosingPlayer == null) {
|
||||
return;
|
||||
}
|
||||
getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active
|
||||
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
|
||||
startingPlayerId = targetPlayer.getTargets().get(0);
|
||||
} else if (getState().getPlayers().size() < 3) {
|
||||
// not possible to choose starting player, choosing player has probably conceded, so stop here
|
||||
return;
|
||||
}
|
||||
choosingPlayer = getPlayer(choosingPlayerId);
|
||||
}
|
||||
if (choosingPlayer == null) {
|
||||
return;
|
||||
}
|
||||
getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active
|
||||
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
|
||||
startingPlayerId = targetPlayer.getTargets().get(0);
|
||||
} else if (getState().getPlayers().size() < 3) {
|
||||
// not possible to choose starting player, choosing player has probably conceded, so stop here
|
||||
return;
|
||||
}
|
||||
if (startingPlayerId == null) {
|
||||
// choose any available player as starting player
|
||||
|
@ -898,15 +899,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
logger.debug("Starting player not found. playerId:" + startingPlayerId);
|
||||
return;
|
||||
}
|
||||
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
|
||||
if (choosingPlayer.getId().equals(startingPlayerId)) {
|
||||
message.append("he or she");
|
||||
} else {
|
||||
message.append(startingPlayer.getLogName());
|
||||
}
|
||||
message.append(" takes the first turn");
|
||||
|
||||
this.informPlayers(message.toString());
|
||||
sendStartMessage(choosingPlayer, startingPlayer);
|
||||
|
||||
//20091005 - 103.3
|
||||
int startingHandSize = 7;
|
||||
|
@ -1019,6 +1012,21 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
}
|
||||
|
||||
protected void sendStartMessage(Player choosingPlayer, Player startingPlayer) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (choosingPlayer != null) {
|
||||
message.append(choosingPlayer.getLogName()).append(" chooses that ");
|
||||
}
|
||||
if (choosingPlayer != null && choosingPlayer.getId().equals(startingPlayer.getId())) {
|
||||
message.append("he or she");
|
||||
} else {
|
||||
message.append(startingPlayer.getLogName());
|
||||
}
|
||||
message.append(" takes the first turn");
|
||||
|
||||
this.informPlayers(message.toString());
|
||||
}
|
||||
|
||||
protected UUID findWinnersAndLosers() {
|
||||
UUID winnerIdFound = null;
|
||||
for (Player player : state.getPlayers().values()) {
|
||||
|
@ -2834,6 +2842,11 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
return startingPlayerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartingPlayerId(UUID startingPlayerId) {
|
||||
this.startingPlayerId = startingPlayerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLife() {
|
||||
return startLife;
|
||||
|
|
Loading…
Reference in a new issue