mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Merge branch 'master' of https://github.com/magefree/mage.git
This commit is contained in:
commit
e7458aec80
7 changed files with 28 additions and 11 deletions
|
|
@ -81,7 +81,10 @@ public class TableView implements Serializable {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
StringBuilder sbScore = new StringBuilder();
|
StringBuilder sbScore = new StringBuilder();
|
||||||
for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) {
|
for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) {
|
||||||
if (!matchPlayer.getPlayer().getName().equals(table.getControllerName())) {
|
if (matchPlayer.getPlayer() == null) {
|
||||||
|
sb.append(", ").append("[unknown]");
|
||||||
|
sbScore.append("-").append(matchPlayer.getWins());
|
||||||
|
} else if (!matchPlayer.getPlayer().getName().equals(table.getControllerName())) {
|
||||||
sb.append(", ").append(matchPlayer.getPlayer().getName());
|
sb.append(", ").append(matchPlayer.getPlayer().getName());
|
||||||
sbScore.append("-").append(matchPlayer.getWins());
|
sbScore.append("-").append(matchPlayer.getWins());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -701,7 +701,11 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("getAmount", game);
|
updateGameStatePriority("getAmount", game);
|
||||||
game.fireGetAmountEvent(playerId, message, min, max);
|
game.fireGetAmountEvent(playerId, message, min, max);
|
||||||
waitForIntegerResponse(game);
|
waitForIntegerResponse(game);
|
||||||
|
if (response != null) {
|
||||||
return response.getInteger();
|
return response.getInteger();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,13 @@ public class TableController {
|
||||||
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
|
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
if (user == null) {
|
||||||
|
logger.fatal(new StringBuilder("User for userId ").append(userId).append(" could not be retrieved from UserManager").toString());
|
||||||
|
controllerName = "[unknown]";
|
||||||
|
} else {
|
||||||
controllerName = user.getName();
|
controllerName = user.getName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
controllerName = "System";
|
controllerName = "System";
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +182,9 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||||
|
if (player == null) {
|
||||||
|
throw new GameException(new StringBuilder("Could not create player ").append(name).append(" of type ").append(seat.getPlayerType().toString()).toString());
|
||||||
|
}
|
||||||
match.addPlayer(player, deck);
|
match.addPlayer(player, deck);
|
||||||
table.joinTable(player, seat);
|
table.joinTable(player, seat);
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
|
@ -456,7 +464,7 @@ public class TableController {
|
||||||
public void endGame() {
|
public void endGame() {
|
||||||
// get player that chooses who goes first
|
// get player that chooses who goes first
|
||||||
UUID choosingPlayerId = match.getChooser();
|
UUID choosingPlayerId = match.getChooser();
|
||||||
|
logger.warn("endGame() " + match.getPlayers().toString());
|
||||||
match.endGame();
|
match.endGame();
|
||||||
table.endGame();
|
table.endGame();
|
||||||
// Saving of games caused memory leaks - so save is deactivated
|
// Saving of games caused memory leaks - so save is deactivated
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,12 @@ public class ReplayManager {
|
||||||
private ConcurrentHashMap<String, ReplaySession> replaySessions = new ConcurrentHashMap<String, ReplaySession>();
|
private ConcurrentHashMap<String, ReplaySession> replaySessions = new ConcurrentHashMap<String, ReplaySession>();
|
||||||
|
|
||||||
public void replayGame(UUID gameId, UUID userId) {
|
public void replayGame(UUID gameId, UUID userId) {
|
||||||
|
if (1 == 2) { // deactivated because replay causes memor leaks
|
||||||
ReplaySession replaySession = new ReplaySession(gameId, userId);
|
ReplaySession replaySession = new ReplaySession(gameId, userId);
|
||||||
replaySessions.put(gameId.toString() + userId.toString(), replaySession);
|
replaySessions.put(gameId.toString() + userId.toString(), replaySession);
|
||||||
UserManager.getInstance().getUser(userId).replayGame(gameId);
|
UserManager.getInstance().getUser(userId).replayGame(gameId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void startReplay(UUID gameId, UUID userId) {
|
public void startReplay(UUID gameId, UUID userId) {
|
||||||
replaySessions.get(gameId.toString() + userId.toString()).replay();
|
replaySessions.get(gameId.toString() + userId.toString()).replay();
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ class DeadbridgeChantEffect extends OneShotEffect<DeadbridgeChantEffect> {
|
||||||
if (player != null && !player.getGraveyard().isEmpty()) {
|
if (player != null && !player.getGraveyard().isEmpty()) {
|
||||||
Card card = player.getGraveyard().getRandom(game);
|
Card card = player.getGraveyard().getRandom(game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
Card sourceCard = game.getCard(source.getId());
|
|
||||||
Zone targetZone = Zone.HAND;
|
Zone targetZone = Zone.HAND;
|
||||||
String text = " put into hand of ";
|
String text = " put into hand of ";
|
||||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||||
|
|
@ -106,7 +105,7 @@ class DeadbridgeChantEffect extends OneShotEffect<DeadbridgeChantEffect> {
|
||||||
text = " put onto battlefield for ";
|
text = " put onto battlefield for ";
|
||||||
}
|
}
|
||||||
card.moveToZone(targetZone, source.getId(), game, false);
|
card.moveToZone(targetZone, source.getId(), game, false);
|
||||||
game.informPlayers(new StringBuilder(sourceCard.getName()).append(": ").append(card.getName()).append(text).append(player.getName()).toString());
|
game.informPlayers(new StringBuilder("Deadbridge Chant: ").append(card.getName()).append(text).append(player.getName()).toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ public class DevourEffect extends ReplacementEffectImpl<DevourEffect> {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
return (List<ArrayList<String>>) object;
|
return (List<ArrayList<String>>) object;
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<ArrayList<String>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDevouredCreaturesAmount(Game game, UUID permanentId) {
|
public int getDevouredCreaturesAmount(Game game, UUID permanentId) {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.TableState;
|
|
||||||
import mage.cards.decks.DeckValidator;
|
import mage.cards.decks.DeckValidator;
|
||||||
|
import mage.constants.TableState;
|
||||||
import mage.game.events.Listener;
|
import mage.game.events.Listener;
|
||||||
import mage.game.events.TableEvent;
|
import mage.game.events.TableEvent;
|
||||||
import mage.game.events.TableEventSource;
|
import mage.game.events.TableEventSource;
|
||||||
|
|
@ -56,6 +56,7 @@ public class Table implements Serializable {
|
||||||
private Seat[] seats;
|
private Seat[] seats;
|
||||||
private int numSeats;
|
private int numSeats;
|
||||||
private boolean isTournament;
|
private boolean isTournament;
|
||||||
|
private boolean isTournamentSubTable;
|
||||||
private DeckValidator validator;
|
private DeckValidator validator;
|
||||||
private TableState state = TableState.WAITING;
|
private TableState state = TableState.WAITING;
|
||||||
private Match match;
|
private Match match;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue