monster #20
@@ -1,11 +1,13 @@
|
|||||||
public abstract class Action {
|
public abstract class Action {
|
||||||
private int cost;
|
private final int cost;
|
||||||
|
|
||||||
public Action(int cost) {
|
|
||||||
|
|
||||||
|
Action(int cost) {
|
||||||
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCost() {
|
public int getCost() {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract boolean performAction();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
public enum Actions {
|
|
||||||
HEAL(2);
|
|
||||||
|
|
||||||
private final int cost;
|
|
||||||
|
|
||||||
Actions(int cost) {
|
|
||||||
this.cost = cost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
src/main/java/AttackAction.java
Normal file
2
src/main/java/AttackAction.java
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
public class AttackAction extends Action {
|
||||||
|
}
|
||||||
5
src/main/java/CanAttack.java
Normal file
5
src/main/java/CanAttack.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import Entity.Player;
|
||||||
|
|
||||||
|
public interface CanAttack {
|
||||||
|
abstract boolean performAttack(Attacks attack, Player player);
|
||||||
|
}
|
||||||
18
src/main/java/HealAction.java
Normal file
18
src/main/java/HealAction.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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,8 +0,0 @@
|
|||||||
public class Healing extends Action {
|
|
||||||
private int healthRegenerated;
|
|
||||||
|
|
||||||
public Healing() {
|
|
||||||
super(2);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -46,6 +46,4 @@ public abstract class Monster implements CanMove {
|
|||||||
|
|
||||||
abstract void takeDamage(int amount);
|
abstract void takeDamage(int amount);
|
||||||
|
|
||||||
abstract boolean performAttack(Attacks attack, Player player);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Entity.Player;
|
|||||||
import Entity.Position;
|
import Entity.Position;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Shade extends Monster implements CanMove {
|
public class Shade extends Monster implements CanMove, CanAttack {
|
||||||
public static final List<Biomes> habitat = Collections.unmodifiableList(Arrays.asList(Biomes.COAST, Biomes.FOREST, Biomes.GRASSLAND, Biomes.MOUNTAIN));
|
public static final List<Biomes> habitat = Collections.unmodifiableList(Arrays.asList(Biomes.COAST, Biomes.FOREST, Biomes.GRASSLAND, Biomes.MOUNTAIN));
|
||||||
public static final int MAX_HEALTH = 20;
|
public static final int MAX_HEALTH = 20;
|
||||||
public static final int MAX_ENERGY = 14;
|
public static final int MAX_ENERGY = 14;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class MonsterTest {
|
|||||||
@Test
|
@Test
|
||||||
void monster_cannot_act_after_death() {
|
void monster_cannot_act_after_death() {
|
||||||
defaultShade.kill();
|
defaultShade.kill();
|
||||||
assertThat(false, anyOf(is(defaultShade.moveTo(new Position(0, 1))), is(defaultShade.performAttack(Attacks.CHILL, defaultPlayer))));
|
assertThat(false, anyOf(is(defaultShade.moveTo(new Position(0, 1))),
|
||||||
|
is(defaultShade.performAttack(Attacks.CHILL, defaultPlayer))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user