monster #20

Merged
viud3133 merged 39 commits from monster into equipments 2025-10-30 12:05:40 +01:00
5 changed files with 37 additions and 36 deletions
Showing only changes of commit e4a90efa08 - Show all commits

View File

@ -1,13 +0,0 @@
public abstract class Action {
private final int cost;
Action(int cost) {
this.cost = cost;
}
public int getCost() {
return cost;
}
abstract boolean performAction();
}

View File

@ -1,2 +0,0 @@
public class AttackAction extends Action {
}

View File

@ -1,18 +0,0 @@
public class HealAction extends Action {
private static final int DEFAULT_HEALTH_RECHARGE = 5;
private int healthGain;
public HealAction(int cost, int healthGain) {
super(cost);
this.healthGain = healthGain;
}
public int getHealthGain() {
return healthGain;
}
public boolean performAction(Monster monster) {
}
}

View File

@ -1,3 +1,6 @@
import Entity.Position;
import java.util.*;
public enum MovementPatterns {
ONE_STEP_DIAGONALLY(1);
@ -6,4 +9,12 @@ public enum MovementPatterns {
MovementPatterns(int cost) {
this.cost = cost;
}
public List<Position> getLegalDestinations(Position position) {
List<Position> legalDestinations = new ArrayList<>();
switch {
case
}
}
}

View File

@ -7,6 +7,9 @@ import Job.*;
import Shared.*;
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.*;
@ -24,10 +27,15 @@ public class MonsterTest {
}
@Test
void monster_cannot_act_after_death() {
void monster_cannot_move_after_death() {
defaultShade.kill();
assertThat(false, anyOf(is(defaultShade.moveTo(new Position(0, 1))),
is(defaultShade.performAttack(Attacks.CHILL, defaultPlayer))));
assertThat(false, equalTo(defaultShade.moveTo(new Position(0, 1))));
}
@Test
void monster_cannot_attack_after_death() {
defaultShade.kill();
assertThat(false, equalTo(defaultShade.performAttack(Attacks.CHILL, defaultPlayer)));
}
@Test
@ -41,4 +49,19 @@ public class MonsterTest {
defaultShade.kill();
assertThrows(IllegalStateException.class, () -> defaultShade.heal());
}
@Test
void method_move_places_monster_in_legal_position() {
Position startingPosition = defaultShade.getPosition();
List<Position> legalDestinations = new ArrayList<>();
List<MovementPatterns> moves = defaultShade.MOVES;
for (MovementPatterns move : moves) {
legalDestinations.addAll(move.getLegalDestinations(startingPosition));
}
defaultShade.move();
assertThat(legalDestinations, hasItem(defaultShade.getPosition()));
}
}