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

starting to craft a recipe does not remove ingredients from the inventory #16

Closed
Windfisch opened this issue Oct 7, 2018 · 3 comments
Closed

Comments

@Windfisch
Copy link
Owner

When a craft is started, this does not remove the ingredients from the player's inventory (bug!). When the craft is finished, however, the products are correctly added to the inventory.

@Windfisch
Copy link
Owner Author

looks like the inventory_changed message only outputs positive, but not negative changes. this needs to be fixed in the luamod.
However, additionally, these item removals must be attributed to a task/actionid, so the claim can be removed...

Alternatively, the claim is removed once the craft is submitted.

But how to deal with items being removed, while still being claimed? Should the claim persist (possible problem: code will think more is available that it's the case) or be removed (problem: which claim is to be removed? probably the lowest-priority claim first)

@Windfisch
Copy link
Owner Author

probably, there should be a periodic or on-change full inventory update (not a diff). To make this work with pending actions, the bot needs to track two inventories:

  1. the confirmed, but old inventory (representing the last full inventory update from the game)

  2. the extrapolated inventory that already incorporates negative changes that are submitted but not confirmed yet.

  3. if an action is submitted, it's registered as pending action. The extrapolated inventory is updated, if the action removed items.

  4. if an action is confirmed, the timestamp is registered.

  5. if a full inventory update is received, the extrapolated inventory is updated by using that update plus all submitted-but-not-confirmed actions.

Implementation: all actions can define arbitrary states, ranging from "submitted" over "started" to "finished" and have a method returning their inventory change when at that state.

@Windfisch
Copy link
Owner Author

fixed by 090617d

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

No branches or pull requests

1 participant