-
Notifications
You must be signed in to change notification settings - Fork 1
/
controller.py
184 lines (151 loc) · 5.91 KB
/
controller.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
# __author__ = 'User'
from league_model import LeagueModel
# from ViewModel.TableBuilder import TableBuilder
from ViewModel.ViewModel import ViewModel
import pickle
from FilerModule.FilerModule import FilerModule
vm = ViewModel()
fm = FilerModule()
print("loading pickles")
with open('data.pickles', 'rb') as f:
imported_pickles_from_tina = pickle.load(f)
imported_pickles_from_tina = fm.import_binary_league()
print(imported_pickles_from_tina)
print(imported_pickles_from_tina.export_league())
print(imported_pickles_from_tina._my_league)
print(dir(imported_pickles_from_tina))
print(imported_pickles_from_tina.__dict__)
vm.display(vm.build_table(imported_pickles_from_tina.export_league()))
print("\r\r")
'''
lm = LeagueModel()
lm.set_abilities_file(fm.read_file("Abilities.txt"))
# Debugging:
for a in lm.get_all_abilities():
# print(a)
pass
print("\r")
lm.add_league("Buffalo")
lm.get_current_league().add_character("L", char_type="Leader", health="d10",
brawl="3d10", shoot="2d10", dodge="3d8",
might="3d10", finesse="2d10",
cunning="3d8", arg1="Mighty",
arg2="Brash", arg3="Crafty")
print("\r")
lm.get_current_league().add_character("J", char_type="SideKick", health="d8",
brawl="2d6", shoot="3d6", dodge="2d6",
might="3d8", finesse="2d8",
cunning="3d8", arg1="Mighty",
arg2="Brash", arg3="")
print("\r")
lm.get_current_league().add_character("A", char_type="Ally", health="d6",
brawl="2d6", shoot="2d6", dodge="1d6",
might="1d6", finesse="1d6", cunning="1d6",
arg1="Mighty", arg2="",
arg3="")
'''
print("\r")
lm.get_current_league().add_character("G", char_type="Follower", health="d6",
brawl="1d6", shoot="1d6", dodge="1d6",
might="1d6", finesse="1d6", cunning="1d6",
arg1="Mighty", arg2="",
arg3="")
print("\r")
lm.get_current_league().add_character("B", char_type="Ally", health="d6",
brawl="2d6", shoot="2d6", dodge="1d6",
might="1d6", finesse="1d6", cunning="1d6",
arg1="Mighty", arg2="",
arg3="")
print("\r")
lm.get_current_league().add_character("C", char_type="Ally", health="d6",
brawl="2d6", shoot="2d6", dodge="1d6",
might="1d6", finesse="1d6", cunning="1d6",
arg1="Mighty", arg2="",
arg3="")
print("\r")
lm.get_current_league().add_character("D", char_type="Ally", health="d6",
brawl="2d6", shoot="2d6", dodge="1d6",
might="1d6", finesse="1d6", cunning="1d6",
arg1="Mighty", arg2="",
arg3="")
print("\r")
'''
l = lm.get_current_league().find_character("L")
w = lm.get_current_league().find_character("A")
# Testing export strings array
print("League export")
print(str(lm.export_league()))
print("\r")
print("View model version")
vm.display(vm.build_table(lm.export_league()))
print("\r")
'''
if l is not None:
print("Some of " + str(l) + "'s skills and abilities:")
print("Health: " + l.get_health().get_number_dice()
+ l.get_health().get_dice_type().name)
print("Brawl: " + l.get_brawl().get_number_dice()
+ l.get_brawl().get_dice_type().name)
print("Might: " + l.get_might().get_number_dice()
+ l.get_might().get_dice_type().name)
print("Ability 1: " + l.get_abilities()[0].get_name())
print("\r")
print("League name: " + l.get_my_league().get_name())
# the above line is the same as: print(lm.get_current_league())
print("\r")
l.replace_ability(l, "Mighty", "Brash")
"""
print(str(j) + "'s abilities:")
for abili in j.get_abilities():
print(abili.get_name())
print("\r")
l = lm.get_current_league()
l.char_remove_ability("Brash", "J")
print("\r")
l.char_add_ability("Mighty", "J")
print("\r")
print(str(j) + "'s abilities:")
for abili in j.get_abilities():
print(abili.get_name())
print("\r")
l.char_add_ability("Sharp", "J")
print("\r")
print(str(j) + "'s abilities:")
for abili in j.get_abilities():
print(abili.get_name())
print("\r")
l.char_add_ability("Clever", "J")
print("\r")
print(str(j) + "'s abilities:")
for abili in j.get_abilities():
print(abili.get_name())
print("\r")
"""
if l is not None and w is not None:
print("\r")
# Interesting test (if two characters add the same ability):
if l.get_abilities()[0] is w.get_abilities()[0]:
print("The instances of " + l.get_abilities()[0].get_name() +
" and " + w.get_abilities()[0].get_name() + " for " +
str(l) + " and " + str(w) + " are the same")
else:
print("The instances of " + l.get_abilities()[0].get_name() +
" and " + w.get_abilities()[0].get_name() + " for " +
str(l) + " and " + str(w) + " are different.")
print("\r")
'''
# if __name__ == "__main__":
# import doctest
# doctest.testmod()
print("Saving Pickles")
fm.export_league_binary_to_fs(lm)
'''
with open('data.pickles', 'wb') as f:
pickle.dump(lm, f)
del lm
'''
'''
with open('data.pickle', 'rb') as f:
imported_pickles_from_tina = pickle.load(f)
print(imported_pickles_from_tina.export_league())
'''