equipments #13
37
src/main/java/Item/AttributeModifier.java
Normal file
37
src/main/java/Item/AttributeModifier.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
public class AttributeModifier {
|
||||||
|
private int maxHpMod;
|
||||||
|
private int maxMpMod;
|
||||||
|
private int strMod;
|
||||||
|
private int magicStrMod;
|
||||||
|
private int defMod;
|
||||||
|
private int magicDefMod;
|
||||||
|
|
||||||
|
public AttributeModifier(int maxHpMod, int maxMpMod, int strMod, int magicStrMod, int defMod, int magicDefMod) {
|
||||||
|
this.maxHpMod = maxHpMod;
|
||||||
|
this.maxMpMod = maxMpMod;
|
||||||
|
this.strMod = strMod;
|
||||||
|
this.magicStrMod = magicStrMod;
|
||||||
|
this.defMod = defMod;
|
||||||
|
this.magicDefMod = magicDefMod;
|
||||||
|
}
|
||||||
|
public int getMaxHpMod() {
|
||||||
|
return maxHpMod;
|
||||||
|
}
|
||||||
|
public int getMaxMpMod() {
|
||||||
|
return maxMpMod;
|
||||||
|
}
|
||||||
|
public int getStrMod() {
|
||||||
|
return strMod;
|
||||||
|
}
|
||||||
|
public int getMagicStrMod() {
|
||||||
|
return magicStrMod;
|
||||||
|
}
|
||||||
|
public int getDefMod() {
|
||||||
|
return defMod;
|
||||||
|
}
|
||||||
|
public int getMagicDefMod() {
|
||||||
|
return magicDefMod;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/Item/BodyArmour.java
Normal file
25
src/main/java/Item/BodyArmour.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
public class BodyArmour extends EquipmentType{
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private AttributeModifier modifiers;
|
||||||
|
|
||||||
|
public BodyArmour(String name, AttributeModifier modifiers) {
|
||||||
|
this.name = name;
|
||||||
|
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() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "" + modifiers;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/main/java/Item/Equipment.java
Normal file
39
src/main/java/Item/Equipment.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
public class Equipment implements Item {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private EquipmentType equipmentType;
|
||||||
|
private int slot;
|
||||||
|
|
||||||
|
public Equipment(String id, String name, EquipmentType equipmentType, int slot) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.equipmentType = equipmentType;
|
||||||
|
this.slot = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EquipmentType getEquipmentType() {
|
||||||
|
return equipmentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot() {
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name + equipmentType + slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main/java/Item/EquipmentType.java
Normal file
11
src/main/java/Item/EquipmentType.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
public abstract class EquipmentType {
|
||||||
|
public String name;
|
||||||
|
public AttributeModifier attributeModifier;
|
||||||
|
|
||||||
|
public abstract String getName();
|
||||||
|
public abstract String toString();
|
||||||
|
public abstract AttributeModifier getModifiers();
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/Item/MageHat.java
Normal file
25
src/main/java/Item/MageHat.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
public class MageHat extends EquipmentType{
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private AttributeModifier modifiers;
|
||||||
|
|
||||||
|
public MageHat(String name, AttributeModifier modifiers) {
|
||||||
|
this.name = name;
|
||||||
|
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() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "" + modifiers;
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/test/java/EquipmentTest.java
Normal file
76
src/test/java/EquipmentTest.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import Item.Equipment;
|
||||||
|
import Item.BodyArmour;
|
||||||
|
import Item.AttributeModifier;
|
||||||
|
|
||||||
|
public class EquipmentTest {
|
||||||
|
private Equipment defaultBodyArmour() {
|
||||||
|
AttributeModifier a = new AttributeModifier(4,8,7,1,2,8);
|
||||||
|
BodyArmour b = new BodyArmour("Body Armour", a);
|
||||||
|
return new Equipment("5", "Thornmail", b, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Equipment defaultMageHat() {
|
||||||
|
AttributeModifier a = new AttributeModifier(4,8,2,10,2,8);
|
||||||
|
BodyArmour b = new BodyArmour("Mage Hat", a);
|
||||||
|
return new Equipment("6", "Deathmage Cap", b, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setNameOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals("Thornmail", e.getName(), "Equipment name should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setTypeOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals("helmet", e.getEquipmentType().getName(), "Equipment type should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setSlotOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(2, e.getSlot(), "Equipment slot should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setMaxHpModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getMaxHpMod(), "Equipment max hp modifier should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setMaxMpModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getMaxMpMod(), "Equipment max mp modifier should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setStrModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getStrMod(), "Equipment strength modifier should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setMagicStrModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getMagicStrMod(), "Equipment magic strength modifier should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setDefModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getDefMod(), "Equipment defence modifier should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setMagicDefModOnCreation() {
|
||||||
|
var e = defaultBodyArmour();
|
||||||
|
assertEquals(1, e.getEquipmentType().getModifiers().getMagicDefMod(), "Equipment magic defence modifier should have been set");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user