-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomizer.py
More file actions
813 lines (726 loc) · 32.3 KB
/
randomizer.py
File metadata and controls
813 lines (726 loc) · 32.3 KB
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
from specialCard import SpecialCard
from standardCard import StandardCard
from prophecyCard import ProphecyCard
from allyCard import AllyCard
import csv
import random
import os
from PIL import ImageTk, Image
root = Tk()
root.title('Dominion Card Randomizer')
root.configure(background="#f0d5b6")
expandedSets = ['Dominion First', 'Dominion Second', 'Intrigue First', 'Intrigue Second', 'Seaside First', 'Seaside Second', 'Alchemy', 'Prosperity First', 'Prosperity Second','Cornucopia & Guilds First',
'Cornucopia & Guilds Second', 'Hinterlands First', 'Hinterlands Second', 'Dark Ages', 'Adventures', 'Empires', 'Nocturne', 'Renaissance', 'Menagerie', 'Allies', 'Plunder', 'Rising Sun', 'Promo']
sets = {}
for name in expandedSets:
sets[name] = BooleanVar(value=False)
frameStyle = ttk.Style()
frameStyle.configure("TFrame", background = "#f0d5b6")
checkStyle = ttk.Style()
checkStyle.configure("TCheckbutton", background = "#f0d5b6", font = ("Arial", 18))
labelStyle = ttk.Style()
labelStyle.configure("TLabel", background = "#f0d5b6",font = ("Arial", 18))
RadioStyle = ttk.Style()
RadioStyle.configure("TRadiobutton", background = "#f0d5b6", font = ("Arial", 18))
leftframe = ttk.Frame(root, padding="3 3 12 12")
leftframe.grid(column = 0, row = 0, sticky=(N, W, E, S))
rightframe = ttk.Frame(root, padding="3 3 12 12")
rightframe.grid(column = 1, row = 0, sticky=(N, W, E, S))
selectorframe = ttk.Frame(leftframe, padding="3 3 12 12", style="TFrame")
selectorframe.grid(column=0, row=0, sticky=(N, W, E, S))
baseframe = ttk.Frame(rightframe,borderwidth=5, relief="ridge")
baseframe.grid(column=0, row=0, sticky=(N, W, E, S))
setModifierframe = ttk.Frame(rightframe,borderwidth = 5, relief="ridge", style="TFrame")
setModifierframe.grid(column = 1, row = 0, columnspan=2, sticky = (N, W, E, S))
horizontalSetModifierframe = ttk.Frame(rightframe,borderwidth = 5, relief="ridge", style="TFrame")
horizontalSetModifierframe.grid(column=1, row=1, sticky = (N, W, E, S))
specialframe = ttk.Frame(rightframe,borderwidth=5, relief="ridge", style="TFrame")
specialframe.grid(column = 0, row = 1, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.columnconfigure(1, weight=3)
def submit():
# Generate all available cards in selected sets
resetFrame()
if checkForAttackCollision():
return
baseCards = fillBaseLibrary(sets)
if checkForMinimumCards(baseCards):
return
specialCards = fillSpecialLibrary(sets)
prophecyCards = fillProphecyLibrary(sets)
allyCards = fillAllyLibrary(sets)
# Select random cards from available cards
selectedBaseCards = sortCards(selectBaseCards(baseCards))
selectedSpecialCards = sortCards(selectSpecialCards(specialCards))
if checkForOmen(selectedBaseCards):
selectedProphecy = (selectProphecy(prophecyCards))
if checkForApproachingArmy(selectedProphecy, baseCards, selectedBaseCards) and excludeAttackToggle.get():
selectedProphecy = rerollProphecy(prophecyCards)
prophecySpace = generateProphecy()
prophecySpace.config(image=selectedProphecy.image, text = selectedProphecy.name)
prophecySpace.image = selectedProphecy.image
if checkForLiaison(selectedBaseCards):
selectedAlly = (selectAlly(allyCards))
allySpace = generateAlly()
allySpace.config(image=selectedAlly.image, text = selectedAlly.name)
allySpace.image = selectedAlly.image
checkProsperity(selectedBaseCards)
checkDarkAges(selectedBaseCards)
checkAlchemy(selectedBaseCards)
checkLooter(selectedBaseCards)
checkLoot(selectedBaseCards, selectedSpecialCards)
checkSpoils(selectedBaseCards)
checkForGhost(selectedBaseCards)
checkForImp(selectedBaseCards)
checkForWillOWhisp(selectedBaseCards)
checkForWish(selectedBaseCards)
checkForFerryman(selectedBaseCards, baseCards)
checkForYoungWitch(selectedBaseCards, baseCards)
checkForWayOfTheMouse(selectedSpecialCards, baseCards, selectedBaseCards)
checkFate(selectedBaseCards)
checkDoom(selectedBaseCards)
# Prepare cards for UI display
generateBaseCards(selectedBaseCards)
generateSpecialCards(selectedBaseCards,selectedSpecialCards)
def fillBaseLibrary(setDictionary):
cardList = set (())
with open('standardCards.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
for key, value in setDictionary.items():
if value.get() == True:
if row[5] in key:
if "First" in key:
strippedCard = key[:-6]
edition = key[-5:]
if row[5] == strippedCard and row[4] == edition or row[4] == "Base":
if "+2 Actions" in row[6]:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6],None,True))
else:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6]))
if "Second" in key:
strippedCard = key[:-7]
edition = key[-6:]
if row[5] == strippedCard and row[4] == edition or row[4] == "Base":
if "+2 Actions" in row[6]:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6],None,True))
else:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6]))
else:
if row[5] == key:
if "+2 Actions" in row[6]:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6],None,True))
else:
cardList.add(StandardCard(row[0],int(row[1]),row[2],row[3],row[4],row[5],row[6]))
addImage(cardList)
return cardList
def fillSpecialLibrary(setDictionary):
cardList = set(())
with open('specialCards.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
for key, value in setDictionary.items():
if value.get() == True:
if key.endswith("Base"):
edition = key[-5:]
if row[2] == edition:
cardList.add(SpecialCard(row[0], row[1], row[2], row[3], row[4]))
if "First" in key:
edition = key[-6:]
if row[2] == edition or row[2] == "Base":
cardList.add(SpecialCard(row[0], row[1], row[2], row[3], row[4]))
if "Second" in key:
edition = key[-7:]
if row[2] == edition or row[2] == "Base":
cardList.add(SpecialCard(row[0], row[1], row[2], row[3], row[4]))
else:
if row[2] == key:
cardList.add(SpecialCard(row[0], row[1], row[2], row[3], row[4]))
addImage(cardList)
return cardList
def addImage (cardList):
for card in cardList:
if isinstance(card,StandardCard):
width = 200
height = 320
else:
width = 320
height = 200
directory = "cardImages\\"+shortenTitle(card.set)
with os.scandir(directory) as entries:
for entry in entries:
cleanEntry = entry.path.lower().split("px")[1]
if cleanName(card) == cleanEntry:
img = Image.open(entry.path)
resizedPhoto = img.resize((width, height), Image.LANCZOS)
photo = ImageTk.PhotoImage(resizedPhoto)
card.image = photo
# Strips everything but the first word in the expansion
def shortenTitle (expansion):
return expansion.split(" ",1)[0]
def cleanName(card):
return card.name.replace(" ","").lower() + ".jpg"
def fillProphecyLibrary(setDictionary):
cardList = []
with open('prophecyCards.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
for key, value in setDictionary.items():
if value.get() == True:
if row[2] == key:
cardList.append(ProphecyCard(row[0], row[1], row[2]))
addImage(cardList)
return cardList
def fillAllyLibrary(setDictionary):
cardList = []
with open('allyCards.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
for key, value in setDictionary.items():
if value.get() == True:
if row[2] == key:
cardList.append(AllyCard(row[0], row[1], row[2]))
addImage(cardList)
return cardList
def selectBaseCards(cardList):
selectedCards = set(())
if len(cardList) > 0:
while len(selectedCards) < 10:
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
excludeAttack(cardList, selectedCards)
checkAttack(cardList,selectedCards)
checkVillage(cardList,selectedCards)
checkCostCurve(cardList,selectedCards)
# for card in selectedCards:
# print(card.name)
return selectedCards
def selectSpecialCards(cardList):
selectedCards = set(())
if len(cardList) > 0:
while len(selectedCards) < eventNumber.get():
if len(selectedCards) == eventNumber.get() or len(cardList) == 0 or len(selectedCards) == len(cardList):
break
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
if len(cardList) < eventNumber.get():
messagebox.showwarning("Not enough special cards", "There are not enough special cards in the set to fulfill your request")
return selectedCards
def sortCards (cardSet):
cardList = []
for card in cardSet:
cardList.append(card)
cardList.sort(key=cardCost)
return cardList
def excludeAttack(cardList, selectedCards):
attackCards = []
if len(selectedCards) == 10 and excludeAttackToggle.get() and lookForAttack(selectedCards):
while lookForAttack(selectedCards):
for card in selectedCards:
if "Attack" in card.type:
attackCards.append(card)
if len(attackCards) > 0:
for card in attackCards:
selectedCards.remove(card)
while len(selectedCards) < 10:
randomCard = random.choice(list(cardList))
while "Attack" in randomCard.type:
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
def checkAttack(cardList, selectedCards):
if len(selectedCards) == 10 and includeAttackToggle.get() and not lookForAttack(selectedCards):
selectedCards.pop()
randomCard = random.choice(list(cardList))
while "Attack" not in randomCard.type:
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
def checkVillage(cardList, selectedCards):
if len(selectedCards) == 10 and villageToggle.get() and not lookForVillage(selectedCards):
if includeAttackToggle.get():
removedCard = selectedCards.pop()
while "Attack" in removedCard.type:
selectedCards.add(removedCard)
removedCard = selectedCards.pop()
else:
selectedCards.pop()
randomCard = random.choice(list(cardList))
if includeAttackToggle.get():
while randomCard.village != True or "Attack" in randomCard.type:
randomCard = random.choice(list(cardList))
else:
while randomCard.village != True:
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
def checkCostCurve(cardList,selectedCards):
# Checks if cost curve is possible
allCardsRequired = True
totalCardCosts = []
for card in cardList:
totalCardCosts.append(card.cost)
for i in range (2,6):
if totalCardCosts.count(i) == 0:
allCardsRequired = False
if curveToggle.get():
messagebox.showwarning("Not enough values", "There are not enough cards that cost between 2-5")
return
if len(selectedCards) == 10 and curveToggle.get() and allCardsRequired:
cardCosts = []
for card in selectedCards:
cardCosts.append(card.cost)
# Check for any missing costs
for i in range (2,6):
if cardCosts.count(i) == 0:
missingCost = i
# Check for duplicate cost card and remove it
for i in range(2,6):
if cardCosts.count(i) > 1:
for card in selectedCards:
if includeAttackToggle.get() and "Attack" in card.type:
continue
if villageToggle.get() and card.village == True:
continue
if card.cost == i:
selectedCards.remove(card)
break
# Add another card that is the needed cost
randomCard = random.choice(list(cardList))
if excludeAttackToggle.get() and villageToggle.get():
while randomCard.cost != missingCost and "Attack" in randomCard.type and randomCard.village == True:
randomCard = random.choice(list(cardList))
elif excludeAttackToggle.get():
while randomCard.cost != missingCost and "Attack" in randomCard.type:
randomCard = random.choice(list(cardList))
elif villageToggle.get():
while randomCard.cost != missingCost and randomCard.village == True:
randomCard = random.choice(list(cardList))
else:
while randomCard.cost != missingCost:
randomCard = random.choice(list(cardList))
selectedCards.add(randomCard)
def checkProsperity(selectedCards):
for card in selectedCards:
if card.set == "Prosperity":
rawImage = Image.open("cardImages\\Extras\\Colony-Platinum.png")
fixedImage = ImageTk.PhotoImage(rawImage)
colonyPlatinum = generateColonyPlatinum()
colonyPlatinum.configure(image = fixedImage)
colonyPlatinum.image = fixedImage
def checkDarkAges(selectedCards):
for card in selectedCards:
if "Dark Ages" in card.set:
rawImage = Image.open("cardImages\\Extras\\Shelters.webp")
fixedImage = ImageTk.PhotoImage(rawImage)
shelters = generateShelters()
shelters.configure(image = fixedImage)
shelters.image = fixedImage
def checkAlchemy(selectedCards):
for card in selectedCards:
if "Alchemy" in card.set:
rawImage = Image.open("cardImages\\Extras\\Potion.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
potion = generatePotion()
potion.configure(image = fixedImage)
potion.image = fixedImage
def checkLooter(selectedCards):
for card in selectedCards:
if "Looter" in card.type:
rawImage = Image.open("cardImages\\Extras\\Ruins.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
ruin = generateRuin()
ruin.configure(image = fixedImage)
ruin.image = fixedImage
def checkLoot(baseCards, specialCards):
lootNeeded = False
for card in baseCards:
if "Loot" in card.text:
lootNeeded = True
if lootNeeded == False:
for card in specialCards:
if "Loot" in card.text:
lootNeeded = True
if lootNeeded == True:
rawImage = Image.open("cardImages\\Extras\\Loot.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
loot = generateLoot()
loot.configure(image = fixedImage)
loot.image = fixedImage
def checkSpoils(selectedCards):
for card in selectedCards:
if "Spoils" in card.text:
rawImage = Image.open("cardImages\\Extras\\Spoils.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
spoils = generateSpoils()
spoils.configure(image = fixedImage)
spoils.image = fixedImage
def checkForFerryman (selectedCards, cardList):
for card in selectedCards:
if card.name == "Ferryman":
possibleCards = []
for card in cardList:
if (card.cost == 3 or card.cost == 4) and card not in selectedCards:
possibleCards.append(card)
cardLabel = generateFerryman()
randomCard = possibleCards[random.randrange(0,len(possibleCards))]
cardLabel.config(image = randomCard.image, text = randomCard.name)
cardLabel.image = randomCard.image
def checkForYoungWitch (selectedCards, cardList):
for card in selectedCards:
if card.name == "Young Witch":
possibleCards = []
for card in cardList:
if (card.cost == 2 or card.cost == 3) and card not in selectedCards:
possibleCards.append(card)
cardLabel = generateYoungWitch()
randomCard = possibleCards[random.randrange(0,len(possibleCards))]
cardLabel.config(image = randomCard.image, text = randomCard.name)
cardLabel.image = randomCard.image
def checkForGhost (selectedCards):
for card in selectedCards:
if card.name == "Cemetery" or card.name == "Exorcist":
rawImage = Image.open("cardImages\\Extras\\Ghost.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
ghost = generateGhost()
ghost.configure(image = fixedImage)
ghost.image = fixedImage
def checkForImp (selectedCards):
for card in selectedCards:
if card.name == "Devil's Workshop" or card.name == "Tormentor" or card.name == "Exorcist":
rawImage = Image.open("cardImages\\Extras\\Imp.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
imp = generateImp()
imp.configure(image = fixedImage)
imp.image = fixedImage
def checkForWillOWhisp (selectedCards):
for card in selectedCards:
if card.name == "Exorcist":
rawImage = Image.open("cardImages\\Extras\\Will-o'-Wisp.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
wisp = generateWillOWhisp()
wisp.configure(image = fixedImage)
wisp.image = fixedImage
def checkForWish (selectedCards):
for card in selectedCards:
if card.name == "Leprechaun" or card.name == "Secret Cave":
rawImage = Image.open("cardImages\\Extras\\Wish.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
wish = generateWish()
wish.configure(image = fixedImage)
wish.image = fixedImage
def checkForWayOfTheMouse (specialCards, cardList, basecards):
for card in specialCards:
if card.name == "Way of the Mouse":
possibleCards = []
for card in cardList:
if (card.cost == 2 or card.cost == 3) and "Duration" not in card.type and card not in basecards:
possibleCards.append(card)
cardLabel = generateMouse()
randomCard = possibleCards[random.randrange(0,len(possibleCards))]
cardLabel.config(image = randomCard.image, text = randomCard.name)
cardLabel.image = randomCard.image
def checkForApproachingArmy (prophecy, cardList, basecards):
if prophecy.name == "Approaching Army":
possibleCards = []
for card in cardList:
if "Attack" in card.type and card not in basecards:
possibleCards.append(card)
cardLabel = generateApproachingArmy()
randomCard = possibleCards[random.randrange(0,len(possibleCards))]
cardLabel.config(image = randomCard.image, text = randomCard.name)
cardLabel.image = randomCard.image
return True
return False
def checkFate(selectedCards):
for card in selectedCards:
if "Fate" in card.type:
rawImage = Image.open("cardImages\\Extras\\Will-o'-Wisp.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
wisp = generateWillOWhisp()
wisp.configure(image = fixedImage)
wisp.image = fixedImage
rawImage = Image.open("cardImages\\Extras\\Boon.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
boons = generateBoon()
boons.configure(image = fixedImage)
boons.image = fixedImage
def checkDoom(selectedCards):
for card in selectedCards:
if "Doom" in card.type:
rawImage = Image.open("cardImages\\Extras\\Hex.jpg")
fixedImage = ImageTk.PhotoImage(rawImage)
hexes = generateHex()
hexes.configure(image = fixedImage)
hexes.image = fixedImage
def cardCost (StandardCard):
return StandardCard.cost
def selectProphecy (cardList: list[ProphecyCard]):
return random.choice(list(cardList))
def selectAlly (cardList: list[AllyCard]):
return random.choice(list(cardList))
def rerollProphecy (prophecyList):
randomCard = prophecyList[random.randrange(0,len(prophecyList))]
while randomCard.name == "Approaching Army":
randomCard = prophecyList[random.randrange(0,len(prophecyList))]
return randomCard
def resetFrame():
for card in baseframe.winfo_children():
card.destroy()
for card in specialframe.winfo_children():
card.destroy()
for card in setModifierframe.winfo_children():
card.destroy()
for card in horizontalSetModifierframe.winfo_children():
card.destroy()
def checkForOmen (cardList):
for card in cardList:
if 'Omen' in card.type:
return True
return False
def checkForLiaison (cardList):
for card in cardList:
if 'Liaison' in card.type:
return True
return False
def checkForAttackCollision():
if excludeAttackToggle.get() and includeAttackToggle.get():
messagebox.showerror("Invalid option", "Both Include Attacks and Exclude Attacks are selected")
return True
return False
def checkForMinimumCards(cardList):
if len(cardList) < 10:
messagebox.showerror("Set error", "Not enough cards to generate a full set")
return True
return False
def lookForAttack (cardSet):
for card in cardSet:
if 'Attack' in card.type:
return True
return False
def lookForVillage (cardSet):
for card in cardSet:
if card.village == True:
return True
return False
# Generate checkboxes and place on grid
checkboxes = []
gridRow = 0
for name in expandedSets:
pogCheck = ttk.Checkbutton(selectorframe, text=name, variable=sets[name], style="TCheckbutton").grid(column = 0, row = gridRow, sticky=W)
checkboxes.append(pogCheck)
gridRow = gridRow + 1
eventCountLabel = ttk.Label(selectorframe, text="Event number", style="TLabel")
eventCountLabel.grid(column=0, row=100, sticky=W)
eventNumber = IntVar()
for i in range(5):
radio = ttk.Radiobutton(selectorframe, text = i, variable = eventNumber, value = i, style="TRadiobutton")
radio.grid(column=0, row=101 + i,sticky=W)
excludeAttackToggle = BooleanVar()
excludeAttackCheck = ttk.Checkbutton(selectorframe, text = "Exclude attacks", variable = excludeAttackToggle)
excludeAttackCheck.grid(column = 0, row = 112, sticky = W)
includeAttackToggle = BooleanVar()
includeAttackCheck = ttk.Checkbutton(selectorframe, text = "Include at least one attack", variable = includeAttackToggle)
includeAttackCheck.grid(column=0, row = 113, sticky=W)
villageToggle = BooleanVar()
villageCheck = ttk.Checkbutton(selectorframe, text = "Include +2 Actions", variable = villageToggle)
villageCheck.grid(column=0, row=114, sticky=W)
curveToggle = BooleanVar()
curveCheck = ttk.Checkbutton(selectorframe, text = "Guarantee 2-5 cost curve", variable = curveToggle)
curveCheck.grid(column = 0, row = 115, sticky = W)
submitButton = ttk.Button(selectorframe,text='Submit', command=submit,).grid(column = 0, row = 200)
def generateBaseCards(selectedBasecards):
gridCol = 0
gridRow = 0
for i in range(len(selectedBasecards)):
if i == 5:
gridCol = 0
gridRow = 1
cardframe = ttk.Frame(baseframe)
cardframe.grid(column=gridCol, row=gridRow, sticky=(N,W,E,S))
gridCol = gridCol + 1
basecard = ttk.Label(cardframe, image=selectedBasecards[i].image, text=selectedBasecards[i].name)
basecard.image = selectedBasecards[i].image
basecard.grid(column = 0, row = 0)
basecardLabel = ttk.Label(cardframe, text = selectedBasecards[i].set)
basecardLabel.config(font=("Arial", 12, "bold"))
basecardLabel.grid(column = 0, row = 1, pady=(5,15))
def generateSpecialCards(selectedBasecards ,selectedSpecialcards):
gridCol = 0
gridRow = 0
availableCards = selectedBasecards
for i in range(len(selectedSpecialcards)):
cardframe = ttk.Frame(specialframe)
cardframe.grid(column=gridCol, row=gridRow, sticky=(N,W,E,S), pady = (0,7))
gridCol = gridCol + 1
specialcard = ttk.Label(cardframe, image=selectedSpecialcards[i].image, text=selectedSpecialcards[i].name)
specialcard.image = selectedSpecialcards[i].image
specialcard.grid(column = 0, row = 0)
specialcardLabel = ttk.Label(cardframe, text = selectedSpecialcards[i].set)
specialcardLabel.config(font=("Arial", 10, "bold"))
specialcardLabel.grid(column = 0, row = 1)
if selectedSpecialcards[i].type == "Trait":
availableCards.remove(assignTrait(cardframe, availableCards))
def assignTrait(cardframe, selectedBasecards):
cleanedList = []
for card in selectedBasecards:
if "Action" in card.type or "Treasure" in card.type:
cleanedList.append(card)
selectedCard = random.choice(cleanedList)
traitLabel = ttk.Label(cardframe, text = "Applies to "+ selectedCard.name)
traitLabel.config(font=("Arial", 10))
traitLabel.grid(column = 0, row = 2, pady = (0,5))
return selectedCard
def generateProphecy():
prophecyCard = ttk.Label(specialframe, image=None, text = None)
prophecyCard.grid(column = 1, row = 3)
return prophecyCard
def generateAlly():
allyCard = ttk.Label(specialframe, image=None, text = None)
allyCard.grid(column=0, row = 3)
return allyCard
def generateColonyPlatinum():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 0, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(setModifierframe, text="Colonies and Platinums needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateShelters():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 1, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Shelters needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generatePotion():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 3, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Potions needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateLoot():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 4, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Loot needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateFerryman():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 1, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Ferried Card")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateYoungWitch():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 1, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Young Witch's Bane")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateMouse():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 2, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Way of the Mouse Card")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateApproachingArmy():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 3, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Approaching Army Card")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateRuin():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 4, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Ruins needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateSpoils():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 5, row = 2)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Spoils needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateGhost():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 0, row = 3)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Ghost needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateImp():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 1, row = 3)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Imp needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateWillOWhisp():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 2, row = 3)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Will O' Wisp needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateWish():
cardframe = ttk.Frame(setModifierframe)
cardframe.grid(column = 3, row = 3)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Wish needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateBoon():
cardframe = ttk.Frame(horizontalSetModifierframe)
cardframe.grid(column = 0, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Boons needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
def generateHex():
cardframe = ttk.Frame(horizontalSetModifierframe)
cardframe.grid(column = 1, row = 0)
card = ttk.Label(cardframe, image=None)
card.grid(column = 0, row = 0)
text = ttk.Label(cardframe, text="Hexes needed")
text.config(font=("Arial", 10, "bold"))
text.grid(column = 0, row = 1)
return card
root.mainloop()