ToolStroke: update Park tool to use new ToolEffect class

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@632 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-05-16 23:42:21 +00:00
parent b3522c514c
commit eb63e3817a
2 changed files with 9 additions and 12 deletions

View file

@ -323,7 +323,7 @@ public class TileConstants
}
}
public static boolean isRubble(char cell)
public static boolean isRubble(int cell)
{
return (((cell & LOMASK) >= RUBBLE) &&
((cell & LOMASK) <= LASTRUBBLE));

View file

@ -411,18 +411,18 @@ public class ToolStroke
ToolResult applyParkTool(int xpos, int ypos)
{
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
ToolEffect eff = new ToolEffect(city, xpos, ypos);
int cost = tool.getToolCost();
if (city.getTile(xpos, ypos) != DIRT) {
if (eff.getTile(0, 0) != DIRT) {
// some sort of bulldozing is necessary
if (!city.autoBulldoze) {
return ToolResult.UH_OH;
}
if (isRubble(city.getTile(xpos, ypos))) {
//FIXME- use a canAutoBulldoze-style function here
if (isRubble(eff.getTile(0, 0))) {
// this tile can be auto-bulldozed
cost++;
}
@ -432,10 +432,6 @@ public class ToolStroke
}
}
if (city.budget.totalFunds < cost) {
return ToolResult.INSUFFICIENT_FUNDS;
}
int z = city.PRNG.nextInt(5);
int tile;
if (z < 4) {
@ -444,9 +440,10 @@ public class ToolStroke
tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT;
}
city.spend(cost);
city.setTile(xpos, ypos, (char) tile);
return ToolResult.SUCCESS;
eff.spend(cost);
eff.setTile(0, 0, tile);
return eff.apply();
}
static char neutralizeRoad(char tile)