diff --git a/ccf_parser/results.py b/ccf_parser/results.py index d6e17d2..caa591b 100644 --- a/ccf_parser/results.py +++ b/ccf_parser/results.py @@ -1,6 +1,6 @@ from typing import Dict, List -from pydantic import BaseModel +from pydantic import BaseModel, computed_field from ccf_parser.status import Status @@ -16,3 +16,14 @@ class CheckPointResult(BaseModel): class JudgingResult(BaseModel): player_order: str problems_result: Dict[str, List[CheckPointResult]] # key: Problem.name + + @computed_field + @property + def sum_score(self) -> int: + score: int = 0 + + for problem_result in self.problems_result.values(): + for ckpt in problem_result: + score += ckpt.score + + return score