2013-11-16 00:21:00 +01:00
|
|
|
package com.gmail.nossr50.skills.alchemy;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
2014-02-03 20:52:28 +01:00
|
|
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
2013-11-16 00:21:00 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
|
|
|
|
|
|
|
public class AlchemyManager extends SkillManager {
|
|
|
|
private final double LUCKY_MODIFIER = 4.0 / 3.0;
|
|
|
|
|
|
|
|
public AlchemyManager(McMMOPlayer mcMMOPlayer) {
|
|
|
|
super(mcMMOPlayer, SkillType.ALCHEMY);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTier() {
|
|
|
|
for (Alchemy.Tier tier : Alchemy.Tier.values()) {
|
|
|
|
if (getSkillLevel() >= tier.getLevel()) {
|
|
|
|
return tier.toNumerical();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ItemStack> getIngredients() {
|
2014-02-11 22:22:57 +01:00
|
|
|
return PotionConfig.getInstance().getIngredients(getTier());
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getIngredientList() {
|
2014-01-19 11:49:30 +01:00
|
|
|
StringBuilder list = new StringBuilder();
|
|
|
|
|
2013-11-16 00:21:00 +01:00
|
|
|
for (ItemStack ingredient : getIngredients()) {
|
2014-02-11 22:22:57 +01:00
|
|
|
short durability = ingredient.getDurability();
|
|
|
|
|
|
|
|
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (durability != 0 ? ":" + durability : "");
|
|
|
|
|
2014-01-17 14:00:22 +01:00
|
|
|
if (string.equals("Long Grass:2")) {
|
2013-12-31 00:30:58 +01:00
|
|
|
string = "Fern";
|
|
|
|
}
|
2014-01-17 14:00:22 +01:00
|
|
|
else if (string.equals("Raw Fish:3")) {
|
2013-12-31 00:30:58 +01:00
|
|
|
string = "Pufferfish";
|
|
|
|
}
|
|
|
|
|
2014-02-11 22:22:57 +01:00
|
|
|
list.append(", ").append(string);
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
2014-02-11 22:22:57 +01:00
|
|
|
|
2013-11-16 00:21:00 +01:00
|
|
|
return list.substring(2);
|
|
|
|
}
|
|
|
|
|
2014-02-11 22:22:57 +01:00
|
|
|
public double calculateBrewSpeed(boolean isLucky) {
|
|
|
|
int skillLevel = getSkillLevel();
|
|
|
|
|
|
|
|
if (skillLevel < Alchemy.catalysisUnlockLevel) {
|
|
|
|
return Alchemy.catalysisMinSpeed;
|
|
|
|
}
|
2013-12-31 00:30:58 +01:00
|
|
|
|
2014-02-11 22:22:57 +01:00
|
|
|
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
2013-12-31 00:30:58 +01:00
|
|
|
|
2013-11-16 00:21:00 +01:00
|
|
|
public void handlePotionBrewSuccesses(int amount) {
|
|
|
|
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount));
|
|
|
|
}
|
|
|
|
}
|