-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
86 lines (72 loc) · 3.37 KB
/
main.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
#!/usr/bin/env python3
import sys
from PyQt5.QtWidgets import QMainWindow,QMessageBox,QApplication
from mainwindow import MainWindow
from onlinewindow import OnlineWindow
from mygame import MyGame
__author__ = "Kushagra Surana"
class Window(QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.mainWidget = MainWindow()
self.mainWidget.ui.start.clicked.connect(self.change_central_widget)
self.mainWidget.ui.load_game2.clicked.connect(self.showLoadGameWindow)
self.mainWidget.ui.onlineGameButton.clicked.connect(self.show_online_game_window)
self.setCentralWidget(self.mainWidget)
def show_online_game_window(self):
self.onlineWindow = OnlineWindow()
self.setCentralWidget(self.onlineWindow)
def change_central_widget(self):
f = 1
if not ((self.mainWidget.ui.rb1.isChecked() or self.mainWidget.ui.rb2.isChecked()) and (
self.mainWidget.ui.rb3.isChecked() or self.mainWidget.ui.rb4.isChecked())):
QMessageBox.about(None, "", "Select Players")
else:
if self.mainWidget.ui.rb1.isChecked():
if self.mainWidget.ui.rb3.isChecked(): # bot vs bot
if self.mainWidget.ui.bot_path1.text() == "" or self.mainWidget.ui.bot_path2.text() == "":
QMessageBox.about(None, "error", "no bot file")
f = 0 # dialog for null
self.gameWidget = MyGame(1, "", self.mainWidget.ui.bot_path1.text(),
self.mainWidget.ui.bot_path2.text())
else:
if self.mainWidget.ui.bot_path1.text() == "":
QMessageBox.about(None, "error", "no bot file")
f = 0
else:
self.gameWidget = MyGame(1, "", self.mainWidget.ui.bot_path1.text()) # bot vs human
else:
if self.mainWidget.ui.rb3.isChecked():
if self.mainWidget.ui.bot_path2.text() == "":
QMessageBox.about(None, "error", "no bot file")
f = 0
else:
self.gameWidget = MyGame(1, "", "", self.mainWidget.ui.bot_path2.text()) # human vs bot
else:
self.gameWidget = MyGame() # human vs human
if f:
self.setCentralWidget(self.gameWidget)
self.gameWidget.back.clicked.connect(self.change_central_widget2)
def change_central_widget2(self):
self.mainWidget = MainWindow()
self.mainWidget.ui.start.clicked.connect(self.change_central_widget)
self.mainWidget.ui.load_game2.clicked.connect(self.showLoadGameWindow)
self.setCentralWidget(self.mainWidget)
def showLoadGameWindow(self):
new_game = 0
print("loading")
file_path = self.mainWidget.ui.load_path.text()
if (file_path == ""):
pass
else:
self.gameWidget = MyGame(new_game, file_path)
self.setCentralWidget(self.gameWidget)
self.gameWidget.back.clicked.connect(self.change_central_widget2)
def main():
app = QApplication(sys.argv)
my_app = Window()
my_app.show()
my_app.setWindowTitle("3Knights")
sys.exit(app.exec_())
if __name__ == "__main__":
main()