-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_gui.py
246 lines (217 loc) · 9.83 KB
/
start_gui.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import tkinter as tk
from tkinter import ttk
from backshot import *
import time
def font(size: int, bold = False):
font_name = "Arial Black" if bold else "Arial"
return (font_name, size)
def get_int_value(widget: tk.Spinbox):
value = widget.get()
if value.isdigit():
return int(value)
raise ValueError()
def string_to_item(item_string: str):
item_string = item_string.lower()
items = []
for char in item_string:
match char:
case "h":
items += [Items.HANDCUFFS]
case "s":
items += [Items.HAND_SAW]
case "c":
items += [Items.CIGARETTES]
case "b":
items += [Items.BEER]
case "m":
items += [Items.MAGNIFYING_GLASS]
case "a":
items += [Items.ADRENALINE]
case "e":
items += [Items.EXPIRED_MEDICINE]
case "f":
items += [Items.BURNER_PHONE]
case "i":
items += [Items.INVERTER]
return items
class GraphicBackshot: # ha ha ha ha ha
def __init__(self):
self.window = tk.Tk()
self.window.title("Backshot Roulette GUI")
self.window.geometry("480x720")
self.window.resizable(True, False)
self.set_up_labels()
self.set_up_inputs()
def set_up_inputs(self):
self.maximum_health = tk.Spinbox(self.window,
from_ = 2,
to = 5,
font = font(16),
state = "readonly"
)
self.maximum_health.grid(row = 1, column = 1)
self.dealer_health = tk.Spinbox(self.window,
from_ = 1,
to = 5,
font = font(16),
state = "readonly"
)
self.dealer_health.grid(row = 2, column = 1)
self.player_health = tk.Spinbox(self.window,
from_ = 1,
to = 5,
font = font(16),
state = "readonly"
)
self.player_health.grid(row = 3, column = 1)
self.live_shells = tk.Spinbox(self.window,
from_ = 0,
to = 4,
font = font(16),
state = "readonly"
)
self.live_shells.grid(row = 5, column = 1)
self.blank_shells = tk.Spinbox(self.window,
from_ = 0,
to = 4,
font = font(16),
state = "readonly"
)
self.blank_shells.grid(row = 6, column = 1)
self.dealer_items = tk.Entry(self.window,
font = font(16)
)
self.dealer_items.grid(row = 8, column = 1)
self.player_items = tk.Entry(self.window,
font = font(16)
)
self.player_items.grid(row = 9, column = 1)
self.handcuffed = ttk.Combobox(self.window,
values = ["Not handcuffed", "Has already skipped turn", "Has not skipped turn"],
font = font(16),
state = "readonly"
)
self.handcuffed.current(0)
self.handcuffed.grid(row = 11, column = 1)
self.gun_is_sawed = tk.IntVar()
self.is_players_turn = tk.IntVar(value = 1)
self.current_shell = ttk.Combobox(self.window,
values = ["Unknown", "Live", "Blank"],
font = font(16),
state = "readonly"
)
self.current_shell.current(0)
self.current_shell.grid(row = 12, column = 1)
self.sawed_button = tk.Checkbutton(self.window,
variable = self.gun_is_sawed,
onvalue = 1,
offvalue = 0
)
self.sawed_button.grid(row = 13, column = 1)
self.turn_button = tk.Checkbutton(self.window,
variable = self.is_players_turn,
onvalue = 1,
offvalue = 0
)
self.turn_button.grid(row = 14, column = 1)
tk.Button(self.window,
text = "Search",
font = font(20),
command = lambda: self.search()
).grid(row = 15, column = 0, columnspan = 2)
def set_up_labels(self):
tk.Label(self.window,
text = "Backshot Roulette GUI",
font = font(32)
).grid(row = 0, column = 0, columnspan = 2, sticky = "N")
tk.Label(self.window,
text = "Maximum Health",
font = font(20)
).grid(row = 1, column = 0, sticky = "E")
tk.Label(self.window,
text = "Dealer's Health",
font = font(20)
).grid(row = 2, column = 0, sticky = "E")
tk.Label(self.window,
text = "Player's Health",
font = font(20)
).grid(row = 3, column = 0, sticky = "E")
tk.Label(self.window).grid(row = 4, column = 0)
tk.Label(self.window,
text = "# Live Shells",
font = font(20)
).grid(row = 5, column = 0, sticky = "E")
tk.Label(self.window,
text = "# Blank Shells",
font = font(20)
).grid(row = 6, column = 0, sticky = "E")
tk.Label(self.window).grid(row = 7, column = 0)
tk.Label(self.window,
text = "Dealer Items",
font = font(20)
).grid(row = 8, column = 0, sticky = "E")
tk.Label(self.window,
text = "Player Items",
font = font(20)
).grid(row = 9, column = 0, sticky = "E")
tk.Label(self.window).grid(row = 10, column = 0)
tk.Label(self.window,
text = "Handcuffed?",
font = font(20)
).grid(row = 11, column = 0, sticky = "E")
tk.Label(self.window,
text = "Current Shell?",
font = font(20)
).grid(row = 12, column = 0, sticky = "E")
tk.Label(self.window,
text = "Sawed Gun?",
font = font(20)
).grid(row = 13, column = 0, sticky = "E")
tk.Label(self.window,
text = "Player's Turn?",
font = font(20)
).grid(row = 14, column = 0, sticky = "E")
self.result_label = tk.Label(self.window,
text = "",
font = font(18)
)
self.result_label.grid(row = 16, column = 0, columnspan = 2)
def search(self):
self.result_label["text"] = "Searching..."
is_players_turn = bool(self.is_players_turn.get())
max_health = get_int_value(self.maximum_health)
dealer_health = max(max_health, get_int_value(self.dealer_health))
player_health = max(max_health, get_int_value(self.player_health))
lives = get_int_value(self.live_shells)
blanks = get_int_value(self.blank_shells)
dealer_items = string_to_item(self.dealer_items.get())[:8]
player_items = string_to_item(self.player_items.get())[:8]
position = BuckshotRouletteMove(is_players_turn,
max_health, dealer_health, player_health,
lives, blanks,
dealer_items,
player_items)
match self.current_shell.get():
case "Unknown":
current_shell = None
case "Live":
current_shell = "live"
case "Blank":
current_shell = "blank"
position.current_shell = current_shell
match self.handcuffed.get():
case "Not handcuffed":
handcuffed = 0
case "Has already skipped turn":
handcuffed = 1
case "Has not skipped turn":
handcuffed = 2
position.handcuffed = handcuffed
position.gun_is_sawed = bool(self.gun_is_sawed.get())
try:
self.result_label["text"] = BackshotRoulette().search(18, position).gui_string()
except UnboundLocalError:
self.result_label["text"] = "Error when trying to evaluate,\ncheck bullet counts or health."
def start(self):
self.window.mainloop()
GraphicBackshot().start()