Calculate Alchemy XP based on potion stage

Adds #1926
This commit is contained in:
TfT_02 2014-06-08 23:03:26 +02:00
parent 28a846e0cb
commit 8f4096cf1d
6 changed files with 94 additions and 7 deletions

View File

@ -24,6 +24,7 @@ Version 1.5.01-dev
! Changed player data saving. Save tasks are now asynchronous
! Vanished players no longer get hit by AoE effects
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
- Removed salvage ability from Repair, salvage has it's own (child) skill now
Version 1.5.00

View File

@ -13,6 +13,7 @@ import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
@ -80,8 +81,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
*/
/* Alchemy */
if (getPotionXP() <= 0) {
reason.add("Experience.Alchemy.Potion should be greater than 0!");
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Combat XP Multipliers */
@ -201,7 +204,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP() { return config.getDouble("Experience.Alchemy.Potion", 150D); }
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Fishing */
public int getFishXp(MaterialData data) {

View File

@ -0,0 +1,70 @@
package com.gmail.nossr50.datatypes.skills.alchemy;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
public enum PotionStage {
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
int numerical;
private PotionStage(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
private static PotionStage getPotionStageNumerical(int numerical) {
for (PotionStage potionStage : values()) {
if (numerical >= potionStage.toNumerical()) {
return potionStage;
}
}
return ONE;
}
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
PotionStage potionStage = getPotionStage(output);
if (getPotionStage(input) == potionStage) {
potionStage = PotionStage.FIVE;
}
return potionStage;
}
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
Potion potion = Potion.fromItemStack(new ItemStack(Material.POTION, 1, alchemyPotion.getDataValue()));
int stage = 1;
// Check if potion isn't awkward or mundane
if (potion.getType() != null) {
stage++;
}
// Check if potion has a glowstone dust amplifier
if (potion.getLevel() > 1) {
stage++;
}
// Check if potion has a redstone dust amplifier
if (potion.hasExtendedDuration()) {
stage++;
}
// Check if potion has a gunpowder amplifier
if (potion.isSplash()) {
stage++;
}
return PotionStage.getPotionStageNumerical(stage);
}
}

View File

@ -9,6 +9,7 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.StringUtils;
@ -64,7 +65,7 @@ public class AlchemyManager extends SkillManager {
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
}
public void handlePotionBrewSuccesses(int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount), XPGainReason.PVE);
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
}
}

View File

@ -17,6 +17,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
import com.gmail.nossr50.util.Permissions;
@ -114,7 +115,8 @@ public final class AlchemyPotionBrewer {
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
if (player != null) {
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
PotionStage potionStage = PotionStage.getPotionStage(input, output);
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
}
}
}

View File

@ -80,7 +80,17 @@ Experience:
# FeatherFall_Multiplier: Multiply Acrobatics XP by this value when wearing boots with the Feather Fall enchant
FeatherFall_Multiplier: 2.0
Alchemy:
Potion: 120
# Alchemy potion stages are based on the number of ingredients added
# Potion_Stage_1 represents a base potion
# Potion_Stage_2 represents a base potion with one ingredient
# Potion_Stage_3 represents a base potion with one ingredient and one amplifier
# Potion_Stage_4 represents a base potion with one ingredient and two amplifiers
# Potion_Stage_5 represents a base potion with one ingredient where the amplifiers are swapped
Potion_Stage_1: 15
Potion_Stage_2: 30
Potion_Stage_3: 60
Potion_Stage_4: 120
Potion_Stage_5: 0
Fishing:
Raw_Fish: 800
Raw_Salmon: 800