chainsol

Untitled

Nov 28th, 2017
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. USAGE_CMDPRAY = "Usage: pray <diety>"
  2. DEITIES = {
  3.     "deity1": {
  4.         "caliphate": "whererever",
  5.         "empire": "wherever",
  6.         "kingdom": "wherever"
  7.     },
  8.     "deity2": {
  9.         "caliphate": "whererever",
  10.         "empire": "wherever",
  11.         "kingdom": "wherever"
  12.     },
  13.     "deity3": {
  14.         "caliphate": "whererever",
  15.         "empire": "wherever",
  16.         "kingdom": "wherever"
  17.     },
  18.     "atheist": {
  19.         "caliphate": "whererever",
  20.         "empire": "wherever",
  21.         "kingdom": "wherever"
  22.     }
  23. }
  24.  
  25. ERROR_MESSAGE = "You reach towards the light, but something pulls you back.\n|rAn error occured - the administrator has been notified ({})|n"
  26.  
  27. class CmdPray(MuxCommand):
  28.     """
  29.    Pray to the diety of your choice to be resurrected.
  30.    Usage: pray <diety>
  31.    """
  32.     key = 'pray'
  33.     lock = 'cmd:all(),attr(permadeath, False)'
  34.    
  35.     def func(self):
  36.         args = self.args
  37.         caller = self.caller
  38.         if not args:
  39.             caller.msg(USAGE_CMDPRAY)
  40.         result = DEITIES.get(args, None)
  41.         if not result:
  42.             caller.msg("You can't pray to {}.\nThe gods of this realm are:{}"\
  43.                   .format(args,
  44.                           "\n".join(DEITIES.keys())
  45.                           )
  46.                   )
  47.         if result:
  48.             loc_name = result.get(caller.db.Nation.lower(), None)
  49.             if loc_name:
  50.                 loc = caller.search(loc_name, global_search=True, quiet=True).first()
  51.             if not loc_name:
  52.                 print("Caller is not assigned to a nation")
  53.                 caller.msg(ERROR_MESSAGE.format("NONATION"))
  54.                 return
  55.             if not loc:
  56.                 print("Could not find location based on caller's nation")
  57.                 caller.msg(ERROR_MESSAGE.format("INVALIDLOCATION"))
  58.                 return
  59.             caller.move_to(loc)
Advertisement
Add Comment
Please, Sign In to add comment