Эх сурвалжийг харах

no more negative xp, leveling upnow more expensive each time

tBKwtWS 7 жил өмнө
parent
commit
a79b30ab64

+ 1 - 2
irc/commands/common.py

@@ -166,7 +166,7 @@ class GameHelpers():
         
         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
-        total_xp = ((joins + kickxp + chatxp) / 120) + float(coin_spent + ap_spent / 8) - (level * 3) 
+        total_xp = ((joins + kickxp + chatxp) / 120) + float(coin_spent + ap_spent / 8)
         
         xp = total_xp - xp_spent
         ap = total_xp - float(ap_spent)
@@ -183,7 +183,6 @@ class GameHelpers():
         kickkarma = ((given * received) / total_xp) / 2
         xpkarma = xp / 25
         coinkarma = (coin - coin_given / (xp_spent + 1)) / 99
-        print(karma_correction)
         karma = float(joinkarma) + float(chatkarma) - float(kickkarma) + float(xpkarma) - float(coinkarma) + float(karma_correction)
         if xp < 0:
             xp = 0

+ 8 - 9
irc/commands/games.py

@@ -168,19 +168,18 @@ def do_command(self, connection, event):
     
     elif command.split()[0] == "levelup":
         if cmdtype == "help":    #Display help text.
-            connection.privmsg(replyto, "Spend 10 XP per level gained. Gain multiple levels by specifying the amount.")
+            connection.privmsg(replyto, "Spend XP to gain a level. Gain multiple levels by specifying the amount.")
         elif cmdtype == "cmd":
             
             user = event.source.nick.lower()
             level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, user)
             if len(command.split()) == 1:
-                print("XP < 10: " + str(xp < 10))
-                if xp < 10:
-                    connection.privmsg(replyto, "Insuficcient XP, you need at least 10.")
+                if xp < int(level * 2.7):
+                    connection.privmsg(replyto, "Insuficcient XP, you need at least " + str(int(level * 2.7)) + ".")
                 elif ap < 1:
                     connection.privmsg(replyto, "Insuficcient AP, you need at least 1.")
                 else:
-                    self.db.run("UPDATE users SET level=level+1, xp_spent=xp_spent+10, ap_spent=ap_spent+1 WHERE LOWER(name)=%s AND network=%s", (user, self.network, ))
+                    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, ))
             elif len(command.split()) == 2:
                 try:
@@ -188,15 +187,14 @@ def do_command(self, connection, event):
                 except:
                     connection.privmsg(replyto, "Invalid amount.")
                     return
-                print("XP < level * 10: " + str(xp < levels * 10))
                 if levels < 1:
                     connection.privmsg(replyto, "Invalid amount.")
-                elif xp < levels * 10:
-                    connection.privmsg(replyto, "Insuficcient XP, you need at least " + str(levels * 10) + ".")
+                elif xp < int(level * 2.7):
+                    connection.privmsg(replyto, "Insuficcient 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, levels * 10, levels, user, self.network, ))
+                    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, ))
             else:
                 connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "levelup " + reset + ".")
@@ -224,6 +222,7 @@ def do_command(self, connection, event):
                         return
                 except TypeError:
                     connection.privmsg(replyto, "Invalid amount. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
+                    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.")