Fixed some more exception and/or logging problems.

This commit is contained in:
LevelX2 2018-01-27 13:19:20 +01:00
parent 9268281c4b
commit 2f016c8ea6
11 changed files with 63 additions and 47 deletions

View file

@ -550,6 +550,6 @@ public class VintageCubeDecember2017 extends DraftCube {
cubeCards.add(new DraftCube.CardIdentity("Sphinx of the Steel Wind", ""));
cubeCards.add(new DraftCube.CardIdentity("Basalt Monolith", ""));
cubeCards.add(new DraftCube.CardIdentity("Fire // Ice", ""));
cubeCards.add(new DraftCube.CardIdentity("Thran Dynam", ""));
cubeCards.add(new DraftCube.CardIdentity("Thran Dynamo", ""));
}
}
}

View file

@ -959,13 +959,13 @@ public class TableController {
if (!table.isTournament()) {
if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) {
if (match == null) {
logger.debug("- Match table with no match:");
logger.debug("-- matchId:" + match.getId() + " [" + match.getName() + ']');
logger.warn("- Match table with no match:");
logger.warn("-- matchId:" + match.getId() + " [" + match.getName() + ']');
// return false;
} else if (match.isDoneSideboarding() && match.getGame() == null) {
// no sideboarding and not active game -> match seems to hang (maybe the Draw bug)
logger.debug("- Match with no active game and not in sideboard state:");
logger.debug("-- matchId:" + match.getId() + " [" + match.getName() + ']');
logger.warn("- Match with no active game and not in sideboard state:");
logger.warn("-- matchId:" + match.getId() + " [" + match.getName() + ']');
// return false;
}
}
@ -976,10 +976,10 @@ public class TableController {
for (Map.Entry<UUID, UUID> userPlayerEntry : userPlayerMap.entrySet()) {
MatchPlayer matchPlayer = match.getPlayer(userPlayerEntry.getValue());
if (matchPlayer == null) {
logger.debug("- Match player not found:");
logger.debug("-- matchId:" + match.getId());
logger.debug("-- userId:" + userPlayerEntry.getKey());
logger.debug("-- playerId:" + userPlayerEntry.getValue());
logger.warn("- Match player not found:");
logger.warn("-- matchId:" + match.getId());
logger.warn("-- userId:" + userPlayerEntry.getKey());
logger.warn("-- playerId:" + userPlayerEntry.getValue());
continue;
}
if (matchPlayer.getPlayer().isHuman()) {
@ -991,10 +991,10 @@ public class TableController {
|| (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
Optional<User> user = UserManager.instance.getUser(userPlayerEntry.getKey());
if (!user.isPresent()) {
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
logger.debug("-- matchId:" + match.getId());
logger.debug("-- userId:" + userPlayerEntry.getKey());
logger.debug("-- playerId:" + userPlayerEntry.getValue());
logger.warn("- Active user of match is missing: " + matchPlayer.getName());
logger.warn("-- matchId:" + match.getId());
logger.warn("-- userId:" + userPlayerEntry.getKey());
logger.warn("-- playerId:" + userPlayerEntry.getValue());
return false;
}
// user exits on the server and match player has not quit -> player is valid

View file

@ -27,6 +27,7 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
@ -50,8 +51,6 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author spjspj
*/
@ -152,7 +151,8 @@ class CurseOfVengeancePlayerLosesTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return game.getPermanent(this.getSourceId()).getAttachedTo().equals(event.getPlayerId());
Permanent sourceObject = game.getPermanentOrLKIBattlefield(this.getSourceId());
return sourceObject != null && sourceObject.getAttachedTo().equals(event.getPlayerId());
}
@Override

View file

@ -113,7 +113,7 @@ class GhostlyFlickerEffect extends OneShotEffect {
for (Card card : toExile) {
Zone currentZone = game.getState().getZone(card.getId());
if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
toBattlefield.add(game.getCard(card.getId()));
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);

View file

@ -76,7 +76,12 @@ class JackInTheMoxManaEffect extends ManaEffect {
JackInTheMoxManaEffect() {
super();
staticText = "Roll a six-sided die. If result is 1 - Sacrifice {this} and you lose 5 life. 2 - Add {W} 3 - Add {U} 4 - Add {B} 5 - Add {R} 6 - Add {G} to your mana pool";
staticText = "Roll a six-sided die for {this}. On a 1, sacrifice {this} and lose 5 life. Otherwise, {this} has one of the following effects. Treat this ability as a mana source."
+ "<br/>2 Add {W} to your mana pool.\n"
+ "<br/>3 Add {U} to your mana pool.\n"
+ "<br/>4 Add {B} to your mana pool.\n"
+ "<br/>5 Add {R} to your mana pool.\n"
+ "<br/>6 Add {G} to your mana pool.";
}
JackInTheMoxManaEffect(final JackInTheMoxManaEffect effect) {

View file

@ -57,8 +57,9 @@ import mage.util.CardUtil;
public class TrainingGrounds extends CardImpl {
public TrainingGrounds(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}");
// Activated abilities of creatures you control cost up to {2} less to activate. This effect can't reduce the amount of mana an ability costs to activate to less than one mana.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new TrainingGroundsEffect()));
}
@ -107,10 +108,14 @@ class TrainingGroundsEffect extends CostModificationEffectImpl {
}
choice.setChoices(set);
choice.setMessage("Reduce ability cost");
if (controller.choose(Outcome.Benefit, choice, game)) {
int reduce = Integer.parseInt(choice.getChoice());
CardUtil.reduceCost(abilityToModify, reduce);
while (!choice.isChosen()) {
controller.choose(Outcome.Benefit, choice, game);
if (!controller.isInGame()) {
return false;
}
}
int reduce = Integer.parseInt(choice.getChoice());
CardUtil.reduceCost(abilityToModify, reduce);
}
return true;
}

View file

@ -668,17 +668,20 @@ public abstract class GameImpl implements Game, Serializable {
if (!simulation && !this.hasEnded()) { // if player left or game is over no undo is possible - this could lead to wrong winner
if (bookmark != 0) {
if (!savedStates.contains(bookmark - 1)) {
throw new UnsupportedOperationException("It was not possible to do the requested undo operation (bookmark " + (bookmark - 1) + " does not exist) context: " + context);
}
int stateNum = savedStates.get(bookmark - 1);
removeBookmark(bookmark);
GameState restore = gameStates.rollback(stateNum);
if (restore != null) {
state.restore(restore);
playerList.setCurrent(state.getPlayerByOrderId());
logger.error("It was not possible to do the requested undo operation (bookmark " + (bookmark - 1) + " does not exist) context: " + context);
logger.info("Saved states: " + savedStates.toString());
} else {
int stateNum = savedStates.get(bookmark - 1);
removeBookmark(bookmark);
GameState restore = gameStates.rollback(stateNum);
if (restore != null) {
state.restore(restore);
playerList.setCurrent(state.getPlayerByOrderId());
}
}
}
}
}
@Override
@ -1355,7 +1358,7 @@ public abstract class GameImpl implements Game, Serializable {
logger.fatal(ex.getStackTrace());
}
this.fireErrorEvent("Game exception occurred: ", ex);
restoreState(bookmark, "");
restoreState(bookmark, "Game exception: " + ex.getMessage());
bookmark = 0;
Player activePlayer = this.getPlayer(getActivePlayerId());
if (errorContinueCounter > 15) {

View file

@ -304,7 +304,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
Map<UUID, Integer> assigned = new HashMap<>();
if (blocked) {
boolean excessDamageToDefender = true;
for (UUID blockerId : blockerOrder) {
for (UUID blockerId : new ArrayList<>(blockerOrder)) { // prevent ConcurrentModificationException
Permanent blocker = game.getPermanent(blockerId);
if (blocker != null) {
int lethalDamage;

View file

@ -703,7 +703,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
}
if (getSpellAbility() == null) {
logger.info("FATAL : no spell ability for attach to permanent: " + getName());
// Can happen e.g. for Token Equipments like Stoneforged Blade
return;
}
if (!getSpellAbility().getTargets().isEmpty() && (getSpellAbility().getTargets().get(0) instanceof TargetCard)) {

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.players;
import java.util.UUID;
@ -38,7 +37,8 @@ import mage.util.CircularList;
*/
public class PlayerList extends CircularList<UUID> {
public PlayerList() {}
public PlayerList() {
}
public PlayerList(final PlayerList list) {
super(list);
@ -47,23 +47,25 @@ public class PlayerList extends CircularList<UUID> {
public Player getCurrent(Game game) {
return game.getPlayer(this.get());
}
public Player getNextInRange(Player basePlayer, Game game) {
UUID currentPlayerBefore = get();
UUID currentPlayerBefore = get();
UUID nextPlayerId = super.getNext();
do {
if (basePlayer.getInRange().contains(nextPlayerId)) {
return game.getPlayer(nextPlayerId);
return game.getPlayer(nextPlayerId);
}
nextPlayerId = super.getNext();
}
while (!nextPlayerId.equals(currentPlayerBefore));
} while (!nextPlayerId.equals(currentPlayerBefore));
return null;
}
public Player getNext(Game game) {
Player player;
UUID start = this.get();
if (start == null) {
return null;
}
Player player;
while (true) {
player = game.getPlayer(super.getNext());
if (!player.hasLeft() && !player.hasLost()) {

View file

@ -27,8 +27,6 @@
*/
package mage.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@ -111,7 +109,10 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
* @return
*/
public E get() {
return list.get(this.index);
if (list.size() > this.index) {
return list.get(this.index);
}
return null;
}
@Override