Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genie_logiciel_2015
the_dungeon_project
Commits
bcb9d28b
Commit
bcb9d28b
authored
Jan 06, 2016
by
Lucas Delcros
Browse files
Added javadoc
parent
eb63b414
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/map_generation/tests/MapGenerationTestMain.java
View file @
bcb9d28b
...
...
@@ -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
{
...
...
src/map_generation/tests/MapTests.java
View file @
bcb9d28b
...
...
@@ -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"
));
...
...
src/map_generation/tiles/Tile.java
View file @
bcb9d28b
...
...
@@ -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...
/**
*
...
...
src/map_generation/tiles/TileBuilder.java
View file @
bcb9d28b
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
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment