Job terrain #12
@ -2,11 +2,11 @@ package Action;
|
||||
|
||||
import Job.HasJob;
|
||||
import Job.Miner;
|
||||
import Terrain.Biomes;
|
||||
import Terrain.Biome;
|
||||
|
||||
public class DigAction implements Action {
|
||||
Biomes biome;
|
||||
public DigAction(Biomes biome) {
|
||||
Biome biome;
|
||||
public DigAction(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
@Override
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package Job;
|
||||
|
||||
import Inventory.HasInventory;
|
||||
import Terrain.Biomes;
|
||||
import Terrain.Biome;
|
||||
|
||||
|
||||
public class Miner extends Job {
|
||||
@ -16,7 +16,7 @@ public class Miner extends Job {
|
||||
return actor;
|
||||
}
|
||||
|
||||
public void dig(Biomes biome) {
|
||||
public void dig(Biome biome) {
|
||||
switch (biome) {
|
||||
case COAST:
|
||||
actor.getInventory().addItem("Sand");
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
import Entity.Position;
|
||||
import Terrain.Biomes;
|
||||
import Terrain.Biome;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class Monster extends Character{
|
||||
|
||||
private final List<Biomes> habitat = new ArrayList<>();
|
||||
private final List<Biome> habitat = new ArrayList<>();
|
||||
|
||||
public Monster() {
|
||||
habitat.addAll(Arrays.asList(Biomes.GRASSLAND, Biomes.MOUNTAIN, Biomes.COAST, Biomes.FOREST));
|
||||
habitat.addAll(Arrays.asList(Biome.GRASSLAND, Biome.MOUNTAIN, Biome.COAST, Biome.FOREST));
|
||||
}
|
||||
|
||||
public Monster(Position position) {
|
||||
super(position);
|
||||
habitat.addAll(Arrays.asList(Biomes.GRASSLAND, Biomes.MOUNTAIN, Biomes.COAST, Biomes.FOREST));
|
||||
habitat.addAll(Arrays.asList(Biome.GRASSLAND, Biome.MOUNTAIN, Biome.COAST, Biome.FOREST));
|
||||
}
|
||||
|
||||
public Monster(double health, double level, double energy, Position position) {
|
||||
super(health, level, energy, position);
|
||||
habitat.addAll(Arrays.asList(Biomes.GRASSLAND, Biomes.MOUNTAIN, Biomes.COAST, Biomes.FOREST));
|
||||
habitat.addAll(Arrays.asList(Biome.GRASSLAND, Biome.MOUNTAIN, Biome.COAST, Biome.FOREST));
|
||||
}
|
||||
|
||||
public Monster(double health, double level, double energy, Position position, List<Biomes> habitat) {
|
||||
public Monster(double health, double level, double energy, Position position, List<Biome> habitat) {
|
||||
super(health, level, energy, position);
|
||||
this.habitat.addAll(habitat);
|
||||
}
|
||||
|
||||
//Är detta bra??? Med unmodifiableList dvs
|
||||
public List<Biomes> getHabitat() {
|
||||
public List<Biome> getHabitat() {
|
||||
return Collections.unmodifiableList(habitat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package Terrain;
|
||||
|
||||
public enum Biomes {
|
||||
public enum Biome {
|
||||
GRASSLAND, MOUNTAIN, COAST, FOREST //Är inte fäst vid dessa
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Entity.Player;
|
||||
import Job.Miner;
|
||||
import Terrain.Biomes;
|
||||
import Terrain.Biome;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
@ -41,14 +41,14 @@ public class MinerTest {
|
||||
@Test
|
||||
void dig_in_coast_use_coast_loot() {
|
||||
var job = new Miner(defaultPlayer());
|
||||
job.dig(Biomes.COAST);
|
||||
job.dig(Biome.COAST);
|
||||
assertThat(job.getActor().getInventory().getItems(), hasItem("Sand"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void dig_in_mountain_use_mountain_loot() {
|
||||
var job = new Miner(defaultPlayer());
|
||||
job.dig(Biomes.MOUNTAIN);
|
||||
job.dig(Biome.MOUNTAIN);
|
||||
assertThat(job.getActor().getInventory().getItems(), hasItem("Stone"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import Combat.OffensiveDamageSpell;
|
||||
import Entity.Position;
|
||||
import Job.Miner;
|
||||
import Entity.Player;
|
||||
import Terrain.Biomes;
|
||||
import Terrain.Biome;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import Job.Wizard;
|
||||
|
||||
@ -58,7 +58,7 @@ class PlayerTest {
|
||||
void miner_can_dig() {
|
||||
var p = new Player("John");
|
||||
p.learnJob(new Miner(p));
|
||||
p.performAction(new DigAction(Biomes.FOREST));
|
||||
p.performAction(new DigAction(Biome.FOREST));
|
||||
assertThat(p.getInventory().getItems(), hasItem("Clay"));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user