From 22812b1d38864636a637f155746fbe39f98c981a Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Tue, 24 Apr 2012 11:48:00 +0000 Subject: [PATCH] - "Bill the Pony" no longer is discarded when moving to Underground site, before it decreases the shadow number of the site, when adding twilight for moving. --- .../lotro/cards/set3/shire/Card3_106.java | 3 +- .../gempukku/lotro/game/state/GameState.java | 9 ++ .../turn/move/MovementGameProcess.java | 14 +++ .../java/com/gempukku/lotro/db/PlayerDAO.java | 94 ++++++++++--------- .../src/main/webapp/includes/changeLog.html | 4 + 5 files changed, 80 insertions(+), 44 deletions(-) diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set3/shire/Card3_106.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set3/shire/Card3_106.java index 0aed35436..55922e82f 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set3/shire/Card3_106.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set3/shire/Card3_106.java @@ -45,7 +45,8 @@ public class Card3_106 extends AbstractAttachableFPPossession { @Override public List getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) { - if (game.getModifiersQuerying().hasKeyword(game.getGameState(), game.getGameState().getCurrentSite(), Keyword.UNDERGROUND)) { + if (!game.getGameState().isMoving() + && game.getModifiersQuerying().hasKeyword(game.getGameState(), game.getGameState().getCurrentSite(), Keyword.UNDERGROUND)) { RequiredTriggerAction action = new RequiredTriggerAction(self); action.appendEffect( new SelfDiscardEffect(self)); diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java index 21ac914a4..f4450bb9f 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java @@ -33,6 +33,7 @@ public class GameState { private int _twilightPool; private int _moveCount; + private boolean _moving; private boolean _fierceSkirmishes; private boolean _extraSkirmishes; @@ -90,6 +91,14 @@ public class GameState { listener.setPlayerOrder(playerOrder.getAllPlayers()); } + public boolean isMoving() { + return _moving; + } + + public void setMoving(boolean moving) { + _moving = moving; + } + private void addPlayerCards(String playerId, List cards, LotroCardBlueprintLibrary library) { for (String blueprintId : cards) { PhysicalCardImpl physicalCard = createPhysicalCard(playerId, library, blueprintId); diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/processes/turn/move/MovementGameProcess.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/processes/turn/move/MovementGameProcess.java index 6f2ef3b06..dcfe17441 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/processes/turn/move/MovementGameProcess.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/processes/turn/move/MovementGameProcess.java @@ -28,6 +28,13 @@ public class MovementGameProcess implements GameProcess { public void process(LotroGame game) { PhysicalCard currentSite = game.getGameState().getCurrentSite(); final SystemQueueAction action = new SystemQueueAction(); + action.appendEffect( + new UnrespondableEffect() { + @Override + protected void doPlayEffect(LotroGame game) { + game.getGameState().setMoving(true); + } + }); action.appendEffect( new UnrespondableEffect() { @Override @@ -90,6 +97,13 @@ public class MovementGameProcess implements GameProcess { action.insertEffect(effect); } }); + action.appendEffect( + new UnrespondableEffect() { + @Override + protected void doPlayEffect(LotroGame game) { + game.getGameState().setMoving(false); + } + }); game.getActionsEnvironment().addActionToStack(action); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/PlayerDAO.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/PlayerDAO.java index a63fd0dc0..87c73a972 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/PlayerDAO.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/PlayerDAO.java @@ -14,64 +14,42 @@ public class PlayerDAO { private final String validLoginChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"; private DbAccess _dbAccess; - private Map _players = new ConcurrentHashMap(); + private Map _playersByName = new ConcurrentHashMap(); + private Map _playersById = new ConcurrentHashMap(); public PlayerDAO(DbAccess dbAccess) { _dbAccess = dbAccess; } public void clearCache() { - _players.clear(); + _playersByName.clear(); + _playersById.clear(); } public Player getPlayer(int id) { - try { - Connection conn = _dbAccess.getDataSource().getConnection(); - try { - PreparedStatement statement = conn.prepareStatement("select id, name, type, last_login_reward from player where id=?"); - try { - statement.setInt(1, id); - ResultSet rs = statement.executeQuery(); - try { - if (rs.next()) { - String name = rs.getString(2); - String type = rs.getString(3); - Integer lastLoginReward = rs.getInt(4); - if (rs.wasNull()) - lastLoginReward = null; + if (_playersById.containsKey(id)) + return _playersById.get(id); - return new Player(id, name, type, lastLoginReward); - } else { - return null; - } - } finally { - rs.close(); - } - } finally { - statement.close(); - } - } finally { - conn.close(); - } + try { + final Player player = getPlayerFromDBById(id); + if (player != null) + _playersById.put(id, player); + return player; } catch (SQLException exp) { throw new RuntimeException("Error while retrieving player", exp); } } public Player getPlayer(String playerName) { - if (_players.containsKey(playerName)) - return _players.get(playerName); - else { - try { - Player player = getPlayerFromDB(playerName); - if (player != null) { - _players.put(playerName, player); - return player; - } else - return null; - } catch (SQLException exp) { - throw new RuntimeException("Unable to get player from DB", exp); - } + if (_playersByName.containsKey(playerName)) + return _playersByName.get(playerName); + try { + Player player = getPlayerFromDBByName(playerName); + if (player != null) + _playersByName.put(playerName, player); + return player; + } catch (SQLException exp) { + throw new RuntimeException("Unable to get player from DB", exp); } } @@ -222,7 +200,37 @@ public class PlayerDAO { return hexString.toString(); } - private Player getPlayerFromDB(String playerName) throws SQLException { + private Player getPlayerFromDBById(int id) throws SQLException { + Connection conn = _dbAccess.getDataSource().getConnection(); + try { + PreparedStatement statement = conn.prepareStatement("select id, name, type, last_login_reward from player where id=?"); + try { + statement.setInt(1, id); + ResultSet rs = statement.executeQuery(); + try { + if (rs.next()) { + String name = rs.getString(2); + String type = rs.getString(3); + Integer lastLoginReward = rs.getInt(4); + if (rs.wasNull()) + lastLoginReward = null; + + return new Player(id, name, type, lastLoginReward); + } else { + return null; + } + } finally { + rs.close(); + } + } finally { + statement.close(); + } + } finally { + conn.close(); + } + } + + private Player getPlayerFromDBByName(String playerName) throws SQLException { Connection conn = _dbAccess.getDataSource().getConnection(); try { PreparedStatement statement = conn.prepareStatement("select id, name, type, last_login_reward from player where name=?"); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html index c11a4e25c..335f0a032 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html @@ -1,4 +1,8 @@
+24 Apr. 2012
+- "Bill the Pony" no longer is discarded when moving to Underground site, before it decreases the shadow number of the
+site, when adding twilight for moving.
+
 23 Apr. 2012
 - Adding 0 threats is now possible and legal, hence playing "Plotting" will not fail now, if you can't add any threats
 anymore (number of threats is equal to or greater than number of companions).