From a18e7b1ff42a9e5933ad0ac33c8700ba47b9228a Mon Sep 17 00:00:00 2001 From: Alireza Karimi Date: Sun, 11 Aug 2024 02:19:58 +0330 Subject: [PATCH] Add {NaatoWon} and Showing Scores to Players. --- Controller.py | 18 +++++++++++++++++- Models.py | 2 +- main.py | 18 ++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Controller.py b/Controller.py index a5489ca..ec21ea0 100644 --- a/Controller.py +++ b/Controller.py @@ -170,6 +170,18 @@ def Terminator(self, userID): return userT + def AllUsersPoints(self, groupID): + + users = model.FetchTheAllMembersOfGroup(groupID) + + usersPoints = [] + + for user in users: + + usersPoints.append([user[2], user[1], user[4], user[6], None]) + + return usersPoints + def EndTheGame(self, groupID, Naato = None): if Naato != None: @@ -180,6 +192,10 @@ def EndTheGame(self, groupID, Naato = None): model.ToghseThePoint(groupID=groupID) # Share points equally with the team members + UsersPoints = self.AllUsersPoints(groupID=groupID) + model.ClearTheGroup(groupID=groupID) # Reset the group field - model.DeleteTheGroup(groupID=groupID) # Deleting the Group table will cascade to the deletion of score_scope, questions, and answers tables \ No newline at end of file + model.DeleteTheGroup(groupID=groupID) # Deleting the Group table will cascade to the deletion of score_scope, questions, and answers tables + + return UsersPoints \ No newline at end of file diff --git a/Models.py b/Models.py index a05ad47..09c95ee 100644 --- a/Models.py +++ b/Models.py @@ -619,7 +619,7 @@ def ToghseThePoint(self, groupID): mycursor.execute(sql) - myDB.commit() + myDB.commit() def NaatoWon(self, groupID): diff --git a/main.py b/main.py index 7ea32a7..70771fb 100644 --- a/main.py +++ b/main.py @@ -360,6 +360,10 @@ async def sendMessage(user, option="", poll=None, keyboard=[], text=""): # Masse await client.send_message(int(user[2]), text) + elif option == "ShowPoints": + + await client.send_message(int(user[0]), text) + @client.on(events.CallbackQuery()) async def callback(event): if event.data == b'1': @@ -883,7 +887,11 @@ async def A(event): await sendMessage(user=user, option="UserWin", text="و این که شما ........\n\nبرنده شدید ✌️🍾") - cont.EndTheGame(groupID=userT[0][5]) + end = cont.EndTheGame(groupID=userT[0][5]) + + for points in end: + + await sendMessage(user=points, option="ShowPoints", text=f"مجموعه امتیازات شما در این بازی {points[3]} میباشد.") elif len(Trust) < 2: @@ -897,7 +905,13 @@ async def A(event): await sendMessage(user=user, option="UserWin", text="و این که شما ........\n\nباختید 🥲👹") - cont.EndTheGame(groupID=userT[0][5], Naato="Naato") + end = cont.EndTheGame(groupID=userT[0][5], Naato="Naato") + + for points in end: + + print(points) + + await sendMessage(user=points, option="ShowPoints", text=f"مجموعه امتیازات شما در این بازی ***{points[3]}*** میباشد.") elif event.data == b"20":