Closed Crain-32 closed 2 years ago
FYI https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
I'm not exactly positive about how singletons are related to this Issue. I reread the issue and noticed I used the word singleton. That's my bad, it can just be a class, smh Crain.
I believe the only instance of one was for the Config, which you've already made a PR for.
Reason
In order for Multiworld to Properly work with the current implementation, the Client needs to know when it should remove Items, and when it should give Items. This helps handle the player getting other player's items.
Expected Implementation
The expectation is a Singleton Class (
PlayerInventory
?InventoryManager
? just make it relevant) with the following functions.server_received_item(item_id: int,) -> bool:
False
, then the Client should not send the Item to theAbstractGameHandler
, and instead raise aDuplicateItemWarning
, otherwise it should give the item to theAbstractGameHandler
server_sent_item(item_id: int) -> bool:
If it returns
True
, then the Client should tell theAbstractGameHandler
to remove the given Item ID from the Player.found_item(item_id:int) -> None:
AbstractGameHandler
should call this function in order to add it to the tracked Inventory.current_items() -> dict[str, int]:
Returns all the items in a dictionary of the following format
Example Situations
World One finds a Deku Leaf for World 2. World One already has their Deku Leaf.
AbstractGameHandler
doesn't callfound_item
, as this belongs to a different World ID.Before World One sends the Deku Leaf to the Server, it calls
server_sent_item
, which returnsFalse
, as World One doesn't need to lose it's Deku Leafserver_received_item
, which returnsTrue
, so World Two'sAbstractGameHandler
gets the Deku Leaf, and gives it to the Player.World Three finds a DRC Small Key for World One, but World One already has 4 Tracked DRC Small Keys, and World Three has 2 Tracked DRC Small Keys
AbstractGameHandler
doesn't callfound_item
, as this belongs to a different World ID.server_sent_item
, which returnsTrue
, and so World Three'sAbstractGameHandler
removes a DRC Small Key from the Player.server_received_time
, which returnsFalse
, so the Client raises aDuplicateItemWarning
and doesn't give the DRC Small Key to the Player.