add profile picture for opponent and remove username of p1 in getUserInfo

This commit is contained in:
2024-09-28 18:37:27 +02:00
parent 20ead24a3a
commit 10c2ef0e63
2 changed files with 16 additions and 8 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
# Updated: 2024/09/28 04:10:56 by tomoron ### ########.fr #
# Updated: 2024/09/28 18:18:51 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -73,6 +73,7 @@ class Game:
self.end = False
self.left = None
self.winner = None
self.expSleepTime = 0
self.p1Pos = {"pos":0, "up": False}
self.p2Pos = {"pos":0, "up": False}
@ -396,6 +397,8 @@ class Game:
print("AAAAAAAAAAAAAAAAAAAAAAA update")
now = time.time()
delta = now - self.lastUpdate
print("delta :", delta)
print("\033[31msleep time diff :", (delta - self.expSleepTime) * 1000, "ms")
currentBallPos = self.ballPos["pos"]
velX = self.ballVel[0]
velZ = self.ballVel[1]
@ -449,6 +452,7 @@ class Game:
break;
sleep_time = self.getSleepTime()
print("sleep time : " , sleep_time)
self.expSleepTime = sleep_time
await asyncio.sleep(sleep_time)
print("game end")
await self.saveResults()

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/20 00:16:57 by edbernar #+# #+# #
# Updated: 2024/09/28 04:43:44 by tomoron ### ########.fr #
# Updated: 2024/09/28 18:35:21 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -18,14 +18,18 @@ import json
def getHistory(user, games):
res = []
for x in games:
p1 = {"score":int(x.p1Score), "username":x.player1.username}
p2 = {"score":int(x.p2Score), "username":x.player2.username}
if(x.player2 == user):
p1, p2 = p2, p1
player = None
opponent = None
if(x.player1 == user):
player = {"score":int(x.p1Score)}
opponent = {"score":int(x.p2Score), "username":x.player2.username, "pfp":x.player2.pfp}
else:
player = {"score":int(x.p2Score)}
opponent = {"score":int(x.p1Score), "username":x.player1.username, "pfp":x.player1.pfp}
res.append({
"id":x.id,
"p1":p1,
"p2":p2,
"p1":player,
"p2":opponent,
"won":x.winner == user
})
return(res)