Introducing adventures.
This commit is contained in:
@@ -2,8 +2,25 @@ package com.gempukku.lotro.game;
|
||||
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
|
||||
import com.gempukku.lotro.logic.actions.SystemQueueAction;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersLogic;
|
||||
import com.gempukku.lotro.logic.timing.PlayerOrderFeedback;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface Adventure {
|
||||
public void applyAdventureRules(LotroGame game, DefaultActionsEnvironment actionsEnvironment, ModifiersLogic modifiersLogic);
|
||||
|
||||
public void appendNextSiteAction(SystemQueueAction action);
|
||||
|
||||
public GameProcess getAfterFellowshipArcheryGameProcess(int fellowshipArcheryTotal, GameProcess followingProcess);
|
||||
|
||||
public GameProcess getAfterFellowshipAssignmentGameProcess(Set<PhysicalCard> leftoverMinions, GameProcess followingProcess);
|
||||
|
||||
GameProcess getBeforeFellowshipChooseToMoveGameProcess(GameProcess followingProcess);
|
||||
|
||||
GameProcess getPlayerStaysGameProcess(LotroGame game, GameProcess followingProcess);
|
||||
|
||||
GameProcess getStartingGameProcess(Set<String> players, PlayerOrderFeedback playerOrderFeedback);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,90 @@
|
||||
package com.gempukku.lotro.game.adventure;
|
||||
|
||||
import com.gempukku.lotro.game.Adventure;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprint;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
|
||||
import com.gempukku.lotro.logic.PlayOrder;
|
||||
import com.gempukku.lotro.logic.actions.SystemQueueAction;
|
||||
import com.gempukku.lotro.logic.effects.PlaySiteEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersLogic;
|
||||
import com.gempukku.lotro.logic.timing.PlayerOrderFeedback;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.pregame.BiddingGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.archery.FellowshipPlayerChoosesShadowPlayerToAssignDamageToGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.assign.ShadowPlayersAssignTheirMinionsGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.DiscardAllMinionsGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.PlayerReconcilesGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.ReturnFollowersToSupportGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.ShadowPlayersReconcileGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.rules.WinConditionRule;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class DefaultAdventure implements Adventure {
|
||||
@Override
|
||||
public void applyAdventureRules(LotroGame game, DefaultActionsEnvironment actionsEnvironment, ModifiersLogic modifiersLogic) {
|
||||
new WinConditionRule(actionsEnvironment).applyRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendNextSiteAction(final SystemQueueAction action) {
|
||||
action.appendEffect(
|
||||
new UnrespondableEffect() {
|
||||
@Override
|
||||
protected void doPlayEffect(LotroGame game) {
|
||||
GameState gameState = game.getGameState();
|
||||
|
||||
final int nextSiteNumber = gameState.getCurrentSiteNumber() + 1;
|
||||
PhysicalCard nextSite = gameState.getSite(nextSiteNumber);
|
||||
|
||||
if (nextSite == null) {
|
||||
LotroCardBlueprint.Direction nextSiteDirection = gameState.getCurrentSite().getBlueprint().getSiteDirection();
|
||||
String playerToPlaySite;
|
||||
if (nextSiteDirection == LotroCardBlueprint.Direction.LEFT) {
|
||||
PlayOrder order = gameState.getPlayerOrder().getClockwisePlayOrder(gameState.getCurrentPlayerId(), false);
|
||||
order.getNextPlayer();
|
||||
playerToPlaySite = order.getNextPlayer();
|
||||
} else {
|
||||
PlayOrder order = gameState.getPlayerOrder().getCounterClockwisePlayOrder(gameState.getCurrentPlayerId(), false);
|
||||
order.getNextPlayer();
|
||||
playerToPlaySite = order.getNextPlayer();
|
||||
}
|
||||
|
||||
action.insertEffect(
|
||||
new PlaySiteEffect(action, playerToPlaySite, null, nextSiteNumber));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getAfterFellowshipArcheryGameProcess(int fellowshipArcheryTotal, GameProcess followingProcess) {
|
||||
return new FellowshipPlayerChoosesShadowPlayerToAssignDamageToGameProcess(fellowshipArcheryTotal, followingProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getAfterFellowshipAssignmentGameProcess(Set<PhysicalCard> leftoverMinions, GameProcess followingProcess) {
|
||||
return new ShadowPlayersAssignTheirMinionsGameProcess(followingProcess, leftoverMinions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getBeforeFellowshipChooseToMoveGameProcess(GameProcess followingProcess) {
|
||||
return new ShadowPlayersReconcileGameProcess(followingProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getPlayerStaysGameProcess(LotroGame game, GameProcess followingProcess) {
|
||||
return new PlayerReconcilesGameProcess(game.getGameState().getCurrentPlayerId(),
|
||||
new ReturnFollowersToSupportGameProcess(
|
||||
new DiscardAllMinionsGameProcess(followingProcess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getStartingGameProcess(Set<String> players, PlayerOrderFeedback playerOrderFeedback) {
|
||||
return new BiddingGameProcess(players, playerOrderFeedback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,6 @@ public interface LotroGame {
|
||||
public LotroFormat getFormat();
|
||||
|
||||
public boolean shouldAutoPass(String playerId, Phase phase);
|
||||
|
||||
public boolean isSolo();
|
||||
}
|
||||
|
||||
@@ -105,6 +105,11 @@ public class DefaultLotroGame implements LotroGame {
|
||||
return passablePhases.contains(phase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolo() {
|
||||
return _allPlayers.size() == 1;
|
||||
}
|
||||
|
||||
public void addGameResultListener(GameResultListener listener) {
|
||||
_gameResultListeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,19 @@ import com.gempukku.lotro.logic.decisions.ActionSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.CardActionSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.pregame.BiddingGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult;
|
||||
import com.gempukku.lotro.logic.timing.results.KilledResult;
|
||||
import com.gempukku.lotro.logic.timing.results.ReturnCardsToHandResult;
|
||||
import com.gempukku.lotro.logic.timing.rules.CharacterDeathRule;
|
||||
import com.gempukku.lotro.logic.timing.rules.InitiativeChangeRule;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
// Action generates multiple Effects, both costs and result of an action are Effects.
|
||||
|
||||
@@ -42,7 +47,7 @@ public class TurnProcedure {
|
||||
|
||||
_gameStats = new GameStats();
|
||||
|
||||
_gameProcess = new BiddingGameProcess(players, playerOrderFeedback);
|
||||
_gameProcess = lotroGame.getFormat().getAdventure().getStartingGameProcess(players, playerOrderFeedback);
|
||||
}
|
||||
|
||||
public GameStats getGameStats() {
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.Map;
|
||||
public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
|
||||
private Map<String, Integer> _bids;
|
||||
private String _firstPlayer;
|
||||
private GameProcess _nextProcess;
|
||||
|
||||
public PlayRingBearerRingAndAddBurdersGameProcess(Map<String, Integer> bids, String firstPlayer) {
|
||||
_bids = bids;
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.general.PlayersPlayPhaseActionsInOrderGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.general.StartOfPhaseGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.FellowshipPlayerChoosesToMoveOrStayGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.regroup.ShadowPlayersReconcileGameProcess;
|
||||
|
||||
public class RegroupGameProcess implements GameProcess {
|
||||
private GameProcess _followingGameProcess;
|
||||
@@ -15,7 +14,7 @@ public class RegroupGameProcess implements GameProcess {
|
||||
public void process(LotroGame game) {
|
||||
_followingGameProcess = new StartOfPhaseGameProcess(Phase.REGROUP,
|
||||
new PlayersPlayPhaseActionsInOrderGameProcess(game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(game.getGameState().getCurrentPlayerId(), true), 0,
|
||||
new ShadowPlayersReconcileGameProcess(
|
||||
game.getFormat().getAdventure().getBeforeFellowshipChooseToMoveGameProcess(
|
||||
new FellowshipPlayerChoosesToMoveOrStayGameProcess())));
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ArcheryFireGameProcess implements GameProcess {
|
||||
|
||||
private int _fellowshipArcheryTotal;
|
||||
private int _shadowArcheryTotal;
|
||||
private LotroGame _game;
|
||||
|
||||
public ArcheryFireGameProcess(GameProcess followingGameProcess) {
|
||||
_followingGameProcess = followingGameProcess;
|
||||
@@ -16,6 +17,7 @@ public class ArcheryFireGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public void process(LotroGame game) {
|
||||
_game = game;
|
||||
_fellowshipArcheryTotal = RuleUtils.calculateFellowshipArcheryTotal(game);
|
||||
|
||||
_shadowArcheryTotal = RuleUtils.calculateShadowArcheryTotal(game);
|
||||
@@ -25,6 +27,6 @@ public class ArcheryFireGameProcess implements GameProcess {
|
||||
@Override
|
||||
public GameProcess getNextProcess() {
|
||||
return new FellowshipPlayerAssignsArcheryDamageGameProcess(_shadowArcheryTotal,
|
||||
new FellowshipPlayerChoosesShadowPlayerToAssignDamageToGameProcess(_fellowshipArcheryTotal, _followingGameProcess));
|
||||
_game.getFormat().getAdventure().getAfterFellowshipArcheryGameProcess(_fellowshipArcheryTotal, _followingGameProcess));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Set;
|
||||
public class FreePeoplePlayerAssignsMinionsGameProcess implements GameProcess {
|
||||
private Set<PhysicalCard> _leftoverMinions;
|
||||
private GameProcess _followingAssignments;
|
||||
private LotroGame _game;
|
||||
|
||||
public FreePeoplePlayerAssignsMinionsGameProcess(GameProcess followingAssignments) {
|
||||
_followingAssignments = followingAssignments;
|
||||
@@ -33,6 +34,7 @@ public class FreePeoplePlayerAssignsMinionsGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public void process(LotroGame game) {
|
||||
_game = game;
|
||||
final SystemQueueAction action = new SystemQueueAction();
|
||||
action.appendEffect(
|
||||
new TriggeringResultEffect(new FreePlayerStartsAssigningResult(), "Free people player starts assigning"));
|
||||
@@ -94,6 +96,6 @@ public class FreePeoplePlayerAssignsMinionsGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public GameProcess getNextProcess() {
|
||||
return new ShadowPlayersAssignTheirMinionsGameProcess(_followingAssignments, _leftoverMinions);
|
||||
return _game.getFormat().getAdventure().getAfterFellowshipAssignmentGameProcess(_leftoverMinions, _followingAssignments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,11 @@ package com.gempukku.lotro.logic.timing.processes.turn.move;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprint;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.PlayOrder;
|
||||
import com.gempukku.lotro.logic.actions.SystemQueueAction;
|
||||
import com.gempukku.lotro.logic.effects.AddTwilightEffect;
|
||||
import com.gempukku.lotro.logic.effects.PlaySiteEffect;
|
||||
import com.gempukku.lotro.logic.effects.TriggeringResultEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
@@ -37,33 +34,7 @@ public class MovementGameProcess implements GameProcess {
|
||||
game.getGameState().setMoving(true);
|
||||
}
|
||||
});
|
||||
action.appendEffect(
|
||||
new UnrespondableEffect() {
|
||||
@Override
|
||||
protected void doPlayEffect(LotroGame game) {
|
||||
GameState gameState = game.getGameState();
|
||||
|
||||
final int nextSiteNumber = gameState.getCurrentSiteNumber() + 1;
|
||||
PhysicalCard nextSite = gameState.getSite(nextSiteNumber);
|
||||
|
||||
if (nextSite == null) {
|
||||
LotroCardBlueprint.Direction nextSiteDirection = gameState.getCurrentSite().getBlueprint().getSiteDirection();
|
||||
String playerToPlaySite;
|
||||
if (nextSiteDirection == LotroCardBlueprint.Direction.LEFT) {
|
||||
PlayOrder order = gameState.getPlayerOrder().getClockwisePlayOrder(gameState.getCurrentPlayerId(), false);
|
||||
order.getNextPlayer();
|
||||
playerToPlaySite = order.getNextPlayer();
|
||||
} else {
|
||||
PlayOrder order = gameState.getPlayerOrder().getCounterClockwisePlayOrder(gameState.getCurrentPlayerId(), false);
|
||||
order.getNextPlayer();
|
||||
playerToPlaySite = order.getNextPlayer();
|
||||
}
|
||||
|
||||
action.insertEffect(
|
||||
new PlaySiteEffect(action, playerToPlaySite, null, nextSiteNumber));
|
||||
}
|
||||
}
|
||||
});
|
||||
game.getFormat().getAdventure().appendNextSiteAction(action);
|
||||
action.appendEffect(
|
||||
new TriggeringResultEffect(new WhenMoveFromResult(currentSite), "Fellowship moved from"));
|
||||
action.appendEffect(
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
package com.gempukku.lotro.logic.timing.processes.turn.regroup;
|
||||
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.actions.SystemQueueAction;
|
||||
import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.EndOfTurnGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.general.EndOfPhaseGameProcess;
|
||||
|
||||
public class DiscardAllMinionsGameProcess implements GameProcess {
|
||||
private GameProcess _followingGameProcess;
|
||||
|
||||
public DiscardAllMinionsGameProcess(GameProcess followingGameProcess) {
|
||||
_followingGameProcess = followingGameProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(LotroGame game) {
|
||||
SystemQueueAction action = new SystemQueueAction();
|
||||
action.appendEffect(
|
||||
new DiscardCardsFromPlayEffect(null, CardType.MINION));
|
||||
game.getActionsEnvironment().addActionToStack(action);
|
||||
_followingGameProcess = new EndOfPhaseGameProcess(Phase.REGROUP,
|
||||
new EndOfTurnGameProcess());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifierFlag;
|
||||
import com.gempukku.lotro.logic.timing.RuleUtils;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.EndOfTurnGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.ShadowPhasesGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.general.EndOfPhaseGameProcess;
|
||||
import com.gempukku.lotro.logic.timing.processes.turn.move.MovementGameProcess;
|
||||
@@ -29,13 +30,13 @@ public class FellowshipPlayerChoosesToMoveOrStayGameProcess implements GameProce
|
||||
if (result.equals("Yes"))
|
||||
playerMoves();
|
||||
else {
|
||||
playerStays(currentPlayerId);
|
||||
playerStays(game);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
playerStays(currentPlayerId);
|
||||
playerStays(game);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +46,10 @@ public class FellowshipPlayerChoosesToMoveOrStayGameProcess implements GameProce
|
||||
new ShadowPhasesGameProcess()));
|
||||
}
|
||||
|
||||
private void playerStays(String currentPlayerId) {
|
||||
_nextProcess = new PlayerReconcilesGameProcess(currentPlayerId,
|
||||
new ReturnFollowersToSupportGameProcess(
|
||||
new DiscardAllMinionsGameProcess()));
|
||||
private void playerStays(LotroGame game) {
|
||||
_nextProcess = game.getFormat().getAdventure().getPlayerStaysGameProcess(game,
|
||||
new EndOfPhaseGameProcess(Phase.REGROUP,
|
||||
new EndOfTurnGameProcess()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user