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 handling of bags on class attributes to Item similar as it is on Room #46

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

Conversation

edmw
Copy link

@edmw edmw commented May 5, 2024

Not sure if this is intentional. But the room class initializer contains code to deepcopy instances of Bag from class attributes to instance variables. Which allows to define

Room.items = Bag()

and add items afterwards

room = Room(...)
room.items.add(item)

My son was using this pattern to build items which can contain other items (for example a shelf).

Because the initializer of class Item is missing that code to copy bags, this did not work as expected, because there will be only one instance of Bag for every item.

I suggest to add the same handling of bags to class Item.

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

1 participant