-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBouncingMath.py
221 lines (177 loc) · 7.04 KB
/
BouncingMath.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# ============Main Code=============
# Import packages quick game
import QuickGame.GetInput
import CustomGame.Easy
import CustomGame.Medium
import CustomGame.Hard
import Database.gamedb
import Database.createdb
import sys
# Creating variables
begin = ''
num1 = 0
opp = ''
num2 = 0
count = 0
ans = 0
# begin = str(sys.argv[1])
# Checking the existence of the database
ex = Database.createdb.bdexist()
if ex == 0:
# Function to create databse
Database.createdb.createdb()
elif ex == 1:
pass
else:
print("Opps!! something is wrong with your xamp connection")
# Checking the existence of tables
extbl = Database.createdb.tblexist()
if extbl == 0:
# Function to create table
Database.createdb.createtbl()
Database.createdb.alttbl()
elif extbl == 1:
pass
else:
print("Opps!! something is wring with your xamp connection")
if sys.argv[1] == "play":
while True:
# Display Selection menue
print("==========Game Menu==========")
print("1 - Quick game")
print("2 - Custom game")
print("3 - View past game details")
print("4 - Exit")
print("-----------------------------\n")
choice = input("Enter your option: ")
print("\n")
if choice == '4':
print("Game Over")
break
elif choice == '1':
# ============Quick game==========
name = QuickGame.GetInput.getname()
# Calling function to display questions
QuickGame.GetInput.questions()
print("=============Game Results=========")
print("Your name is", name)
print("You played with Quick game play mode.")
print("You answered 10 questions")
print("\n", end="")
# Calling function to display player performance information
QuickGame.GetInput.info()
print("\n", end="")
# Calling finction to display score
print("Correct answers: ", QuickGame.GetInput.score())
print("Score as percentage: ", QuickGame.GetInput.perc(), "%")
print("\n", end="")
elif choice == '2':
# ===========Custom game==========
# Levels
print("\n", end=" ")
print("******Difficulty Levels******")
print("1 - Easy")
print("2 - Medium")
print("3 - Hard")
print("\n", end="")
# Level Selection
level = input("Select Level: ")
print("\n", end="")
# -------------------Level Easy--------------
if level == '1':
lev = "Easy"
# Getting name and no.of Questions
name, num = CustomGame.Easy.details()
# Calling function to display questions
CustomGame.Easy.questions()
# Function to display player performance
print("============Game Results=========")
print("Your name is", name)
print("You played with Easy mode.")
print("You answered ", num, "questions")
print("\n", end="")
CustomGame.Easy.performance()
# Calling function to calculate correct answes
score = CustomGame.Easy.score()
print("No.of Correct answers: ", score)
# Calling function to calculate percentage
perc = CustomGame.Easy.percScore()
print("Percentage score ", perc, "%")
print("\n", end="")
# Geting current date and time
time, date = CustomGame.Easy.clock()
print("Time : ", time)
print("Date : ", date)
print("\n", end="")
# Database connection
Database.gamedb.connect()
# Inserting values to database
Database.gamedb.insert(name, num, score, perc, lev, time, date)
# -------------------Level Medium--------------
elif level == '2':
lev = "Medium"
# Getting name and no.of Questions
name, num = CustomGame.Medium.details()
# Calling function to display qestions
CustomGame.Medium.questions()
# Function to display player performance
print("Your name is", name)
print("You played with Medium mode.")
print("You answered ", num, "questions")
print("\n", end="")
CustomGame.Medium.performance()
# Calling function to calculate score
score = CustomGame.Medium.score()
print("No.of Correct answers: ", score)
# Calling function to calculate percentage
perc = CustomGame.Medium.percScore()
print("Percentage score: ", perc, "%")
print("\n", end="")
# Geting current date and time
time, date = CustomGame.Medium.clock()
print("Time : ", time)
print("Date : ", date)
print("\n", end="")
# Database connection
Database.gamedb.connect()
# Inserting values to database
Database.gamedb.insert(name, num, score, perc, lev, time, date)
# -------------------Level Medium--------------
elif (level == '3'):
lev = "Hard"
# Getting name and no.of Questions
name, num = CustomGame.Hard.details()
##Calling function to display qestions
CustomGame.Hard.questions()
# Function to display player performance
print("Your name is", name)
print("You played with Hard mode.")
print("You answered ", num, "questions")
print("\n", end="")
CustomGame.Hard.performance()
# Calling function to calculate score
score = CustomGame.Hard.score()
print("No.of Correct answers: ", score)
# Calling function to calculate percentage
perc = CustomGame.Hard.percScore()
print("Percentage score: ", perc, "%")
print("\n", end="")
# Geting current date and time
time, date = CustomGame.Hard.clock()
print("Current time : ", time)
print("Current date : ", date)
print("\n", end="")
# Database connection
Database.gamedb.connect()
# Inserting values to database
Database.gamedb.insert(name, num, score, perc, lev, time, date)
else:
print("Invalied Difficulty level !!!")
elif choice == '3':
# ------------Past game details-------------
# Database connection
Database.gamedb.connect()
# Get user option
Database.gamedb.method()
else:
print("please type <play> to start the game")