2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
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;
|
2019-01-25 05:45:26 +01:00
|
|
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
|
|
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
|
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
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
|
2019-01-25 05:45:26 +01:00
|
|
|
protected void dataCalculations(Player player, float skillValue) {
|
2018-12-29 14:24:55 +01:00
|
|
|
// ACROBATICS_DODGE
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canDodge) {
|
2019-01-25 05:45:26 +01:00
|
|
|
String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_DODGE);
|
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-25 05:45:26 +01:00
|
|
|
double rollChance, graceChance;
|
2019-01-21 22:41:56 +01:00
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
//Chance to roll at half
|
|
|
|
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
|
2019-01-21 22:41:56 +01:00
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
//Chance to graceful roll
|
|
|
|
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
|
|
|
|
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
|
2019-01-21 22:41:56 +01:00
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
//Chance Stat Calculations
|
|
|
|
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
|
|
|
|
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
|
|
|
|
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
2019-01-24 01:44:51 +01:00
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
//Format
|
|
|
|
double rollChanceLucky = rollChance * 1.333D;
|
|
|
|
double graceChanceLucky = graceChance * 1.333D;
|
|
|
|
|
|
|
|
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, String.valueOf(rollChance))
|
|
|
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", String.valueOf(rollChanceLucky)) : ""));
|
|
|
|
|
|
|
|
messages.add(getStatMessage(true, false, SubSkillType.ACROBATICS_ROLL, String.valueOf(graceChance))
|
|
|
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", String.valueOf(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
|
|
|
}
|