-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunClubsNightDraft.py
65 lines (48 loc) · 1.39 KB
/
FunClubsNightDraft.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
import Tkinter as tk
import tkSimpleDialog
import math
from random import randint
players = []
def draft ():
playerCount = 0;
# Put all the players into an array
for line in text.get('1.0', 'end-1c').splitlines():
if line:
players.append("@"+line)
playerCount += 1
text.pack_forget()
draftBtn.pack_forget()
# How many teams to split players into?
teams = tkSimpleDialog.askstring("How many teams?", "How many teams to draft?", parent=main, minvalue=0)
#players per team
ppt = math.floor(playerCount / int(teams))
remainder = playerCount % int(teams)
remainderAssigned = 0
col = 0
# Display Draft
for i in range(int(teams)):
currentTeam = ""
# Create a random team of ppt players
for z in range(int(ppt)):
index = randint(0, len(players)-1)
currentTeam += players[index]+"\n"
del players[index]
# Add remainder players if necessary
if remainderAssigned != remainder:
index = randint(0, len(players)-1)
currentTeam += players[index]+"\n"
remainderAssigned += 1
tk.Label(main, text="Team "+str(i+1)).grid(column=col, row=0)
teamBox = tk.Text(main, width=40)
teamBox.insert(tk.END, currentTeam)
teamBox.grid(column=col, row=1)
# Reset temp var
del teamBox
col += 1
main = tk.Tk()
text = tk.Text(main)
draftBtn = tk.Button(main, text="Draft!", width = 75, command=draft)
text.pack()
draftBtn.pack()
text.focus_set()
main.mainloop()