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:
parent
b3522c514c
commit
eb63e3817a
2 changed files with 9 additions and 12 deletions
src/micropolisj/engine
|
@ -323,7 +323,7 @@ public class TileConstants
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRubble(char cell)
|
public static boolean isRubble(int cell)
|
||||||
{
|
{
|
||||||
return (((cell & LOMASK) >= RUBBLE) &&
|
return (((cell & LOMASK) >= RUBBLE) &&
|
||||||
((cell & LOMASK) <= LASTRUBBLE));
|
((cell & LOMASK) <= LASTRUBBLE));
|
||||||
|
|
|
@ -411,18 +411,18 @@ public class ToolStroke
|
||||||
|
|
||||||
ToolResult applyParkTool(int xpos, int ypos)
|
ToolResult applyParkTool(int xpos, int ypos)
|
||||||
{
|
{
|
||||||
if (!city.testBounds(xpos, ypos))
|
ToolEffect eff = new ToolEffect(city, xpos, ypos);
|
||||||
return ToolResult.UH_OH;
|
|
||||||
|
|
||||||
int cost = tool.getToolCost();
|
int cost = tool.getToolCost();
|
||||||
|
|
||||||
if (city.getTile(xpos, ypos) != DIRT) {
|
if (eff.getTile(0, 0) != DIRT) {
|
||||||
// some sort of bulldozing is necessary
|
// some sort of bulldozing is necessary
|
||||||
if (!city.autoBulldoze) {
|
if (!city.autoBulldoze) {
|
||||||
return ToolResult.UH_OH;
|
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
|
// this tile can be auto-bulldozed
|
||||||
cost++;
|
cost++;
|
||||||
}
|
}
|
||||||
|
@ -432,10 +432,6 @@ public class ToolStroke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (city.budget.totalFunds < cost) {
|
|
||||||
return ToolResult.INSUFFICIENT_FUNDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int z = city.PRNG.nextInt(5);
|
int z = city.PRNG.nextInt(5);
|
||||||
int tile;
|
int tile;
|
||||||
if (z < 4) {
|
if (z < 4) {
|
||||||
|
@ -444,9 +440,10 @@ public class ToolStroke
|
||||||
tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT;
|
tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
city.spend(cost);
|
eff.spend(cost);
|
||||||
city.setTile(xpos, ypos, (char) tile);
|
eff.setTile(0, 0, tile);
|
||||||
return ToolResult.SUCCESS;
|
|
||||||
|
return eff.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
static char neutralizeRoad(char tile)
|
static char neutralizeRoad(char tile)
|
||||||
|
|
Reference in a new issue