Merge branch 'master' of https://github.com/bokrosbalint/cicaprojekt
This commit is contained in:
commit
296fa45c54
5
ZPMTest.dungeon
Normal file
5
ZPMTest.dungeon
Normal file
@ -0,0 +1,5 @@
|
||||
4x3
|
||||
|
||||
W W W W
|
||||
W O Z W
|
||||
W W W W
|
@ -28,11 +28,18 @@ 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;
|
||||
Tile jaffalocation = null;
|
||||
Tile defaultTile = new Field();
|
||||
defaultTile.setX(-666);
|
||||
defaultTile.setY(-666);
|
||||
|
||||
Tile oneilllocation = defaultTile;
|
||||
Tile jaffalocation = defaultTile;
|
||||
Tile replicatorlocation = defaultTile;
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(input)))
|
||||
{
|
||||
String[] sizedata = reader.readLine().split("x"); // read size data at beginning of file
|
||||
@ -51,49 +58,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':
|
||||
tile = new Gap();
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
tile = new Field();
|
||||
replicatorlocation = tile;
|
||||
break;
|
||||
}
|
||||
tile.setY(y); tile.setX(x);
|
||||
dungeon[y][x] = tile;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +118,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 */
|
||||
@ -139,6 +166,7 @@ public class Dungeon {
|
||||
Map<String, Tile> playermap = new HashMap<>();
|
||||
playermap.put("oneill", oneilllocation);
|
||||
playermap.put("jaffa", jaffalocation);
|
||||
playermap.put("replicator", replicatorlocation);
|
||||
|
||||
return playermap;
|
||||
}
|
||||
|
@ -1,129 +1,65 @@
|
||||
package cicaprojekt;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class Menu {
|
||||
public static String tabulator = "\t";
|
||||
|
||||
|
||||
public static void addTab() {
|
||||
tabulator += '\t';
|
||||
}
|
||||
|
||||
public static void removeTab() {
|
||||
tabulator = tabulator.substring(0, tabulator.length() - 1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
System.out.println("Continuously Integrated Cica Projekt - Skeleton");
|
||||
public static void main(String[] args) throws IOException, InvocationTargetException, IllegalAccessException {
|
||||
System.out.println("Continuously Integrated Cica Projekt - Proto");
|
||||
System.out.println("Üdvözöllek a Babylon Simulator 2000 játékban! Kérlek válassz egy menüpontot!");
|
||||
|
||||
Tester tester = new Tester();
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
boolean isExiting = false;
|
||||
while (!isExiting) {
|
||||
System.out.println("1. Lépés");
|
||||
System.out.println("2. Doboz felvétele");
|
||||
System.out.println("3. Doboz lerakása");
|
||||
System.out.println("4. Elforgatás");
|
||||
System.out.println("5. Nézés");
|
||||
System.out.println("6. Csillagkapu lövés");
|
||||
System.out.println("X. Kilépés");
|
||||
|
||||
Player oNeill = new Player(new Field(), Direction.NORTH);
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case '1':
|
||||
System.out.println("O’Neill [északi|nyugati|déli|keleti] irányba lép egyet,");
|
||||
System.out.println("Elfogadott bemenet: W, A, S, D");
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'W':
|
||||
oNeill.move(Direction.NORTH);
|
||||
try {
|
||||
String[] input = br.readLine().split(" ");
|
||||
switch (input[0]) {
|
||||
case "loadMap":
|
||||
tester.loadMap(input[1]);
|
||||
break;
|
||||
case 'A':
|
||||
oNeill.move(Direction.WEST);
|
||||
case "listPlayers":
|
||||
System.out.println(tester.listPlayers());
|
||||
break;
|
||||
case 'S':
|
||||
oNeill.move(Direction.SOUTH);
|
||||
case "move":
|
||||
tester.move(input[1]);
|
||||
break;
|
||||
case 'D':
|
||||
oNeill.move(Direction.EAST);
|
||||
case "boxLift":
|
||||
System.out.println(tester.boxLift(input[1]));
|
||||
break;
|
||||
case 'X':
|
||||
case "boxDrop":
|
||||
System.out.println(tester.boxDrop(input[1]));
|
||||
break;
|
||||
}
|
||||
case "shootONeillsGun":
|
||||
tester.shootONeillsGun(input[1]);
|
||||
break;
|
||||
case '2':
|
||||
System.out.println("Doboz felvétele");
|
||||
System.out.println("Elfogadott bemenet: L");
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'L':
|
||||
oNeill.boxLift();
|
||||
case "rotate":
|
||||
tester.rotate(input[1], input[2]);
|
||||
break;
|
||||
case 'X':
|
||||
case "listStargates":
|
||||
System.out.println(tester.listStargates());
|
||||
break;
|
||||
}
|
||||
case "runAllTests":
|
||||
boolean testresult = tester.runAllTests();
|
||||
if (testresult)
|
||||
System.out.println("All tests successful!");
|
||||
else
|
||||
System.out.println("Tests failed!");
|
||||
break;
|
||||
case '3':
|
||||
System.out.println("Doboz lerakása");
|
||||
System.out.println("Elfogadott bemenet: D");
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'D':
|
||||
oNeill.boxDrop();
|
||||
break;
|
||||
case 'X':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
System.out.println("Elforgás");
|
||||
System.out.println("Elfogadott bemenet: L, R");
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'L':
|
||||
oNeill.rotateLeft();
|
||||
break;
|
||||
case 'D':
|
||||
oNeill.rotateRight();
|
||||
break;
|
||||
case 'X':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
System.out.println("Nézés");
|
||||
System.out.println("Elfogadott bemenet: W");
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'W':
|
||||
Tile t = oNeill.getCurrentTile().getAdjacentTile(oNeill.getFacingDirection());
|
||||
System.out.println("O'Neill előtt egy " + t.toString() + "mező található");
|
||||
break;
|
||||
case 'X':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '6':
|
||||
System.out.println("Csillagkapu lövés");
|
||||
System.out.println("Elfogadott bemenet: Y, B");
|
||||
Tile t = oNeill.getCurrentTile();
|
||||
switch (sc.nextLine().charAt(0)) {
|
||||
case 'Y':
|
||||
t.spawnStargate(Stargate.yellowStargate, oNeill.getFacingDirection());
|
||||
break;
|
||||
case 'B':
|
||||
t.spawnStargate(Stargate.blueStargate, oNeill.getFacingDirection());
|
||||
break;
|
||||
case 'X':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'X':
|
||||
System.out.println("Kilépés");
|
||||
case "exit":
|
||||
isExiting = true;
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//TODO not so granular error handling
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,9 @@ public class Player extends PlayerBase {
|
||||
private Box boxLifted;
|
||||
|
||||
|
||||
public Player(Tile startTile, Direction startDirection) {
|
||||
public Player(String name, Tile startTile, Direction startDirection) {
|
||||
super(name, startTile, startDirection);
|
||||
zpmContainer = new ArrayList<>();
|
||||
currentTile = startTile;
|
||||
facingDirection = startDirection; /* Be lehetne állítani egy defaultot is, nem tudom, mennyire kéne */
|
||||
}
|
||||
|
||||
public void boxLift() {
|
||||
@ -31,4 +30,8 @@ public class Player extends PlayerBase {
|
||||
public void shootStargate(Stargate stargate) {
|
||||
this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection);
|
||||
}
|
||||
|
||||
public int getZPMCount(){
|
||||
return zpmContainer.size();
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,23 @@ public class PlayerBase implements Destroyable {
|
||||
protected Game game;
|
||||
protected Tile currentTile;
|
||||
protected Direction facingDirection;
|
||||
protected String name;
|
||||
protected boolean destroyed;
|
||||
|
||||
public PlayerBase(String name, Tile startTile, Direction startDirection) {
|
||||
this.name = name;
|
||||
currentTile = startTile;
|
||||
facingDirection = startDirection;
|
||||
destroyed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s: %s", name, currentTile);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
destroyed = true;
|
||||
}
|
||||
|
||||
public Tile getCurrentTile() {
|
||||
@ -67,4 +81,8 @@ public class PlayerBase implements Destroyable {
|
||||
public void setFacingDirection(Direction direction) {
|
||||
facingDirection = direction;
|
||||
}
|
||||
|
||||
public boolean isDestroyed(){
|
||||
return destroyed;
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,8 @@ public class Scale extends Field {
|
||||
else
|
||||
gateConnected.setOpen(false);
|
||||
}
|
||||
|
||||
public Gate getGateConnected() {
|
||||
return gateConnected;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,19 @@
|
||||
package cicaprojekt;
|
||||
|
||||
public class Stargate {
|
||||
public static final Stargate yellowStargate = new Stargate();
|
||||
public static final Stargate blueStargate = new Stargate();
|
||||
public static final Stargate redStargate = new Stargate();
|
||||
public static final Stargate greenStargate = new Stargate();
|
||||
public static final Stargate yellowStargate = new Stargate("Yellow Stargate");
|
||||
public static final Stargate blueStargate = new Stargate("Blue Stargate");
|
||||
public static final Stargate redStargate = new Stargate("Red Stargate");
|
||||
public static final Stargate greenStargate = new Stargate("Green Stargate");
|
||||
public /*final*/ Stargate other; //TODO find better ways to do this
|
||||
private boolean isSpawned;
|
||||
private Wall currentWall;
|
||||
private String name;
|
||||
|
||||
|
||||
private Stargate() {
|
||||
private Stargate(String name) {
|
||||
isSpawned = false;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
@ -27,12 +29,37 @@ public class Stargate {
|
||||
|
||||
public void setCurrentWall(Wall wall) {
|
||||
currentWall = wall;
|
||||
if(wall != null) {
|
||||
isSpawned = true;
|
||||
}
|
||||
else {
|
||||
isSpawned = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return isSpawned;
|
||||
return isSpawned & other.isSpawned;
|
||||
}
|
||||
|
||||
public void teleport(Direction incomingDirection) {
|
||||
private Direction getExitDirection() {
|
||||
if(currentWall.getAdjacentTile(Direction.EAST) == null)
|
||||
return Direction.WEST;
|
||||
else if(currentWall.getAdjacentTile(Direction.WEST) == null)
|
||||
return Direction.EAST;
|
||||
else if(currentWall.getAdjacentTile(Direction.NORTH) == null)
|
||||
return Direction.SOUTH;
|
||||
else
|
||||
return Direction.NORTH;
|
||||
}
|
||||
|
||||
public void teleport(PlayerBase player) {
|
||||
player.setCurrentTile(other.getCurrentWall().getAdjacentTile(getExitDirection()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(isSpawned)
|
||||
return String.format("%s: %s", name, currentWall);
|
||||
else return String.format("%s: not spawned", name, currentWall);
|
||||
}
|
||||
}
|
||||
|
286
cicaprojekt/Tester.java
Normal file
286
cicaprojekt/Tester.java
Normal file
@ -0,0 +1,286 @@
|
||||
package cicaprojekt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
public class Tester {
|
||||
private Player oneill;
|
||||
private Player jaffa;
|
||||
private PlayerBase replicator;
|
||||
|
||||
|
||||
Dungeon loadMap(String param) throws IOException{
|
||||
Dungeon dungeon = new Dungeon();
|
||||
Map playerLocations = dungeon.buildDungeon(new File(param));
|
||||
oneill = new Player("ONeill", (Tile) playerLocations.get("oneill"), Direction.NORTH);
|
||||
jaffa = new Player("Jaffa", (Tile) playerLocations.get("jaffa"), Direction.NORTH);
|
||||
replicator = new PlayerBase("Replicator", (Tile) playerLocations.get("replicator"), Direction.NORTH);
|
||||
return dungeon;
|
||||
}
|
||||
|
||||
String listPlayers() {
|
||||
return oneill.toString() + " " + jaffa.toString() + " " + replicator.toString();
|
||||
}
|
||||
|
||||
void move(String param) {
|
||||
switch (param) {
|
||||
case "O" :
|
||||
oneill.move(oneill.getFacingDirection());
|
||||
break;
|
||||
case "J" :
|
||||
jaffa.move(jaffa.getFacingDirection());
|
||||
break;
|
||||
default:
|
||||
//TODO error handling
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String boxLift(String param) {
|
||||
switch (param) {
|
||||
case "O" :
|
||||
oneill.boxLift();
|
||||
break;
|
||||
case "J" :
|
||||
jaffa.boxLift();
|
||||
break;
|
||||
}
|
||||
return "box lifted";
|
||||
}
|
||||
|
||||
String boxDrop(String param) {
|
||||
switch (param) {
|
||||
case "O" :
|
||||
oneill.boxDrop();
|
||||
break;
|
||||
case "J" :
|
||||
jaffa.boxDrop();
|
||||
break;
|
||||
}
|
||||
return "box dropped";
|
||||
}
|
||||
|
||||
void shootONeillsGun(String param) {
|
||||
switch (param) {
|
||||
case "B" :
|
||||
oneill.shootStargate(Stargate.blueStargate);
|
||||
break;
|
||||
case "Y" :
|
||||
oneill.shootStargate(Stargate.yellowStargate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String rotate(String playerParam, String directionParam) {
|
||||
switch (playerParam) {
|
||||
case "O" :
|
||||
switch (directionParam) {
|
||||
case "L" :
|
||||
oneill.rotateLeft();
|
||||
return oneill.getFacingDirection().toString();
|
||||
case "R" :
|
||||
oneill.rotateRight();
|
||||
return oneill.getFacingDirection().toString();
|
||||
default: return "Hiba, nem fordult!";
|
||||
}
|
||||
case "J" :
|
||||
switch (directionParam) {
|
||||
case "L" :
|
||||
jaffa.rotateLeft();
|
||||
return jaffa.getFacingDirection().toString();
|
||||
case "R" :
|
||||
jaffa.rotateRight();
|
||||
return jaffa.getFacingDirection().toString();
|
||||
default: return "Hiba, nem fordult!";
|
||||
}
|
||||
default: return "Hiba, nem létező játékos!";
|
||||
}
|
||||
}
|
||||
|
||||
String listStargates() {
|
||||
String blue = Stargate.blueStargate.toString();
|
||||
String yellow = Stargate.yellowStargate.toString();
|
||||
String red = Stargate.redStargate.toString();
|
||||
String green = Stargate.greenStargate.toString();
|
||||
|
||||
return blue + " " + yellow + " " + red + " " + green;
|
||||
}
|
||||
|
||||
String getConnectedGateOpen(Scale s){
|
||||
if(s.getGateConnected().isOpen())
|
||||
return "gate open";
|
||||
else return "gate closed";
|
||||
}
|
||||
|
||||
/* custom Test annotation */
|
||||
@Target(ElementType.METHOD) // it's for methods
|
||||
@Retention(RetentionPolicy.RUNTIME) // we want to retain annotations in runtime
|
||||
private @interface Test {}
|
||||
|
||||
/* run all methods annotated with @Test */
|
||||
public boolean runAllTests() throws InvocationTargetException, IllegalAccessException
|
||||
{
|
||||
boolean testspassed = true;
|
||||
|
||||
for (Method m : this.getClass().getMethods()) // iterate over all methods of this
|
||||
{
|
||||
if (m.isAnnotationPresent(Test.class)) // if its annotated with @Test...
|
||||
{
|
||||
Boolean testresult = (Boolean) m.invoke(null); // call it!
|
||||
if (!testresult)
|
||||
{
|
||||
testspassed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return testspassed;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean moveTest() throws IOException{
|
||||
boolean success = true;
|
||||
|
||||
loadMap("moveTest.dungeon");
|
||||
|
||||
String listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 1, 1 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
success = false;
|
||||
|
||||
move("O");
|
||||
|
||||
listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 1, 2 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testStargates() throws IOException{
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testStargates.dungeon");
|
||||
shootONeillsGun("B");
|
||||
rotate("O", "L");
|
||||
shootONeillsGun("Y");
|
||||
|
||||
String listOfStargates = listStargates();
|
||||
if(!listOfStargates.equals("BlueStargate: 5, 10 YellowStargate: 10, 5 RedStargate: not spawned GreenStargate: not spawned"))
|
||||
success = false;
|
||||
|
||||
move("O");
|
||||
move("O");
|
||||
move("O");
|
||||
|
||||
String listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 5, 9 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testScalesAndGates() throws IOException {
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testScalesAndGates.dungeon");
|
||||
boxLift("O");
|
||||
rotate("O", "L");
|
||||
boxDrop("O");
|
||||
|
||||
String gateOpen = getConnectedGateOpen((Scale)oneill.getCurrentTile().getAdjacentTile(oneill.facingDirection));
|
||||
|
||||
if(!gateOpen.equals("gate open"))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean gapTest() throws IOException{
|
||||
|
||||
loadMap("gapTest.dungeon");
|
||||
move("O");
|
||||
|
||||
boolean success = oneill.isDestroyed();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean ZPMTest() throws IOException{
|
||||
boolean success = true;
|
||||
|
||||
loadMap("ZPMTest.dungeon");
|
||||
move("O");
|
||||
|
||||
if(oneill.getZPMCount() != 1)
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testReplicatorPosition(){
|
||||
String[] commands = {"loadMap testReplicatorPosition\n",
|
||||
"move O\n"};
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean timeUpTest(){
|
||||
String[] commands = {"loadMap timeUpTest\n"};
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
boolean rotationTest() throws IOException {
|
||||
boolean success = true;
|
||||
|
||||
loadMap("rotationTest.dungeon");
|
||||
|
||||
if(!rotate("O", "L").equals("WEST"))
|
||||
success = false;
|
||||
|
||||
if(!rotate("O", "R").equals("NORTH"))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testBoxes() throws IOException{
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testBoxes.dungeon");
|
||||
|
||||
if(!boxLift("O").equals("box lifted"))
|
||||
success = false;
|
||||
|
||||
if(!boxDrop("O").equals("box dropped"))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -8,10 +8,27 @@ public abstract class Tile {
|
||||
protected Map<Direction, Tile> adjacentTile;
|
||||
protected ZPM zpmOnTile;
|
||||
protected Stack<Box> boxStack;
|
||||
protected int y = -666;
|
||||
protected int x = -666;
|
||||
|
||||
|
||||
public Tile() {
|
||||
adjacentTile = new HashMap<Direction, Tile>();
|
||||
boxStack = new Stack<>();
|
||||
}
|
||||
|
||||
public int getX() { return this.x; }
|
||||
|
||||
public int getY() { return this.y; }
|
||||
|
||||
public void setX(int x) {
|
||||
if (x >= 0)
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
if (y >= 0)
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Tile getAdjacentTile(Direction direction) {
|
||||
@ -49,4 +66,9 @@ public abstract class Tile {
|
||||
return null;
|
||||
return boxStack.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d, %d", x, y);
|
||||
}
|
||||
}
|
||||
|
@ -8,21 +8,28 @@ public class Wall extends Tile {
|
||||
}
|
||||
|
||||
public void spawnStargate(Stargate stargate, Direction direction) {
|
||||
if (sg == null)
|
||||
clearStargate();
|
||||
if (sg == null) {
|
||||
sg = stargate;
|
||||
sg.setCurrentWall(this);
|
||||
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
public void clearStargate() {
|
||||
if(sg != null) {
|
||||
sg.setCurrentWall(null);
|
||||
sg = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntry(PlayerBase playerBase) {
|
||||
if (sg == null) {
|
||||
return;
|
||||
} else {
|
||||
sg.teleport(playerBase.facingDirection);
|
||||
sg.teleport(playerBase);
|
||||
}
|
||||
}
|
||||
|
||||
|
6
gapTest.dungeon
Normal file
6
gapTest.dungeon
Normal file
@ -0,0 +1,6 @@
|
||||
4x3
|
||||
|
||||
W W W W
|
||||
W O X W
|
||||
W W W W
|
||||
|
9283
graphicsclasses_diagram.mdj
Normal file
9283
graphicsclasses_diagram.mdj
Normal file
File diff suppressed because it is too large
Load Diff
8
moveTest.dungeon
Normal file
8
moveTest.dungeon
Normal file
@ -0,0 +1,8 @@
|
||||
5x5
|
||||
|
||||
W W W W W
|
||||
W O F F W
|
||||
W F F F W
|
||||
W F F F W
|
||||
W W W W W
|
||||
|
5
rotate.dungeon
Normal file
5
rotate.dungeon
Normal file
@ -0,0 +1,5 @@
|
||||
3x3
|
||||
|
||||
W W W
|
||||
W O W
|
||||
W W W
|
6
testBoxes.dungeon
Normal file
6
testBoxes.dungeon
Normal file
@ -0,0 +1,6 @@
|
||||
4x4
|
||||
|
||||
W W W W
|
||||
W O B W
|
||||
W F F W
|
||||
W W W W
|
5
testReplicatorInGap.dungeon
Normal file
5
testReplicatorInGap.dungeon
Normal file
@ -0,0 +1,5 @@
|
||||
4x3
|
||||
|
||||
W W W W
|
||||
W O X W
|
||||
W W W W
|
6
testReplicatorPosition.dungeon
Normal file
6
testReplicatorPosition.dungeon
Normal file
@ -0,0 +1,6 @@
|
||||
4x4
|
||||
|
||||
W W W W
|
||||
W R O W
|
||||
W S B W
|
||||
W W W W
|
8
testScalesAndGates.dungeon
Normal file
8
testScalesAndGates.dungeon
Normal file
@ -0,0 +1,8 @@
|
||||
5x4
|
||||
|
||||
W W W W W
|
||||
W O F F G
|
||||
W F S B W
|
||||
W W W W W
|
||||
|
||||
2-2-1-4-1
|
6
testStargates.dungeon
Normal file
6
testStargates.dungeon
Normal file
@ -0,0 +1,6 @@
|
||||
5x4
|
||||
|
||||
W W W W W
|
||||
W O F F W
|
||||
W F F F W
|
||||
W W W W W
|
5
timeUpTest.dungeon
Normal file
5
timeUpTest.dungeon
Normal file
@ -0,0 +1,5 @@
|
||||
4x3
|
||||
|
||||
X X X X
|
||||
X O X Z
|
||||
X X X X
|
Loading…
Reference in New Issue
Block a user