package com.gmail.nossr50.skills.axes;

import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;

public class AxesCommand extends SkillCommand {
    private String critChance;
    private String critChanceLucky;
    private String bonusDamage;
    private String impactDamage;
    private String greaterImpactDamage;
    private String skullSplitterLength;
    private String skullSplitterLengthEndurance;

    private boolean canSkullSplitter;
    private boolean canCritical;
    private boolean canBonusDamage;
    private boolean canImpact;
    private boolean canGreaterImpact;

    public AxesCommand() {
        super(SkillType.AXES);
    }

    @Override
    protected void dataCalculations() {
        //IMPACT
        impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel));
        greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);

        //SKULL SPLITTER
        String[] skullSplitterStrings = calculateLengthDisplayValues();
        skullSplitterLength = skullSplitterStrings[0];
        skullSplitterLengthEndurance = skullSplitterStrings[1];

        //CRITICAL STRIKES
        String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
        critChance = criticalStrikeStrings[0];
        critChanceLucky = criticalStrikeStrings[1];

        //AXE MASTERY
        if (skillValue >= Axes.bonusDamageMaxBonusLevel) {
            bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
        }
        else {
            bonusDamage = String.valueOf(skillValue / Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus);
        }
    }

    @Override
    protected void permissionsCheck() {
        canSkullSplitter = Permissions.skullSplitter(player);
        canCritical = Permissions.criticalHit(player);
        canBonusDamage = Permissions.axeBonus(player);
        canImpact = Permissions.impact(player);
        canGreaterImpact = Permissions.greaterImpact(player);
    }

    @Override
    protected boolean effectsHeaderPermissions() {
        return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
    }

    @Override
    protected void effectsDisplay() {
        luckyEffectsDisplay();

        if (canSkullSplitter) {
            player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
        }

        if (canCritical) {
            player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
        }

        if (canBonusDamage) {
            player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
        }

        if (canImpact) {
            player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
        }

        if (canGreaterImpact) {
            player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
        }
    }

    @Override
    protected boolean statsHeaderPermissions() {
        return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
    }

    @Override
    protected void statsDisplay() {
        if (canBonusDamage) {
            player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
        }

        if (canImpact) {
            player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
        }

        if (canGreaterImpact) {
            player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
        }

        if (canCritical) {
            if (isLucky) {
                player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { critChanceLucky }));
            }
            else {
                player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
            }
        }

        if (canSkullSplitter) {
            if (hasEndurance) {
                player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { skullSplitterLengthEndurance }));
            }
            else {
                player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
            }
        }
    }
}

@@ -1752,24 +1752,25 @@
 killValue / 
+(
 Axes.bonusDa
@@ -1806,32 +1806,33 @@
 sDamageMaxBonus)
+)
 ;%0D%0A        %7D%0D%0A  

Fix AxesMastery displaying wrong values