Extract DraftCommunicationChannel to be accessed directly.
This commit is contained in:
@@ -117,7 +117,7 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri
|
|||||||
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_hallServer.draftPick(tournamentId, resourceOwner, blueprintId);
|
_hallServer.getDraft(tournamentId).playerChosenCard(resourceOwner.getName(), blueprintId);
|
||||||
responseWriter.writeXmlResponse(null);
|
responseWriter.writeXmlResponse(null);
|
||||||
} catch (DraftFinishedException exp) {
|
} catch (DraftFinishedException exp) {
|
||||||
responseWriter.writeError(204);
|
responseWriter.writeError(204);
|
||||||
@@ -177,8 +177,8 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri
|
|||||||
try {
|
try {
|
||||||
Draft draft = _hallServer.getDraft(_tournamentId);
|
Draft draft = _hallServer.getDraft(_tournamentId);
|
||||||
SerializeDraftVisitor serializeDraftVisitor = new SerializeDraftVisitor(doc, draftElem);
|
SerializeDraftVisitor serializeDraftVisitor = new SerializeDraftVisitor(doc, draftElem);
|
||||||
draft.getCommunicationChannel(_player.getName(), _channelNumber).processCommunicationChannel(draft.getCardChoice(_player.getName()), serializeDraftVisitor);
|
draft.getCommunicationChannel(_player.getName(), _channelNumber)
|
||||||
serializeDraftVisitor.chosenCards(draft.getChosenCards(_player));
|
.processCommunicationChannel(draft.getCardChoice(_player.getName()), draft.getChosenCards(_player.getName()), serializeDraftVisitor);
|
||||||
|
|
||||||
doc.appendChild(draftElem);
|
doc.appendChild(draftElem);
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class CollectionsManager {
|
|||||||
return _defaultCollection;
|
return _defaultCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CardCollection getPlayerCollection(String playerName, String collectionType) {
|
||||||
|
return getPlayerCollection(_playerDAO.getPlayer(playerName), collectionType);
|
||||||
|
}
|
||||||
|
|
||||||
public CardCollection getPlayerCollection(Player player, String collectionType) {
|
public CardCollection getPlayerCollection(Player player, String collectionType) {
|
||||||
_readWriteLock.readLock().lock();
|
_readWriteLock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.gempukku.lotro.db.vo.CollectionType;
|
|||||||
import com.gempukku.lotro.game.CardCollection;
|
import com.gempukku.lotro.game.CardCollection;
|
||||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||||
import com.gempukku.lotro.game.MutableCardCollection;
|
import com.gempukku.lotro.game.MutableCardCollection;
|
||||||
import com.gempukku.lotro.game.Player;
|
|
||||||
import com.gempukku.lotro.packs.PacksStorage;
|
import com.gempukku.lotro.packs.PacksStorage;
|
||||||
import com.gempukku.lotro.tournament.TournamentCallback;
|
import com.gempukku.lotro.tournament.TournamentCallback;
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ public class DefaultDraft implements Draft {
|
|||||||
public void signUpForDraft(String playerName, DraftChannelVisitor draftChannelVisitor) {
|
public void signUpForDraft(String playerName, DraftChannelVisitor draftChannelVisitor) {
|
||||||
DraftCommunicationChannel draftCommunicationChannel = new DraftCommunicationChannel(_nextChannelNumber++);
|
DraftCommunicationChannel draftCommunicationChannel = new DraftCommunicationChannel(_nextChannelNumber++);
|
||||||
_playerDraftCommunications.put(playerName, draftCommunicationChannel);
|
_playerDraftCommunications.put(playerName, draftCommunicationChannel);
|
||||||
draftCommunicationChannel.processCommunicationChannel(getCardChoice(playerName), draftChannelVisitor);
|
draftCommunicationChannel.processCommunicationChannel(getCardChoice(playerName), getChosenCards(playerName), draftChannelVisitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftCommunicationChannel getCommunicationChannel(String playerName, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException {
|
public DraftCommunicationChannel getCommunicationChannel(String playerName, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException {
|
||||||
@@ -103,8 +102,8 @@ public class DefaultDraft implements Draft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CardCollection getChosenCards(Player player) {
|
public CardCollection getChosenCards(String playerName) {
|
||||||
return _collectionsManager.getPlayerCollection(player, _collectionType.getCode());
|
return _collectionsManager.getPlayerCollection(playerName, _collectionType.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.gempukku.lotro.draft;
|
|||||||
import com.gempukku.lotro.SubscriptionConflictException;
|
import com.gempukku.lotro.SubscriptionConflictException;
|
||||||
import com.gempukku.lotro.SubscriptionExpiredException;
|
import com.gempukku.lotro.SubscriptionExpiredException;
|
||||||
import com.gempukku.lotro.game.CardCollection;
|
import com.gempukku.lotro.game.CardCollection;
|
||||||
import com.gempukku.lotro.game.Player;
|
|
||||||
import com.gempukku.lotro.tournament.TournamentCallback;
|
import com.gempukku.lotro.tournament.TournamentCallback;
|
||||||
|
|
||||||
public interface Draft {
|
public interface Draft {
|
||||||
@@ -16,7 +15,7 @@ public interface Draft {
|
|||||||
public DraftCommunicationChannel getCommunicationChannel(String playerName, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException;
|
public DraftCommunicationChannel getCommunicationChannel(String playerName, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException;
|
||||||
|
|
||||||
public DraftCardChoice getCardChoice(String playerName);
|
public DraftCardChoice getCardChoice(String playerName);
|
||||||
public CardCollection getChosenCards(Player player);
|
public CardCollection getChosenCards(String player);
|
||||||
|
|
||||||
public boolean isFinished();
|
public boolean isFinished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class DraftCommunicationChannel {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processCommunicationChannel(DraftCardChoice draftCardChoice, DraftChannelVisitor draftChannelVisitor) {
|
public void processCommunicationChannel(DraftCardChoice draftCardChoice, CardCollection chosenCards, DraftChannelVisitor draftChannelVisitor) {
|
||||||
updateLastAccess();
|
updateLastAccess();
|
||||||
|
|
||||||
CardCollection cardCollection = draftCardChoice.getCardCollection();
|
CardCollection cardCollection = draftCardChoice.getCardCollection();
|
||||||
@@ -53,5 +53,6 @@ public class DraftCommunicationChannel {
|
|||||||
draftChannelVisitor.noCardChoice();
|
draftChannelVisitor.noCardChoice();
|
||||||
_cardChoiceOnClient = null;
|
_cardChoiceOnClient = null;
|
||||||
}
|
}
|
||||||
|
draftChannelVisitor.chosenCards(chosenCards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,24 +339,6 @@ public class HallServer extends AbstractServer {
|
|||||||
if (draft == null)
|
if (draft == null)
|
||||||
throw new DraftFinishedException();
|
throw new DraftFinishedException();
|
||||||
draft.signUpForDraft(player.getName(), draftChannelVisitor);
|
draft.signUpForDraft(player.getName(), draftChannelVisitor);
|
||||||
CardCollection cardCollection = _collectionsManager.getPlayerCollection(player, tournament.getCollectionType().getCode());
|
|
||||||
draftChannelVisitor.chosenCards(cardCollection);
|
|
||||||
} finally {
|
|
||||||
_hallDataAccessLock.readLock().unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draftPick(String tournamentId, Player player, String blueprintId)
|
|
||||||
throws DraftFinishedException {
|
|
||||||
_hallDataAccessLock.readLock().lock();
|
|
||||||
try {
|
|
||||||
Tournament tournament = _runningTournaments.get(tournamentId);
|
|
||||||
if (tournament == null)
|
|
||||||
throw new DraftFinishedException();
|
|
||||||
Draft draft = tournament.getDraft();
|
|
||||||
if (draft == null)
|
|
||||||
throw new DraftFinishedException();
|
|
||||||
draft.playerChosenCard(player.getName(), blueprintId);
|
|
||||||
} finally {
|
} finally {
|
||||||
_hallDataAccessLock.readLock().unlock();
|
_hallDataAccessLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user