feat: calculate inspection resource points

This commit is contained in:
nyan404 committed 2026-08-16 16:41:31 +03:00
1 parent 5809d5a595
commit 21652d0001
6 files changed
+46 -2

No files matched your search

+24
View File
@@ -146,3 +146,27 @@ class InspectionReport:
for name, amount in self.resources:
if not name.strip() or not isinstance(amount, int):
raise ValueError("Ресурс должен иметь название и целое количество")
@dataclass(frozen=True)
class InspectionResult:
points: int
def _inspection_resource_value(name: str) -> int:
normalized = " ".join(name.casefold().replace("ё", "е").split())
if "надпис" in normalized or "ядовит" in normalized:
return 0
if normalized in ("паутина", "паук"):
return 7
if normalized == "обычный мох":
return 3
if normalized == "водяной мох":
return 2
return 1
def calculate_inspection(report: InspectionReport) -> InspectionResult:
points = report.inspections * 2
points += sum(amount * _inspection_resource_value(name) for name, amount in report.resources)
return InspectionResult(points=points)