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

Merge branch 'master' of /srv/git/pyRot

www-data 7 лет назад
Родитель
Сommit
2eb2bbac90
2 измененных файлов с 9 добавлено и 9 удалено
  1. 3 2
      irc/commands/common.py
  2. 6 7
      irc/commands/games.py

+ 3 - 2
irc/commands/common.py

@@ -164,6 +164,7 @@ class GameHelpers():
         ap_spent = userrecord[5]
         total_xp = ((level + joins + (given * received) + messages + (messages_words / 4) + (messages_characters / 10) + ((actions + (actions_words / 4) + (actions_characters / 10)) * 2) + ((notices + (notices_words / 4) + (notices_characters / 10)) / 2)) / 120) - (level * 5) + float(coin_spent) + float(ap_spent / 4)
         xp = total_xp - xp_spent
+        ap = total_xp + xp - float(ap_spent)
         total_messages = messages + actions + notices
         total_words = messages_words + actions_words + notices_words
         total_characters = messages_characters + actions_characters + notices_characters
@@ -188,7 +189,7 @@ class GameHelpers():
         karma = float(joinkarma) + float(chatkarma) - float(kickkarma) + float(xpkarma) - float(coinkarma)
         print("karma: " + str(joinkarma) + " + "+ str(chatkarma) + " - " + str(kickkarma) + " + " + str(xpkarma) + " - " + str(coinkarma) + " = " + str(karma))
         
-        return level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap_spent
+        return level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent
     
     def list_top_players(self, sort):
         result = self.db.all("SELECT name, level, xp_spent, coin FROM users WHERE network=%s ORDER BY " + sort + " DESC LIMIT 3 ", (self.network, ))
@@ -204,7 +205,7 @@ class GameHelpers():
         message = ""
         for record in result:
             if not record[column] <= threshold:
-                level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, record[0])
+                level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, record[0])
                 ap = xp + xpspent
                 if ap < 0:
                     ap = 0

+ 6 - 7
irc/commands/games.py

@@ -161,8 +161,7 @@ def do_command(self, connection, event):
                 connection.privmsg(replyto, "Too many arguments, For help type " + blue + self.helpchar + "players " + reset + ".")
                 return
              
-            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
-            ap = xp + xpspent
+            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: " + grey + str(xpspent) + "/" + reset + str(round(xp + xpspent, 4)) + grey + ", " + reset + "AP: " + str(int(ap - float(apspent))) + grey + ", " + reset + "coin: " + str(coin) + grey + "[S " + str(coinspent) + ", G " + str(coingiven) + "], " + reset + "karma: " + str(round(karma, 4)))
@@ -173,7 +172,7 @@ def do_command(self, connection, event):
         elif cmdtype == "cmd":
             
             user = event.source.nick.lower()
-            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
+            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:
@@ -192,7 +191,7 @@ def do_command(self, connection, event):
                     connection.privmsg(replyto, "Invalid amount.")
                 elif xp < levels * 10:
                     connection.privmsg(replyto, "Insuficcient XP, you need at least " + str(levels * 10) + ".")
-                if xp - apspent < 1:
+                if ap < 1:
                     connection.privmsg(replyto, "Insufficient AP, you need at least 1.")
                     return
                 else:
@@ -217,7 +216,7 @@ def do_command(self, connection, event):
                 connection.privmsg(replyto, "You already have your own coin. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
                 return
                 
-            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, event.source.nick)
+            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, event.source.nick)
             receivingrecord = self.db.one("SELECT level, away FROM users WHERE LOWER(name)=%s AND network=%s", (command.split()[1], self.network, ))
             if level < 1:
                 connection.privmsg(replyto, "You need to " + blue + self.cmdchar + "levelup " + reset + "to be able to give coin.")
@@ -234,7 +233,7 @@ def do_command(self, connection, event):
             elif receivingrecord[1] == True:
                 connection.privmsg(replyto, red + trigger.split()[1] + reset + "is not here right now.")
                 return
-            elif apspent >= totalxp:
+            elif ap < 1:
                 connection.privmsg(replyto, "You have no action points, go use IRC some more...")
                 return
             if len(command.split()) == 2:
@@ -269,7 +268,7 @@ def do_command(self, connection, event):
             connection.privmsg(replyto, "XP is earned by using IRC and playing the game, in channels with " + red + connection.get_nickname() + reset + ". Ask any operator in " + red + self.homechannel + reset + " to add a channel. XP is used to level up, advance classes, as a limit and as a multiplier. Once XP is expended it keeps counting towards your total.")
     elif command.split()[0] == "ap":
         if cmdtype == "help":    #Display help text.
-            connection.privmsg(replyto, "XP is earned by using IRC and playing the game in channels with " + red + connection.get_nickname() + reset + ". Ask any operator in " + red + self.homechannel + reset + " to add a channel. AP is expended for every action you take in the game.")
+            connection.privmsg(replyto, "AP is earned by using IRC and playing the game in channels with " + red + connection.get_nickname() + reset + ". Ask any operator in " + red + self.homechannel + reset + " to add a channel. AP is expended for every action you take in the game.")
     elif command.split()[0] == "coin":
         if cmdtype == "help":    #Display help text.
             connection.privmsg(replyto, "Coin is earned when certain events occur, for instance when a player expends XP. Coin is used to buy items and classes. To give a player coin use " + blue + self.cmdchar + "givecoin" + reset + ". Coin affects karma.")