mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08: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.addDelayedTriggeredAbility(new KarnLiberatedDelayedTriggeredAbility(exileId), source);
|
||||||
|
game.setStartingPlayerId(source.getControllerId());
|
||||||
game.start(null);
|
game.start(null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,8 @@ public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
UUID getStartingPlayerId();
|
UUID getStartingPlayerId();
|
||||||
|
|
||||||
|
void setStartingPlayerId(UUID startingPlayerId);
|
||||||
|
|
||||||
void saveRollBackGameState();
|
void saveRollBackGameState();
|
||||||
|
|
||||||
boolean canRollbackTurns(int turnsToRollback);
|
boolean canRollbackTurns(int turnsToRollback);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.*;
|
import mage.abilities.*;
|
||||||
|
|
@ -92,11 +96,6 @@ import mage.watchers.Watchers;
|
||||||
import mage.watchers.common.*;
|
import mage.watchers.common.*;
|
||||||
import org.apache.log4j.Logger;
|
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 {
|
public abstract class GameImpl implements Game, Serializable {
|
||||||
|
|
||||||
private static final int ROLLBACK_TURNS_MAX = 4;
|
private static final int ROLLBACK_TURNS_MAX = 4;
|
||||||
|
|
@ -855,31 +854,33 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
//20091005 - 103.2
|
//20091005 - 103.2
|
||||||
TargetPlayer targetPlayer = new TargetPlayer();
|
|
||||||
targetPlayer.setTargetName("starting player");
|
|
||||||
Player choosingPlayer = null;
|
Player choosingPlayer = null;
|
||||||
if (choosingPlayerId != null) {
|
if (startingPlayerId == null) {
|
||||||
choosingPlayer = this.getPlayer(choosingPlayerId);
|
TargetPlayer targetPlayer = new TargetPlayer();
|
||||||
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
|
targetPlayer.setTargetName("starting player");
|
||||||
choosingPlayer = null;
|
if (choosingPlayerId != null) {
|
||||||
|
choosingPlayer = this.getPlayer(choosingPlayerId);
|
||||||
|
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
|
||||||
|
choosingPlayer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (choosingPlayer == null) {
|
||||||
if (choosingPlayer == null) {
|
choosingPlayerId = pickChoosingPlayer();
|
||||||
choosingPlayerId = pickChoosingPlayer();
|
if (choosingPlayerId == null) {
|
||||||
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;
|
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) {
|
if (startingPlayerId == null) {
|
||||||
// choose any available player as starting player
|
// 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);
|
logger.debug("Starting player not found. playerId:" + startingPlayerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
|
sendStartMessage(choosingPlayer, startingPlayer);
|
||||||
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());
|
|
||||||
|
|
||||||
//20091005 - 103.3
|
//20091005 - 103.3
|
||||||
int startingHandSize = 7;
|
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() {
|
protected UUID findWinnersAndLosers() {
|
||||||
UUID winnerIdFound = null;
|
UUID winnerIdFound = null;
|
||||||
for (Player player : state.getPlayers().values()) {
|
for (Player player : state.getPlayers().values()) {
|
||||||
|
|
@ -2834,6 +2842,11 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
return startingPlayerId;
|
return startingPlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStartingPlayerId(UUID startingPlayerId) {
|
||||||
|
this.startingPlayerId = startingPlayerId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLife() {
|
public int getLife() {
|
||||||
return startLife;
|
return startLife;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue