adds a difficulty parameter
All checks were successful
Build / build (push) Successful in 3m10s

This commit is contained in:
unurled 2024-05-30 22:52:01 +02:00
parent 22fa239f38
commit 92fd2242b3
Signed by: unurled
GPG key ID: FDBC9CBE1F82423F
12 changed files with 436 additions and 12 deletions

View file

@ -46,6 +46,14 @@ public class CombatManager extends Manager {
double luck = dLuck - eLuck;
if (!pm.isSRPlayer(player.getUniqueId())) {
return;
}
SRPlayer sr = pm.getPlayer(player.getUniqueId());
if (sr == null) {
return;
}
if (luck < -1000) {
// 100% chance of miss
player.sendMessage(comp("<red>You dodged!"));
@ -56,7 +64,7 @@ public class CombatManager extends Manager {
// 100% chance of critical hit
luck = 10000d;
player.playSound(player, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0f, 1.0f);
damage = damage * 2;
damage = damage * 2 * sr.getDifficulty().getDamageMultiplier();
}
if (luck < 0) {
@ -71,7 +79,7 @@ public class CombatManager extends Manager {
// chance of critical hit
player.playSound(player, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0f, 1.0f);
// damage * 2
damage = damage * 2;
damage = damage * 2 * sr.getDifficulty().getDamageMultiplier();
}
// apply damage

View file

@ -0,0 +1,42 @@
package me.unurled.sacredrealms.sr.components.difficulty;
import static me.unurled.sacredrealms.sr.utils.Component.textComp;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
public enum Difficulty {
EASY(textComp("Easy"), 1.75, 0.75, NamedTextColor.GREEN),
NORMAL(textComp("Normal"), 1, 1, NamedTextColor.YELLOW),
HARD(textComp("Hard"), 0.75, 1.75, NamedTextColor.RED),
INSANE(textComp("<obf>aa</obf>Insane<obf>aa</obf>"), 0.05, 5, NamedTextColor.DARK_RED);
private final TextComponent name;
private final double damageMultiplier;
private final double xpMultiplier;
private final TextColor color;
Difficulty(TextComponent name, double damageMultiplier, double xpMultiplier, TextColor color) {
this.name = name;
this.damageMultiplier = damageMultiplier;
this.xpMultiplier = xpMultiplier;
this.color = color;
}
public TextComponent getName() {
return this.name;
}
public double getDamageMultiplier() {
return this.damageMultiplier;
}
public double getXpMultiplier() {
return this.xpMultiplier;
}
public TextColor getColor() {
return this.color;
}
}

View file

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
import me.unurled.sacredrealms.sr.components.difficulty.Difficulty;
import me.unurled.sacredrealms.sr.components.item.Item;
import me.unurled.sacredrealms.sr.events.player.PlayerKillEvent;
import me.unurled.sacredrealms.sr.managers.Manager;
@ -39,6 +40,7 @@ public class SRPlayer {
@Expose private List<PotionEffect> potionEffects = new ArrayList<>();
@Expose private Inventory inventory;
@Expose private List<Integer> treasuresOpened = new ArrayList<>();
@Expose private Difficulty difficulty;
private boolean isClientBuilder = false;
private boolean firstTime = true;
@ -255,7 +257,7 @@ public class SRPlayer {
public void setExperience(Long experience) {
// checks if experience is above next level requirements
if (experience >= levelRequirements.get(level - 1)) {
if (experience >= levelRequirements.get(level - 1) * difficulty.getXpMultiplier()) {
PlayerManager pm = Manager.getInstance(PlayerManager.class);
setLevel(level + 1);
pm.levelUp(this, level - 1);
@ -290,4 +292,12 @@ public class SRPlayer {
public void setFirstTime(boolean b) {
firstTime = b;
}
public Difficulty getDifficulty() {
return difficulty;
}
public void setDifficulty(Difficulty difficulty) {
this.difficulty = difficulty;
}
}