static-cleanup #21
@@ -5,7 +5,7 @@ import Job.Miner;
|
|||||||
import Terrain.Biome;
|
import Terrain.Biome;
|
||||||
|
|
||||||
public class DigAction implements Action {
|
public class DigAction implements Action {
|
||||||
Biome biome;
|
final Biome biome;
|
||||||
public DigAction(Biome biome) {
|
public DigAction(Biome biome) {
|
||||||
this.biome = biome;
|
this.biome = biome;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ public abstract class Attack {
|
|||||||
private static final double DEFAULT_ENERGY_COST = 5d;
|
private static final double DEFAULT_ENERGY_COST = 5d;
|
||||||
private static final double DEFAULT_DAMAGE = 5d;
|
private static final double DEFAULT_DAMAGE = 5d;
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private double energyCost;
|
private final double energyCost;
|
||||||
private double damage;
|
private final double damage;
|
||||||
|
|
||||||
public Attack() {
|
public Attack() {
|
||||||
name = DEFAULT_NAME;
|
name = DEFAULT_NAME;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class Entity implements Positionable {
|
public abstract class Entity implements Positionable {
|
||||||
protected String name;
|
protected final String name;
|
||||||
protected Position position;
|
protected Position position;
|
||||||
private static final List<Entity> entities = new ArrayList<Entity>();
|
private static final List<Entity> entities = new ArrayList<Entity>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package Entity;
|
package Entity;
|
||||||
|
|
||||||
|
|
||||||
public interface Movable {
|
public interface Movable {
|
||||||
void moveTo(Position position);
|
void moveTo(Position position);
|
||||||
boolean canMoveTo(Position position);
|
boolean canMoveTo(Position position);
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ public class Player extends Entity implements Movable, Actor, InventoryHolder, H
|
|||||||
protected Job job;
|
protected Job job;
|
||||||
protected Position position = new Position(0,0);
|
protected Position position = new Position(0,0);
|
||||||
protected Inventory inventory= new Inventory();
|
protected Inventory inventory= new Inventory();
|
||||||
protected List<Spell> spells = new LinkedList<>();
|
protected final List<Spell> spells = new LinkedList<>();
|
||||||
protected List<String> conditions = new LinkedList<>();
|
protected final List<String> conditions = new LinkedList<>();
|
||||||
protected List<Equipment> equipments = new ArrayList<>();
|
protected final List<Equipment> equipments = new ArrayList<>();
|
||||||
public Player(String name, Job job) {
|
public Player(String name, Job job) {
|
||||||
super(name);
|
super(name);
|
||||||
this.job = job;
|
this.job = job;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package Item;
|
package Item;
|
||||||
|
|
||||||
public class AttributeModifier {
|
public class AttributeModifier {
|
||||||
private int maxHpMod;
|
private final int maxHpMod;
|
||||||
private int maxMpMod;
|
private final int maxMpMod;
|
||||||
private int strMod;
|
private final int strMod;
|
||||||
private int magicStrMod;
|
private final int magicStrMod;
|
||||||
private int defMod;
|
private final int defMod;
|
||||||
private int magicDefMod;
|
private final int magicDefMod;
|
||||||
|
|
||||||
public AttributeModifier(int maxHpMod, int maxMpMod, int strMod, int magicStrMod, int defMod, int magicDefMod) {
|
public AttributeModifier(int maxHpMod, int maxMpMod, int strMod, int magicStrMod, int defMod, int magicDefMod) {
|
||||||
this.maxHpMod = maxHpMod;
|
this.maxHpMod = maxHpMod;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package Item;
|
|||||||
|
|
||||||
public class BodyArmour extends EquipmentType{
|
public class BodyArmour extends EquipmentType{
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public BodyArmour(String name, AttributeModifier modifiers) {
|
public BodyArmour(String name, AttributeModifier modifiers) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import Job.Job;
|
|||||||
|
|
||||||
public class Equipment implements Item {
|
public class Equipment implements Item {
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
private String name;
|
private final String name;
|
||||||
private EquipmentType equipmentType;
|
private final EquipmentType equipmentType;
|
||||||
private Job equipable;
|
private final Job equipable;
|
||||||
private int slot;
|
private final int slot;
|
||||||
|
|
||||||
public Equipment(String id, String name, EquipmentType equipmentType, Job equipable, int slot) {
|
public Equipment(String id, String name, EquipmentType equipmentType, Job equipable, int slot) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package Item;
|
|||||||
|
|
||||||
public class MageHat extends EquipmentType{
|
public class MageHat extends EquipmentType{
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public MageHat(String name, AttributeModifier modifiers) {
|
public MageHat(String name, AttributeModifier modifiers) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Shared.Levelable;
|
|||||||
public abstract class Job implements Levelable {
|
public abstract class Job implements Levelable {
|
||||||
protected int level;
|
protected int level;
|
||||||
protected int experience;
|
protected int experience;
|
||||||
protected String name;
|
protected final String name;
|
||||||
|
|
||||||
Job(String name) {
|
Job(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Terrain.Biome;
|
|||||||
|
|
||||||
|
|
||||||
public class Miner extends Job {
|
public class Miner extends Job {
|
||||||
InventoryHolder actor;
|
final InventoryHolder actor;
|
||||||
|
|
||||||
public Miner(InventoryHolder actor) {
|
public Miner(InventoryHolder actor) {
|
||||||
super("Miner");
|
super("Miner");
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DigActionTest {
|
|||||||
var player = mock(Player.class);
|
var player = mock(Player.class);
|
||||||
when(player.getJob()).thenReturn(mockMiner);
|
when(player.getJob()).thenReturn(mockMiner);
|
||||||
var biome = mock(Biome.class);
|
var biome = mock(Biome.class);
|
||||||
var action = new DigAction(biome);
|
var action = new DigAction(Biome.COAST);
|
||||||
action.execute(player);
|
action.execute(player);
|
||||||
verify(mockMiner, times(1)).dig(biome);
|
verify(mockMiner, times(1)).dig(biome);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import Item.AttributeModifier;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class EquipmentTest {
|
public class EquipmentTest {
|
||||||
private Knight knight = new Knight();
|
private final Knight knight = new Knight();
|
||||||
private Wizard wizard = new Wizard();
|
private final Wizard wizard = new Wizard();
|
||||||
private Player defaultWizard(){
|
private Player defaultWizard(){
|
||||||
return new Player("name", wizard);
|
return new Player("name", wizard);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ class PlayerTest {
|
|||||||
var inventory = mock(Inventory.class);
|
var inventory = mock(Inventory.class);
|
||||||
var player = new Player("abc", job, inventory);
|
var player = new Player("abc", job, inventory);
|
||||||
assertThat(player, instanceOf(Player.class));
|
assertThat(player, instanceOf(Player.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user