Job + Spell merge #9
3
src/main/java/Biomes.java
Normal file
3
src/main/java/Biomes.java
Normal file
@@ -0,0 +1,3 @@
|
||||
public enum Biomes {
|
||||
GRASSLAND, MOUNTAIN, COAST, FOREST //Är inte fäst vid dessa
|
||||
}
|
||||
@@ -1,28 +1,69 @@
|
||||
//Vill inte göra så mycket med den här klassen, då jag vill påverka implementeringen av Player så lite som möjligt
|
||||
public abstract class Character {
|
||||
protected String name;
|
||||
protected int health;
|
||||
protected int level;
|
||||
protected Position position;
|
||||
private static final int DEFAULT_HEALTH = 10;
|
||||
private static final int DEFAULT_LEVEL = 1;
|
||||
private static final Position DEFAULT_POSITION = new Position(0,0); //Är detta en bra idé?? Mest för att kunna ha defaultkonstruktor
|
||||
|
||||
// Borde jag bara sätta allt till default direkt här????
|
||||
private int health;
|
||||
private int level;
|
||||
private Position position;
|
||||
private boolean isAlive; //osäker på om den här variabeln är en bra idé
|
||||
|
||||
public Character(String name) {
|
||||
this.name = name;
|
||||
this.health = 10;
|
||||
this.level = 1;
|
||||
// Hur många varianter på konstruktorn behövs?
|
||||
public Character() {
|
||||
this.health = DEFAULT_HEALTH;
|
||||
this.level = DEFAULT_LEVEL;
|
||||
this.position = DEFAULT_POSITION;
|
||||
}
|
||||
|
||||
public Character(String name, int level) {
|
||||
this.name = name;
|
||||
// Jag antar att den som instansierar massa monster i världen ansvarar
|
||||
// för att kolla att "position" har ett tillåtet värde.
|
||||
public Character(Position position) {
|
||||
this.health = DEFAULT_HEALTH;
|
||||
this.level = DEFAULT_LEVEL;
|
||||
this.position = position;
|
||||
this.isAlive = true;
|
||||
}
|
||||
|
||||
public Character(int health, int level, Position position) {
|
||||
this.health = health;
|
||||
this.level = level;
|
||||
this.position = position;
|
||||
this.isAlive = true;
|
||||
}
|
||||
|
||||
public void setHealth(int i) {
|
||||
this.health = i;
|
||||
public int getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(int newHealth) {
|
||||
health = newHealth;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int newLevel) {
|
||||
level = newLevel;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Position newPosition) {
|
||||
position = newPosition;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return health > 0;
|
||||
return isAlive;
|
||||
}
|
||||
|
||||
// "status" är kanske inte ett jättebra namn...
|
||||
public void setAlive(boolean status) {
|
||||
isAlive = status;
|
||||
}
|
||||
|
||||
public abstract void spawn(int x, int y);
|
||||
}
|
||||
|
||||
14
src/main/java/Monster.java
Normal file
14
src/main/java/Monster.java
Normal file
@@ -0,0 +1,14 @@
|
||||
public abstract class Monster extends Character{
|
||||
|
||||
public Monster() {
|
||||
|
||||
}
|
||||
|
||||
public Monster(Position position) {
|
||||
super(position);
|
||||
}
|
||||
|
||||
public Monster(int health, int level, Position position) {
|
||||
super(health, level, position);
|
||||
}
|
||||
}
|
||||
10
src/test/java/MonsterTest.java
Normal file
10
src/test/java/MonsterTest.java
Normal file
@@ -0,0 +1,10 @@
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MonsterTest {
|
||||
|
||||
@Test
|
||||
void nothing_in_particular() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user