-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
440 lines (332 loc) · 12.1 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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#Owen Haney, Atishay Jain
#Rev UC 2023
#GUIzero interface for RFID reading
from re import Match
from types import MappingProxyType
from guizero import App, Text, PushButton, TextBox, Combo, Box, Window
from rfid_module import readCharacter, writeCharacter
from time import sleep
import sys
import random
app = App(title="D&RFID",height=800)
def up(re):
re.update()
def kill():
app.destroy()
def write2(name,classs,race,xp,st,dex,con,intt,wis,cha,money,armor):
#Actually write the RFID
out=[st,dex,con,intt,wis,cha,classs,race,name,xp,armor,money]
export=" ".join(out)
writeCharacter(export)
#Sets up the area
wr2=Window(app,title="D&RFID WRITE2",height=800)
person=Box(wr2,width="fill",border=2)
chars=Text(person,text="Character", size=15)
stats=Box(wr2,border=2,width="fill",height="fill")
stat=Text(stats,text="Stats",size=15)
abil=Box(wr2,border=2,width="fill",height="fill")
abili=Text(abil,text="Ability Scores",size=15)
ski=Box(wr2,border=2,width="fill",height="fill")
skil=Text(ski,text="Skills",size=15)
at=Box(wr2,border=2,width="fill",height="fill")
att=Text(at,text="Attacks",size=15)
#Puts out Character information
cn=Text(person,text=name)
race=Text(person,text=race)
clas=Text(person,text=classs)
x=Text(stats, text="Xp {}".format(xp),size=10)
abs=Text(stats, text="Armour {}".format(armor),size=10)
abs=Text(stats, text="Money {}".format(money),size=10)
#Calculate modifiers
st=int(st);dex=int(dex);con=int(con);intt=int(intt);wis=int(wis);cha=int(cha)
Mstr = ((st-(st%2))/2)-5
Mdex = ((dex-(dex%2))/2)-5
Mcon = ((con-(con%2))/2)-5
Mint = ((intt-(intt%2))/2)-5
Mwis = ((wis-(wis%2))/2)-5
Mcha = ((cha-(cha%2))/2)-5
if race=="Human":
Minv+=1
if race=="elf":
Mcha = Mcha +1
if race=="orc":
Mst = Mst +1
if race=="Dwarf":
Mcon+=1
Mat = Mstr
Mac = Mdex
Msn = Mdex
Mar = Mint
Minv = Mint
Mins = Mwis
Mhe = Mwis
Mpec = Mwis
Mpes = Mcha
Mde = Mcha
if classs == "Barbarian":
Mat = Mat+2
Mpec = Mpec+2
if classs == "Knight":
Mac = Mac+2
Mpes = Mpes+2
if classs == "Wizard":
Mar = Mat+2
Mhe = Mpec+2
abs=Text(abil, text="Strength {}, Modifier: {}".format(st,Mstr),size=10)
abs=Text(abil, text="dexterity {}, Modifier: {}".format(dex,Mdex),size=10)
abs=Text(abil, text="Constitution {}, Modifier: {}".format(con,Mcon),size=10)
abs=Text(abil, text="Intelligence {}, Modifier: {}".format(intt,Mint),size=10)
abs=Text(abil, text="Wisdom {}, Modifier: {}".format(wis,Mwis),size=10)
abs=Text(abil, text="Charisma {}, Modifier: {}".format(cha,Mcha),size=10)
#The Skills Printed
abs=Text(ski, text="Atheletics {}".format(Mat),size=10)
abs=Text(ski, text="Acrobatics {}".format(Mac),size=10)
abs=Text(ski, text="Sneaking {}".format(Msn),size=10)
abs=Text(ski, text="Arcana {}".format(Mar),size=10)
abs=Text(ski, text="Investigation {}".format(Minv),size=10)
abs=Text(ski, text="Insight {}".format(Mins),size=10)
abs=Text(ski, text="Healing {}".format(Mhe),size=10)
abs=Text(ski, text="Perception {}".format(Mpec),size=10)
abs=Text(ski, text="Persuasion {}".format(Mpes),size=10)
abs=Text(ski, text="Deception {}".format(Mde),size=10)
#Calculate level
if int(xp)<300:
level=2
elif int(xp)<900:
level=3
elif int(xp)<2700:
level=4
elif int(xp)<6500:
level=5
elif int(xp)<14000:
level=5
elif int(xp)<23000:
level=6
elif int(xp)<34000:
level=7
elif int(xp)<48000:
level=8
elif int(xp)<64000:
level=9
elif int(xp)<85000:
level=10
elif int(xp)<100000:
level=11
elif int(xp)<900:
level=12
abs=Text(stats, text="Level {}".format(level),size=10)
#Attacks
if classs=="Knight":
if level>0:
abs=Text(at, text="Pike d4",size=10)
if level>4:
abs=Text(at, text="Short Sword d6",size=10)
if level>9:
abs=Text(at, text="Long Sword d8",size=10)
if level>14:
abs=Text(at, text="Calvary Charge d10",size=10)
if level>19:
abs=Text(at, text="Noble Smite d100",size=10)
h=10*level
elif classs=="Barbarian":
if level>0:
abs=Text(at, text="Fists d4",size=10)
if level>4:
abs=Text(at, text="Club Bash d6",size=10)
if level>9:
abs=Text(at, text="Battleaxe d8",size=10)
if level>14:
abs=Text(at, text="Lesser Rage d10",size=10)
if level>19:
abs=Text(at, text="Berserker Rage d100",size=10)
h=12*level
elif classs=="Wizard":
if level>0:
abs=Text(at, text="Gust d4",size=10)
if level>4:
abs=Text(at, text="Magic Missile d6",size=10)
if level>9:
abs=Text(at, text="Lightning Bolt d8",size=10)
if level>14:
abs=Text(at, text="Fireball d10",size=10)
if level>19:
abs=Text(at, text="Meteor Swarm d100",size=10)
h=8*level
abs=Text(stats, text="Max Hp {}".format(h),size=10)
kille=PushButton(wr2,text="Exit",command=kill)
def readApp():
t=readCharacter()
var=t.split()
re=Window(app,title="D&RFID READ",height=800)
person=Box(re,width="fill",border=2,height="fill")
chars=Text(person,text="Character",size=15)
stats=Box(re,border=2,width="fill",height="fill")
stat=Text(stats,text="Stats",size=15)
abil=Box(re,border=2,width="fill",height="fill")
abili=Text(abil,text="Ability Scores",size=15)
ski=Box(re,border=2,width="fill",height="fill")
skil=Text(ski,text="Skills",size=15)
at=Box(re,border=2,width="fill",height="fill")
att=Text(at,text="Attacks",size=15)
cn=Text(person,text=var[6])
race=Text(person,text=var[7])
clas=Text(person,text=var[8])
x=Text(stats, text="Xp {}".format(var[9]),size=10)
abs=Text(stats, text="Armour {}".format(var[10]),size=10)
abs=Text(stats, text="Money {}".format(var[11]),size=10)
st=int(var[0]);dex=int(var[1]);con=int(var[2]);intt=int(var[3]);wis=int(var[4]);cha=int(var[5]); xp=var[10]
Mstr = ((st-(st%2))/2)-5
Mdex = ((dex-(dex%2))/2)-5
Mcon = ((con-(con%2))/2)-5
Mint = ((intt-(intt%2))/2)-5
Mwis = ((wis-(wis%2))/2)-5
Mcha = ((cha-(cha%2))/2)-5
if race=="Human":
Minv+=1
if race=="elf":
Mcha = Mcha +1
if race=="orc":
Mst = Mst +1
if race=="Dwarf":
Mcon+=1
Mat = Mstr
Mac = Mdex
Msn = Mdex
Mar = Mint
Minv = Mint
Mins = Mwis
Mhe = Mwis
Mpec = Mwis
Mpes = Mcha
Mde = Mcha
if var[6] == "Barbarian":
Mat = Mat+2
Mpec = Mpec+2
if var[6] == "Knight":
Mac = Mac+2
Mpes = Mpes+2
if var[6] == "Wizard":
Mar = Mat+2
Mhe = Mpec+2
#The Ability Score section of inputes all in Text Boxes
abs=Text(abil, text="Strength {}, Modifier: {}".format(var[0],Mstr),size=10)
abs=Text(abil, text="dexterity {}, Modifier: {}".format(var[1],Mdex),size=10)
abs=Text(abil, text="Constitution {}, Modifier: {}".format(var[2],Mcon),size=10)
abs=Text(abil, text="Intelligence {}, Modifier: {}".format(var[3],Mint),size=10)
abs=Text(abil, text="Wisdom {}, Modifier: {}".format(var[4],Mwis),size=10)
abs=Text(abil, text="Charisma {}, Modifier: {}".format(var[5],Mcha),size=10)
#The Skills Printed
abs=Text(ski, text="Atheletics {}".format(Mat),size=10)
abs=Text(ski, text="Acrobatics {}".format(Mac),size=10)
abs=Text(ski, text="Sneaking {}".format(Msn),size=10)
abs=Text(ski, text="Arcana {}".format(Mar),size=10)
abs=Text(ski, text="Investigation {}".format(Minv),size=10)
abs=Text(ski, text="Insight {}".format(Mins),size=10)
abs=Text(ski, text="Healing {}".format(Mhe),size=10)
abs=Text(ski, text="Perception {}".format(Mpec),size=10)
abs=Text(ski, text="Persuasion {}".format(Mpes),size=10)
abs=Text(ski, text="Deception {}".format(Mde),size=10)
#Calculate level
if int(xp)<300:
level=2
elif int(xp)<900:
level=3
elif int(xp)<2700:
level=4
elif int(xp)<6500:
level=5
elif int(xp)<14000:
level=5
elif int(xp)<23000:
level=6
elif int(xp)<34000:
level=7
elif int(xp)<48000:
level=8
elif int(xp)<64000:
level=9
elif int(xp)<85000:
level=10
elif int(xp)<100000:
level=11
elif int(xp)<900:
level=12
abs=Text(stats, text="Level {}".format(level),size=10)
#Attacks
if var[6]=="Knight":
if level>0:
abs=Text(at, text="Pike d4",size=10)
if level>4:
abs=Text(at, text="Short Sword d6",size=10)
if level>9:
abs=Text(at, text="Long Sword d8",size=10)
if level>14:
abs=Text(at, text="Calvary Charge d10",size=10)
if level>19:
abs=Text(at, text="Noble Smite d100",size=10)
h=12*level
elif var[6]=="Barbarian":
if level>0:
abs=Text(at, text="Fists d4",size=10)
if level>4:
abs=Text(at, text="Club Bash d6",size=10)
if level>9:
abs=Text(at, text="Battleaxe d8",size=10)
if level>14:
abs=Text(at, text="Lesser Rage d10",size=10)
if level>19:
abs=Text(at, text="Berserker Rage d100",size=10)
h=10*level
elif var[6]=="Wizard":
if level>0:
abs=Text(at, text="Gust d4",size=10)
if level>4:
abs=Text(at, text="Magic Missile d6",size=10)
if level>9:
abs=Text(at, text="Lightning Bolt d8",size=10)
if level>14:
abs=Text(at, text="Fireball d10",size=10)
if level>19:
abs=Text(at, text="Meteor Swarm d100",size=10)
h=8*level
abs=Text(stats, text="Max Hp {}".format(h),size=10)
kille=PushButton(re,text="Exit",command=kill)
#Create the write
def writeApp():
wr=Window(app, title="D&RFID WRITE",height=800)
abs=Text(wr,text="\n\n")
cn=TextBox(wr,text="Enter Name",width=24)
clas=Combo(wr, options=["Select Class","Knight", "Wizard", "Barbarian"])
race=Combo(wr, options=["Select Race","Human", "Elf", "Dwarf", "Orc"])
xp=TextBox(wr,text="Enter XP",width=15)
abs=Text(wr, text="\n\nAbility Scores")
abs=Text(wr, text="STR",size=8)
st=TextBox(wr)
abs=Text(wr, text="DEX",size=8)
dex=TextBox(wr)
abs=Text(wr, text="CON",size=8)
con=TextBox(wr)
abs=Text(wr, text="INT",size=8)
intt=TextBox(wr)
abs=Text(wr, text="WIS",size=8)
wis=TextBox(wr)
abs=Text(wr, text="CHA",size=8)
cha=TextBox(wr)
abs=Text(wr, text="Money",size=8)
money =TextBox(wr)
abs=Text(wr, text="Armor",size=8)
armor =TextBox(wr)
fwrite=PushButton(wr,text="WRITE!",command=lambda:write2(cn.value,clas.value,race.value,xp.value,st.value,dex.value,con.value,intt.value,wis.value,cha.value,money.value,armor.value))
def Dice2(nds):
Dc2=Window(app,title="Dice2")
Rr = random.randint(1,nds)
abs= Text(Dc2,text =str(Rr),width=24)
def Dice():
Dc=Window(app, title="Roll Dice")
nds=TextBox(Dc,text="Enter Number of dice sides",width=24)
fwrite=PushButton(Dc,text="Roll!",command=lambda:Dice2(int(nds.value)))
intro = Text(app,text="RFID - Interactive Interface",size=30)
read = PushButton(app, text="Read Figure",width=35,height=10,command=readApp)
write = PushButton(app, text="Write to Figure",command=writeApp,width=35,height=10)
Dice_Roll = PushButton(app, text="Roll dice",command=Dice,width=35,height=10)
app.display()