2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2019-01-21 22:41:56 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2019-01-22 23:21:48 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-09 04:52:52 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2019-01-21 22:41:56 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
|
|
|
import com.gmail.nossr50.listeners.InteractionManager;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2019-01-09 04:52:52 +01:00
|
|
|
import com.gmail.nossr50.util.TextComponentFactory;
|
|
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
2019-01-02 17:06:18 +01:00
|
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
2013-10-29 20:38:20 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public class AcrobaticsCommand extends SkillCommand {
|
|
|
|
private String dodgeChance;
|
|
|
|
private String dodgeChanceLucky;
|
|
|
|
|
|
|
|
private boolean canDodge;
|
|
|
|
private boolean canRoll;
|
|
|
|
|
|
|
|
public AcrobaticsCommand() {
|
2019-01-13 08:54:53 +01:00
|
|
|
super(PrimarySkillType.ACROBATICS);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
2018-12-29 14:24:55 +01:00
|
|
|
// ACROBATICS_DODGE
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canDodge) {
|
2019-01-09 04:52:52 +01:00
|
|
|
String[] dodgeStrings = SkillUtils.calculateAbilityDisplayValues(skillValue, SubSkillType.ACROBATICS_DODGE, isLucky);
|
2013-03-12 21:25:42 +01:00
|
|
|
dodgeChance = dodgeStrings[0];
|
|
|
|
dodgeChanceLucky = dodgeStrings[1];
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void permissionsCheck(Player player) {
|
2019-01-15 12:16:21 +01:00
|
|
|
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE);
|
|
|
|
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
|
|
|
|
2019-01-23 21:53:38 +01:00
|
|
|
if (canDodge) {
|
|
|
|
messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance)
|
|
|
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
|
|
|
|
}
|
|
|
|
|
2019-01-21 17:46:08 +01:00
|
|
|
if (canRoll) {
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2019-01-21 22:41:56 +01:00
|
|
|
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
|
|
|
|
|
|
|
|
if(abstractSubSkill != null)
|
|
|
|
{
|
2019-01-24 01:44:51 +01:00
|
|
|
double maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(abstractSubSkill);
|
2019-01-21 22:41:56 +01:00
|
|
|
double maxChance = AdvancedConfig.getInstance().getMaxChance(abstractSubSkill);
|
|
|
|
double rollChance = SkillUtils.getChanceOfSuccess(skillValue, maxBonusLevel, maxChance);
|
|
|
|
double graceChance = SkillUtils.getChanceOfSuccess(skillValue, maxBonusLevel, maxChance / 2);
|
|
|
|
|
2019-01-24 01:44:51 +01:00
|
|
|
rollChance = Math.min(100.0D, rollChance);
|
|
|
|
graceChance = Math.min(100.0D, graceChance);
|
2019-01-21 22:41:56 +01:00
|
|
|
|
2019-01-24 01:44:51 +01:00
|
|
|
String rollChanceLucky = isLucky ? percent.format(Math.min(100.0D, (rollChance * 1.3333D) / 100.0D)) : null;
|
|
|
|
String graceChanceLucky = isLucky ? percent.format(Math.min(100.0D, (graceChance * 1.3333D) / 100.0D)) : null;
|
2019-01-21 22:41:56 +01:00
|
|
|
|
2019-01-24 01:44:51 +01:00
|
|
|
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, percent.format(rollChance)
|
|
|
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : "")));
|
|
|
|
|
|
|
|
messages.add(getStatMessage(true, false, SubSkillType.ACROBATICS_ROLL, percent.format(graceChance)
|
|
|
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", graceChanceLucky) : "")));
|
2019-01-21 22:41:56 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-09 04:52:52 +01:00
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
return messages;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2019-01-02 17:06:18 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<TextComponent> getTextComponents(Player player) {
|
|
|
|
List<TextComponent> textComponents = new ArrayList<>();
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-02 17:06:18 +01:00
|
|
|
return textComponents;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|