equipments #22
@@ -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();
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
public class AttackAction extends Action {
|
|
||||||
}
|
|
||||||
@@ -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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import Entity.Position;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public enum MovementPatterns {
|
public enum MovementPatterns {
|
||||||
ONE_STEP_DIAGONALLY(1);
|
ONE_STEP_DIAGONALLY(1);
|
||||||
|
|
||||||
@@ -6,4 +9,12 @@ public enum MovementPatterns {
|
|||||||
MovementPatterns(int cost) {
|
MovementPatterns(int cost) {
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Position> getLegalDestinations(Position position) {
|
||||||
|
List<Position> legalDestinations = new ArrayList<>();
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import Job.*;
|
|||||||
import Shared.*;
|
import Shared.*;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.*;
|
import static org.hamcrest.MatcherAssert.*;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@@ -24,10 +27,15 @@ public class MonsterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void monster_cannot_act_after_death() {
|
void monster_cannot_move_after_death() {
|
||||||
defaultShade.kill();
|
defaultShade.kill();
|
||||||
assertThat(false, anyOf(is(defaultShade.moveTo(new Position(0, 1))),
|
assertThat(false, equalTo(defaultShade.moveTo(new Position(0, 1))));
|
||||||
is(defaultShade.performAttack(Attacks.CHILL, defaultPlayer))));
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void monster_cannot_attack_after_death() {
|
||||||
|
defaultShade.kill();
|
||||||
|
assertThat(false, equalTo(defaultShade.performAttack(Attacks.CHILL, defaultPlayer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -41,4 +49,19 @@ public class MonsterTest {
|
|||||||
defaultShade.kill();
|
defaultShade.kill();
|
||||||
assertThrows(IllegalStateException.class, () -> defaultShade.heal());
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user