reimplemented most of buildDungeon: terrible code is now less terrible
This commit is contained in:
parent
df953dc6fc
commit
1d2171b713
@ -28,7 +28,9 @@ public class Dungeon {
|
||||
* O: Field with ONeill
|
||||
* J: Field with Jaffa
|
||||
* G: Gate
|
||||
* S: Scale */
|
||||
* S: Scale
|
||||
* X: Gap
|
||||
* R: Replicator */
|
||||
Map<String, Tile> buildDungeon(File input) throws IOException
|
||||
{
|
||||
Tile oneilllocation = null;
|
||||
@ -52,59 +54,57 @@ public class Dungeon {
|
||||
line = reader.readLine().replaceAll("\\s",""); // read line and remove whitespaces
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
Tile tile = null;
|
||||
switch (line.charAt(x)) // set the dungeon up
|
||||
{
|
||||
case 'W':
|
||||
dungeon[y][x] = new Wall();
|
||||
tile = new Wall();
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
dungeon[y][x] = new Field();
|
||||
tile = new Field();
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
Field zpmfield = new Field();
|
||||
zpmfield.setZPMOnTile(new ZPM());
|
||||
dungeon[y][x] = zpmfield;
|
||||
tile = new Field();
|
||||
tile.setZPMOnTile(new ZPM());
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
Field boxfield = new Field();
|
||||
boxfield.putABox(new Box());
|
||||
dungeon[y][x] = boxfield;
|
||||
tile = new Field();
|
||||
tile.putABox(new Box());
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
Field oneillfield = new Field();
|
||||
dungeon[y][x] = oneillfield;
|
||||
oneilllocation = oneillfield;
|
||||
tile = new Field();
|
||||
oneilllocation = tile;
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
Field jaffafield = new Field();
|
||||
dungeon[y][x] = jaffafield;
|
||||
jaffalocation = jaffafield;
|
||||
tile = new Field();
|
||||
jaffalocation = tile;
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
dungeon[y][x] = tempgate;
|
||||
tile = tempgate;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
dungeon[y][x] = tempscale;
|
||||
tile = tempscale;
|
||||
scalecount++;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
dungeon[y][x] = new Gap();
|
||||
tile = new Gap();
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
Field replicatorfield = new Field();
|
||||
dungeon[y][x] = replicatorfield;
|
||||
replicatorlocation = replicatorfield;
|
||||
tile = new Field();
|
||||
replicatorlocation = tile;
|
||||
break;
|
||||
}
|
||||
tile.setY(y); tile.setX(x);
|
||||
dungeon[y][x] = tile;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,9 +114,21 @@ public class Dungeon {
|
||||
{
|
||||
String[] scaledata = reader.readLine().split("-");
|
||||
|
||||
dungeon[Integer.parseInt(scaledata[0])][Integer.parseInt(scaledata[1])] =
|
||||
new Scale((Gate)dungeon[Integer.parseInt(scaledata[2])][Integer.parseInt(scaledata[3])],
|
||||
Integer.parseInt(scaledata[4]));
|
||||
int sy = Integer.parseInt(scaledata[0]);
|
||||
int sx = Integer.parseInt(scaledata[1]);
|
||||
int gy = Integer.parseInt(scaledata[2]);
|
||||
int gx = Integer.parseInt(scaledata[3]);
|
||||
int triggerweight = Integer.parseInt(scaledata[4]);
|
||||
|
||||
Gate gate = new Gate();
|
||||
gate.setY(gy);
|
||||
gate.setX(gx);
|
||||
|
||||
Scale scale = new Scale(gate, triggerweight);
|
||||
scale.setY(sy);
|
||||
scale.setX(sx);
|
||||
|
||||
dungeon[sy][sx] = scale;
|
||||
}
|
||||
|
||||
/* setting up Tile cross references */
|
||||
|
Loading…
Reference in New Issue
Block a user