Job + Spell merge #9

Merged
erns6604 merged 23 commits from Job into main 2025-10-27 12:18:22 +01:00
4 changed files with 82 additions and 14 deletions
Showing only changes of commit 1622fc12c8 - Show all commits

View File

@@ -0,0 +1,3 @@
public enum Biomes {
GRASSLAND, MOUNTAIN, COAST, FOREST //Är inte fäst vid dessa
}

View File

@@ -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 { public abstract class Character {
protected String name; private static final int DEFAULT_HEALTH = 10;
protected int health; private static final int DEFAULT_LEVEL = 1;
protected int level; private static final Position DEFAULT_POSITION = new Position(0,0); //Är detta en bra idé?? Mest för att kunna ha defaultkonstruktor
protected Position position;
// 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) { // Hur många varianter på konstruktorn behövs?
this.name = name; public Character() {
this.health = 10; this.health = DEFAULT_HEALTH;
this.level = 1; this.level = DEFAULT_LEVEL;
this.position = DEFAULT_POSITION;
} }
public Character(String name, int level) { // Jag antar att den som instansierar massa monster i världen ansvarar
this.name = name; // 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.level = level;
this.position = position;
this.isAlive = true;
} }
public void setHealth(int i) { public int getHealth() {
this.health = i; 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() { 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);
} }

View 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);
}
}

View 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() {
}
}