Game channel number.

This commit is contained in:
marcins78@gmail.com
2012-04-05 09:02:24 +00:00
parent 834413f7b6
commit 3115d5d463
2 changed files with 21 additions and 16 deletions

View File

@@ -259,27 +259,32 @@ public class LotroGameMediator {
}
}
public void playerAnswered(Player player, int decisionId, String answer) {
public void playerAnswered(Player player, int channelNumber, int decisionId, String answer) {
String playerName = player.getName();
_writeLock.lock();
try {
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(playerName);
if (awaitingDecision != null) {
if (awaitingDecision.getAwaitingDecisionId() == decisionId) {
try {
_userFeedback.participantDecided(playerName);
awaitingDecision.decisionMade(answer);
GatheringParticipantCommunicationChannel communicationChannel = _communicationChannels.get(playerName);
if (communicationChannel != null) {
if (communicationChannel.getChannelNumber() == channelNumber) {
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(playerName);
if (awaitingDecision != null) {
if (awaitingDecision.getAwaitingDecisionId() == decisionId) {
try {
_userFeedback.participantDecided(playerName);
awaitingDecision.decisionMade(answer);
// Decision successfully made, add the time to user clock
addTimeSpentOnDecisionToUserClock(playerName);
// Decision successfully made, add the time to user clock
addTimeSpentOnDecisionToUserClock(playerName);
_lotroGame.carryOutPendingActionsUntilDecisionNeeded();
startClocksForUsersPendingDecision();
_lotroGame.carryOutPendingActionsUntilDecisionNeeded();
startClocksForUsersPendingDecision();
} catch (DecisionResultInvalidException decisionResultInvalidException) {
// Participant provided wrong answer - send a warning message, and ask again for the same decision
_userFeedback.sendWarning(playerName, decisionResultInvalidException.getWarningMessage());
_userFeedback.sendAwaitingDecision(playerName, awaitingDecision);
} catch (DecisionResultInvalidException decisionResultInvalidException) {
// Participant provided wrong answer - send a warning message, and ask again for the same decision
_userFeedback.sendWarning(playerName, decisionResultInvalidException.getWarningMessage());
_userFeedback.sendAwaitingDecision(playerName, awaitingDecision);
}
}
}
}
}

View File

@@ -146,7 +146,7 @@ public class GameResource extends AbstractResource {
if (decisionId != null) {
try {
gameMediator.playerAnswered(resourceOwner, decisionId, decisionValue);
gameMediator.playerAnswered(resourceOwner, channelNumber, decisionId, decisionValue);
} catch (RuntimeException exp) {
_logger.error("Error while sending decision", exp);
throw exp;