tBKwtWS 7 лет назад
Родитель
Сommit
0455ad008a
3 измененных файлов с 10 добавлено и 4 удалено
  1. 3 2
      irc/commands/common.py
  2. 6 1
      irc/commands/games.py
  3. 1 1
      irc/commands/public.py

+ 3 - 2
irc/commands/common.py

@@ -155,13 +155,14 @@ class GameHelpers():
             notices += int(record[6])
             notices_words += int(record[7])
             notices_characters += int(record[8])
-        userrecord = self.db.one("SELECT xp_spent, level, coin, coin_given, coin_spent, ap_spent FROM users WHERE LOWER(name)=%s AND network='" + self.network + "'", (user, ))
+        userrecord = self.db.one("SELECT xp_spent, level, coin, coin_given, coin_spent, ap_spent, karma_correction FROM users WHERE LOWER(name)=%s AND network='" + self.network + "'", (user, ))
         xp_spent = userrecord[0]
         level = userrecord[1]
         coin = userrecord[2]
         coin_given = userrecord[3]
         coin_spent = userrecord[4]
         ap_spent = userrecord[5]
+        karma_correction = userrecord[6]
         
         chatxp = messages + (messages_words / 4) + (messages_characters / 10) + ((actions + (actions_words / 4) + (actions_characters / 10)) * 2) + ((notices + (notices_words / 4) + (notices_characters / 10)) / 2)
         kickxp = given * received
@@ -182,7 +183,7 @@ class GameHelpers():
         kickkarma = ((given * received) / total_xp) / 2
         xpkarma = xp / 25
         coinkarma = (coin - coin_given / (xp_spent + 1)) / 99
-        karma = float(joinkarma) + float(chatkarma) - float(kickkarma) + float(xpkarma) - float(coinkarma)
+        karma = float(joinkarma) + float(chatkarma) - float(kickkarma) + float(xpkarma) - float(coinkarma) + karma_correction
         if xp < 0:
             xp = 0
         

+ 6 - 1
irc/commands/games.py

@@ -216,6 +216,11 @@ def do_command(self, connection, event):
             elif command.split()[1] == event.source.nick.lower():
                 connection.privmsg(replyto, "You already have your own coin. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
                 return
+            elif len(command.split()) == 3:
+                if 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
             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.")
@@ -245,7 +250,7 @@ def do_command(self, connection, event):
                 self.db.run("UPDATE users SET coin=coin-1, coin_spent=coin_spent+1, coin_given=coin_given+1, ap_spent=ap_spent+1 WHERE name=%s AND network=%s", (event.source.nick, self.network, ))
                 self.db.run("UPDATE users SET coin=coin+1 WHERE LOWER(name)=%s AND network=%s", (command.split()[1], self.network, ))
             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+%s WHERE name=%s AND network=%s", (command.split()[2], command.split()[2], command.split()[2], command.split()[2], event.source.nick, self.network, ))
+                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))
     
     elif command.split()[0] == "players":

+ 1 - 1
irc/commands/public.py

@@ -30,7 +30,7 @@ def do_command(self, connection, event):
             connection.privmsg(replyto, "Strictly for testing purposes only!")
         elif cmdtype == "cmd":
             connection.privmsg(replyto, str(self.channels[self.homechannel].owners()))
-            print(self.channels[self.homechannel].users())
+            connection.privmsg(event.source.nick, self.channels[event.target].users())
     
     elif command == "cmd" or command == "cmds" or command == "commands":
         if cmdtype == "help":    #Display help text.