Просмотр исходного кода

spam chanserv less, improverd XP and leveling

tBKwtWS 7 лет назад
Родитель
Сommit
3772fc8c94
3 измененных файлов с 22 добавлено и 8 удалено
  1. 6 0
      irc/commands/common.py
  2. 16 6
      irc/commands/games.py
  3. 0 2
      irc/common/do_everything_to.py

+ 6 - 0
irc/commands/common.py

@@ -213,6 +213,12 @@ class GameHelpers():
                 if sort == "coin":
                     message += red + str(record[0]) + reset + " [L " + green + str(level) + reset + ", X " + grey + str(xpspent) + "/" + green + str(int(xp)) + reset + ", " + reset + "A " + str(int(ap)) + ", " + blue + "C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
         return message[:-2]
+    
+    def player_info(self, user):
+        level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, user)
+        if ap < 0:
+            ap = 0
+        return "Level: " + str(level) + grey + ", " + reset + "XP: " + str(int(xp)) + "/" + grey + str(round(totalxp, 4)) + ", " + reset + "AP: " + str(int(ap)) + grey + ", " + reset + "coin: " + str(coin) + grey + "[S " + str(coinspent) + ", G " + str(coingiven) + "], " + reset + "karma: " + str(round(karma, 4))
 
 class StatisticsHelpers():
     def add_message_stats(stats):

+ 16 - 6
irc/commands/games.py

@@ -164,7 +164,8 @@ def do_command(self, connection, event):
             level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, user)
             if ap < 0:
                 ap = 0
-            connection.privmsg(replyto, message + "Level: " + str(level) + grey + ", " + reset + "XP: " + str(int(xp)) + "/" + grey + str(round(totalxp, 4)) + ", " + reset + "AP: " + str(int(ap)) + grey + ", " + reset + "coin: " + str(coin) + grey + "[S " + str(coinspent) + ", G " + str(coingiven) + "], " + reset + "karma: " + str(round(karma, 4)))
+            info = GameHelpers.player_info(self, user)
+            connection.privmsg(replyto, message + info)
     
     elif command.split()[0] == "levelup":
         if cmdtype == "help":    #Display help text.
@@ -175,12 +176,14 @@ def do_command(self, connection, event):
             level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, user)
             if len(command.split()) == 1:
                 if xp < int(level * 2.7):
-                    connection.privmsg(replyto, "Insuficcient XP, you need at least " + str(int(level * 2.7)) + ".")
+                    connection.privmsg(replyto, "Insufficient XP, you need at least " + str(int(level * 2.7)) + ".")
                 elif ap < 1:
-                    connection.privmsg(replyto, "Insuficcient AP, you need at least 1.")
+                    connection.privmsg(replyto, "Insufficient AP, you need at least 1.")
                 else:
                     self.db.run("UPDATE users SET level=level+1, xp_spent=xp_spent+%s, ap_spent=ap_spent+1 WHERE LOWER(name)=%s AND network=%s", (int(level * 2.7), user, self.network, ))
                     self.db.run("UPDATE users SET coin=coin+0.3 WHERE level>0 AND network=%s", (self.network, ))
+                    info = GameHelpers.player_info(self, user)
+                    connection.privmsg(replyto, "Your new statistics: " + info)
             elif len(command.split()) == 2:
                 try:
                     levels = int(command.split()[1])
@@ -190,12 +193,14 @@ def do_command(self, connection, event):
                 if levels < 1:
                     connection.privmsg(replyto, "Invalid amount.")
                 elif xp < int(level * 2.7):
-                    connection.privmsg(replyto, "Insuficcient XP, you need at least " + str(int(level * 2.7)) + ".")
+                    connection.privmsg(replyto, "Insufficient XP, you need at least " + str(int(level * 2.7)) + ".")
                 elif ap < levels:
                     connection.privmsg(replyto, "Insufficient AP, you need at least 1.")
                 else:
                     self.db.run("UPDATE users SET level=level+%s, xp_spent=xp_spent+%s, ap_spent=ap_spent+%s WHERE LOWER(name)=LOWER(%s) AND network=%s", (levels, int(level * 2.7), levels, user, self.network, ))
                     self.db.run("UPDATE users SET coin=coin+%s WHERE level>0 AND network=%s", (levels * 0.3, self.network, ))
+                    info = GameHelpers.player_info(self, user)
+                    connection.privmsg(replyto, "Your new statistics: " + info)
             else:
                 connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "levelup " + reset + ".")
     
@@ -215,14 +220,17 @@ def do_command(self, connection, event):
                 connection.privmsg(replyto, "You already have your own coin. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
                 return
             elif len(command.split()) == 3:
+                stop = False
                 try:
                     if int(command.split()[2]) < 0:
                         connection.privmsg(replyto, "You clever abuser! The " + red + self.cmdchar + bold + "give" + bold + "coin" + reset + " command is not designed for robbing. There will be consequences...")
-                        self.db.run("UPDATE users SET coin=coin-3, karma_correction=karma_correction-0.5 WHERE name=%s", (event.source.nick))
-                        return
+                        self.db.run("UPDATE users SET coin=coin-3, karma_correction=karma_correction-0.5 WHERE name=%s AND network=%s", (event.source.nick, self.network))
+                        stop = True
                 except TypeError:
                     connection.privmsg(replyto, "Invalid amount. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
                     return
+                if stop:
+                    return
             elif not event.target == connection.get_nickname():
                 if not command.split()[1] in self.channels[event.target].users():
                     connection.privmsg(replyto, red + trigger.split()[1] + reset + " is not present.")
@@ -254,6 +262,8 @@ def do_command(self, connection, event):
             elif len(command.split()) == 3:
                 self.db.run("UPDATE users SET coin=coin-%s, coin_spent=coin_spent+%s, coin_given=coin_given+%s, ap_spent=ap_spent+1 WHERE name=%s AND network=%s", (command.split()[2], command.split()[2], command.split()[2], event.source.nick, self.network, ))
                 self.db.run("UPDATE users SET coin=coin+%s WHERE LOWER(name)=%s AND network=%s", (command.split()[2], command.split()[1], self.network))
+            info = GameHelpers.player_info(self, user)
+            connection.notice(event.source.nick, "Your new statistics: " + info)
     
     elif command.split()[0] == "players":
         if cmdtype == "help":    #Display help text.

+ 0 - 2
irc/common/do_everything_to.py

@@ -1,8 +1,6 @@
 from common.networkservices import ChanServ
 
 def join(self, connection, channel, key=False):
-    connection.privmsg("ChanServ", "UNBAN")
-    connection.privmsg("ChanServ", "UNBAN " + channel)
     ChanServ.unban(connection, channel, connection.get_nickname())
     ChanServ.akick_del(connection, channel, connection.get_nickname())
     ChanServ.invite(connection, channel)