Merge pull request #3053 from Antrare/patch-3

Update extended_room.py
This commit is contained in:
Griatch 2023-02-25 08:32:32 +01:00 committed by GitHub
commit 02ed398045
2 changed files with 22 additions and 2 deletions

View file

@ -359,7 +359,10 @@ class CmdExtendedRoomLook(default_cmds.CmdLook):
): ):
detail = location.return_detail(args) detail = location.return_detail(args)
if detail: if detail:
# we found a detail instead. Show that. # we found a detail
# tell all the objects in the room we're looking closely at something
caller.location.msg_contents(f"$You() $conj(look) closely at {args}.\n", from_obj=caller)
# show the detail to the player
caller.msg(detail) caller.msg(detail)
return return
# no detail found. Trigger delayed error messages # no detail found. Trigger delayed error messages

View file

@ -63,10 +63,27 @@ class TestExtendedRoom(BaseEvenniaCommandTest):
"here", "here",
"Room(#{})\n{}".format(rid, self.SPRING_DESC), "Room(#{})\n{}".format(rid, self.SPRING_DESC),
) )
self.call(extended_room.CmdExtendedRoomLook(), "testdetail", self.DETAIL_DESC) self.call(
extended_room.CmdExtendedRoomLook(),
"testdetail",
"You look closely at {}.\n|{}".format("testdetail", self.DETAIL_DESC)
)
self.call( self.call(
extended_room.CmdExtendedRoomLook(), "nonexistent", "Could not find 'nonexistent'." extended_room.CmdExtendedRoomLook(), "nonexistent", "Could not find 'nonexistent'."
) )
def test_cmdextendedlook_second_person(self):
# char2 is already in the same room.
# replace char2.msg with a Mock; this disables it and will catch what it is called with
self.char2.msg = Mock()
self.call(
extended_room.CmdExtendedRoomLook(),
"testdetail"
)
# check what char2 saw.
self.char2.msg.assert_called_with(text=('Char looks closely at testdetail.\n', {}), from_obj=self.char1)
def test_cmdsetdetail(self): def test_cmdsetdetail(self):
self.call(extended_room.CmdExtendedRoomDetail(), "", "Details on Room") self.call(extended_room.CmdExtendedRoomDetail(), "", "Details on Room")