/
main.py
251 lines (225 loc) · 10.5 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
from os import path, remove
import funcs
from save_data import save_data, load_data
from barbarian import Barbarian, Tank, Totem
from bard import Bard, Eloquent, Valor
from character import Character
from fighter import Fighter, Sword, Bow
from rogue import Rogue, Assasin, Thief
from wizard import Wizard, Storms, Arcanum
# Checks if a saved character already exists###################################
load = 'no'
if (path.exists("savedcharacter.obj") is True):
load = input('Would you like to load your last saved character? ')
# Load Previously Saved Character##############################################
if (load == 'yes'):
file = open('savedcharacter.obj', 'rb')
save_data(file)
# Initial Character Creation with Random stats#################################
elif((path.exists("savedcharacter.obj") is False) or (load != 'yes')):
strength = funcs.d20(8)
constitution = funcs.d20(10)
dexterity = funcs.d20(8)
wisdom = funcs.d20(8)
intelligence = funcs.d20(8)
charisma = funcs.d20(8)
player = Character(strength, constitution, dexterity,
intelligence, wisdom, charisma)
print(player.getStats())
# Allows user to choose what class their character is and resets character#####
characterClass = None
while characterClass not in ('bard', 'wizard', 'fighter',
'rogue', 'barbarian'):
characterClass = input('What Class Do You Want'
'(Barbarian, Bard, Fighter,'
'Rogue, or Wizard)? ').lower()
###############################################################################
# Branching Paths allow user to choose sub class appropriate to chosen class
# Barbarian Class Branch#######################################################
if (characterClass.lower() == 'barbarian'):
player = Barbarian(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
print(player.getStats())
answer = None
while answer not in ("totem", "tank"):
answer = input("What Sub Class (Totem or Tank): ").lower()
if(answer == "totem"):
player = Totem(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
elif(answer == "tank"):
player = Tank(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
else:
print("Please enter Totem or Tank.")
###############################################################################
# Bard Class Branch############################################################
if (characterClass.lower() == 'bard'):
player = Bard(player.strength, player.constitution, player.dexterity,
player.intelligence, player.wisdom, player.charisma)
print(player.getStats())
answer = None
while answer not in ("eloquent", "valor"):
answer = input("What Sub Class (Eloquent or Valor): ").lower()
if(answer == "eloquent"):
player = Eloquent(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
elif(answer == "valor"):
player = Valor(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
else:
print("Please enter Eloquent or Valor.")
###############################################################################
# Fighter Class Branch########################################################
if (characterClass.lower() == 'fighter'):
player = Fighter(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
print(player.getStats())
answer = None
while answer not in ("sword", "bow"):
answer = input("What Sub Class (Sword or Bow): ").lower()
if(answer == "sword"):
player = Sword(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
elif(answer == "bow"):
player = Bow(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
else:
print("Please enter Sword or Bow.")
###############################################################################
# Rogue Class Branch###########################################################
if (characterClass.lower() == 'rogue'):
player = Rogue(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
print(player.getStats())
answer = None
while answer not in ("assasin", "thief"):
answer = input("What Sub Class (Assasin or Thief): ").lower()
if(answer == "assasin"):
player = Assasin(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
elif(answer == "thief"):
player = Thief(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
else:
print("Please enter Assasin or Thief.")
###############################################################################
# Wizard Class Branch##########################################################
if (characterClass.lower() == 'wizard'):
player = Wizard(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
print(player.getStats())
answer = None
while answer not in ("arcane", "storm"):
answer = input("What Speciality (Arcane or Storm): ").lower()
if(answer == "arcane"):
player = Arcanum(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
elif(answer == "storm"):
player = Storms(player.strength,
player.constitution,
player.dexterity,
player.intelligence,
player.wisdom,
player.charisma)
else:
print("Please enter Arcane or Storm.")
# lets player set a starting level#############################################
levels = int(input("What Level do you want to start from? "))
for i in range(1, levels):
player.levelUP()
###############################################################################
# End Of Character Creation Branches###########################################
# Creates an enemy with reduced possible stats#################################
strength = funcs.d20(8)
constitution = funcs.d20(10)
dexterity = funcs.d20(8)
intelligence = funcs.d20(8)
wisdom = funcs.d20(8)
charisma = funcs.d20(8)
enemy = Character(strength, constitution, dexterity,
intelligence, wisdom, charisma)
while(enemy.level < player.level):
enemy.levelUP()
###############################################################################
print(player.getStats(), '\n')
print(enemy.getStats(), '\n')
funcs.battle(player, enemy)
if (player.hp > enemy.hp):
print("\nYou Win")
modDiff = (enemy.totalMods / player.totalMods)
expGained = int(300 * modDiff)
player.exp = player.exp + expGained
print(
f'You Got {expGained} EXP!!! only {300 - player.exp}'
'left to the next level!')
else:
print("\nYou Lose")
if(player.exp >= 300):
while(player.exp >= 300):
player.levelUP()
player.exp = player.exp - 300
# Saves current character######################################################
savecharacter = input('Do you want to save this character? ')
if(savecharacter.lower() == 'yes'):
file = open(b"savedcharacter.obj", "wb")
load_data(file)
# Creates a printable character sheet##########################################
characterSheet = input('Do you want a printable Character Sheet? ')
if(characterSheet == 'yes'):
if(path.exists("Character Sheet.txt")):
remove("Character Sheet.txt")
characterSheet = open(r"Character Sheet.txt", "a")
characterSheet.write(player.getStats())
characterSheet.close()