forked from Upstream/mmocore
Skills now always have mana and stamina
This commit is contained in:
parent
9cbc951fad
commit
7496b2d2b9
@ -1,23 +1,16 @@
|
||||
package net.Indyuce.mmocore.api.skill;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class Skill {
|
||||
private final String id;
|
||||
@ -38,6 +31,10 @@ public abstract class Skill {
|
||||
|
||||
Validate.notNull(id, "ID cannot be null");
|
||||
Validate.notNull(id, "Name cannot be null");
|
||||
|
||||
// Default modifiers
|
||||
addModifierIfNone("mana", LinearValue.ZERO);
|
||||
addModifierIfNone("stamina", LinearValue.ZERO);
|
||||
}
|
||||
|
||||
public Skill(String id) {
|
||||
@ -88,8 +85,10 @@ public abstract class Skill {
|
||||
return icon.clone();
|
||||
}
|
||||
|
||||
/*
|
||||
* passive skills do not display any message
|
||||
/**
|
||||
* Passive skills do not display any message when trying to cast them
|
||||
*
|
||||
* @return If the skill is passive
|
||||
*/
|
||||
public boolean isPassive() {
|
||||
return passive;
|
||||
@ -103,6 +102,11 @@ public abstract class Skill {
|
||||
modifiers.put(modifier, linear);
|
||||
}
|
||||
|
||||
public void addModifierIfNone(String mod, LinearValue defaultValue) {
|
||||
if (!hasModifier(mod))
|
||||
addModifier(mod, defaultValue);
|
||||
}
|
||||
|
||||
public LinearValue getModifierInfo(String modifier) {
|
||||
return modifiers.get(modifier);
|
||||
}
|
||||
|
@ -7,11 +7,15 @@ public class LinearValue {
|
||||
private final double base, perLevel, min, max;
|
||||
private final boolean hasmin, hasmax;
|
||||
|
||||
public static final LinearValue ZERO = new LinearValue(0, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* a number which depends on the player level. it can be used as a skill
|
||||
* modifier to make the ability better depending on the player level or as
|
||||
* an attrribute value to make attributes increase with the player level
|
||||
/**
|
||||
* A number formula which depends on the player level. It can be used
|
||||
* to handle skill modifiers so that the ability gets better with the
|
||||
* skill level, or as an attribute value to make them scale with the class level.
|
||||
*
|
||||
* @param base Base value
|
||||
* @param perLevel Every level, final value is increased by X
|
||||
*/
|
||||
public LinearValue(double base, double perLevel) {
|
||||
this.base = base;
|
||||
@ -22,6 +26,16 @@ public class LinearValue {
|
||||
max = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A number formula which depends on the player level. It can be used
|
||||
* to handle skill modifiers so that the ability gets better with the
|
||||
* skill level, or as an attribute value to make them scale with the class level.
|
||||
*
|
||||
* @param base Base value
|
||||
* @param perLevel Every level, final value is increased by X
|
||||
* @param min Minimum final value
|
||||
* @param max Maximum final value
|
||||
*/
|
||||
public LinearValue(double base, double perLevel, double min, double max) {
|
||||
this.base = base;
|
||||
this.perLevel = perLevel;
|
||||
@ -31,6 +45,11 @@ public class LinearValue {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a linear formula
|
||||
*
|
||||
* @param value Formula to copy
|
||||
*/
|
||||
public LinearValue(LinearValue value) {
|
||||
base = value.base;
|
||||
perLevel = value.perLevel;
|
||||
@ -40,6 +59,11 @@ public class LinearValue {
|
||||
max = value.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a linear formula from a config section
|
||||
*
|
||||
* @param config Config to load the formula from
|
||||
*/
|
||||
public LinearValue(ConfigurationSection config) {
|
||||
base = config.getDouble("base");
|
||||
perLevel = config.getDouble("per-level");
|
||||
|
Loading…
Reference in New Issue
Block a user