Jon Solow
commited on
Commit
·
0425b22
1
Parent(s):
abf137d
Add score types and score settings page
Browse files- src/pages/13_Score_Settings.py +22 -0
- src/stats.py +25 -18
src/pages/13_Score_Settings.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from config import DEFAULT_ICON
|
4 |
+
from shared_page import common_page_config
|
5 |
+
|
6 |
+
from stats import STAT_TYPE_KEY_MAP
|
7 |
+
|
8 |
+
|
9 |
+
def get_page():
|
10 |
+
page_title = "Score Settings"
|
11 |
+
st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
|
12 |
+
common_page_config()
|
13 |
+
st.title(page_title)
|
14 |
+
|
15 |
+
for stat_type in ["Offense", "Kicking", "Defense / Special Teams"]:
|
16 |
+
st.header(stat_type)
|
17 |
+
for stat in STAT_TYPE_KEY_MAP[stat_type].values():
|
18 |
+
st.write(f"{stat.key}: {stat.score}")
|
19 |
+
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
get_page()
|
src/stats.py
CHANGED
@@ -22,42 +22,49 @@ STAT_CACHE_SECONDS = 60
|
|
22 |
class StatType:
|
23 |
key: str
|
24 |
score: float
|
|
|
25 |
|
26 |
def __post_init__(self):
|
27 |
STAT_KEY_MAP[self.key] = self
|
|
|
28 |
|
29 |
|
30 |
STAT_KEY_MAP: dict[str, StatType] = {}
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
RUSH_TD = StatType(key="RUSH TD", score=6.0)
|
33 |
REC_TD = StatType(key="REC TD", score=6.0)
|
34 |
OFF_FUM_TD = StatType(key="OFF FUM TD", score=6.0)
|
35 |
PASS_TD = StatType(key="PASS TD", score=4.0)
|
36 |
-
FG_0_49 = StatType(key="FG 0-49", score=3.0)
|
37 |
-
FG_50_ = StatType(key="FG 50+", score=5.0)
|
38 |
TWO_PT = StatType(key="2 PT", score=2.0)
|
39 |
RECEPTION = StatType(key="REC", score=1.0)
|
40 |
RUSH_YD = StatType(key="RUSH YD", score=0.1)
|
41 |
REC_YD = StatType(key="REC YD", score=0.1)
|
42 |
PASS_YD = StatType(key="PASS YD", score=0.04)
|
43 |
-
XP = StatType(key="XP", score=1.0)
|
44 |
FUM_LOST = StatType(key="FUM LOST", score=-2.0)
|
45 |
PASS_INT = StatType(key="PASS INT", score=-2.0)
|
46 |
-
RET_TD = StatType(key="RET TD", score=6.0)
|
47 |
-
DEF_TD = StatType(key="DEF TD", score=6.0)
|
48 |
-
DEF_INT = StatType(key="DEF INT", score=2.0)
|
49 |
-
FUM_REC = StatType(key="FUM REC", score=2.0)
|
50 |
-
SAFETY = StatType(key="SAFETY", score=2.0)
|
51 |
-
SACK = StatType(key="SACK", score=1.0)
|
52 |
-
PTS_ALLOW_0 = StatType(key="PTS 0", score=10.0)
|
53 |
-
PTS_ALLOW_1_6 = StatType(key="PTS 1-6", score=7.0)
|
54 |
-
PTS_ALLOW_7_13 = StatType(key="PTS 7-13", score=4.0)
|
55 |
-
PTS_ALLOW_14_20 = StatType(key="PTS 14-20", score=1.0)
|
56 |
-
PTS_ALLOW_21_27 = StatType(key="PTS 21-27", score=0.0)
|
57 |
-
PTS_ALLOW_28_34 = StatType(key="PTS 28-34", score=-1.0)
|
58 |
-
PTS_ALLOW_35_ = StatType(key="PTS 35+", score=-4.0)
|
59 |
-
TEAM_WIN = StatType(key="TEAM WIN", score=5.0)
|
60 |
-
ST_TD = StatType(key="ST TD", score=6.0)
|
61 |
|
62 |
|
63 |
NFLVERSE_STAT_COL_TO_ID: dict[str, str] = {
|
|
|
22 |
class StatType:
|
23 |
key: str
|
24 |
score: float
|
25 |
+
stat_type: str = "Offense"
|
26 |
|
27 |
def __post_init__(self):
|
28 |
STAT_KEY_MAP[self.key] = self
|
29 |
+
STAT_TYPE_KEY_MAP[self.stat_type][self.key] = self
|
30 |
|
31 |
|
32 |
STAT_KEY_MAP: dict[str, StatType] = {}
|
33 |
+
STAT_TYPE_KEY_MAP: dict[str, dict[str, StatType]] = {
|
34 |
+
"Offense": {},
|
35 |
+
"Kicking": {},
|
36 |
+
"Defense / Special Teams": {},
|
37 |
+
}
|
38 |
|
39 |
RUSH_TD = StatType(key="RUSH TD", score=6.0)
|
40 |
REC_TD = StatType(key="REC TD", score=6.0)
|
41 |
OFF_FUM_TD = StatType(key="OFF FUM TD", score=6.0)
|
42 |
PASS_TD = StatType(key="PASS TD", score=4.0)
|
43 |
+
FG_0_49 = StatType(key="FG 0-49", score=3.0, stat_type="Kicking")
|
44 |
+
FG_50_ = StatType(key="FG 50+", score=5.0, stat_type="Kicking")
|
45 |
TWO_PT = StatType(key="2 PT", score=2.0)
|
46 |
RECEPTION = StatType(key="REC", score=1.0)
|
47 |
RUSH_YD = StatType(key="RUSH YD", score=0.1)
|
48 |
REC_YD = StatType(key="REC YD", score=0.1)
|
49 |
PASS_YD = StatType(key="PASS YD", score=0.04)
|
50 |
+
XP = StatType(key="XP", score=1.0, stat_type="Kicking")
|
51 |
FUM_LOST = StatType(key="FUM LOST", score=-2.0)
|
52 |
PASS_INT = StatType(key="PASS INT", score=-2.0)
|
53 |
+
RET_TD = StatType(key="RET TD", score=6.0, stat_type="Defense / Special Teams")
|
54 |
+
DEF_TD = StatType(key="DEF TD", score=6.0, stat_type="Defense / Special Teams")
|
55 |
+
DEF_INT = StatType(key="DEF INT", score=2.0, stat_type="Defense / Special Teams")
|
56 |
+
FUM_REC = StatType(key="FUM REC", score=2.0, stat_type="Defense / Special Teams")
|
57 |
+
SAFETY = StatType(key="SAFETY", score=2.0, stat_type="Defense / Special Teams")
|
58 |
+
SACK = StatType(key="SACK", score=1.0, stat_type="Defense / Special Teams")
|
59 |
+
PTS_ALLOW_0 = StatType(key="PTS 0", score=10.0, stat_type="Defense / Special Teams")
|
60 |
+
PTS_ALLOW_1_6 = StatType(key="PTS 1-6", score=7.0, stat_type="Defense / Special Teams")
|
61 |
+
PTS_ALLOW_7_13 = StatType(key="PTS 7-13", score=4.0, stat_type="Defense / Special Teams")
|
62 |
+
PTS_ALLOW_14_20 = StatType(key="PTS 14-20", score=1.0, stat_type="Defense / Special Teams")
|
63 |
+
PTS_ALLOW_21_27 = StatType(key="PTS 21-27", score=0.0, stat_type="Defense / Special Teams")
|
64 |
+
PTS_ALLOW_28_34 = StatType(key="PTS 28-34", score=-1.0, stat_type="Defense / Special Teams")
|
65 |
+
PTS_ALLOW_35_ = StatType(key="PTS 35+", score=-4.0, stat_type="Defense / Special Teams")
|
66 |
+
TEAM_WIN = StatType(key="TEAM WIN", score=5.0, stat_type="Defense / Special Teams")
|
67 |
+
ST_TD = StatType(key="ST TD", score=6.0, stat_type="Defense / Special Teams")
|
68 |
|
69 |
|
70 |
NFLVERSE_STAT_COL_TO_ID: dict[str, str] = {
|