code-coverage-Emilia #24
@ -37,13 +37,6 @@ public abstract class Spell {
|
|||||||
return spellName.equals(spell.spellName);
|
return spellName.equals(spell.spellName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = spellName.hashCode();
|
|
||||||
result = 31 * result + cost;
|
|
||||||
result = 31 * result + range;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
20
src/main/java/Entity/Chest.java
Normal file
20
src/main/java/Entity/Chest.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package Entity;
|
||||||
|
|
||||||
|
public class Chest extends Entity {
|
||||||
|
|
||||||
|
private Position position;
|
||||||
|
|
||||||
|
public Chest(String name, Position position) {
|
||||||
|
super(name);
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(Position position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,7 +21,6 @@ public abstract class Entity implements Positionable {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) return true;
|
if (this == obj) return true;
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
|
||||||
|
|
||||||
Entity entity = (Entity) obj;
|
Entity entity = (Entity) obj;
|
||||||
|
|
||||||
|
|||||||
@ -2,17 +2,13 @@ package Item;
|
|||||||
|
|
||||||
public class BodyArmour extends EquipmentType{
|
public class BodyArmour extends EquipmentType{
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public BodyArmour(String name, AttributeModifier modifiers) {
|
public BodyArmour(String name, AttributeModifier modifiers) {
|
||||||
this.name = name;
|
super(name);
|
||||||
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod(), modifiers.getDefMod()*2, modifiers.getMagicDefMod()*2);
|
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod(), modifiers.getDefMod()*2, modifiers.getMagicDefMod()*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttributeModifier getModifiers() {
|
public AttributeModifier getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
@ -20,6 +16,6 @@ public class BodyArmour extends EquipmentType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + modifiers;
|
return getName() + modifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,10 +1,15 @@
|
|||||||
package Item;
|
package Item;
|
||||||
|
|
||||||
public abstract class EquipmentType {
|
public abstract class EquipmentType {
|
||||||
public String name;
|
private String name;
|
||||||
public AttributeModifier attributeModifier;
|
|
||||||
|
|
||||||
public abstract String getName();
|
public EquipmentType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
};
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
public abstract AttributeModifier getModifiers();
|
public abstract AttributeModifier getModifiers();
|
||||||
|
|
||||||
|
|||||||
@ -2,17 +2,13 @@ package Item;
|
|||||||
|
|
||||||
public class MageHat extends EquipmentType{
|
public class MageHat extends EquipmentType{
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public MageHat(String name, AttributeModifier modifiers) {
|
public MageHat(String name, AttributeModifier modifiers) {
|
||||||
this.name = name;
|
super(name);
|
||||||
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod()*2, modifiers.getDefMod(), modifiers.getMagicDefMod()*2);
|
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod()*2, modifiers.getDefMod(), modifiers.getMagicDefMod()*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttributeModifier getModifiers() {
|
public AttributeModifier getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
@ -20,6 +16,6 @@ public class MageHat extends EquipmentType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + modifiers;
|
return getName() + modifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,9 +31,6 @@ public class Shade extends Monster implements CanMove, CanAttack {
|
|||||||
if (isDead()) {
|
if (isDead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (health == MIN_HEALTH) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (health == MAX_HEALTH) {
|
if (health == MAX_HEALTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,9 +36,7 @@ public class Troll extends Monster implements CanMove, CanAttack {
|
|||||||
if (isDead()) {
|
if (isDead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (health == MIN_HEALTH) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (health == MAX_HEALTH) {
|
if (health == MAX_HEALTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public class World {
|
|||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public World(int x, int y) {
|
public World(int x, int y) {
|
||||||
this.map = new String[(x * 2) + 1][y + 2];
|
this.map = new String[x][y];
|
||||||
addWorldToMap();
|
addWorldToMap();
|
||||||
width = x;
|
width = x;
|
||||||
height = y;
|
height = y;
|
||||||
|
|||||||
24
src/test/java/ChestTest.java
Normal file
24
src/test/java/ChestTest.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import Entity.Chest;
|
||||||
|
import Entity.Position;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
|
public class ChestTest {
|
||||||
|
private Chest defaultChest() {
|
||||||
|
return new Chest("Lost chest", new Position(0,0));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void chest_has_a_position() {
|
||||||
|
Chest chest = defaultChest();
|
||||||
|
assertThat(chest.getPosition(), equalTo(new Position(0,0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void chest_position_can_update() {
|
||||||
|
Chest chest = defaultChest();
|
||||||
|
chest.setPosition(new Position(2,2));
|
||||||
|
assertThat(chest.getPosition(), equalTo(new Position(2,2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/test/java/EntityTest.java
Normal file
14
src/test/java/EntityTest.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import Entity.Entity;
|
||||||
|
import Entity.Player;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
|
public class EntityTest {
|
||||||
|
private final String DEFAULT_NAME = "John";
|
||||||
|
@Test
|
||||||
|
void entity_does_not_equal_other_objects() {
|
||||||
|
Entity p = new Player(DEFAULT_NAME);
|
||||||
|
assertNotEquals("", p);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,12 @@
|
|||||||
import Entity.Player;
|
import Entity.Player;
|
||||||
import Item.MageHat;
|
import Item.*;
|
||||||
import Job.Wizard;
|
import Job.Wizard;
|
||||||
import Job.Knight;
|
import Job.Knight;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import Item.Equipment;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import Item.BodyArmour;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import Item.AttributeModifier;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class EquipmentTest {
|
public class EquipmentTest {
|
||||||
@ -16,8 +15,14 @@ public class EquipmentTest {
|
|||||||
private Player defaultWizard(){
|
private Player defaultWizard(){
|
||||||
return new Player("name", wizard);
|
return new Player("name", wizard);
|
||||||
}
|
}
|
||||||
|
private AttributeModifier defaultAttributeModifier(){
|
||||||
|
return new AttributeModifier(4,8,7,1,2,8);
|
||||||
|
}
|
||||||
|
private BodyArmour defaultArmorType(){
|
||||||
|
return new BodyArmour("Body Armour", defaultAttributeModifier());
|
||||||
|
}
|
||||||
private Equipment defaultBodyArmour() {
|
private Equipment defaultBodyArmour() {
|
||||||
AttributeModifier a = new AttributeModifier(4,8,7,1,2,8);
|
AttributeModifier a = defaultAttributeModifier();
|
||||||
BodyArmour b = new BodyArmour("Body Armour", a);
|
BodyArmour b = new BodyArmour("Body Armour", a);
|
||||||
return new Equipment("5", "Thornmail", b, knight, 2);
|
return new Equipment("5", "Thornmail", b, knight, 2);
|
||||||
}
|
}
|
||||||
@ -129,6 +134,14 @@ public class EquipmentTest {
|
|||||||
assertTrue(p.getEquipments().get(defaultMageHat().getSlot()).equals(defaultMageHat()), "Wizard can equip wizard hat");
|
assertTrue(p.getEquipments().get(defaultMageHat().getSlot()).equals(defaultMageHat()), "Wizard can equip wizard hat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isNotEqualIfNameIsDifferent() {
|
||||||
|
var e1 = new Equipment("e1", "equipment 1", defaultArmorType(), knight, 1);
|
||||||
|
var e2 = new Equipment("e2", "equipment 2", defaultArmorType(), knight, 1);
|
||||||
|
assertFalse(e1.equals(e2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void canNotEquipWithWrongJob() {
|
void canNotEquipWithWrongJob() {
|
||||||
var p = defaultWizard();
|
var p = defaultWizard();
|
||||||
|
|||||||
@ -4,26 +4,37 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class ItemStackTest {
|
public class ItemStackTest {
|
||||||
@Test
|
private ItemStack defaultStack() {
|
||||||
void instantiated_with_no_quantity_throws_exception() {
|
return new ItemStack(new BasicItem("id", "name", 5), 5);
|
||||||
assertThrows(IllegalArgumentException.class, () -> new ItemStack(
|
}
|
||||||
new BasicItem("id", "name", 5), 0
|
|
||||||
));
|
private ItemStack stackNoQty() {
|
||||||
|
return new ItemStack(new BasicItem("id", "name", 5), 0);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void instantiated_with_negative_quantity_throws_exception() {
|
void instantiated_with_no_quantity_throws_exception() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new ItemStack(
|
assertThrows(IllegalArgumentException.class, this::stackNoQty);
|
||||||
new BasicItem("id", "name", 5), -4
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void can_be_created_with_positive_quantity() {
|
void can_be_created_with_positive_quantity() {
|
||||||
var i = new ItemStack(new BasicItem("id", "name", 5), 5);
|
assertThat(defaultStack(), instanceOf(ItemStack.class));
|
||||||
assertThat(i, instanceOf(ItemStack.class));
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void has_default_record_method_for_item() {
|
||||||
|
var i = defaultStack();
|
||||||
|
assertThat(i.item(), instanceOf(BasicItem.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void has_default_record_method_for_quantity() {
|
||||||
|
var i = defaultStack();
|
||||||
|
assertEquals(5, i.quantity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,4 +42,16 @@ public class LootTableTest {
|
|||||||
assertThat(result, equalTo("Iron"));
|
assertThat(result, equalTo("Iron"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void returns_null_if_broken_roll() {
|
||||||
|
LootTable<String> loot = new LootTable<>();
|
||||||
|
var mockRandomProvider = mock(RandomProvider.class);
|
||||||
|
when(mockRandomProvider.nextInt(anyInt())).thenReturn(Integer.MAX_VALUE);
|
||||||
|
loot.addEntry("Stone", 90);
|
||||||
|
loot.addEntry("Iron", 10);
|
||||||
|
loot.setRandomProvider(mockRandomProvider);
|
||||||
|
String result = loot.roll();
|
||||||
|
assertThat(result, is(nullValue()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,13 +27,13 @@ public class MonsterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shade_cannot_move_after_death() {
|
void shade_cannot_moveTo_after_death() {
|
||||||
defaultShade.kill();
|
defaultShade.kill();
|
||||||
assertThat(false, equalTo(defaultShade.moveTo(defaultDestination, mockWorld)));
|
assertThat(false, equalTo(defaultShade.moveTo(defaultDestination, mockWorld)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void troll_cannot_move_after_death() {
|
void troll_cannot_moveTo_after_death() {
|
||||||
defaultTroll.kill();
|
defaultTroll.kill();
|
||||||
assertThat(false, equalTo(defaultTroll.moveTo(defaultDestination, mockWorld)));
|
assertThat(false, equalTo(defaultTroll.moveTo(defaultDestination, mockWorld)));
|
||||||
}
|
}
|
||||||
@ -130,13 +130,13 @@ public class MonsterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shade_cannot_heal_when_out_of_energy() {
|
void shade_cannot_heal_when_out_of_energy() {
|
||||||
Shade shade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
Shade shade = new Shade(Shade.MAX_HEALTH - 1, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||||
assertThat(shade.heal(), equalTo(false));
|
assertThat(shade.heal(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void troll_cannot_heal_when_out_of_energy() {
|
void troll_cannot_heal_when_out_of_energy() {
|
||||||
Troll troll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
Troll troll = new Troll(Troll.MAX_HEALTH - 1, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||||
assertThat(troll.heal(), equalTo(false));
|
assertThat(troll.heal(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,8 +257,136 @@ public class MonsterTest {
|
|||||||
assertThat(defaultTroll.heal(), equalTo(false));
|
assertThat(defaultTroll.heal(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HÄR BÖRJAR BESLUTSTABELLSTESTERNA
|
@Test
|
||||||
|
void shade_wont_heal_at_max_health() {
|
||||||
|
assertThat(defaultShade.heal(), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_wont_heal_at_max_health() {
|
||||||
|
assertThat(defaultTroll.heal(), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_taking_damage_greater_than_health_dies() {
|
||||||
|
defaultShade.takeDamage(Shade.MAX_HEALTH+1);
|
||||||
|
assertThat(defaultShade.isDead(), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_taking_damage_greater_than_health_dies() {
|
||||||
|
defaultTroll.takeDamage(Troll.MAX_HEALTH + 1);
|
||||||
|
assertThat(defaultTroll.isDead(), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_wont_move_at_zero_energy() {
|
||||||
|
defaultShade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.move(mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_wont_move_at_zero_energy() {
|
||||||
|
defaultTroll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.move(mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_shade_with_negative_energy() {
|
||||||
|
defaultShade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY - 1, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.getEnergy(), equalTo(Shade.MIN_ENERGY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_troll_with_negative_energy() {
|
||||||
|
defaultTroll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY - 1, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.getEnergy(), equalTo(Troll.MIN_ENERGY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_shade_with_no_health() {
|
||||||
|
defaultShade = new Shade(Shade.MIN_HEALTH, Shade.MAX_ENERGY, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.getHealth(), greaterThan(Shade.MIN_HEALTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_troll_with_no_health() {
|
||||||
|
defaultTroll = new Troll(Troll.MIN_HEALTH, Troll.MAX_ENERGY, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.getHealth(), greaterThan(Troll.MIN_HEALTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_cant_take_negative_damage() {
|
||||||
|
assertThat(defaultShade.takeDamage(-9), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_cant_take_negative_damage() {
|
||||||
|
assertThat(defaultTroll.takeDamage(-9), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_wont_move_when_dead() {
|
||||||
|
defaultShade.kill();
|
||||||
|
assertThat(defaultShade.move(mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_wont_move_when_dead() {
|
||||||
|
defaultTroll.kill();
|
||||||
|
assertThat(defaultTroll.move(mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_wont_moveTo_at_zero_energy() {
|
||||||
|
defaultShade = new Shade(Shade.MAX_HEALTH, Shade.MIN_ENERGY, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.moveTo(defaultDestination, mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void troll_wont_moveTo_at_zero_energy() {
|
||||||
|
defaultTroll = new Troll(Troll.MAX_HEALTH, Troll.MIN_ENERGY, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.moveTo(defaultDestination, mockWorld), equalTo(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_shade_with_more_than_max_health() {
|
||||||
|
defaultShade = new Shade(Shade.MAX_HEALTH + 1, Shade.MAX_ENERGY, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.getHealth(), lessThanOrEqualTo(Shade.MAX_HEALTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_troll_with_more_than_max_health() {
|
||||||
|
defaultTroll = new Troll(Troll.MAX_HEALTH + 1, Troll.MAX_ENERGY, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.getHealth(), lessThanOrEqualTo(Troll.MAX_HEALTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_shade_with_more_than_max_energy() {
|
||||||
|
defaultShade = new Shade(Shade.MAX_HEALTH, Shade.MAX_ENERGY + 1, Shade.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultShade.getEnergy(), lessThanOrEqualTo(Shade.MAX_ENERGY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cant_create_troll_with_more_than_max_energy() {
|
||||||
|
defaultTroll = new Troll(Troll.MAX_HEALTH, Troll.MAX_ENERGY + 1, Troll.DEFAULT_POSITION);
|
||||||
|
assertThat(defaultTroll.getEnergy(), lessThanOrEqualTo(Troll.MAX_ENERGY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shade_can_move_to_tile_with_non_player_entity() {
|
||||||
|
Chest mockChest = mock(Chest.class);
|
||||||
|
when(mockChest.getPosition()).thenReturn(defaultDestination);
|
||||||
|
Map<Position, List<Entity>> entitiesAtDestination = new HashMap<>();
|
||||||
|
entitiesAtDestination.put(defaultDestination, List.of(mockChest));
|
||||||
|
when(mockWorld.getPositionEntityMap()).thenReturn(entitiesAtDestination);
|
||||||
|
|
||||||
|
assertThat(defaultShade.moveTo(defaultDestination, mockWorld), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// HÄR BÖRJAR BESLUTSTABELLSTESTERNA
|
||||||
|
//
|
||||||
@Test
|
@Test
|
||||||
void decision_table_t1() {
|
void decision_table_t1() {
|
||||||
defaultTroll.kill();
|
defaultTroll.kill();
|
||||||
|
|||||||
@ -23,14 +23,7 @@ class WorldTest {
|
|||||||
@Test
|
@Test
|
||||||
void worldCreationTest() {
|
void worldCreationTest() {
|
||||||
World test = new World(5, 5);
|
World test = new World(5, 5);
|
||||||
String[][] mapTest = test.getMap();
|
assertEquals(25, test.getMap().length * test.getMap()[0].length);
|
||||||
int counter = 0;
|
|
||||||
for (int i = 0; i < mapTest.length; i++) {
|
|
||||||
for (int j = 0; j < mapTest[i].length; j++) {
|
|
||||||
counter += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(counter, 5 * 5);
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void mapCreationTest() {
|
void mapCreationTest() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user