cmd_inform.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. '''
  2. cmd_inform.py
  3. Contains various commands that are informative in nature. For instance, look,
  4. equipment, inventory, etc...
  5. '''
  6. import mud, mudsys, inform, utils
  7. ################################################################################
  8. # utility functions
  9. ################################################################################
  10. def cmd_inventory(ch, cmd, arg):
  11. '''Lists all of the items currently carried in your inventory.'''
  12. if len(ch.inv) == 0:
  13. ch.send("You are not carrying anything.")
  14. else:
  15. ch.send("You are carrying:")
  16. visible = utils.find_all_objs(ch, ch.inv, "", None, True)
  17. utils.show_list(ch, visible, lambda(x): x.name, lambda(x): x.mname)
  18. def cmd_equipment(ch, cmd, arg):
  19. '''Displays all of the equipment you are currently wearing.'''
  20. ch.send("You are wearing:")
  21. inform.show_equipment(ch, ch)
  22. def cmd_who(ch, cmd, arg):
  23. '''List all of the players currently online.'''
  24. ch.page(inform.build_who(ch))
  25. def cmd_look(ch, cmd, arg):
  26. '''allows players to examine just about anything in the game'''
  27. if arg == '':
  28. inform.look_at_room(ch, ch.room)
  29. else:
  30. found, type = mud.generic_find(ch, arg, "all", "immediate", False)
  31. # what did we find?
  32. if found == None:
  33. ch.send("What did you want to look at?")
  34. elif type == "obj" or type == "in":
  35. inform.look_at_obj(ch, found)
  36. elif type == "char":
  37. inform.look_at_char(ch, found)
  38. elif type == "exit":
  39. inform.look_at_exit(ch, found)
  40. # extra descriptions as well
  41. ############
  42. # FINISH ME
  43. ############
  44. ################################################################################
  45. # add our commands
  46. ################################################################################
  47. mudsys.add_cmd("inventory", "i", cmd_inventory, "player", False)
  48. mudsys.add_cmd("equipment", "eq", cmd_equipment, "player", False)
  49. mudsys.add_cmd("worn", None, cmd_equipment, "player", False)
  50. mudsys.add_cmd("who", None, cmd_who, "player", False)
  51. '''
  52. mudsys.add_cmd("look", "l", cmd_look, "player", False)
  53. '''