Esempio n. 1
0
 def _doArrow(self, message):
     arrows = message.items.get(4939, 0)
     if arrows == 0:
         return None
     if arrows >= 2:
         return (self.newMessage(message.uid,
                                 "Please do not send more than one time's arrow.",
                                 message.meat)
                                 .addItems(message.items))
     try:
         r = CursePlayerRequest(self.session, message.uid, 4939)
         self.tryRequest(r, numTries=1)
         return self.newMessage(-1)
     except kol.Error.Error as e:
         if e.code == kol.Error.USER_IN_HARDCORE_RONIN:
             return (self.newMessage(message.uid,
                                     "You are in hardcore or ronin.",
                                     message.meat)
                                     .addItems(message.items))
         if e.code == kol.Error.ALREADY_COMPLETED:
             return (self.newMessage(message.uid,
                                     "You have already been arrow'd today.",
                                     message.meat)
                                     .addItems(message.items))
         return (self.newMessage(message.uid,
                                 "Unknown error: {}".format(e.msg),
                                 message.meat)
                                 .addItems(message.items))
Esempio n. 2
0
 def __use_spider(self, pname, pid):
     try:
         # Try to use a rubber spider on them
         c = CursePlayerRequest(self.__session, pid, 7698)
         c.doRequest()
     except Exception as e:
         # Something went wrong! Maybe they're in HC or ronin
         self.log("I couldn't use a spider on {} (#{}): {}".format(
             pname, pid, str(e)))
         try:
             self.__send_kmail(pname, pid,
                               "You already have a rubber spider on you, "
                               "so I'm returning this one.",
                               7698)
         except Error as e2:
             self.log("I couldn't return their spider: {}".format(str(e2)))
             self.__chat_say(pname, pid,
                             "I couldn't use that spider on you and "
                             "something went wrong when I tried to "
                             "return it. Sorry!")
     else:
         # Success! Tell them they can expect their spider
         self.log("I used a spider on {} (#{}).".format(pname, pid))
         self.__chat_say(pname, pid, "I used that spider on you.")
     bookkeeping[id(self)][1] += 1
Esempio n. 3
0
 def _doMallows(self, message):
     mallows = message.items.get(3128, 0)
     if mallows == 0:
         return None
     with InventoryLock.lock:
         self.inventoryManager.refreshInventory()
         cinv = self.inventoryManager.completeInventory()
         inv = self.inventoryManager.inventory()
         gun = cinv.get(5066, 0)
         if gun == 0:
             return (self.newMessage(message.uid,
                                     "Sorry, I don't have a s'more gun. "
                                     "Somebody needs to donate one, or you "
                                     "can send one along with your "
                                     "marshmallows.", message.meat)
                                    .addItems(message.items))
         self.inventoryManager.refreshInventory()
         mallowsBefore = inv.get(3128, 0)
         print mallowsBefore
         try:
             for _ in range(min(mallows, 40)):
                 r = CursePlayerRequest(self.session, message.uid, 5066)
                 self.tryRequest(r, numTries=1)
         except kol.Error.Error:
             pass
         self.inventoryManager.refreshInventory()
         mallowsAfter = self.inventoryManager.inventory().get(3128, 0)
         print mallowsAfter
         mallowsSent = mallowsBefore - mallowsAfter
         
         returnItems = message.items
         
         if mallowsSent == mallows:
             del returnItems[3128]
         else:
             returnItems[3128] -= mallowsSent
             returnItems[3128] = min(returnItems[3128], mallowsAfter)
         print returnItems
         
         sendStuffBack = returnItems or message.meat > 0
         
         if not sendStuffBack:
             return self.newMessage(-1)
         elif 3128 in returnItems:
             return self.newMessage(message.uid, 
                                    "There was an error sending you all "
                                    "of your smores (are you in "
                                    "Ronin/Hardcore? Did you request too "
                                    "many?). You can have your "
                                    "marshmallows back.",
                                    message.meat).addItems(returnItems)
         else:
             return self.newMessage(message.uid, 
                                    "Enjoy your smores!\n\n(Also, you sent "
                                    "me some other stuff. You can have it "
                                    "back.)", 
                                    message.meat).addItems(returnItems)
Esempio n. 4
0
 def __use_arrow(self, pid):
     try:
         # Try to use a time's arrow on them
         c = CursePlayerRequest(self.__session, pid, 4939)
         c.doRequest()
     except Exception as e:
         # Something went wrong! Maybe they're in HC or ronin
         self.log("I couldn't use an arrow on them: {}".format(str(e)))
         self.__chat_say(pid, "I couldn't use that arrow on you.")
     else:
         # Success! No need to tell them, they'll be notified
         self.log("I used an arrow on them.")
     self.actions += 1
Esempio n. 5
0
 def __use_spider(self, pid):
     try:
         # Try to use a rubber spider on them
         c = CursePlayerRequest(self.__session, pid, 7698)
         c.doRequest()
     except Exception as e:
         # Something went wrong! Maybe they're in HC or ronin
         self.log("I couldn't use a spider on them: {}".format(str(e)))
         self.__chat_say(pid, "I couldn't use that spider on you.")
     else:
         # Success! Tell them they can expect their spider
         self.log("I used a spider on them.")
         self.__chat_say(pid, "I used that spider on you.")
     self.actions += 1
Esempio n. 6
0
 def __use_wang(self, pname, pid, target):
     try:
         c = CursePlayerRequest(self.__session, target, 625)
         c.doRequest()
     except Error as e:
         if e.code == kol.Error.ITEM_NOT_FOUND:
             self.__chat_say(pname, pid, "I'm sorry, I'm out of wangs.")
         elif e.code == kol.Error.USER_NOT_FOUND:
             self.__chat_say(pname, pid,
                 "Your kmail contained a message but it wasn't a valid "
                 "username.")
         else:
             self.log("Something went wrong wanging: " + e)
     else:
         if target != pname:
             self.__chat_say(pname, pid,
                 "Successfully wanged {}.".format(target))
         else:
             self.log("Successfully wanged {}.".format(target))
Esempio n. 7
0
 def __use_arrow(self, pname, pid):
     try:
         # Try to use a time's arrow on them
         c = CursePlayerRequest(self.__session, pid, 4939)
         c.doRequest()
     except Exception as e:
         # Something went wrong! Maybe they're in HC or ronin
         self.log("I couldn't use an arrow on them: {}".format(str(e)))
         try:
             self.__send_kmail(pname, pid,
                               "I couldn't use that arrow on you, "
                               "so I'm returning it.",
                               4939)
         except Error as e2:
             self.log("I couldn't return their arrow: {}".format(str(e2)))
             self.__chat_say(pname, pid,
                             "I couldn't use that arrow on you and "
                             "something went wrong when I tried to "
                             "return it. Sorry!")
     else:
         # Success! No need to tell them, they'll be notified
         self.log("I used an arrow on {} (#{})".format(pname, pid))
     bookkeeping[id(self)][1] += 1