From 46fe658d0a51c8e555254ec11ad1247e3e259109 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 May 2024 21:04:56 +0200 Subject: [PATCH] Add handling of bags on class attributes to Item similar as it is on Room --- adventurelib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/adventurelib.py b/adventurelib.py index fc14d68..0a13fa8 100644 --- a/adventurelib.py +++ b/adventurelib.py @@ -208,6 +208,11 @@ def __init__(self, name, *aliases): for label in (name,) + aliases ) + # Copy class Bags to instance variables + for k, v in vars(type(self)).items(): + if isinstance(v, Bag): + setattr(self, k, deepcopy(v)) + def __repr__(self): return '%s(%s)' % ( type(self).__name__,