Introducing adventures.

This commit is contained in:
marcins78
2014-07-25 16:19:50 +00:00
parent 29d8b773d3
commit d26acd2d0d
3 changed files with 26 additions and 4 deletions

View File

@@ -47,6 +47,8 @@ public class GameUtils {
}
public static String getFirstShadowPlayer(LotroGame game) {
if (game.isSolo())
throw new InvalidSoloAdventureException("Shadow player requested");
final String fpPlayer = game.getGameState().getCurrentPlayerId();
final PlayOrder counterClockwisePlayOrder = game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(fpPlayer, false);
// Skip FP player
@@ -55,6 +57,8 @@ public class GameUtils {
}
public static String[] getShadowPlayers(LotroGame game) {
if (game.isSolo())
throw new InvalidSoloAdventureException("Shadow player requested");
final String fpPlayer = game.getGameState().getCurrentPlayerId();
List<String> shadowPlayers = new LinkedList<String>(game.getGameState().getPlayerOrder().getAllPlayers());
shadowPlayers.remove(fpPlayer);
@@ -66,6 +70,8 @@ public class GameUtils {
}
public static String[] getOpponents(LotroGame game, String playerId) {
if (game.isSolo())
throw new InvalidSoloAdventureException("Opponent requested");
List<String> shadowPlayers = new LinkedList<String>(game.getGameState().getPlayerOrder().getAllPlayers());
shadowPlayers.remove(playerId);
return shadowPlayers.toArray(new String[shadowPlayers.size()]);

View File

@@ -0,0 +1,7 @@
package com.gempukku.lotro.logic;
public class InvalidSoloAdventureException extends RuntimeException {
public InvalidSoloAdventureException(String message) {
super(message);
}
}

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
import com.gempukku.lotro.logic.InvalidSoloAdventureException;
import com.gempukku.lotro.logic.PlayOrder;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
import com.gempukku.lotro.logic.actions.SystemQueueAction;
@@ -77,9 +78,13 @@ public class TurnProcedure {
} else {
Effect effect = _actionStack.getNextEffect(_game);
if (effect != null) {
if (effect.getType() == null)
effect.playEffect(_game);
else
if (effect.getType() == null) {
try {
effect.playEffect(_game);
} catch (InvalidSoloAdventureException exp) {
_game.playerLost(_game.getGameState().getCurrentPlayerId(), exp.getMessage());
}
} else
_actionStack.stackAction(new PlayOutEffect(effect));
}
}
@@ -127,7 +132,11 @@ public class TurnProcedure {
@Override
protected void doPlayEffect(LotroGame game) {
_effect.playEffect(game);
try {
_effect.playEffect(game);
} catch (InvalidSoloAdventureException exp) {
_game.playerLost(_game.getGameState().getCurrentPlayerId(), exp.getMessage());
}
}
}