mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Fixed that if in a multiplayer game the player that selects the starting player concedes before he selects a starting player, a starting player is slected by the game. The game starts now correctly with all remaining players.
This commit is contained in:
parent
e36a2819f5
commit
afc6a5aadc
2 changed files with 51 additions and 17 deletions
|
@ -108,12 +108,12 @@ public class LookLibraryControllerEffect extends OneShotEffect {
|
||||||
if (source instanceof SpellAbility) {
|
if (source instanceof SpellAbility) {
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
if (sourceCard != null) {
|
if (sourceCard != null) {
|
||||||
windowName = sourceCard.getName();
|
windowName = sourceCard.getIdName();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
if (sourcePermanent != null) {
|
if (sourcePermanent != null) {
|
||||||
windowName = sourcePermanent.getName();
|
windowName = sourcePermanent.getIdName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -851,28 +851,53 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
Player choosingPlayer = null;
|
Player choosingPlayer = null;
|
||||||
if (choosingPlayerId != null) {
|
if (choosingPlayerId != null) {
|
||||||
choosingPlayer = this.getPlayer(choosingPlayerId);
|
choosingPlayer = this.getPlayer(choosingPlayerId);
|
||||||
|
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
|
||||||
|
choosingPlayer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (choosingPlayer == null) {
|
if (choosingPlayer == null) {
|
||||||
choosingPlayerId = pickChoosingPlayer();
|
choosingPlayerId = pickChoosingPlayer();
|
||||||
|
if (choosingPlayerId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
choosingPlayer = getPlayer(choosingPlayerId);
|
choosingPlayer = getPlayer(choosingPlayerId);
|
||||||
}
|
}
|
||||||
|
if (choosingPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active
|
getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active
|
||||||
if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
|
if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
|
||||||
startingPlayerId = targetPlayer.getTargets().get(0);
|
startingPlayerId = targetPlayer.getTargets().get(0);
|
||||||
Player startingPlayer = state.getPlayer(startingPlayerId);
|
} else if (getState().getPlayers().size() < 3) {
|
||||||
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
|
// not possible to choose starting player, choosing player has probably conceded, so stop here
|
||||||
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());
|
|
||||||
} else {
|
|
||||||
// not possible to choose starting player, stop here
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (startingPlayerId == null) {
|
||||||
|
// choose any available player as starting player
|
||||||
|
for (Player player : state.getPlayers().values()) {
|
||||||
|
if (player.isInGame()) {
|
||||||
|
startingPlayerId = player.getId();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startingPlayerId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Player startingPlayer = state.getPlayer(startingPlayerId);
|
||||||
|
if (startingPlayer == null) {
|
||||||
|
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());
|
||||||
|
|
||||||
//20091005 - 103.3
|
//20091005 - 103.3
|
||||||
int startingHandSize = 7;
|
int startingHandSize = 7;
|
||||||
|
@ -980,6 +1005,7 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UUID findWinnersAndLosers() {
|
protected UUID findWinnersAndLosers() {
|
||||||
|
@ -1014,9 +1040,17 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
|
|
||||||
protected UUID pickChoosingPlayer() {
|
protected UUID pickChoosingPlayer() {
|
||||||
UUID[] players = getPlayers().keySet().toArray(new UUID[0]);
|
UUID[] players = getPlayers().keySet().toArray(new UUID[0]);
|
||||||
UUID playerId = players[rnd.nextInt(players.length)];
|
UUID playerId;
|
||||||
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
|
while (!hasEnded()) {
|
||||||
return playerId;
|
playerId = players[rnd.nextInt(players.length)];
|
||||||
|
Player player = getPlayer(playerId);
|
||||||
|
if (player != null && player.isInGame()) {
|
||||||
|
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
|
||||||
|
return player.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.debug("Game was not possible to pick a choosing player. GameId:" + getId());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue