Cleaning up some of the more egregrious exception infections. Adding the player collection conversion as a unit test, which should run when this is deployed into production.
This commit is contained in:
@@ -24,11 +24,15 @@ CREATE TABLE `collection_entries` (
|
||||
|
||||
SELECT *
|
||||
FROM collection c
|
||||
WHERE player_id = 31040
|
||||
WHERE player_id = 31040;
|
||||
|
||||
SELECT *
|
||||
FROM collection_entries
|
||||
WHERE collection_id = 64643
|
||||
WHERE collection_id = 59510;
|
||||
|
||||
SELECT *
|
||||
FROM collection_entries
|
||||
WHERE collection_id = 64643;
|
||||
|
||||
SELECT *
|
||||
FROM player p
|
||||
@@ -41,5 +45,13 @@ SELECT count(*)
|
||||
FROM collection_entries
|
||||
GROUP BY collection_id
|
||||
|
||||
SELECT TYPE
|
||||
FROM collection c
|
||||
GROUP BY type
|
||||
|
||||
SELECT *
|
||||
FROM transfer t
|
||||
ORDER BY ID DESC
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.gempukku.lotro.logic.timing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GameResultListener {
|
||||
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) throws SQLException, IOException;
|
||||
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons);
|
||||
|
||||
public void gameCancelled();
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class CollectionsManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, Player player, CollectionType collectionType, Iterable<CardCollection.Item> items, Map<String, Object> extraInformation) throws SQLException, IOException {
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, Player player, CollectionType collectionType, Iterable<CardCollection.Item> items, Map<String, Object> extraInformation){
|
||||
_readWriteLock.writeLock().lock();
|
||||
try {
|
||||
final CardCollection playerCollection = getPlayerCollection(player, collectionType.getCode());
|
||||
@@ -197,16 +197,18 @@ public class CollectionsManager {
|
||||
|
||||
_transferDAO.addTransferTo(notifyPlayer, player.getName(), reason, collectionType.getFullName(), 0, addedCards);
|
||||
}
|
||||
} catch (SQLException | IOException e) {
|
||||
throw new RuntimeException("Could not add items to player collection", e);
|
||||
} finally {
|
||||
_readWriteLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, Player player, CollectionType collectionType, Iterable<CardCollection.Item> items) throws SQLException, IOException {
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, Player player, CollectionType collectionType, Iterable<CardCollection.Item> items) {
|
||||
addItemsToPlayerCollection(notifyPlayer, reason, player, collectionType, items, null);
|
||||
}
|
||||
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, String player, CollectionType collectionType, Iterable<CardCollection.Item> items) throws SQLException, IOException {
|
||||
public void addItemsToPlayerCollection(boolean notifyPlayer, String reason, String player, CollectionType collectionType, Iterable<CardCollection.Item> items) {
|
||||
addItemsToPlayerCollection(notifyPlayer, reason, _playerDAO.getPlayer(player), collectionType, items);
|
||||
}
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ public class HallServer extends AbstractServer {
|
||||
if (league != null) {
|
||||
listener = new GameResultListener() {
|
||||
@Override
|
||||
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) throws SQLException, IOException {
|
||||
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) {
|
||||
_leagueService.reportLeagueGameResult(league, leagueSerie, winnerPlayerId, loserPlayerIdsWithReasons.keySet().iterator().next());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import com.gempukku.lotro.draft2.SoloDraft;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public interface LeagueData {
|
||||
@@ -19,5 +17,5 @@ public interface LeagueData {
|
||||
|
||||
CardCollection joinLeague(CollectionsManager collecionsManager, Player player, int currentTime);
|
||||
|
||||
int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) throws SQLException, IOException;
|
||||
int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class LeagueService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized void reportLeagueGameResult(League league, LeagueSerieData serie, String winner, String loser) throws SQLException, IOException {
|
||||
public synchronized void reportLeagueGameResult(League league, LeagueSerieData serie, String winner, String loser) {
|
||||
_leagueMatchDao.addPlayedMatch(league.getType(), serie.getName(), winner, loser);
|
||||
|
||||
_leagueStandings.remove(LeagueMapKeys.getLeagueMapKey(league));
|
||||
@@ -153,7 +153,7 @@ public class LeagueService {
|
||||
awardPrizesToPlayer(league, serie, loser, false);
|
||||
}
|
||||
|
||||
private void awardPrizesToPlayer(League league, LeagueSerieData serie, String player, boolean winner) throws SQLException, IOException {
|
||||
private void awardPrizesToPlayer(League league, LeagueSerieData serie, String player, boolean winner) {
|
||||
int count = 0;
|
||||
Collection<LeagueMatchResult> playerMatchesPlayedOn = getPlayerMatchesInSerie(league, serie, player);
|
||||
for (LeagueMatchResult leagueMatch : playerMatchesPlayedOn) {
|
||||
@@ -167,7 +167,8 @@ public class LeagueService {
|
||||
else
|
||||
prize = serie.getPrizeForLeagueMatchLoser(count, playerMatchesPlayedOn.size());
|
||||
if (prize != null)
|
||||
_collectionsManager.addItemsToPlayerCollection(true, "Prize for winning league game", player, CollectionType.MY_CARDS, prize.getAll());
|
||||
_collectionsManager.addItemsToPlayerCollection(true, "Prize for winning league game", player, CollectionType.MY_CARDS, prize.getAll());
|
||||
|
||||
}
|
||||
|
||||
public synchronized Collection<LeagueMatchResult> getPlayerMatchesInSerie(League league, LeagueSerieData serie, String player) {
|
||||
|
||||
@@ -9,8 +9,6 @@ import com.gempukku.lotro.draft2.SoloDraftDefinitions;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -90,7 +88,7 @@ public class SoloDraftLeagueData implements LeagueData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) throws SQLException, IOException {
|
||||
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
|
||||
int status = oldStatus;
|
||||
|
||||
if (status == 0) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gempukku.lotro.db.DbCollectionDAO;
|
||||
import com.gempukku.lotro.db.DbPlayerDAO;
|
||||
import com.gempukku.lotro.game.CardNotFoundException;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
@@ -23,7 +24,7 @@ public class NewCollectionManagerTests
|
||||
}
|
||||
|
||||
//This is probably never needed anymore now that it's been ran once
|
||||
//@Test
|
||||
@Test
|
||||
public void ConvertAllPlayerCollectionsTest() throws IOException, SQLException {
|
||||
var collDAO = new DbCollectionDAO(dbAccess, new CollectionSerializer());
|
||||
var playerDAO = new DbPlayerDAO(dbAccess);
|
||||
|
||||
Reference in New Issue
Block a user