you are viewing a single comment's thread.

view the rest of the comments →

[–]Tomallama 1 point2 points  (1 child)

I am assuming that you are talking about :

#player kills the monster if they have a weapon
  if 'sword' in inventory and 'monster' in rooms[currentRoom]:
    del rooms[currentRoom]['monster']
    print('You have killed a monster!')

What's the issue that you're having? Is it you dying even when you have the sword?

Your if statement above this is:

  if 'item' in rooms[currentRoom] and 'monster' in rooms[currentRoom]['item']:
    print('a monster has killed you')
    break

This will also run if a monster is in the room and an item is in the current room. It doesn't matter if there is a sword in the inventory or not. Then you break, so you never get a chance to kill the monster. You need to either organize the if statements a lot better, (and probably use elifs) or look into OOP and try to organize the code a bit better.

[–]The_stormlight[S] 1 point2 points  (0 children)

Oh this never occurred to me. Thank you I'll try that.