refactor: consolidate checkSize() into getZoneSizeFor()

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@790 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-08-12 02:23:54 +00:00
parent 4e11a80a2a
commit 33cd0d02ed
2 changed files with 16 additions and 28 deletions

View file

@ -47,7 +47,7 @@ class Bulldozer extends ToolStroke
assert isZoneCenter(currTile);
eff.spend(1);
switch (checkSize(currTile))
switch (getZoneSizeFor(currTile))
{
case 3:
eff.makeSound(0, 0, Sound.EXPLOSION_HIGH);
@ -108,28 +108,4 @@ class Bulldozer extends ToolStroke
}
fixBorder(eff, w, h);
}
int checkSize(int tile)
{
tile = tile & LOMASK;
if ((tile >= (RESBASE-1) && tile <= (PORTBASE-1)) ||
(tile >= (LASTPOWERPLANT+1) && tile <= (POLICESTATION+4)))
{
return 3;
}
else if ((tile >= PORTBASE && tile <= LASTPORT) ||
(tile >= COALBASE && tile <= LASTPOWERPLANT) ||
(tile >= STADIUMBASE && tile <= LASTZONE))
{
return 4;
}
else if (tile == TileConstants.AIRPORT)
{
return 6;
}
else
{
return 0;
}
}
}

View file

@ -426,15 +426,27 @@ public class TileConstants
public static int getZoneSizeFor(int tile)
{
int ch = tile & LOMASK;
if (ch < PORTBASE) {
if (ch >= RESBASE && ch < PORTBASE) {
return 3;
}
else if (ch == AIRPORT) {
else if (ch >= PORTBASE && ch <= LASTPORT) {
return 4;
}
else if (ch >= AIRPORTBASE && ch < COALBASE) {
return 6;
}
else {
else if (ch >= COALBASE && ch <= LASTPOWERPLANT) {
return 4;
}
else if (ch >= FIRESTBASE && ch < STADIUMBASE) {
return 3;
}
else if (ch >= STADIUMBASE && ch <= LASTZONE) {
return 4;
}
else {
return 0;
}
}
public static boolean isConstructed(int tile)