Selaa lähdekoodia

restore django settings

tBKwtWS 7 vuotta sitten
vanhempi
sitoutus
d322abb11a
5 muutettua tiedostoa jossa 19 lisäystä ja 14 poistoa
  1. 5 5
      .eric6project/pyRot.e6t
  2. 4 2
      irc/commands/admin.py
  3. 2 2
      irc/commands/common.py
  4. 7 4
      irc/commands/games.py
  5. 1 1
      webgui/webgui/settings.py

+ 5 - 5
.eric6project/pyRot.e6t

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Tasks SYSTEM "Tasks-6.0.dtd">
 <!-- eric6 tasks file for project pyRot -->
-<!-- Saved: 2018-02-03, 02:36:35 -->
+<!-- Saved: 2018-02-06, 05:17:33 -->
 <Tasks version="6.0">
   <ProjectScanFilter></ProjectScanFilter>
   <Task priority="1" completed="False" type="2" uid="{234d5c0b-8641-48f6-bd8a-fb56ea9754d7}">
@@ -13,19 +13,19 @@
       <Linenumber>8</Linenumber>
     </Resource>
   </Task>
-  <Task priority="1" completed="False" type="2" uid="{de1813c1-6822-4c7b-9c9a-b31c633a7d6c}">
+  <Task priority="1" completed="False" type="2" uid="{9cd7105d-29ca-4060-aa3c-87d5ae9a5ad5}">
     <Summary>WARNING: keep the secret key used in production secret!</Summary>
     <Description></Description>
-    <Created>2018-02-03, 02:36:32</Created>
+    <Created>2018-02-06, 05:17:30</Created>
     <Resource>
       <Filename>webgui/webgui/settings.py</Filename>
       <Linenumber>22</Linenumber>
     </Resource>
   </Task>
-  <Task priority="1" completed="False" type="2" uid="{77ca5d93-d0c3-4c81-956a-9eec93882aba}">
+  <Task priority="1" completed="False" type="2" uid="{5e540662-9a0b-4404-9d67-5dac0b818bf2}">
     <Summary>WARNING: don't run with debug turned on in production!</Summary>
     <Description></Description>
-    <Created>2018-02-03, 02:36:32</Created>
+    <Created>2018-02-06, 05:17:30</Created>
     <Resource>
       <Filename>webgui/webgui/settings.py</Filename>
       <Linenumber>25</Linenumber>

+ 4 - 2
irc/commands/admin.py

@@ -1,5 +1,5 @@
 import secrets, string, re
-from common import userstatus, do_everything_to
+from common import userstatus, do_everything_to, log
 from commands.common import CommandHelpers as CH
 from commands.common import AdminHelpers as AH
 
@@ -75,9 +75,11 @@ def do_command(self, connection, event):
             connection.privmsg(replyto,  grey + "Usage: " + blue + "!quit " + reset + italic + "reason")
         elif cmdtype == "cmd":
             if len(command.split()) == 1:
+                log.info("Killed by: " + event.source.nick)
                 self.die(msg = "Killed by " + event.source.nick)
             else:
-                self.die(msg = "[" + event.source.nick + "] " + command.split(maxsplit=1)[1])
+                log.info("Killed by " + event.source.nick + " for " + trigger.split(maxsplit=1[1]))
+                self.die(msg = "[" + event.source.nick + "] " + trigger.split(maxsplit=1)[1])
     
     elif command.split()[0] == "reconnect":
         if not userstatus.atleast_oper(self, event.source.nick, self.homechannel): 

+ 2 - 2
irc/commands/common.py

@@ -188,7 +188,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, userrecord[0], karma, coin, coin_spent, coin_given, ap_spent
+        return level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, 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 +204,7 @@ class GameHelpers():
         message = ""
         for record in result:
             if not record[column] <= threshold:
-                level, xp, xpspent, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, record[0])
+                level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, record[0])
                 ap = xp + xpspent
                 if ap < 0:
                     ap = 0

+ 7 - 4
irc/commands/games.py

@@ -161,7 +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, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
+            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
             ap = xp + xpspent
             if ap < 0:
                 ap = 0
@@ -173,7 +173,7 @@ def do_command(self, connection, event):
         elif cmdtype == "cmd":
             
             user = event.source.nick.lower()
-            level, xp, xpspent, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
+            level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
             if len(command.split()) == 1:
                 print("XP < 10: " + str(xp < 10))
                 if xp < 10:
@@ -192,8 +192,11 @@ 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:
+                    connection.privmsg(replyto, "Insufficient AP, you need at least 1.")
+                    return
                 else:
-                    self.db.run("UPDATE users SET level=level+%s, xp_spent=xp_spent+%s WHERE LOWER(name)=LOWER(%s) AND network=%s", (levels, levels * 10, user, self.network, ))
+                    self.db.run("UPDATE users SET level=level+%s, xp_spent=xp_spent+%s, ap_spent=ap_spent-1 WHERE LOWER(name)=LOWER(%s) AND network=%s", (levels, levels * 10, user, self.network, ))
                     self.db.run("UPDATE users SET coin=coin+%s WHERE level>0", (self.network, ))
             else:
                 connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "levelup " + reset + ".")
@@ -272,7 +275,7 @@ def do_command(self, connection, event):
             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.")
     elif command.split()[0] == "karma":
         if cmdtype == "help":    #Display help text.
-            connection.privmsg(replyto, "Karma is a secret formula, based upon on yuor IRC events and how you play the game. It does not increase like XP. Some events, skills and items are karma based.")
+            connection.privmsg(replyto, "Karma is a secret formula, based upon on your IRC events and how you play the game. It does not increase like XP. Some events, skills and items are karma based.")
     
 #    elif command.split()[0] == "classup":
 #        if cmdtype == "help":    #Display help text.

+ 1 - 1
webgui/webgui/settings.py

@@ -93,7 +93,7 @@ DATABASES = {
     }, 
 }
 
-DATABASE_ROUTERS = ['webgui.routers.BotRouter']
+DATABASE_ROUTERS = ['webgui.routers.BotRouter', ]
 
 # Password validation
 # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators