From dd1f2e5950a934dba6d9274e0ab596c160758554 Mon Sep 17 00:00:00 2001 From: LapisBerry Date: Thu, 23 May 2024 23:23:32 +0700 Subject: [PATCH] feat: start implementing Character --- .../entities/characters/BaseCharacter.java | 84 +++++++++++++++++++ .../game/entities/characters/Dummy.java | 7 ++ .../java/com/lapisberry/utils/Config.java | 6 ++ 3 files changed, 97 insertions(+) create mode 100644 src/main/java/com/lapisberry/game/entities/characters/BaseCharacter.java create mode 100644 src/main/java/com/lapisberry/game/entities/characters/Dummy.java diff --git a/src/main/java/com/lapisberry/game/entities/characters/BaseCharacter.java b/src/main/java/com/lapisberry/game/entities/characters/BaseCharacter.java new file mode 100644 index 0000000..6bde7d1 --- /dev/null +++ b/src/main/java/com/lapisberry/game/entities/characters/BaseCharacter.java @@ -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; + } +} diff --git a/src/main/java/com/lapisberry/game/entities/characters/Dummy.java b/src/main/java/com/lapisberry/game/entities/characters/Dummy.java new file mode 100644 index 0000000..49b79c1 --- /dev/null +++ b/src/main/java/com/lapisberry/game/entities/characters/Dummy.java @@ -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); + } +} diff --git a/src/main/java/com/lapisberry/utils/Config.java b/src/main/java/com/lapisberry/utils/Config.java index 2d4832b..026a9b9 100644 --- a/src/main/java/com/lapisberry/utils/Config.java +++ b/src/main/java/com/lapisberry/utils/Config.java @@ -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; }