69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
from __future__ import annotations
|
||
|
||
from .domain import (
|
||
CoachingResult,
|
||
CoachingSession,
|
||
InspectionReport,
|
||
TrainingSession,
|
||
TrainingResult,
|
||
format_clock,
|
||
parse_clock,
|
||
)
|
||
|
||
|
||
def _number(value: float | int) -> str:
|
||
return str(value).rstrip("0").rstrip(".") if isinstance(value, float) else str(value)
|
||
|
||
|
||
def render_coaching(session: CoachingSession, result: CoachingResult) -> str:
|
||
hashtag = "#лазание" if session.skill == "ЛУ" else "#зоркость"
|
||
reminder = (
|
||
"Не забудьте приложить скриншот истории с подтверждением махинации."
|
||
if session.kitten_independence == "несамостоятельно"
|
||
else ""
|
||
)
|
||
lines = [
|
||
hashtag,
|
||
f"{session.escort_name} [{session.escort_id}], помогла {session.kitten_name} [{session.kitten_id}] "
|
||
f"прокачать {session.skill}.",
|
||
f"Время: {format_clock(parse_clock(session.start))} – "
|
||
f"{format_clock(parse_clock(session.end))} [{result.minutes} минут].",
|
||
f"Баллы белки: {_number(result.escort_points)}",
|
||
f"Баллы бельчонка: {_number(result.kitten_points)}",
|
||
]
|
||
lines.append("\nНе забудьте приложить скриншот Игровой с временем и датой начала и конца.")
|
||
if reminder:
|
||
lines.append(reminder)
|
||
return "\n".join(lines)
|
||
|
||
|
||
def render_training(session: TrainingSession, result: TrainingResult | None = None) -> str:
|
||
result = result or TrainingResult()
|
||
return (
|
||
"#урок\n"
|
||
f"{session.escort_name} [{session.escort_id}] провёл(а) тренировку "
|
||
f"{session.kitten_name} [{session.kitten_id}].\n"
|
||
f"Баллы: {result.points}"
|
||
)
|
||
|
||
|
||
def render_inspection(report: InspectionReport) -> str:
|
||
if report.inspections == 1:
|
||
word = "раз"
|
||
else:
|
||
word = "раз"
|
||
lines = [
|
||
"#осмотр",
|
||
f"{report.character_name} [{report.character_id}] осмотрел(а) {report.place} {report.inspections} {word}."
|
||
]
|
||
if report.resources:
|
||
lines.extend(
|
||
f"{('+' + str(abs(amount))) if amount > 0 else ('- ' + str(abs(amount)))} {name}"
|
||
for name, amount in report.resources
|
||
if amount
|
||
)
|
||
else:
|
||
lines.append("0")
|
||
lines.append("Не забудьте приложить скриншот истории и рта.")
|
||
return "\n".join(lines)
|