package co.phoenixlab.discord.commands.dn;

import co.phoenixlab.common.lang.number.ParseLong;
import co.phoenixlab.common.localization.Localizer;

public class DnCommandUtils {

    public static final String DIVINITOR_FOOTER_TEXT = "Powered by Divinitor";
    public static final String DIVINITOR_FOOTER_ICON_URL = "https://divinitor.com/resources/img/dv-logo.png";

    private DnCommandUtils() {}

    public static double parseStat(String s, Localizer loc) throws NumberFormatException {
        //  Check if it ends in thousand or million
        String thousandSuffix = loc.localize("commands.dn.defense.suffix.thousand");
        int start = s.indexOf(thousandSuffix);
        double working;
        double ret = 0;
        if (start == 0) {
            //  Invalid, cannot be just "k"
            throw new NumberFormatException();
        }
        if (start != -1) {
            String num = s.substring(0, start);
            try {
                working = Double.parseDouble(num);
            } catch (NumberFormatException nfe) {
                throw new NumberFormatException();
            }
            ret = working * 1000.0;
        } else {
            String millionSuffix = loc.localize("commands.dn.defense.suffix.million");
            start = s.indexOf(millionSuffix);
            if (start == 0) {
                //  Invalid, cannot be just "m"
                throw new NumberFormatException();
            }
            if (start != -1) {
                String num = s.substring(0, start);
                try {
                    working = Double.parseDouble(num);
                } catch (NumberFormatException nfe) {
                    throw new NumberFormatException();
                }
                ret = working * 1000000.0;
            } else {
                String billionSuffix = loc.localize("commands.dn.defense.suffix.billion");
                start = s.indexOf(billionSuffix);
                if (start == 0) {
                    //  Invalid, cannot be just "b"
                    throw new NumberFormatException();
                }
                if (start != -1) {
                    String num = s.substring(0, start);
                    try {
                        working = Double.parseDouble(num);
                    } catch (NumberFormatException nfe) {
                        throw new NumberFormatException();
                    }
                    ret = working * 1000000000.0;
                } else {
                    ret = ParseLong.parseDec(s);
                }
            }
        }
        return ret;
    }
}

@@ -239,16 +239,17 @@
 ered by 
+%5B
 Divinito
@@ -249,16 +249,40 @@
 ivinitor
+%5D(https://divinitor.com)
 %22;%0A    p

Add divinitor link