Пример #1
0
 def command_help(self, user, rest, isAuthenticated):
     if isAuthenticated:
         self.events.Post(
             events.Message(
                 target=user,
                 message="Commands are: register, classes, guild, class"))
     else:
         self.events.Post(
             events.Message(target=user, message="Commands are: register"))
Пример #2
0
 def command_class(self, user, rest, isAuthenticated):
     if isAuthenticated:
         try:
             self.rpg_changeclass(user, self.classlist[rest.capitalize()])
         except KeyError:
             self.events.Post(
                 events.Message(target=user,
                                message=self.rpg_getlegitclass(user, 2)))
Пример #3
0
 def Notify(self, event):
     if isinstance(event, events.Login):
         if event.guild:
             self.manager.Post(
                 events.Message(
                     "{0} <{1}> the level {2} {3} logged in.".format(
                         event.name, event.guild, event.level, event.cls),
                     "output"))
         else:
             self.manager.Post(
                 events.Message(
                     "{0} the level {1} {2} logged in.".format(
                         event.name, event.level, event.cls), "output"))
     if isinstance(event, events.Levelup):
         self.manager.Post(
             events.Message(
                 "{0} gained level {1}!".format(event.name, event.level),
                 "output"))
Пример #4
0
 def rpg_fight(self, user):
     session = Session()
     #self.fightbuf = session.query(User).filter_by(name=user, network=self.factory.network).first()
     if random.randint(0, 1) == 1:
         self.events.Post(
             events.Message(
                 "%s %s %s with a %s." %
                 (str(user[0][0]), random.choice(self.actions),
                  str(user[1][0]), random.choice(self.weapons)), "output"))
     session.commit()
     session.close()
Пример #5
0
 def rpg_changeclass(self, user, nclass):
     """ Attempts to change user's class. """
     session = Session()
     try:
         if self.users[user]:
             if nclass in self.rpg_getlegitclass(user, 1):
                 self.users[user].cls = nclass
                 self.msg(
                     user, "Congratulations, you are now a %s." %
                     self.rpg_checkclass(nclass))
                 self.events.Post(
                     events.Message(
                         "%s is now a %s." %
                         (str(user), str(self.rpg_checkclass(nclass))),
                         "output"))
                 session.merge(self.users[user])
                 session.commit()
                 session.close()
                 self.users_html()
             else:
                 self.msg(user, "You can't change into that class.")
                 session.close()
     except KeyError:
         session.close()
Пример #6
0
 def command_online(self, user, rest, isAuthenticated):
     self.events.Post(events.Message(target=user, message=str(self.users)))
Пример #7
0
 def command_classes(self, user, rest, isAuthenticated):
     if isAuthenticated:
         self.events.Post(
             events.Message(target=user,
                            message=self.rpg_getlegitclass(user, 2)))
Пример #8
0
 def command_guild(self, user, rest, isAuthenticated):
     if isAuthenticated:
         if not self.users[user].guild:
             session = Session()
             command, sep, rest = rest.partition(' ')
             if command == "create":
                 self.events.Post(
                     events.Message(target=user,
                                    message="Not yet implemented."))
             elif command == "invite":
                 self.events.Post(
                     events.Message(target=user,
                                    message="Not yet implemented."))
             elif command == "join":
                 command, sep, rest = rest.partition(' ')
                 if command == '':
                     result = "Invited to join: "
                     for guild in session.query(GuildInvite).filter(
                             func.lower(
                                 GuildInvite.target) == func.lower(user),
                             func.lower(GuildInvite.network) == func.lower(
                                 self.factory.network)).all():
                         result += "%s (%s) by %s, " % (
                             self.guilds[guild.guild].name,
                             self.guilds[guild.guild].shortname,
                             guild.inviter)
                     if len(result) > 17:
                         self.events.Post(
                             events.Message(target=user,
                                            message=str(result)))
                 else:
                     if not self.users[user].guild:
                         result = session.query(GuildInvite).filter(
                             func.lower(
                                 GuildInvite.target) == func.lower(user),
                             func.lower(
                                 GuildInvite.guild) == func.lower(command),
                             func.lower(GuildInvite.network) == func.lower(
                                 self.factory.network)).first()
                         if result:
                             self.users[user].guild = result.guild
                             session.merge(self.users[user])
                             session.delete(result)
                             session.commit()
                             self.events.Post(
                                 events.Message(
                                     target=user,
                                     message="Joined {0}.".format(
                                         self.guilds[result.guild].name)))
                             self.events.Post(
                                 events.Message(
                                     target="output",
                                     message="{0} has joined {1}.".format(
                                         user,
                                         self.guilds[result.guild].name)))
                         else:
                             self.events.Post(
                                 events.Message(
                                     target=user,
                                     message="Couldn't find that invite."))
                     else:
                         self.events.Post(
                             events.Message(
                                 target=user,
                                 message=
                                 "You must leave you current guild before you can join another."
                             ))
             session.close()