equipments #22
@@ -1,20 +1,19 @@
|
||||
import Entity.*;
|
||||
import Monster.*;
|
||||
import World.*;
|
||||
import org.hamcrest.core.AllOf;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
public class MonsterTest {
|
||||
|
||||
private Shade defaultShade;
|
||||
private Troll defaultTroll;
|
||||
private MapGenerator worldGenerator = new MapGenerator(5, 5);
|
||||
|
||||
private Player mockPlayer = mock(Player.class);
|
||||
@@ -22,36 +21,60 @@ public class MonsterTest {
|
||||
|
||||
@BeforeEach
|
||||
void reset() {
|
||||
defaultShade = new Shade(); //Återställer alla värden till default
|
||||
defaultShade = new Shade();
|
||||
defaultTroll = new Troll();
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_move_after_death() {
|
||||
void shade_cannot_move_after_death() {
|
||||
defaultShade.kill();
|
||||
assertThat(false, equalTo(defaultShade.moveTo(new Position(1, 2), mockWorld)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_attack_after_death() {
|
||||
void troll_cannot_move_after_death() {
|
||||
defaultTroll.kill();
|
||||
assertThat(false, equalTo(defaultTroll.moveTo(new Position(1, 2), mockWorld)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shade_cannot_attack_after_death() {
|
||||
defaultShade.kill();
|
||||
assertThat(false, equalTo(defaultShade.performAttack(Attacks.CHILL, mockPlayer)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reaching_zero_health_triggers_death() {
|
||||
void troll_cannot_attack_after_death() {
|
||||
defaultTroll.kill();
|
||||
assertThat(false, equalTo(defaultTroll.performAttack(Attacks.STOMP, mockPlayer)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reaching_zero_health_triggers_shade_to_die() {
|
||||
defaultShade.takeDamage(Shade.MAX_HEALTH);
|
||||
assertThat(false, equalTo(defaultShade.isAlive()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_heal_after_death() {
|
||||
void reaching_zero_health_triggers_troll_to_die() {
|
||||
defaultTroll.takeDamage(Troll.MAX_HEALTH);
|
||||
assertThat(false, equalTo(defaultTroll.isAlive()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shade_cannot_heal_after_death() {
|
||||
defaultShade.kill();
|
||||
assertThat(false, equalTo(defaultShade.heal()));
|
||||
}
|
||||
|
||||
//Är denna för lång?
|
||||
@Test
|
||||
void method_move_places_monster_in_legal_position() {
|
||||
void troll_cannot_heal_after_death() {
|
||||
defaultTroll.kill();
|
||||
assertThat(false, equalTo(defaultTroll.heal()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void method_move_places_shade_in_legal_position() {
|
||||
Position startingPosition = defaultShade.getPosition();
|
||||
List<Position> legalDestinations = new ArrayList<>();
|
||||
List<MovementPatterns> moves = defaultShade.MOVES;
|
||||
@@ -64,9 +87,22 @@ public class MonsterTest {
|
||||
assertThat(legalDestinations, hasItem(defaultShade.getPosition()));
|
||||
}
|
||||
|
||||
//Borde nog ha mer mocks här men tycker det är svårt med flera lager av dom...
|
||||
@Test
|
||||
void method_move_to_wont_move_shade_to_same_position_as_player() {
|
||||
void method_move_places_troll_in_legal_position() {
|
||||
Position startingPosition = defaultTroll.getPosition();
|
||||
List<Position> legalDestinations = new ArrayList<>();
|
||||
List<MovementPatterns> moves = defaultTroll.MOVES;
|
||||
|
||||
for (MovementPatterns move : moves) {
|
||||
legalDestinations.addAll(move.findLegalDestinations(startingPosition));
|
||||
}
|
||||
|
||||
defaultTroll.move(mockWorld);
|
||||
assertThat(legalDestinations, hasItem(defaultTroll.getPosition()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void method_moveTo_wont_move_shade_to_same_position_as_player() {
|
||||
worldGenerator.randomWorldGeneration();
|
||||
World world = worldGenerator.getWorld();
|
||||
|
||||
@@ -77,6 +113,7 @@ public class MonsterTest {
|
||||
assertThat(defaultShade.moveTo(destination, world), equalTo(false));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void method_move_wont_move_shade_to_same_position_as_player() {
|
||||
worldGenerator.randomWorldGeneration();
|
||||
@@ -91,23 +128,41 @@ public class MonsterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_heal_when_out_of_energy() {
|
||||
void shade_cannot_heal_when_out_of_energy() {
|
||||
Shade shade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||
assertThat(shade.heal(), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_move_to_when_out_of_energy() {
|
||||
void troll_cannot_heal_when_out_of_energy() {
|
||||
Troll troll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||
assertThat(troll.heal(), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shade_cannot_move_when_out_of_energy() {
|
||||
Shade shade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||
assertThat(shade.move(mockWorld), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void monster_cannot_attack_when_out_of_energy() {
|
||||
void troll_cannot_move_when_out_of_energy() {
|
||||
Troll troll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||
assertThat(troll.move(mockWorld), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shade_cannot_attack_when_out_of_energy() {
|
||||
Shade shade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||
assertThat(shade.performAttack(Attacks.CHILL, mockPlayer), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void troll_cannot_attack_when_out_of_energy() {
|
||||
Troll troll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||
assertThat(troll.performAttack(Attacks.STOMP, mockPlayer), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void only_moves_within_energy_budget_are_performed() {
|
||||
Troll troll = new Troll(Troll.MAX_HEALTH, 1, Troll.DEFAULT_POSITION);
|
||||
|
||||
Reference in New Issue
Block a user