Skip to content

Commit

Permalink
Merge pull request #40 from Alireza0K/Develop
Browse files Browse the repository at this point in the history
Add {NaatoWon} and Showing Scores to Players.
  • Loading branch information
Alireza0K authored Aug 10, 2024
2 parents 54558a7 + a18e7b1 commit bbbfafd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
18 changes: 17 additions & 1 deletion Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
model.DeleteTheGroup(groupID=groupID) # Deleting the Group table will cascade to the deletion of score_scope, questions, and answers tables

return UsersPoints
2 changes: 1 addition & 1 deletion Models.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def ToghseThePoint(self, groupID):

mycursor.execute(sql)

myDB.commit()
myDB.commit()

def NaatoWon(self, groupID):

Expand Down
18 changes: 16 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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:

Expand All @@ -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":

Expand Down

0 comments on commit bbbfafd

Please sign in to comment.