donth77 / loot-lookup-plugin

BSD 2-Clause "Simplified" License
3 stars 5 forks source link

DT II Loot table doesn't always show the perfect kill loot #36

Open Sam-Eldin opened 3 months ago

Sam-Eldin commented 3 months ago

Hi ,

there is an issue with displaying the drop quantity when it comes to perfect kills

here is an example. image

I did notice a pattern, if the item has (noted) in it, it shows both as expected, but when the item doesn't then it only shows the 'not perfect' kill.

if I understood your code correctly, the problem is from this function in WikiScrapper.java public static WikiItem parseRow

here you're using NumberFormater to parse the string, but there is a downside for using it, if you give it a string that includes a number then it'll return the said number. e.g. 25 (noted) => 25. so in our case we have 2 cases noted example: 25; 38 (noted) => 25 unnoted example: 25; 38 => 25

then the second problem begins in WikiItem. you have these 2 functions

public String getQuantityLabelText() {
    if (quantityStr.contains("-") || quantityStr.endsWith(" (noted)")) {
        return "x" + quantityStr;
    }
    return quantity > 0 ? "x" + nf.format(quantity) : quantityStr;
}

public String getQuantityLabelTextShort() {
    if (quantityStr.endsWith(" (noted)")) {
        return "x" + quantityStr.replaceAll("\\(.*\\)", "(n)").trim();
    }
    return getQuantityValueText();
}

here we have the quantity in the class as 25 (following the previous example), but the quantityStr doesn't have (noted) in it, as its not noted. hence its returned the quantity which is the first value of these 2 (25;38).

Suggested easy solution, is to handle the ';' in the WikiItem functions as well.

I hope I was clear.

Sam-Eldin commented 3 months ago

Suggested solution:

public String getQuantityLabelText() {
    if (quantityStr.contains("-") || quantityStr.endsWith(" (noted)") || quantityStr.contains(";")) {
        return "x" + quantityStr;
    }
    return quantity > 0 ? "x" + nf.format(quantity) : quantityStr;
}

public String getQuantityLabelTextShort() {
    if (quantityStr.endsWith(" (noted)")) {
        return "x" + quantityStr.replaceAll("\\(.*\\)", "(n)").trim();
    }
    if (quantityStr.contains(";")) {
        return "x" + quantityStr;
    }
    return getQuantityValueText();
}

public String getQuantityValueText() {
    return quantity > 0 ? "x" + Util.rsFormat(quantity) : "";
}