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