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