Fixing plenty of bugs.

This commit is contained in:
marcins78@gmail.com
2011-09-14 18:50:30 +00:00
parent 3c4c3add3a
commit e1b7e9dd2f
11 changed files with 54 additions and 36 deletions

View File

@@ -6,6 +6,4 @@ public interface UserFeedback {
public void sendAwaitingDecision(String playerId, AwaitingDecision awaitingDecision);
public boolean hasPendingDecisions();
public void sendWarning(String playerId, String warning);
}

View File

@@ -0,0 +1,24 @@
package com.gempukku.lotro.logic.timing.processes.turn;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
public class CleanupProcess implements GameProcess {
private LotroGame _game;
public CleanupProcess(LotroGame game) {
_game = game;
}
@Override
public void process() {
_game.getGameState().stopAffectingCardsForCurrentPlayer();
_game.getGameState().setCurrentPhase(Phase.BETWEEN_TURNS);
}
@Override
public GameProcess getNextProcess() {
return new StartOfTurnGameProcess(_game);
}
}

View File

@@ -1,6 +1,5 @@
package com.gempukku.lotro.logic.timing.processes.turn;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.effects.TriggeringEffect;
import com.gempukku.lotro.logic.timing.actions.SimpleEffectAction;
@@ -17,12 +16,10 @@ public class EndOfTurnGameProcess implements GameProcess {
@Override
public void process() {
_game.getActionsEnvironment().addActionToStack(new SimpleEffectAction(new TriggeringEffect(new EndOfTurnResult(), "End of turn"), "End of turn"));
_game.getGameState().stopAffectingCardsForCurrentPlayer();
_game.getGameState().setCurrentPhase(Phase.BETWEEN_TURNS);
}
@Override
public GameProcess getNextProcess() {
return new StartOfTurnGameProcess(_game);
return new CleanupProcess(_game);
}
}

View File

@@ -9,7 +9,6 @@ import java.util.Set;
public class DefaultUserFeedback implements UserFeedback {
private Map<String, AwaitingDecision> _awaitingDecisionMap = new HashMap<String, AwaitingDecision>();
private Map<String, String> _warnings = new HashMap<String, String>();
public void participantDecided(String playerId) {
_awaitingDecisionMap.remove(playerId);
@@ -19,10 +18,6 @@ public class DefaultUserFeedback implements UserFeedback {
return _awaitingDecisionMap.get(playerId);
}
public String consumeWarning(String playerId) {
return _warnings.remove(playerId);
}
@Override
public void sendAwaitingDecision(String playerId, AwaitingDecision awaitingDecision) {
_awaitingDecisionMap.put(playerId, awaitingDecision);
@@ -33,11 +28,6 @@ public class DefaultUserFeedback implements UserFeedback {
return _awaitingDecisionMap.size() > 0;
}
@Override
public void sendWarning(String playerId, String warning) {
_warnings.put(playerId, warning);
}
public Set<String> getUsersPendingDecision() {
return _awaitingDecisionMap.keySet();
}

View File

@@ -15,7 +15,7 @@ public class GameEvent {
ADD_ASSIGNMENT, REMOVE_ASSIGNMENT,
START_SKIRMISH, END_SKIRMISH,
ADD_TOKENS, REMOVE_TOKENS,
MESSAGE
MESSAGE, WARNING
}
private String _message;

View File

@@ -25,8 +25,8 @@ public class LotroGameMediator {
private Map<String, Long> _decisionQuerySentTimes = new HashMap<String, Long>();
private final int _maxSecondsForGamePerPlayer = 60 * 30; // 30 minutes
private final int _channelInactivityTimeoutPeriod = 1000 * 30; // 30 seconds
private final int _playerDecisionTimeoutPeriod = 1000 * 60 * 5; // 5 minutes
private final int _channelInactivityTimeoutPeriod = 1000 * 60 * 5; // 5 minutes
private final int _playerDecisionTimeoutPeriod = 1000 * 60 * 10; // 10 minutes
public LotroGameMediator(LotroFormat lotroFormat, LotroGameParticipant[] participants, LotroCardBlueprintLibrary library, GameResultListener gameResultListener) {
@@ -139,9 +139,6 @@ public class LotroGameMediator {
if (communicationChannel != null) {
for (GameEvent gameEvent : communicationChannel.consumeGameEvents())
visitor.visitGameEvent(gameEvent);
String warning = _userFeedback.consumeWarning(participantId);
if (warning != null)
visitor.visitWarning(warning);
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
if (awaitingDecision != null)
visitor.visitAwaitingDecision(awaitingDecision);
@@ -153,7 +150,7 @@ public class LotroGameMediator {
}
visitor.visitClock(secondsLeft);
} else {
visitor.visitWarning("Your browser was inactive for too long, please refresh your browser window to continue playing");
visitor.visitGameEvent(new GameEvent(GameEvent.Type.WARNING).message("Your browser was inactive for too long, please refresh your browser window to continue playing"));
}
}
@@ -166,9 +163,6 @@ public class LotroGameMediator {
for (GameEvent gameEvent : participantCommunicationChannel.consumeGameEvents())
visitor.visitGameEvent(gameEvent);
String warning = _userFeedback.consumeWarning(participantId);
if (warning != null)
visitor.visitWarning(warning);
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(participantId);
if (awaitingDecision != null)
visitor.visitAwaitingDecision(awaitingDecision);

View File

@@ -8,8 +8,6 @@ import java.util.Map;
public interface ParticipantCommunicationVisitor {
public void visitClock(Map<String, Integer> secondsLeft);
public void visitWarning(String warning);
public void visitAwaitingDecision(AwaitingDecision awaitingDecision);
public void visitGameEvent(GameEvent gameEvent);

View File

@@ -405,11 +405,6 @@ public class ServerResource {
_element = element;
}
@Override
public void visitWarning(String warning) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void visitGameEvent(GameEvent gameEvent) {
_element.appendChild(serializeEvent(_doc, gameEvent));

View File

@@ -58,6 +58,18 @@
border-width: 3px;
border-color: #ff0000;
}
.chatMessage {
color: #3fafff;
}
.gameMessage {
}
.warningMessage {
color: #ff0000;
}
</style>
<link rel="stylesheet" type="text/css" href="css/dark-hive/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="js/jquery/styles/jquery.spinnercontrol.css">

View File

@@ -45,8 +45,10 @@ var ChatBoxUI = Class.extend({
this.chatTalkDiv.css({ position: "absolute", left: x + talkBoxPadding + "px", top: y - 2 * talkBoxPadding + (height - this.talkBoxHeight) + "px", width: width - 3 * talkBoxPadding , height: this.talkBoxHeight });
},
appendMessage: function(message) {
this.chatMessagesDiv.append("<div class='chatMessage'>" + message + "</div>");
appendMessage: function(message, msgClass) {
if (msgClass == undefined)
msgClass = "chatMessage";
this.chatMessagesDiv.append("<div class='" + msgClass + "'>" + message + "</div>");
if ($("div", this.chatMessagesDiv).length > 50) {
$("div", this.chatMessagesDiv).first().remove();
}

View File

@@ -335,6 +335,8 @@ var GempLotrGameUI = Class.extend({
this.removeTokens(gameEvent);
} else if (eventType == "MESSAGE") {
this.message(gameEvent);
} else if (eventType == "WARNING") {
this.message(gameEvent);
}
}
if (gameEvents.length > 0)
@@ -399,7 +401,13 @@ var GempLotrGameUI = Class.extend({
message: function(element) {
var message = element.getAttribute("message");
if (this.chatBox != null)
this.chatBox.appendMessage("<b>" + message + "</b>");
this.chatBox.appendMessage(message, "gameMessage");
},
warning: function(element) {
var message = element.getAttribute("message");
if (this.chatBox != null)
this.chatBox.appendMessage(message, "warningMessage");
},
startSkirmish: function(element) {