mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
* Some changes to user handling / logging.
This commit is contained in:
parent
8ebc5656a3
commit
070e8609f4
5 changed files with 15 additions and 15 deletions
|
@ -420,7 +420,7 @@ public class TableController {
|
|||
if (table.isTournament()) {
|
||||
logger.debug("Quit tournament sub tables for userId: " + userId);
|
||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||
logger.debug("Quit tournament Id: " + table.getTournament().getId());
|
||||
logger.debug("Quit tournament Id: " + table.getTournament().getId() + "(" +table.getTournament().getTournamentState() + ")");
|
||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||
} else {
|
||||
MatchPlayer matchPlayer = match.getPlayer(playerId);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class User {
|
|||
private static final Logger logger = Logger.getLogger(User.class);
|
||||
|
||||
public enum UserState {
|
||||
Created, Connected, Disconnected, Reconnected;
|
||||
Created, Connected, Disconnected, Reconnected, Expired;
|
||||
}
|
||||
|
||||
private final UUID userId;
|
||||
|
@ -252,6 +252,7 @@ public class User {
|
|||
public boolean isExpired(Date expired) {
|
||||
if (lastActivity.before(expired)) {
|
||||
logger.debug(userName + " is expired!");
|
||||
userState = UserState.Expired;
|
||||
return true;
|
||||
}
|
||||
logger.trace(new StringBuilder("isExpired: User ").append(userName).append(" lastActivity: ").append(lastActivity).append(" expired: ").append(expired).toString());
|
||||
|
|
|
@ -173,12 +173,12 @@ public class UserManager {
|
|||
* Is the connection lost for more than 3 minutes, the user will be removed (within 3 minutes the user can reconnect)
|
||||
*/
|
||||
private void checkExpired() {
|
||||
Calendar expired = Calendar.getInstance();
|
||||
expired.add(Calendar.MINUTE, -3);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MINUTE, -3);
|
||||
List<User> usersToCheck = new ArrayList<>();
|
||||
usersToCheck.addAll(users.values());
|
||||
for (User user : usersToCheck) {
|
||||
if (user.isExpired(expired.getTime())) {
|
||||
if (user.isExpired(calendar.getTime())) {
|
||||
logger.info(new StringBuilder(user.getName()).append(": session expired userId: ").append(user.getId())
|
||||
.append(" Host: ").append(user.getHost()));
|
||||
removeUser(user.getId(), DisconnectReason.SessionExpired);
|
||||
|
|
|
@ -320,7 +320,6 @@ public class TournamentController {
|
|||
if (tPlayer != null) {
|
||||
if (started) {
|
||||
if (tPlayer.isInTournament()) {
|
||||
ChatManager.getInstance().broadcast(chatId, "", tPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
||||
String info;
|
||||
if (tournament.isDoneConstructing()) {
|
||||
info = new StringBuilder("during round ").append(tournament.getRounds().size()).toString();
|
||||
|
@ -351,6 +350,7 @@ public class TournamentController {
|
|||
if (tournamentSessions.containsKey(playerId)) {
|
||||
tournamentSessions.get(tPlayer.getPlayer().getId()).quit();
|
||||
}
|
||||
ChatManager.getInstance().broadcast(chatId, "", tPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
||||
}
|
||||
} else {
|
||||
tournament.leave(playerId);
|
||||
|
|
|
@ -70,23 +70,22 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = false;
|
||||
for (UUID targetId: getTargetPointer().getTargets(game, source)) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), tapped)){
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), tapped)) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.changeControllerId(source.getControllerId(), game);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue