Commit bcb9d28b authored by Lucas Delcros's avatar Lucas Delcros

Added javadoc

parent eb63b414
......@@ -5,7 +5,8 @@ import map_generation.map.Map;
import map_generation.map.MapGeneration;
/**
* A simple console test
* @author Lucas Delcros
* Shows a Map in console
*
*/
public class MapGenerationTestMain {
......
......@@ -11,9 +11,16 @@ import org.junit.Test;
import core.gamestate.Entity;
import core.gamestate.SpeciesArray;
import core.zone.Point;
/**
*
* @author Lucas Delcros
* Class of JUnit tests for Map Generation
*/
public class MapTests {
/**
* Test if there is entities in a Map
*/
@Test
public void testThereIsEntities(){
for (int i = 0; i < 100; i++) {
......@@ -21,11 +28,19 @@ public class MapTests {
assertTrue("Error only "+map.getEntities().length, map.getEntities().length > 3);
}
}
/**
* Test if every room is reachable in the map by checking that every tile is reachable
*/
@Test
public void testHardEveryRoomAreReachable(){
Map map = MapGeneration.mapGeneration(20, 1000);
assertTrue(map.check());
}
/**
* Test that there is no Ronflex that spawnw on water
*/
@Test
public void testNoRonflexOnWater(){
Map map = MapGeneration.mapGeneration(20, 100);
......@@ -34,19 +49,28 @@ public class MapTests {
if(entity.getName().equals("Ronflex"))assertFalse("An entity has spawn on water !",map.getTileAt(pt.toMapPoint()).getType() == TileType.WATER);
}
}
/**
* Tests that a map has a starting and an ending room
*/
@Test
public void testMapHasStartEnd(){
Map map = MapGeneration.mapGeneration(20, 100);
assertFalse("The Map doesn't cointains any stairs !", map.getPositionStairs() == null || map.getPositionPlayerStart() == null);
}
/**
* Test that the player doesn't spawn on water
*/
@Test
public void testPlayerNotOnWater(){
Map map = MapGeneration.mapGeneration(20, 100);
assertFalse("The player has spawn on water !", map.getTileAt(map.getPositionPlayerStart()).getType() == TileType.WATER);
}
/**
* Tests that Ponyta entities can spawn on water
*/
@Test
public void ponytaCanSpawnOnLava(){
assertTrue("Ponyta is supossed to be capable to spawn on lava !", SpeciesArray.canSpawn(TileType.WATER, "Ponyta"));
......
......@@ -4,6 +4,7 @@ import java.io.Serializable;
/**
* @author Lucas Delcros
* Represents a single tile of the map
*
*/
......@@ -17,11 +18,7 @@ public class Tile implements Serializable{ // No need for abstract implementatio
public TilePropertyVector tpv;
// public static enum TileDirection{NORTH, SOUTH, EAST, WEST, NE, NW, SE, SW};
private final TileType type;
//A lot of other attributes to add depending on game design !
//Examples : breakable, specials effects etc...
/**
*
......
package map_generation.tiles;
/**
* @author Lucas Delcros
* Builder for class Tile
* Used by MapBuilder to build maps
*
*/
public class TileBuilder {
//Default parameters
private TileType type = TileType.EMPTY;
//private ArrayList<Tile.TileProperty> properties = new ArrayList<Tile.TileProperty>();
// private TileDirection dir = TileDirection.NORTH;
public static Tile[][] buildTiles(TileBuilder[][] tilebs){
Tile[][] tiles = new Tile[tilebs.length][tilebs[0].length];
......@@ -28,18 +24,6 @@ public class TileBuilder {
public void setType(TileType type) {
this.type = type;
}
/*
public void addProperty(TilePropertyVector.TileProperty tProp) {
this.tpv.addProperty(tProp);
}*/
// public TileDirection getDir() {
// return dir;
// }
// public void setDir(TileDirection dir) {
// this.dir = dir;
// }
public Tile build(){
return new Tile(type, type.getTilePropertyVector());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment