/
YearStatSheet.py
116 lines (98 loc) · 3.92 KB
/
YearStatSheet.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
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
from leeger.util.Deci import Deci
@dataclass(kw_only=True, frozen=True)
class YearStatSheet:
# Team Summary
gamesPlayed: dict[str, int]
# Game Outcome
wins: dict[str, int]
losses: dict[str, int]
ties: dict[str, int]
winPercentage: dict[str, Deci]
wal: dict[str, Deci]
walPerGame: dict[str, Deci]
# AWAL
awal: dict[str, Deci]
awalPerGame: dict[str, Deci]
opponentAWAL: dict[str, Deci]
opponentAWALPerGame: dict[str, Deci]
# Smart Wins
smartWins: dict[str, Deci]
smartWinsPerGame: dict[str, Deci]
opponentSmartWins: dict[str, Deci]
opponentSmartWinsPerGame: dict[str, Deci]
# Points Scored
pointsScored: dict[str, Deci]
pointsScoredPerGame: dict[str, Deci]
opponentPointsScored: dict[str, Deci]
opponentPointsScoredPerGame: dict[str, Deci]
# Scoring Share
scoringShare: dict[str, Deci]
opponentScoringShare: dict[str, Deci]
maxScoringShare: dict[str, Deci]
minScoringShare: dict[str, Deci]
# Single Score
maxScore: dict[str, float | int]
minScore: dict[str, float | int]
# Scoring Standard Deviation
scoringStandardDeviation: dict[str, Deci]
# Plus Minus
plusMinus: dict[str, Deci]
# SSL
teamScore: dict[str, Deci]
teamSuccess: dict[str, Deci]
teamLuck: dict[str, Deci]
# Optional Stats
leagueMedianWins: Optional[dict[str, float]] = None
opponentLeagueMedianWins: Optional[dict[str, float]] = None
totalGames: Optional[dict[str, int]] = None
ownerNames: Optional[dict[str, str]] = None
years: Optional[dict[str, int]] = None
def preferredOrderWithTitle(self) -> list[tuple[str, dict]]:
"""
Returns all stats in the preferred order with the title for the stat.
"""
response = [
("Games Played", self.gamesPlayed),
("Wins", self.wins),
("Losses", self.losses),
("Ties", self.ties),
("Win Percentage", self.winPercentage),
("WAL", self.wal),
("WAL Per Game", self.walPerGame),
("AWAL", self.awal),
("AWAL Per Game", self.awalPerGame),
("Opponent AWAL", self.opponentAWAL),
("Opponent AWAL Per Game", self.opponentAWALPerGame),
("Smart Wins", self.smartWins),
("Smart Wins Per Game", self.smartWinsPerGame),
("Opponent Smart Wins", self.opponentSmartWins),
("Opponent Smart Wins Per Game", self.opponentSmartWinsPerGame),
("Points Scored", self.pointsScored),
("Points Scored Per Game", self.pointsScoredPerGame),
("Opponent Points Scored", self.opponentPointsScored),
("Opponent Points Scored Per Game", self.opponentPointsScoredPerGame),
("Scoring Share", self.scoringShare),
("Opponent Scoring Share", self.opponentScoringShare),
("Max Scoring Share", self.maxScoringShare),
("Min Scoring Share", self.minScoringShare),
("Max Score", self.maxScore),
("Min Score", self.minScore),
("Scoring Standard Deviation", self.scoringStandardDeviation),
("Plus/Minus", self.plusMinus),
("Team Score", self.teamScore),
("Team Success", self.teamSuccess),
("Team Luck", self.teamLuck),
]
# add optional stats if needed
if self.leagueMedianWins is not None:
response.insert(1, ("Total Games", self.totalGames))
response.insert(4, ("League Median Wins", self.leagueMedianWins))
response.insert(5, ("Opponent League Median Wins", self.opponentLeagueMedianWins))
if self.ownerNames is not None:
response.insert(0, ("Owner", self.ownerNames))
if self.years is not None:
response.insert(1, ("Year", self.years))
return response