cleaning up code
This commit is contained in:
5
app.py
5
app.py
@@ -87,6 +87,7 @@ def character():
|
||||
level = request.args.get("level", default=1, type=int)
|
||||
role = request.args.get("role", default="fighter", type=str)
|
||||
cache = request.args.get("cache", default='true', type=str)
|
||||
# control inputs to prevent abuse
|
||||
if cache not in [ "true", "false" ]:
|
||||
cache = 'true'
|
||||
if not c_id.startswith('adv-'):
|
||||
@@ -95,12 +96,12 @@ def character():
|
||||
level = 1
|
||||
if role not in [ 'fighter','magic-user','cleric', 'thief', 'dwarf', 'elf', 'halfling']:
|
||||
role = 'fighter'
|
||||
# check cookies for characters
|
||||
if request.cookies and cache != "false":
|
||||
character = return_character_from_cookie(request.cookies[c_id])
|
||||
print(character.player_class)
|
||||
if character.level != level:
|
||||
character.set_level(level)
|
||||
# reroll until we get our class
|
||||
# reroll until we get the class from the cookie, if it doesn't match
|
||||
while character.player_class != role.replace("-"," "):
|
||||
new_char = Adventurer(c_id, level)
|
||||
selected_class = AdventurerGen(new_char).selection()
|
||||
|
||||
Reference in New Issue
Block a user