Another fixes.

This commit is contained in:
marcins78@gmail.com
2011-09-11 17:36:13 +00:00
parent f34a1826b9
commit 19166591cb
10 changed files with 35 additions and 14 deletions

View File

@@ -52,7 +52,7 @@ public abstract class AbstractAttachable extends AbstractLotroCardBlueprint {
if (matchingClassPossessions.size() > 1)
return false;
if (!extraPossessionClass && matchingClassPossessions.size() == 1 &&
!((AbstractAttachable) matchingClassPossessions.get(0)).isExtraPossessionClass())
!((AbstractAttachable) matchingClassPossessions.get(0).getBlueprint()).isExtraPossessionClass())
return false;
}
return true;

View File

@@ -14,13 +14,15 @@ import java.util.List;
public abstract class RevealAndChooseCardsFromOpponentHandEffect extends UnrespondableEffect {
private String _playerId;
private String _opponentId;
private String _text;
private Filter _selectionFilter;
private int _minChosen;
private int _maxChosen;
protected RevealAndChooseCardsFromOpponentHandEffect(String playerId, String opponentId, Filter selectionFilter, int minChosen, int maxChosen) {
protected RevealAndChooseCardsFromOpponentHandEffect(String playerId, String opponentId, String text, Filter selectionFilter, int minChosen, int maxChosen) {
_playerId = playerId;
_opponentId = opponentId;
_text = text;
_selectionFilter = selectionFilter;
_minChosen = minChosen;
_maxChosen = maxChosen;
@@ -32,7 +34,7 @@ public abstract class RevealAndChooseCardsFromOpponentHandEffect extends Unrespo
List<PhysicalCard> selectable = Filters.filter(opponentHand, game.getGameState(), game.getModifiersQuerying(), _selectionFilter);
game.getUserFeedback().sendAwaitingDecision(_playerId,
new ArbitraryCardsSelectionDecision(1, "Opponent's hand", opponentHand, selectable, Math.min(_minChosen, selectable.size()), Math.min(_maxChosen, selectable.size())) {
new ArbitraryCardsSelectionDecision(1, _text, opponentHand, selectable, Math.min(_minChosen, selectable.size()), Math.min(_maxChosen, selectable.size())) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);

View File

@@ -49,7 +49,7 @@ public class Card1_044 extends AbstractEvent {
@Override
protected void opponentChosen(String opponentId) {
action.addEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 1, 1) {
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, "Choose an ISENGARD minion", Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 1, 1) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {

View File

@@ -43,7 +43,7 @@ public class Card1_351 extends AbstractSite {
@Override
protected void opponentChosen(String opponentId) {
action.addEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, Filters.none(), 0, 0) {
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, "Opponent's hand", Filters.none(), 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
// Do nothing, it's just to look at hand

View File

@@ -23,4 +23,10 @@ public class ActionStack {
public boolean isEmpty() {
return _actionStack.isEmpty();
}
public Action getTopmostAction() {
if (_actionStack.isEmpty())
return null;
return _actionStack.peek();
}
}

View File

@@ -116,6 +116,10 @@ public class DefaultLotroGame implements LotroGame {
return _userFeedback;
}
public ActionStack getActionStack() {
return _actionStack;
}
public void addGameStateListener(String playerId, GameStateListener gameStateListener) {
if (_gameState != null)
_gameState.addGameStateListener(playerId, gameStateListener);

View File

@@ -97,7 +97,7 @@ public class LotroGameMediator {
visitor.visitWarning(warning);
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
if (awaitingDecision != null)
visitor.visitAwaitingDecision(awaitingDecision);
visitor.visitAwaitingDecision(_lotroGame.getActionStack().getTopmostAction(), awaitingDecision);
}
public synchronized void singupUserForGame(String participantId, ParticipantCommunicationVisitor visitor) {
@@ -114,6 +114,6 @@ public class LotroGameMediator {
visitor.visitWarning(warning);
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
if (awaitingDecision != null)
visitor.visitAwaitingDecision(awaitingDecision);
visitor.visitAwaitingDecision(_lotroGame.getActionStack().getTopmostAction(), awaitingDecision);
}
}

View File

@@ -2,11 +2,12 @@ package com.gempukku.lotro.game;
import com.gempukku.lotro.GameEvent;
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
import com.gempukku.lotro.logic.timing.Action;
public interface ParticipantCommunicationVisitor {
public void visitWarning(String warning);
public void visitAwaitingDecision(AwaitingDecision awaitingDecision);
public void visitAwaitingDecision(Action currentAction, AwaitingDecision awaitingDecision);
public void visitGameEvent(GameEvent gameEvent);
}

View File

@@ -12,6 +12,7 @@ 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.log4j.Logger;
import org.w3c.dom.Document;
@@ -335,17 +336,22 @@ public class ServerResource {
}
@Override
public void visitAwaitingDecision(AwaitingDecision awaitingDecision) {
_element.appendChild(serializeDecision(_doc, awaitingDecision));
public void visitAwaitingDecision(Action currentAction, AwaitingDecision awaitingDecision) {
_element.appendChild(serializeDecision(_doc, currentAction, awaitingDecision));
}
}
private Node serializeDecision(Document doc, AwaitingDecision decision) {
private Node serializeDecision(Document doc, Action currentAction, AwaitingDecision decision) {
Element decisionElem = doc.createElement("decision");
decisionElem.setAttribute("id", String.valueOf(decision.getAwaitingDecisionId()));
decisionElem.setAttribute("type", decision.getDecisionType().name());
if (decision.getText() != null)
decisionElem.setAttribute("text", decision.getText());
if (decision.getText() != null) {
String text = "";
if (currentAction != null)
text += currentAction.getText() + ": ";
text += decision.getText();
decisionElem.setAttribute("text", text);
}
for (Map.Entry<String, Object> paramEntry : decision.getDecisionParameters().entrySet()) {
if (paramEntry.getValue() instanceof String) {
Element decisionParam = doc.createElement("parameter");

View File

@@ -14,7 +14,9 @@ and go with different selection.
9. Add checkbox option to auto-pass if there is no actions to be played.
10. Add active/all cards switch to the user interface.
11. Merge Shadow and FP support area on the UI and extend the Shadow and FP characters window.
12. Add rule of 4
12. Add rule of 4.
13. Add dead/discard pile displays.
14. Add hand/deck card count displays.
DONE:
1. Introduce AbstractPermanent into Blueprint hierarchy.