Merge branch 'latest-version' of bitbucket.org:FluffyMeowl/stroopwafel into latest-version
This commit is contained in:
@@ -122,7 +122,7 @@ class Points(commands.Cog):
|
||||
"""
|
||||
|
||||
message = "**De puntentelling:** \n```"
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
pointsCountSorted = sorted(pointsCount.items(), key=lambda i: i[1]['points'], reverse=True)
|
||||
for user in pointsCountSorted:
|
||||
if user[0] != self.BANK_ID:
|
||||
@@ -146,31 +146,31 @@ class Points(commands.Cog):
|
||||
|
||||
# Transfer points form one user to another
|
||||
def transferPoints(self, fromUserId, toUserId, points):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
pointsCount[fromUserId]["points"] -= points
|
||||
pointsCount[toUserId]["points"] += points
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
# Do we know this user?
|
||||
def isUserOnList(self, user):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
return user.id in pointsCount.keys()
|
||||
|
||||
# Get a user's point balance
|
||||
def getUserBalance(self, user):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
return pointsCount[user.id]["points"]
|
||||
|
||||
# Get the balance of the bank
|
||||
def getBankBalance(self):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
return pointsCount[self.BANK_ID]["points"]
|
||||
|
||||
# To keep track if a user used some points today, we look at when the last time was he/she used them
|
||||
# If this was in the past: reset
|
||||
# Also, return the updated object. Why not.
|
||||
def refreshDateVarsAndReturnUserVars(self, userId):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
currentDateStr = datetime.now().strftime("%Y%m%d")
|
||||
if pointsCount[userId]["theDate"] != currentDateStr:
|
||||
pointsCount[userId]["theDate"] = currentDateStr
|
||||
@@ -192,14 +192,14 @@ class Points(commands.Cog):
|
||||
# Increase the number of points this user has taken away today.
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersPointTakenOnDate(self, userId, points):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
pointsCount[userId]["pointTakenOnDate"] += points
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
# Increase the number of bank points this user has given today
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersBankPointGivenAwayToday(self, userId, points):
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
pointsCount[userId]["bankPointsGivenOnDate"] += points
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
@@ -252,10 +252,10 @@ class Points(commands.Cog):
|
||||
def init(self):
|
||||
# Check if points file exists:
|
||||
try:
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
except FileNotFoundError:
|
||||
np.save("pointscount.npy", {})
|
||||
pointsCount = np.load('pointscount.npy').item()
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
|
||||
# Initialise the bank:
|
||||
if self.BANK_ID not in pointsCount.keys():
|
||||
|
||||
Reference in New Issue
Block a user