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

Allow users to get the trader price #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rHermes
Copy link
Contributor

@rHermes rHermes commented Apr 14, 2020

This allows the users to check what a trader would give for the items in their inventory.

This allows the users to check what a trader would give for the items in
their inventory.

for (id, price_w) in prices.drain() {
if price_w.len() != 1 {
panic!("The price structure top is wrong");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't panic but instead return a proper error type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I originally had a proper error type here, but I saw that in places like the get_trader_prices_raw if the response doesn't match up, you panic with expect. I am all for errors though, I just couldn't find an appropriate error type.

@dank
Copy link
Owner

dank commented Apr 14, 2020

Is this different than functions like get_trader_items? I don't really understand the purpose of this function other than as a helper function. Is this not possible to implement without the private get_trader_prices_raw function?

@rHermes
Copy link
Contributor Author

rHermes commented Apr 15, 2020

The get_trader_items returns the items the trader is willing to sell as far as I know? This returns the price the merchants is willing to pay for items in the users inventory. I am very new to this API, so I could very much be wrong.

As I see it in the get_trader_items you are limiting the returned items to the items returned by get_trader_items_raw. This is the items the trader has and is not the full range of what they can buy. That is why this needs the get_trader_prices_raw function, to return the full set of prices for items the sellers can buy from player.

Hope that made sense and thanks for an awesome library!

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

Successfully merging this pull request may close these issues.

2 participants