-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_over.py
161 lines (143 loc) · 7.36 KB
/
game_over.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Form implementation generated from reading ui file 'GameOver.ui'
#
# Created by: PyQt6 UI code generator 6.0.3
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
import menu
from auxiliary.gui_base_methods import quit_window
from player import Player
class Ui_Form8(object):
def __init__(self, aux_players, board):
self.players_sorted = aux_players
self.board_handle = board
# ### DEBUG MISC START
# self.number_of_players = len(self.players)
# self.dict_players = {}
# self.players_sorted = []
# for i in range(self.number_of_players):
# self.dict_players[i] = []
# self.dict_players[i].append(self.players[i].name)
# self.dict_players[i].append(self.players[i].score)
# self.dict_players[i].append(self.players[i].fails)
# self.dict_players[i].append(self.players[i].swapped)
#
# for i in range(self.number_of_players):
# self.players_sorted.append([self.dict_players[i][0], self.dict_players[i][1]])
#
# self.players_sorted.sort(key=lambda x: x[1])
# ### DEBUG MISC END
def back_to_menu(self):
# self.window2 = QtWidgets.QMainWindow()
# self.ui = menu.Ui_Form()
# self.ui.setupUi(self.window2)
# self.window2.show()
self.board_handle.menu_handle.show()
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(345, 323)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("images/icon1.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
Form.setWindowIcon(icon)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
Form.setMinimumSize(QtCore.QSize(345, 323))
Form.setMaximumSize(QtCore.QSize(345, 323))
Form.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
Form.setStyleSheet("background-color:\"lightgreen\"\n"
"")
self.ladelabel = QtWidgets.QLabel(Form)
self.ladelabel.setGeometry(QtCore.QRect(130, 10, 111, 41))
font = QtGui.QFont()
font.setPointSize(12)
self.ladelabel.setFont(font)
self.ladelabel.setObjectName("ladelabel")
self.gridLayoutWidget = QtWidgets.QWidget(Form)
self.gridLayoutWidget.setGeometry(QtCore.QRect(30, 70, 291, 201))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.secondPnamelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.secondPnamelabel.setObjectName("secondPnamelabel")
self.gridLayout.addWidget(self.secondPnamelabel, 1, 0, 1, 1)
self.thirdPnamelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.thirdPnamelabel.setObjectName("thirdPnamelabel")
self.gridLayout.addWidget(self.thirdPnamelabel, 2, 0, 1, 1)
self.firstPnamelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.firstPnamelabel.setObjectName("firstPnamelabel")
self.gridLayout.addWidget(self.firstPnamelabel, 0, 0, 1, 1)
self.fourthPnamelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.fourthPnamelabel.setObjectName("fourthPnamelabel")
self.gridLayout.addWidget(self.fourthPnamelabel, 3, 0, 1, 1)
self.firstPscorelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.firstPscorelabel.setObjectName("firstPscorelabel")
self.gridLayout.addWidget(self.firstPscorelabel, 0, 1, 1, 1)
self.secondPscorelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.secondPscorelabel.setObjectName("secondPscorelabel")
self.gridLayout.addWidget(self.secondPscorelabel, 1, 1, 1, 1)
self.thirdPscorelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.thirdPscorelabel.setObjectName("thirdPscorelabel")
self.gridLayout.addWidget(self.thirdPscorelabel, 2, 1, 1, 1)
self.fourthPscorelabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.fourthPscorelabel.setObjectName("fourthPscorelabel")
self.gridLayout.addWidget(self.fourthPscorelabel, 3, 1, 1, 1)
self.backButton = QtWidgets.QPushButton(Form)
self.backButton.setGeometry(QtCore.QRect(60, 280, 230, 35))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.backButton.sizePolicy().hasHeightForWidth())
self.backButton.setSizePolicy(sizePolicy)
self.backButton.setMinimumSize(QtCore.QSize(230, 35))
self.backButton.setMaximumSize(QtCore.QSize(230, 35))
self.backButton.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
self.backButton.setStyleSheet("background-color:\"lightblue\"\n"
"")
self.backButton.setAutoDefault(False)
self.backButton.setObjectName("backButton")
### kurwa tu sie zamyka?
self.backButton.clicked.connect(self.back_to_menu)
self.backButton.clicked.connect(Form.close)
self.number_of_players = len(self.players_sorted)
print(self.players_sorted)
self.firstPnamelabel.setText(self.players_sorted[self.number_of_players - 1][0])
self.firstPscorelabel.setText(str(self.players_sorted[self.number_of_players - 1][1]))
self.secondPnamelabel.setText(self.players_sorted[self.number_of_players - 2][0])
self.secondPscorelabel.setText(str(self.players_sorted[self.number_of_players - 2][1]))
if self.number_of_players == 3:
self.thirdPnamelabel.setText(self.players_sorted[self.number_of_players - 3][0])
self.thirdPscorelabel.setText(str(self.players_sorted[self.number_of_players - 3][1]))
if self.number_of_players == 4:
self.thirdPnamelabel.setText(self.players_sorted[self.number_of_players - 3][0])
self.thirdPscorelabel.setText(str(self.players_sorted[self.number_of_players - 3][1]))
self.fourthPnamelabel.setText(self.players_sorted[self.number_of_players - 4][0])
self.fourthPscorelabel.setText(str(self.players_sorted[self.number_of_players - 4][1]))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Scrabble"))
self.ladelabel.setText(_translate("Form", "Game Over"))
self.backButton.setText(_translate("Form", "Back to menu"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
test1 = Player("", [])
test2 = Player("", [])
test3 = Player("", [])
# test4 = Player("", [])
test1.name = "XD"
test2.name = "elo"
test3.name = "yo"
# test4.name = "asd"
test = [test1, test2, test3]
ui = Ui_Form8(test, None)
ui.setupUi(Form)
Form.show()
sys.exit(app.exec())