Added stacking to clothing contrib's inventory command.

This commit is contained in:
mike 2024-02-04 09:27:40 -08:00
parent 9f1d14bae2
commit 8b37bd7acf
No known key found for this signature in database
GPG key ID: 4F08C3EF8040B5C7

View file

@ -658,12 +658,17 @@ class CmdInventory(MuxCommand):
wear_table = evtable.EvTable(border="header")
carried = [obj for obj in items if not obj.db.worn]
# Build and populate a dict for tallying items
carried_sums = {obj.get_display_name(): 0 for obj in set(carried)}
for obj in carried:
carried_sums[obj.get_display_name()] += 1
worn = [obj for obj in items if obj.db.worn]
message_list.append("|wYou are carrying:|n")
for item in carried:
for key, value in carried_sums.items():
carry_table.add_row(
item.get_display_name(self.caller), item.get_display_desc(self.caller)
f"({value})" if value > 1 else "", key
)
if carry_table.nrows == 0:
carry_table.add_row("Nothing.", "")