- "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.
This commit is contained in:
marcins78@gmail.com
2012-04-24 11:48:00 +00:00
parent 87f6e96a2b
commit 22812b1d38
5 changed files with 80 additions and 44 deletions

View File

@@ -45,7 +45,8 @@ public class Card3_106 extends AbstractAttachableFPPossession {
@Override
public List<RequiredTriggerAction> 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));

View File

@@ -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<String> cards, LotroCardBlueprintLibrary library) {
for (String blueprintId : cards) {
PhysicalCardImpl physicalCard = createPhysicalCard(playerId, library, blueprintId);

View File

@@ -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);
}

View File

@@ -14,64 +14,42 @@ public class PlayerDAO {
private final String validLoginChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
private DbAccess _dbAccess;
private Map<String, Player> _players = new ConcurrentHashMap<String, Player>();
private Map<String, Player> _playersByName = new ConcurrentHashMap<String, Player>();
private Map<Integer, Player> _playersById = new ConcurrentHashMap<Integer, Player>();
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=?");

View File

@@ -1,4 +1,8 @@
<pre style="font-size:80%">
<b>24 Apr. 2012</b>
- "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.
<b>23 Apr. 2012</b>
- 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).