A bit of working with how the actions are played and messages being displayed.
This commit is contained in:
@@ -6,9 +6,11 @@ import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
public class TriggeringEffect extends AbstractEffect {
|
||||
private EffectResult _effectResult;
|
||||
private String _text;
|
||||
|
||||
public TriggeringEffect(EffectResult effectResult) {
|
||||
public TriggeringEffect(EffectResult effectResult, String text) {
|
||||
_effectResult = effectResult;
|
||||
_text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -18,7 +20,7 @@ public class TriggeringEffect extends AbstractEffect {
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return null;
|
||||
return _text;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TurnProcedure {
|
||||
} else {
|
||||
Effect effect = _actionStack.getNextEffect();
|
||||
if (effect != null) {
|
||||
if (effect instanceof UnrespondableEffect) {
|
||||
if (effect.getType() == null) {
|
||||
if (effect.canPlayEffect(_game))
|
||||
effect.playEffect(_game);
|
||||
else
|
||||
@@ -134,7 +134,7 @@ public class TurnProcedure {
|
||||
Map<String, List<Action>> optionalWhenResponses = _game.getActionsEnvironment().getOptionalAfterTriggers(_game.getGameState().getPlayerOrder().getAllPlayers(), _effectResult);
|
||||
DefaultCostToEffectAction action = new DefaultCostToEffectAction(null, null, null);
|
||||
action.addEffect(
|
||||
new PlayoutOptionalAfterResponsesEffect(action, optionalWhenResponses, _game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(_game.getGameState().getCurrentPlayerId(), true), 0, _effectResult));
|
||||
new PlayoutOptionalAfterResponsesEffect(action, optionalWhenResponses, _game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(_game.getGameState().getCurrentPlayerId(), true), 0, _effect, _effectResult));
|
||||
return new StackActionEffect(action);
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class TurnProcedure {
|
||||
|
||||
if (possibleActions.size() > 0) {
|
||||
_game.getUserFeedback().sendAwaitingDecision(activePlayer,
|
||||
new CardActionSelectionDecision(1, "Choose action to play or DONE", possibleActions, true) {
|
||||
new CardActionSelectionDecision(1, _effect.getText() + " - Optional \"is about to\" responses", possibleActions, true) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
Action action = getSelectedAction(result);
|
||||
@@ -196,13 +196,15 @@ public class TurnProcedure {
|
||||
private Map<String, List<Action>> _actionMap = new HashMap<String, List<Action>>();
|
||||
private PlayOrder _playOrder;
|
||||
private int _passCount;
|
||||
private Effect _effect;
|
||||
private EffectResult _effectResult;
|
||||
|
||||
private PlayoutOptionalAfterResponsesEffect(DefaultCostToEffectAction action, Map<String, List<Action>> actionMap, PlayOrder playOrder, int passCount, EffectResult effectResult) {
|
||||
private PlayoutOptionalAfterResponsesEffect(DefaultCostToEffectAction action, Map<String, List<Action>> actionMap, PlayOrder playOrder, int passCount, Effect effect, EffectResult effectResult) {
|
||||
_action = action;
|
||||
_actionMap = actionMap;
|
||||
_playOrder = playOrder;
|
||||
_passCount = passCount;
|
||||
_effect = effect;
|
||||
_effectResult = effectResult;
|
||||
}
|
||||
|
||||
@@ -214,24 +216,24 @@ public class TurnProcedure {
|
||||
|
||||
if (possibleActions.size() > 0) {
|
||||
_game.getUserFeedback().sendAwaitingDecision(activePlayer,
|
||||
new CardActionSelectionDecision(1, "Choose action to play or DONE", possibleActions, true) {
|
||||
new CardActionSelectionDecision(1, _effect.getText() + " - optional \"when\" responses", possibleActions, true) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
Action action = getSelectedAction(result);
|
||||
if (action != null) {
|
||||
_game.getActionsEnvironment().addActionToStack(action);
|
||||
_actionMap.get(activePlayer).remove(action);
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, 0, _effectResult));
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, 0, _effect, _effectResult));
|
||||
} else {
|
||||
if ((_passCount + 1) < _playOrder.getPlayerCount()) {
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, _passCount + 1, _effectResult));
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, _passCount + 1, _effect, _effectResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if ((_passCount + 1) < _playOrder.getPlayerCount()) {
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, _passCount + 1, _effectResult));
|
||||
_action.addEffect(new PlayoutOptionalAfterResponsesEffect(_action, _actionMap, _playOrder, _passCount + 1, _effect, _effectResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +257,7 @@ public class TurnProcedure {
|
||||
_game.getActionsEnvironment().addActionToStack(_actions.get(0));
|
||||
} else {
|
||||
_game.getUserFeedback().sendAwaitingDecision(_game.getGameState().getCurrentPlayerId(),
|
||||
new ActionSelectionDecision(1, "Choose action to play now", _actions) {
|
||||
new ActionSelectionDecision(1, _effect.getText() + " - required responses", _actions) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
Action action = getSelectedAction(result);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class EndOfTurnGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new EndOfTurnResult()), "End of turn"));
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new EndOfTurnResult(), "End of turn"), "End of turn"));
|
||||
_game.getGameState().stopAffectingCardsForCurrentPlayer();
|
||||
_game.getGameState().setCurrentPhase(Phase.BETWEEN_TURNS);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class StartOfTurnGameProcess implements GameProcess {
|
||||
_game.getGameState().startPlayerTurn(nextPlayer);
|
||||
_game.getGameState().startAffectingCardsForCurrentPlayer(_game.getModifiersEnvironment());
|
||||
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new StartOfTurnResult()), "Start of turn"));
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new StartOfTurnResult(), "Start of turn"), "Start of turn"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ public class EndOfPhaseGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new EndOfPhaseResult(_phase)), "End of " + _phase + " phase"));
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new EndOfPhaseResult(_phase), "End of " + _phase + " phase"), "End of " + _phase + " phase"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SimpleTriggeringGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(_effectResult), _text));
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(_effectResult, _text), _text));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public class StartOfPhaseGameProcess implements GameProcess {
|
||||
@Override
|
||||
public void process() {
|
||||
_game.getGameState().setCurrentPhase(_phase);
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new StartOfPhaseResult(_phase)), "Start of " + _phase + " phase"));
|
||||
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new StartOfPhaseResult(_phase), "Start of " + _phase + " phase"), "Start of " + _phase + " phase"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,7 +144,7 @@ public class LotroGameMediator {
|
||||
visitor.visitWarning(warning);
|
||||
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
|
||||
if (awaitingDecision != null)
|
||||
visitor.visitAwaitingDecision(_lotroGame.getActionStack().getTopmostAction(), awaitingDecision);
|
||||
visitor.visitAwaitingDecision(awaitingDecision);
|
||||
|
||||
Map<String, Integer> secondsLeft = new HashMap<String, Integer>();
|
||||
for (Map.Entry<String, Integer> playerClock : _playerClocks.entrySet()) {
|
||||
@@ -171,7 +171,7 @@ public class LotroGameMediator {
|
||||
visitor.visitWarning(warning);
|
||||
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
|
||||
if (awaitingDecision != null)
|
||||
visitor.visitAwaitingDecision(_lotroGame.getActionStack().getTopmostAction(), awaitingDecision);
|
||||
visitor.visitAwaitingDecision(awaitingDecision);
|
||||
|
||||
Map<String, Integer> secondsLeft = new HashMap<String, Integer>();
|
||||
for (Map.Entry<String, Integer> playerClock : _playerClocks.entrySet()) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.gempukku.lotro.game;
|
||||
|
||||
import com.gempukku.lotro.GameEvent;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -11,7 +10,7 @@ public interface ParticipantCommunicationVisitor {
|
||||
|
||||
public void visitWarning(String warning);
|
||||
|
||||
public void visitAwaitingDecision(Action currentAction, AwaitingDecision awaitingDecision);
|
||||
public void visitAwaitingDecision(AwaitingDecision awaitingDecision);
|
||||
|
||||
public void visitGameEvent(GameEvent gameEvent);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultLotroFormat;
|
||||
import com.gempukku.lotro.game.ParticipantCommunicationVisitor;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -417,8 +416,8 @@ public class ServerResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAwaitingDecision(Action currentAction, AwaitingDecision awaitingDecision) {
|
||||
_element.appendChild(serializeDecision(_doc, currentAction, awaitingDecision));
|
||||
public void visitAwaitingDecision(AwaitingDecision awaitingDecision) {
|
||||
_element.appendChild(serializeDecision(_doc, awaitingDecision));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -439,17 +438,12 @@ public class ServerResource {
|
||||
return clocks;
|
||||
}
|
||||
|
||||
private Node serializeDecision(Document doc, Action currentAction, AwaitingDecision decision) {
|
||||
private Node serializeDecision(Document doc, AwaitingDecision decision) {
|
||||
Element decisionElem = doc.createElement("decision");
|
||||
decisionElem.setAttribute("id", String.valueOf(decision.getAwaitingDecisionId()));
|
||||
decisionElem.setAttribute("type", decision.getDecisionType().name());
|
||||
if (decision.getText() != null) {
|
||||
String text = "";
|
||||
if (currentAction != null)
|
||||
text += currentAction.getText() + ": ";
|
||||
text += decision.getText();
|
||||
decisionElem.setAttribute("text", text);
|
||||
}
|
||||
if (decision.getText() != null)
|
||||
decisionElem.setAttribute("text", decision.getText());
|
||||
for (Map.Entry<String, Object> paramEntry : decision.getDecisionParameters().entrySet()) {
|
||||
if (paramEntry.getValue() instanceof String) {
|
||||
Element decisionParam = doc.createElement("parameter");
|
||||
|
||||
Reference in New Issue
Block a user