mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Fixed some possible java exception causes.
This commit is contained in:
parent
b668209f7d
commit
c774e95335
5 changed files with 173 additions and 167 deletions
|
@ -43,6 +43,7 @@ import mage.game.Table;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
|
import mage.players.net.UserGroup;
|
||||||
import mage.server.draft.DraftSession;
|
import mage.server.draft.DraftSession;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
import mage.server.game.GameSessionPlayer;
|
import mage.server.game.GameSessionPlayer;
|
||||||
|
@ -53,7 +54,6 @@ import mage.server.util.SystemUtil;
|
||||||
import mage.view.TableClientMessage;
|
import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -63,6 +63,7 @@ public class User {
|
||||||
private static final Logger logger = Logger.getLogger(User.class);
|
private static final Logger logger = Logger.getLogger(User.class);
|
||||||
|
|
||||||
public enum UserState {
|
public enum UserState {
|
||||||
|
|
||||||
Created, Connected, Disconnected, Reconnected, Expired;
|
Created, Connected, Disconnected, Reconnected, Expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +104,8 @@ public class User {
|
||||||
this.watchedGames = new ArrayList<>();
|
this.watchedGames = new ArrayList<>();
|
||||||
this.tablesToDelete = new ArrayList<>();
|
this.tablesToDelete = new ArrayList<>();
|
||||||
this.sessionId = "";
|
this.sessionId = "";
|
||||||
|
// default these to avaiod NPE -> will be updated from client short after
|
||||||
|
this.userData = new UserData(UserGroup.PLAYER, 0, false, false, false, null, "world.png", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -276,6 +279,7 @@ public class User {
|
||||||
}
|
}
|
||||||
logger.trace(new StringBuilder("isExpired: User ").append(userName).append(" lastActivity: ").append(lastActivity).append(" expired: ").append(expired).toString());
|
logger.trace(new StringBuilder("isExpired: User ").append(userName).append(" lastActivity: ").append(lastActivity).append(" expired: ").append(expired).toString());
|
||||||
return false; /*userState == UserState.Disconnected && */
|
return false; /*userState == UserState.Disconnected && */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reconnect() {
|
private void reconnect() {
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -100,8 +99,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
for (Table table : allTables) {
|
for (Table table : allTables) {
|
||||||
if (table.getState() != TableState.FINISHED) {
|
if (table.getState() != TableState.FINISHED) {
|
||||||
tableList.add(new TableView(table));
|
tableList.add(new TableView(table));
|
||||||
}
|
} else if (matchList.size() < 50) {
|
||||||
else if (matchList.size() < 50) {
|
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
matchList.add(new MatchView(table));
|
matchList.add(new MatchView(table));
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,6 +220,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
class TableListSorter implements Comparator<Table> {
|
class TableListSorter implements Comparator<Table> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Table one, Table two) {
|
public int compare(Table one, Table two) {
|
||||||
if (!one.getState().equals(TableState.SIDEBOARDING) && !one.getState().equals(TableState.DUELING)) {
|
if (!one.getState().equals(TableState.SIDEBOARDING) && !one.getState().equals(TableState.DUELING)) {
|
||||||
|
@ -259,6 +258,7 @@ class TableListSorter implements Comparator<Table> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserNameSorter implements Comparator<UsersView> {
|
class UserNameSorter implements Comparator<UsersView> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(UsersView one, UsersView two) {
|
public int compare(UsersView one, UsersView two) {
|
||||||
return one.getUserName().compareToIgnoreCase(two.getUserName());
|
return one.getUserName().compareToIgnoreCase(two.getUserName());
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
@ -42,7 +42,6 @@ import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -81,9 +80,11 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
|
||||||
if (numPlaneswalkers > 0 && player.chooseUse(outcome, "Redirect damage to planeswalker?", game)) {
|
if (numPlaneswalkers > 0 && player.chooseUse(outcome, "Redirect damage to planeswalker?", game)) {
|
||||||
redirectTarget = new TargetPermanent(filter);
|
redirectTarget = new TargetPermanent(filter);
|
||||||
if (numPlaneswalkers == 1) {
|
if (numPlaneswalkers == 1) {
|
||||||
redirectTarget.add(game.getBattlefield().getAllActivePermanents(filter, target.getId(), game).get(0).getId(), game);
|
List<Permanent> planeswalker = game.getBattlefield().getAllActivePermanents(filter, target.getId(), game);
|
||||||
|
if (!planeswalker.isEmpty()) {
|
||||||
|
redirectTarget.add(planeswalker.get(0).getId(), game);
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
player.choose(Outcome.Damage, redirectTarget, null, game);
|
player.choose(Outcome.Damage, redirectTarget, null, game);
|
||||||
}
|
}
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -108,7 +107,6 @@ public abstract class GameCommanderImpl extends GameImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//20130711
|
//20130711
|
||||||
/*903.8. The Commander variant uses an alternate mulligan rule.
|
/*903.8. The Commander variant uses an alternate mulligan rule.
|
||||||
* Each time a player takes a mulligan, rather than shuffling his or her entire hand of cards into his or her library, that player exiles any number of cards from his or her hand face down.
|
* Each time a player takes a mulligan, rather than shuffling his or her entire hand of cards into his or her library, that player exiles any number of cards from his or her hand face down.
|
||||||
|
@ -145,7 +143,8 @@ public abstract class GameCommanderImpl extends GameImpl {
|
||||||
usedFreeMulligans.put(player.getId(), used + 1);
|
usedFreeMulligans.put(player.getId(), used + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deduction = 0;{
|
deduction = 0;
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
usedFreeMulligans.put(player.getId(), 1);
|
usedFreeMulligans.put(player.getId(), 1);
|
||||||
|
@ -188,6 +187,9 @@ public abstract class GameCommanderImpl extends GameImpl {
|
||||||
protected boolean checkStateBasedActions() {
|
protected boolean checkStateBasedActions() {
|
||||||
for (Player player : getPlayers().values()) {
|
for (Player player : getPlayers().values()) {
|
||||||
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get("CommanderCombatDamageWatcher", player.getCommanderId());
|
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get("CommanderCombatDamageWatcher", player.getCommanderId());
|
||||||
|
if (damageWatcher == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (Map.Entry<UUID, Integer> entrySet : damageWatcher.getDamageToPlayer().entrySet()) {
|
for (Map.Entry<UUID, Integer> entrySet : damageWatcher.getDamageToPlayer().entrySet()) {
|
||||||
if (entrySet.getValue() > 20) {
|
if (entrySet.getValue() > 20) {
|
||||||
Player opponent = getPlayer(entrySet.getKey());
|
Player opponent = getPlayer(entrySet.getKey());
|
||||||
|
|
|
@ -48,10 +48,9 @@ import mage.watchers.Watcher;
|
||||||
*
|
*
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommanderInfoWatcher extends Watcher {
|
public class CommanderInfoWatcher extends Watcher {
|
||||||
|
|
||||||
public Map<UUID, Integer> damageToPlayer = new HashMap<>();
|
public final Map<UUID, Integer> damageToPlayer = new HashMap<>();
|
||||||
public boolean checkCommanderDamage;
|
public boolean checkCommanderDamage;
|
||||||
|
|
||||||
public CommanderInfoWatcher(UUID commander, boolean checkCommanderDamage) {
|
public CommanderInfoWatcher(UUID commander, boolean checkCommanderDamage) {
|
||||||
|
@ -60,7 +59,6 @@ public class CommanderInfoWatcher extends Watcher {
|
||||||
this.checkCommanderDamage = checkCommanderDamage;
|
this.checkCommanderDamage = checkCommanderDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CommanderInfoWatcher(final CommanderInfoWatcher watcher) {
|
public CommanderInfoWatcher(final CommanderInfoWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
this.damageToPlayer.putAll(watcher.damageToPlayer);
|
this.damageToPlayer.putAll(watcher.damageToPlayer);
|
||||||
|
@ -88,8 +86,9 @@ public class CommanderInfoWatcher extends Watcher {
|
||||||
Player player = game.getPlayer(playerUUID);
|
Player player = game.getPlayer(playerUUID);
|
||||||
MageObject commander = game.getObject(sourceId);
|
MageObject commander = game.getObject(sourceId);
|
||||||
if (player != null && commander != null) {
|
if (player != null && commander != null) {
|
||||||
if (!game.isSimulation())
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getLogName() + " during the game.");
|
game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getLogName() + " during the game.");
|
||||||
|
}
|
||||||
this.addCardInfoToCommander(game);
|
this.addCardInfoToCommander(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue