monster #20
@@ -13,6 +13,7 @@ public class MonsterTest {
|
|||||||
|
|
||||||
private Shade defaultShade;
|
private Shade defaultShade;
|
||||||
private Troll defaultTroll;
|
private Troll defaultTroll;
|
||||||
|
private Position defaultDestination = new Position(2, 2);
|
||||||
private MapGenerator worldGenerator = new MapGenerator(5, 5);
|
private MapGenerator worldGenerator = new MapGenerator(5, 5);
|
||||||
|
|
||||||
private Player mockPlayer = mock(Player.class);
|
private Player mockPlayer = mock(Player.class);
|
||||||
@@ -28,13 +29,13 @@ public class MonsterTest {
|
|||||||
@Test
|
@Test
|
||||||
void shade_cannot_move_after_death() {
|
void shade_cannot_move_after_death() {
|
||||||
defaultShade.kill();
|
defaultShade.kill();
|
||||||
assertThat(false, equalTo(defaultShade.moveTo(new Position(1, 2), mockWorld)));
|
assertThat(false, equalTo(defaultShade.moveTo(defaultDestination, mockWorld)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void troll_cannot_move_after_death() {
|
void troll_cannot_move_after_death() {
|
||||||
defaultTroll.kill();
|
defaultTroll.kill();
|
||||||
assertThat(false, equalTo(defaultTroll.moveTo(new Position(1, 2), mockWorld)));
|
assertThat(false, equalTo(defaultTroll.moveTo(defaultDestination, mockWorld)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -216,4 +217,64 @@ public class MonsterTest {
|
|||||||
assertThat(defaultTroll.moveTo(destination, world), equalTo(true));
|
assertThat(defaultTroll.moveTo(destination, world), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HÄR BÖRJAR BESLUTSTABELLSTESTERNA
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t1() {
|
||||||
|
defaultTroll.kill();
|
||||||
|
assertThat(defaultTroll.moveTo(defaultDestination, mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t2() {
|
||||||
|
Monster shade = new Shade(Shade.MAX_HEALTH, 0, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(shade.moveTo(defaultDestination, mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t3() {
|
||||||
|
worldGenerator.randomWorldGeneration();
|
||||||
|
World world = worldGenerator.getWorld();
|
||||||
|
|
||||||
|
when(mockPlayer.getPosition()).thenReturn(defaultDestination);
|
||||||
|
world.addEntityToMap(mockPlayer);
|
||||||
|
|
||||||
|
assertThat(defaultShade.moveTo(defaultDestination, world), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t4() {
|
||||||
|
worldGenerator.randomWorldGeneration();
|
||||||
|
World world = worldGenerator.getWorld();
|
||||||
|
|
||||||
|
when(mockPlayer.getPosition()).thenReturn(new Position(6, 8));
|
||||||
|
world.addEntityToMap(mockPlayer);
|
||||||
|
|
||||||
|
assertThat(defaultShade.moveTo(defaultDestination, world), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t5() {
|
||||||
|
when(mockTile.getBiome()).thenReturn(Biomes.COAST);
|
||||||
|
Position destination = new Position(1, 3);
|
||||||
|
|
||||||
|
worldGenerator.randomWorldGeneration();
|
||||||
|
World world = worldGenerator.getWorld();
|
||||||
|
world.addTile(mockTile, destination);
|
||||||
|
|
||||||
|
assertThat(defaultTroll.moveTo(destination, world), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void decision_table_t6() {
|
||||||
|
when(mockTile.getBiome()).thenReturn(Biomes.FOREST);
|
||||||
|
Position destination = new Position(1, 3);
|
||||||
|
|
||||||
|
worldGenerator.randomWorldGeneration();
|
||||||
|
World world = worldGenerator.getWorld();
|
||||||
|
world.addTile(mockTile, destination);
|
||||||
|
|
||||||
|
assertThat(defaultTroll.moveTo(destination, world), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user