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

Add functions for managing the Villager-style trading system. #507

Merged
merged 7 commits into from Oct 24, 2018

Conversation

jb-aero
Copy link
Member

@jb-aero jb-aero commented Oct 2, 2018

No description provided.

@jb-aero jb-aero self-assigned this Oct 2, 2018
@PseudoKnight
Copy link
Contributor

I like this a lot more.

I think merchant_trading() implies you're getting the merchant or whether they're trading. Perhaps merchant_trader() would be better.

@jb-aero
Copy link
Member Author

jb-aero commented Oct 18, 2018

Oh right, we had talked about that

@PseudoKnight
Copy link
Contributor

I think this is good? Have you tested this iteration? If so, I think it's good to merge.

On a side note, do we prefer boolean returns or exceptions when an id already exists when we try to add it? We haven't been consistent with that.

@jb-aero
Copy link
Member Author

jb-aero commented Oct 19, 2018

I did test b8996e9 before pushing, and while I'm sure I tested it before committing two weeks ago (guess I forgot to push), I did just now test to make sure merchant_trader was working.

I don't have a preference of booleans vs exceptions. Might want to get some more voices on the subject.

@LadyCailin
Copy link
Member

LadyCailin commented Oct 19, 2018 via email

@PseudoKnight
Copy link
Contributor

PseudoKnight commented Oct 19, 2018

There's also a map.put() approach where it overwrites the existing one.

The last time I added something like this was for the virtual inventories, and I threw an exception on creation where the id already existed. However, since it keeps the virtual inventory across recompiles, the script won't behave the same the second time if you didn't consider this; instead it stops entirely.

Virtual Inventories: throws exception
Scoreboards: throws exception
Bossbars: throws exception
Recipes: returns boolean

So, since this was somewhat modeled after recipes, it makes sense that it returns a boolean, but we mostly throw exceptions.

@jb-aero
Copy link
Member Author

jb-aero commented Oct 19, 2018

I think while initially mimicking the virtual inventory system, I switched to match the handling of trade storing, since that was modelled after recipes. My thinking now is more that the relative infrequency merchants would likely be created if created programmatically would likely not make the overhead of an exception an issue, whereas accidentally reusing a name could result in losing previous trade data and inadvertently giving someone access to something you didn't intend to, which I believe is a trickier clean-up than someone not getting something when intended. This is in contrast to other recipes which are automatically available to everyone.

TL;DR I think maybe an exception would be more appropriate after all.

@jb-aero
Copy link
Member Author

jb-aero commented Oct 23, 2018

I was also thinking that perhaps get_virtual_merchants should list_virtual_merchants, since it only provides their names and titles it really is more of a list function than one that gets properties or contents of things.

@PseudoKnight
Copy link
Contributor

list_virtual_merchants() is inconsistent with any existing functions. We've used some combination of "get" and/or "all", like all_players(), get_scoreboards() or get_all_recipes().

@jb-aero jb-aero merged commit afe8873 into EngineHub:master Oct 24, 2018
@jb-aero jb-aero deleted the recipes branch October 24, 2018 23:27
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.

None yet

3 participants