Clearing queues, when server goes down.
This commit is contained in:
@@ -226,6 +226,10 @@ public class CollectionsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCurrencyToPlayerCollection(String player, CollectionType collectionType, int currency) {
|
||||||
|
addCurrencyToPlayerCollection(_playerDAO.getPlayer(player), collectionType, currency);
|
||||||
|
}
|
||||||
|
|
||||||
public void addCurrencyToPlayerCollection(Player player, CollectionType collectionType, int currency) {
|
public void addCurrencyToPlayerCollection(Player player, CollectionType collectionType, int currency) {
|
||||||
_readWriteLock.writeLock().lock();
|
_readWriteLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ public class HallServer extends AbstractServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cancelTournamentQueues() {
|
private void cancelTournamentQueues() {
|
||||||
|
for (TournamentQueue tournamentQueue : _tournamentQueues.values())
|
||||||
|
tournamentQueue.leaveAllPlayers(_collectionsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,6 +161,9 @@ public class HallServer extends AbstractServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinQueue(String queueId, Player player, String deckName) throws HallException {
|
public boolean joinQueue(String queueId, Player player, String deckName) throws HallException {
|
||||||
|
if (_shutdown)
|
||||||
|
throw new HallException("Server is in shutdown mode. Server will be restarted after all running games are finished.");
|
||||||
|
|
||||||
_hallDataAccessLock.writeLock().lock();
|
_hallDataAccessLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
if (isPlayerBusy(player.getName()))
|
if (isPlayerBusy(player.getName()))
|
||||||
@@ -185,6 +189,9 @@ public class HallServer extends AbstractServer {
|
|||||||
* @return If table joined, otherwise <code>false</code> (if the user already is sitting at a table or playing).
|
* @return If table joined, otherwise <code>false</code> (if the user already is sitting at a table or playing).
|
||||||
*/
|
*/
|
||||||
public boolean joinTableAsPlayer(String tableId, Player player, String deckName) throws HallException {
|
public boolean joinTableAsPlayer(String tableId, Player player, String deckName) throws HallException {
|
||||||
|
if (_shutdown)
|
||||||
|
throw new HallException("Server is in shutdown mode. Server will be restarted after all running games are finished.");
|
||||||
|
|
||||||
_hallDataAccessLock.writeLock().lock();
|
_hallDataAccessLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
if (isPlayerBusy(player.getName()))
|
if (isPlayerBusy(player.getName()))
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void leaveAllPlayers(CollectionsManager collectionsManager) {
|
||||||
|
if (_cost > 0) {
|
||||||
|
for (String player : _playerDecks.keySet())
|
||||||
|
collectionsManager.addCurrencyToPlayerCollection(player, _currencyCollection, _cost);
|
||||||
|
}
|
||||||
|
_playerDecks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isPlayerSignedUp(String player) {
|
public synchronized boolean isPlayerSignedUp(String player) {
|
||||||
return _playerDecks.containsKey(player);
|
return _playerDecks.containsKey(player);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public interface TournamentQueue {
|
|||||||
|
|
||||||
public void leavePlayer(CollectionsManager collectionsManager, Player player);
|
public void leavePlayer(CollectionsManager collectionsManager, Player player);
|
||||||
|
|
||||||
|
public void leaveAllPlayers(CollectionsManager collectionsManager);
|
||||||
|
|
||||||
public int getPlayerCount();
|
public int getPlayerCount();
|
||||||
|
|
||||||
public boolean isPlayerSignedUp(String player);
|
public boolean isPlayerSignedUp(String player);
|
||||||
|
|||||||
Reference in New Issue
Block a user