Skip to content

Commit

Permalink
feat: start implementing Character
Browse files Browse the repository at this point in the history
  • Loading branch information
LapisBerry committed May 23, 2024
1 parent f97d740 commit dd1f2e5
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.lapisberry.game.entities.characters;

import com.lapisberry.utils.Config;

public abstract class BaseCharacter {
// Fields
private final String name;
private final String abilityDescription;
private final int rollPerTurn;
private final int diceRequiredForPureMagic;
private int hp;
private int maxHp;
private int rotPower;
private int reRollLeft;
private boolean isWantToUsePureMagic;

// Constructor
public BaseCharacter(String name, String abilityDescription, int hp) {
this.name = name;
this.abilityDescription = abilityDescription;
this.rollPerTurn = Config.DEFAULT_ROLL_PER_TURN;
this.diceRequiredForPureMagic = Config.DEFAULT_DICE_REQUIRED_FOR_PURE_MAGIC;
this.hp = hp;
this.maxHp = hp;
this.rotPower = Config.DEFAULT_ROT_POWER;
}

// Getters Setters
public String getName() {
return name;
}

public String getAbilityDescription() {
return abilityDescription;
}

public boolean isWantToUsePureMagic() {
return isWantToUsePureMagic;
}

public void setWantToUsePureMagic(boolean wantToUsePureMagic) {
isWantToUsePureMagic = wantToUsePureMagic;
}

public int getReRollLeft() {
return reRollLeft;
}

public void setReRollLeft(int reRollLeft) {
this.reRollLeft = reRollLeft;
}

public int getDiceRequiredForPureMagic() {
return diceRequiredForPureMagic;
}

public int getRotPower() {
return rotPower;
}

public void setRotPower(int rotPower) {
this.rotPower = rotPower;
}

public int getMaxHp() {
return maxHp;
}

public void setMaxHp(int maxHp) {
this.maxHp = maxHp;
}

public int getHp() {
return hp;
}

public void setHp(int hp) {
this.hp = Math.max(0, Math.min(hp, maxHp));
}

public int getRollPerTurn() {
return rollPerTurn;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.lapisberry.game.entities.characters;

public final class Dummy extends BaseCharacter {
public Dummy() {
super("Dummy", "I have no special ability", 10);
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/lapisberry/utils/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.lapisberry.utils;

public final class Config {
// Application
public static final int PORT = 1234;

// Game
public static final int DEFAULT_ROLL_PER_TURN = 3;
public static final int DEFAULT_ROT_POWER = 0;
public static final int DEFAULT_DICE_REQUIRED_FOR_PURE_MAGIC = 3;
}

0 comments on commit dd1f2e5

Please sign in to comment.