From eb63e3817a6791d3f1af3e2dfc6cb0daa70ba04a Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Thu, 16 May 2013 23:42:21 +0000 Subject: [PATCH] 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 --- src/micropolisj/engine/TileConstants.java | 2 +- src/micropolisj/engine/ToolStroke.java | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/micropolisj/engine/TileConstants.java b/src/micropolisj/engine/TileConstants.java index 0a5db74..d98a8c5 100644 --- a/src/micropolisj/engine/TileConstants.java +++ b/src/micropolisj/engine/TileConstants.java @@ -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)); diff --git a/src/micropolisj/engine/ToolStroke.java b/src/micropolisj/engine/ToolStroke.java index a0f4f60..03daa4a 100644 --- a/src/micropolisj/engine/ToolStroke.java +++ b/src/micropolisj/engine/ToolStroke.java @@ -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)