-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
69 lines (51 loc) · 1.61 KB
/
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
from player import Player
from beer import Beer
def printGUI(player):
print_resources(player)
printQueue(player.queue)
def char_inserter(chr_length, char = " "):
spaces = ""
for row in range(0,chr_length):
spaces += char
return spaces
# List of strings for easy printing
def invPrintList(inv):
beers = {}
for beer in inv:
if beer.name in beers.keys():
beers[beer.name] += 1
else:
beers[beer.name] = 1
list = [" INVENTORY"]
for beer in beers:
list.append(beer + ": " + str(beers[beer]))
return list
def printQueue(queue):
title = "Queue"
spaces = char_inserter((51-len(title))/2)
print spaces + title + spaces
print "8" + char_inserter(49,"-") + "8"
beer_line = ""
for wort in queue:
turns = str(wort[0].turns-wort[1]+1)
print " " + wort[0].name + " " + turns + "/" + str(wort[0].turns)
def print_resources(player):
title = "RESOURCES"
spaces = char_inserter((51-len(title))/2)
print spaces + title + spaces
print "8" + char_inserter(49,"-") + "8"
beer_line = ""
inv = invPrintList(player.inventory)
for row in range(max(3,len(inv))):
if row <= len(inv)-1:
beer_line = inv[row]
else:
beer_line = ""
# Prints resources
other_line = ""
if row == 0: other_line = "Malt: " + str(player.malt)
if row == 1: other_line = "Hops: " + str(player.hops)
if row == 2: other_line = "Cash: " + str(player.cash)
spaces = char_inserter(49-len(beer_line)-len(other_line))
print " " + beer_line + spaces + other_line
print "8" + char_inserter(49,"-") + "8"