davedotluebke / old-skool-text-game

Coding project used to learn Python
5 stars 4 forks source link

Seems player actions won't work in dark rooms? #102

Closed davedotluebke closed 5 years ago

davedotluebke commented 5 years ago

The code for picking which objects should be considered for matching the verb in the user command looks to me like it won't collect the player themselves if the room is dark:

        # FIRST, search for objects that support the verb the user typed
        # (only include room contents if room is not dark (but always include user)
        room = user.location
        possible_objects = [room] 
        for obj in user.contents + (None if room.is_dark() else room.contents):  
            possible_objects += [obj]
            if isinstance(obj, Container) and obj.see_inside and obj is not user:
                possible_objects += obj.contents

It seems like we should explicitly include the user, but instead they are gathered up as part of the room's contents - but not if the room is dark. I can't test this right now but filing an issue to make sure I don't forget to follow up on it.

davedotluebke commented 5 years ago

Fixed in f83fd59d56a7015eed13395bcdf8d1e7d1f5aeac.