|
From: <ev...@us...> - 2010-12-22 20:56:56
|
Revision: 1463
http://rails.svn.sourceforge.net/rails/?rev=1463&view=rev
Author: evos
Date: 2010-12-22 20:56:50 +0000 (Wed, 22 Dec 2010)
Log Message:
-----------
Fixed a problem where in 18EU minors were allowed to lay green tiles (bug #3064831).
This was caused by the LayTile object have a tileColour allowance map entry {green=0}.
This entry shouldn't have existed, but zero values weren't checked for anywhere either.
This is now checked in two places.
Modified Paths:
--------------
trunk/18xx/rails/game/action/LayTile.java
trunk/18xx/rails/ui/swing/UpgradesPanel.java
Modified: trunk/18xx/rails/game/action/LayTile.java
===================================================================
--- trunk/18xx/rails/game/action/LayTile.java 2010-12-18 21:42:03 UTC (rev 1462)
+++ trunk/18xx/rails/game/action/LayTile.java 2010-12-22 20:56:50 UTC (rev 1463)
@@ -84,7 +84,7 @@
public LayTile(Map<String, Integer> tileColours) {
type = GENERIC;
- this.tileColours = tileColours;
+ setTileColours (tileColours);
}
public LayTile(SpecialTileLay specialProperty) {
@@ -189,11 +189,19 @@
}
public boolean isTileColourAllowed(String tileColour) {
- return tileColours.containsKey(tileColour);
+ return tileColours != null
+ && tileColours.containsKey(tileColour)
+ && tileColours.get(tileColour) > 0;
}
public void setTileColours(Map<String, Integer> map) {
- tileColours = map;
+ tileColours = new HashMap<String, Integer>();
+ // Check the map. Sometimes 0 values creep in, and these can't easily
+ // be intercepted in the UI code (see comment at previous method).
+ // TODO This is a dirty fix, but the quickest one too.
+ for (String colourName : map.keySet()) {
+ if (map.get(colourName) > 0) tileColours.put(colourName, map.get(colourName));
+ }
}
Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java
===================================================================
--- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-18 21:42:03 UTC (rev 1462)
+++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-22 20:56:50 UTC (rev 1463)
@@ -91,17 +91,25 @@
for (LayTile layTile : hexMap.getTileAllowancesForHex(hex)) {
tiles = layTile.getTiles();
- if (tiles == null) {
+ if (tiles == null) {
for (TileI tile : uiHex.getCurrentTile().getValidUpgrades(hex,
orUIManager.gameUIManager.getCurrentPhase())) {
+ // Skip if not allowed in LayTile
+ if (!layTile.isTileColourAllowed(tile.getColourName())) continue;
+
if (!orUIManager.tileUpgrades.contains(tile))
orUIManager.tileUpgrades.add(tile);
}
} else {
for (TileI tile : tiles) {
+ // Skip if not allowed in LayTile
+ if (layTile.getTileColours().get(tile.getColourName()) < 1) continue;
+
// special check: does the tile increase the colour number?
// this avoids that a special tile lay down or equalgrades existing tiles
- if (tile.getColourNumber() <= uiHex.getCurrentTile().getColourNumber()) continue;
+ // TODO EV: I'm not sure if this is a necessary precaution.
+ if (!layTile.isTileColourAllowed(tile.getColourName())) continue;
+
if (!orUIManager.tileUpgrades.contains(tile))
orUIManager.tileUpgrades.add(tile);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|