updated map format to read time limit & max ZPM count needed to win
This commit is contained in:
parent
3be072e282
commit
d64fb27413
@ -5,10 +5,15 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Dungeon {
|
public class Dungeon {
|
||||||
|
private int ZPMsToWin = 0;
|
||||||
|
private long timeLimit = 0;
|
||||||
|
|
||||||
|
|
||||||
/* NOTE: this function assumes that the parameter input is a well-formatted dungeon file.
|
/* NOTE: this function assumes that the parameter input is a well-formatted dungeon file.
|
||||||
* Such file looks like as follows:
|
* Such file looks like as follows:
|
||||||
*
|
*
|
||||||
* <map width>x<map height>
|
* <map width>x<map height>
|
||||||
|
* <time limit in seconds>
|
||||||
* <empty line>
|
* <empty line>
|
||||||
* <map matrix line 1>
|
* <map matrix line 1>
|
||||||
* ...
|
* ...
|
||||||
@ -42,8 +47,9 @@ public class Dungeon {
|
|||||||
Tile replicatorlocation = defaultTile;
|
Tile replicatorlocation = defaultTile;
|
||||||
try(BufferedReader reader = new BufferedReader(new FileReader(input)))
|
try(BufferedReader reader = new BufferedReader(new FileReader(input)))
|
||||||
{
|
{
|
||||||
String[] sizedata = reader.readLine().split("x"); // read size data at beginning of file
|
String[] sizedata = reader.readLine().split("x"); // read size data at beginning of file
|
||||||
reader.readLine(); // throw empty line away
|
timeLimit = Long.parseLong(reader.readLine()) * 1000; // read time limit
|
||||||
|
reader.readLine(); // throw empty line away
|
||||||
int width = Integer.parseInt(sizedata[0]);
|
int width = Integer.parseInt(sizedata[0]);
|
||||||
int height = Integer.parseInt(sizedata[1]);
|
int height = Integer.parseInt(sizedata[1]);
|
||||||
|
|
||||||
@ -75,6 +81,7 @@ public class Dungeon {
|
|||||||
tile = new Field();
|
tile = new Field();
|
||||||
display.addVisual(new FieldDrawer((Field) tile));
|
display.addVisual(new FieldDrawer((Field) tile));
|
||||||
tile.setZPMOnTile(new ZPM());
|
tile.setZPMOnTile(new ZPM());
|
||||||
|
ZPMsToWin++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'B':
|
case 'B':
|
||||||
@ -181,4 +188,12 @@ public class Dungeon {
|
|||||||
|
|
||||||
return playermap;
|
return playermap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getZPMsToWin() {
|
||||||
|
return ZPMsToWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeLimit() {
|
||||||
|
return timeLimit;
|
||||||
|
}
|
||||||
}
|
}
|
@ -50,7 +50,7 @@ public class Game {
|
|||||||
display.addVisual(new PlayerDrawer(jaffa));
|
display.addVisual(new PlayerDrawer(jaffa));
|
||||||
display.addVisual(new PlayerBaseDrawer(replicator));
|
display.addVisual(new PlayerBaseDrawer(replicator));
|
||||||
|
|
||||||
flowoftime.start(420*420);
|
flowoftime.start(dungeon.getTimeLimit());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Direction getRandomDirection() {
|
private Direction getRandomDirection() {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
5x5
|
5x5
|
||||||
|
10
|
||||||
|
|
||||||
W W W W W
|
W W W W W
|
||||||
W O B S W
|
W O B S W
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
5x5
|
5x5
|
||||||
|
5
|
||||||
|
|
||||||
W W W W W
|
W W W W W
|
||||||
W F F F W
|
W F F F W
|
||||||
|
Loading…
Reference in New Issue
Block a user