monster #20

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

View File

@@ -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();
} }

View File

@@ -1,9 +0,0 @@
public enum Actions {
HEAL(2);
private final int cost;
Actions(int cost) {
this.cost = cost;
}
}

View File

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

View File

@@ -0,0 +1,5 @@
import Entity.Player;
public interface CanAttack {
abstract boolean performAttack(Attacks attack, Player player);
}

View 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) {
}
}

View File

@@ -1,8 +0,0 @@
public class Healing extends Action {
private int healthRegenerated;
public Healing() {
super(2);
}
}

View File

@@ -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);
} }

View File

@@ -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;

View File

@@ -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