Merge pull request #3306 from InspectorCaracal/patch-clothing-type
Fix Clothing contrib ignoring clothing type limits
This commit is contained in:
commit
d4302c461a
2 changed files with 21 additions and 2 deletions
|
|
@ -487,12 +487,12 @@ class CmdWear(MuxCommand):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Apply individual clothing type limits.
|
# Apply individual clothing type limits.
|
||||||
if clothing_type := clothing.db.type:
|
if clothing_type := clothing.db.clothing_type:
|
||||||
if clothing_type in CLOTHING_TYPE_LIMIT:
|
if clothing_type in CLOTHING_TYPE_LIMIT:
|
||||||
type_count = single_type_count(already_worn, clothing_type)
|
type_count = single_type_count(already_worn, clothing_type)
|
||||||
if type_count >= CLOTHING_TYPE_LIMIT[clothing_type]:
|
if type_count >= CLOTHING_TYPE_LIMIT[clothing_type]:
|
||||||
self.caller.msg(
|
self.caller.msg(
|
||||||
"You can't wear any more clothes of the type '{clothing_type}'."
|
f"You can't wear any more clothes of the type '{clothing_type}'."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,25 @@ class TestClothingCmd(BaseEvenniaCommandTest):
|
||||||
)
|
)
|
||||||
self.call(clothing.CmdUncover(), "hat", "You uncover test hat.", caller=self.wearer)
|
self.call(clothing.CmdUncover(), "hat", "You uncover test hat.", caller=self.wearer)
|
||||||
|
|
||||||
|
def test_clothing_limits(self):
|
||||||
|
"""
|
||||||
|
make sure clothing type limits are being enforced
|
||||||
|
"""
|
||||||
|
# change the scarf to a hat for convenience
|
||||||
|
# since the "hat" type is limited to 1 by default
|
||||||
|
self.test_scarf.db.clothing_type = "hat"
|
||||||
|
# move to wearer to be wearable
|
||||||
|
self.test_scarf.location = self.wearer
|
||||||
|
self.test_hat.location = self.wearer
|
||||||
|
# try wearing the hat and scarf-hat
|
||||||
|
self.call(clothing.CmdWear(), "hat", "You put on test hat.", caller=self.wearer)
|
||||||
|
self.call(
|
||||||
|
clothing.CmdWear(),
|
||||||
|
"scarf",
|
||||||
|
"You can't wear any more clothes of the type 'hat'.",
|
||||||
|
caller=self.wearer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestClothingFunc(BaseEvenniaTest):
|
class TestClothingFunc(BaseEvenniaTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue