Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEUItems.getPrice 3 options as enum #200

Open
hannibal002 opened this issue Jun 2, 2023 · 1 comment
Open

NEUItems.getPrice 3 options as enum #200

hannibal002 opened this issue Jun 2, 2023 · 1 comment

Comments

@hannibal002
Copy link
Owner

npc, sell offer, buy order
use equivalent variants for ah lbin and average prices

@hannibal002 hannibal002 converted this from a draft issue Jun 2, 2023
@Thunderblade73
Copy link
Contributor

Hey there,

I've been working on the issue you mentiond, and I wanted to confirm if I've understood it correctly. I would implement it like this:

enum class priceOption{
        npc,
        sellOfferOrlbin,
        buyOrderOrAveragePrices,
    }

    fun getPriceOrNull(internalName: String,option :priceOption) : Double?{
        return when(option){
            priceOption.npc -> internalName.asInternalName().getNpcPriceOrNull();
            priceOption.sellOfferOrlbin -> internalName.asInternalName().getPriceOrNull(true);
            priceOption.buyOrderOrAveragePrices -> if(manager.auctionManager.getBazaarInfo(internalName)==null){
                manager.auctionManager.getItemAvgBin(internalName);
            }else {
                internalName.asInternalName().getPriceOrNull(true);
            }
        }
    }

    fun getPrice(internalName: String,option: priceOption) = getPriceOrNull(internalName,option) ?: -1.0

I test it and it gives the correct values. Testet with Seeds and Aspect of the Void:
image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants