Skip to content

Commit

Permalink
feat(judge): JudgingResult新增计算属性sum_score
Browse files Browse the repository at this point in the history
  • Loading branch information
XYCode-Kerman committed Apr 12, 2024
1 parent 060bb2a commit f8312bf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ccf_parser/results.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit f8312bf

Please sign in to comment.