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;
|
2018-12-29 14:24:55 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkill;
|
2014-04-18 21:56:03 +02:00
|
|
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
2014-06-08 23:03:26 +02:00
|
|
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
2013-11-16 00:21:00 +01:00
|
|
|
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) {
|
2018-12-29 14:24:55 +01:00
|
|
|
super(mcMMOPlayer, PrimarySkill.ALCHEMY);
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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()) {
|
2018-09-15 02:50:28 +02:00
|
|
|
String string = StringUtils.getPrettyItemString(ingredient.getType());
|
2013-12-31 00:30:58 +01:00
|
|
|
|
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
|
|
|
|
2014-06-08 23:03:26 +02:00
|
|
|
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
|
|
|
|
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
|
|
|
}
|