-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
70 lines (46 loc) · 1.48 KB
/
app.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
import datetime
from collections import namedtuple
from flask import Flask, render_template
from constants import CHARACTER_STATS
app = Flask(__name__)
START_DATE = datetime.datetime(2011, 7, 1)
@app.route('/')
def index():
return render_template(
"index.html",
dynamic_life_experience=get_dynamic_life_experience(),
character_stats=get_character_stats(),
)
def get_dynamic_life_experience():
dynamic_life_experience = namedtuple(
"DynamicLifeExperience",
"health total_experience level energy exp_to_next_level"
)
total_experience = _get_total_experience()
level = _get_level(total_experience)
return dynamic_life_experience(
_get_health(level),
total_experience,
_get_level(total_experience),
_get_energy(),
_get_exp_to_next_level()
)
def get_character_stats():
return CHARACTER_STATS
def _get_exp_to_next_level():
today = _get_today()
pre = datetime.datetime(today.year, START_DATE.month, START_DATE.day)
post = datetime.datetime(today.year+1, START_DATE.month, START_DATE.day)
return ((pre if pre > today else post) - today).days
def _get_energy():
return 200
def _get_health(level: int):
return level * 73
def _get_total_experience():
return (_get_today() - START_DATE).days
def _get_level(total_experience: int):
return total_experience // 365
def _get_today():
return datetime.datetime.now()
if __name__ == '__main__':
app.run()