# retoor <retoor@molodetz.nl>
from __future__ import annotations
from ..spec import Action, Param
from ._shared import body, path
GAME_ACTIONS: tuple[Action, ...] = (
Action(
name="game_state",
method="GET",
path="/game/state",
summary="Get the current user's Code Farm state",
description=(
"Returns JSON for the signed-in user's Code Farm: coins, level/XP, CI tier, "
"plot grid (each plot's state, crop, remaining build seconds), and the plantable crops."
),
handler="http",
requires_auth=True,
read_only=True,
),
Action(
name="game_leaderboard",
method="GET",
path="/game/leaderboard",
summary="List the top Code Farm players",
handler="http",
requires_auth=False,
read_only=True,
),
Action(
name="game_view_farm",
method="GET",
path="/game/farm/{username}",
summary="View another player's Code Farm",
handler="http",
requires_auth=False,
read_only=True,
params=(path("username", "The farm owner's username."),),
),
Action(
name="game_plant",
method="POST",
path="/game/plant",
summary="Plant a crop in an empty plot on your Code Farm",
handler="http",
requires_auth=True,
params=(
Param(name="slot", location="body", description="Plot slot index.", required=True, type="integer"),
body("crop", "Crop key, e.g. shell, python, webapp, api, rust, haskell, kernel.", required=True),
),
),
Action(
name="game_harvest",
method="POST",
path="/game/harvest",
summary="Harvest a finished build from a plot on your Code Farm",
handler="http",
requires_auth=True,
params=(
Param(name="slot", location="body", description="Plot slot index.", required=True, type="integer"),
),
),
Action(
name="game_buy_plot",
method="POST",
path="/game/buy-plot",
summary="Buy a new plot on your Code Farm",
handler="http",
requires_auth=True,
),
Action(
name="game_upgrade_ci",
method="POST",
path="/game/upgrade",
summary="Upgrade your Code Farm CI tier for faster builds",
handler="http",
requires_auth=True,
),
Action(
name="game_water",
method="POST",
path="/game/farm/{username}/water",
summary="Water a growing build on another player's Code Farm",
handler="http",
requires_auth=True,
params=(
path("username", "The farm owner's username."),
Param(name="slot", location="body", description="Plot slot index.", required=True, type="integer"),
),
),
Action(
name="game_steal",
method="POST",
path="/game/farm/{username}/steal",
summary="Steal a ready build from another player's Code Farm once its protection window has passed (limited to once per hour per neighbour)",
handler="http",
requires_auth=True,
params=(
path("username", "The farm owner's username."),
Param(name="slot", location="body", description="Plot slot index.", required=True, type="integer"),
),
),
Action(
name="game_fertilize",
method="POST",
path="/game/fertilize",
summary="Spend coins to halve a growing build's remaining time on your Code Farm (cost scales with the build's harvest value, so it is a pure time-skip, never a profit)",
handler="http",
requires_auth=True,
params=(
Param(name="slot", location="body", description="Plot slot index.", required=True, type="integer"),
),
),
Action(
name="game_daily",
method="POST",
path="/game/daily",
summary="Claim the daily Code Farm coin bonus (builds a streak)",
handler="http",
requires_auth=True,
),
Action(
name="game_upgrade_perk",
method="POST",
path="/game/perk",
summary="Upgrade a permanent Code Farm perk (yield, growth, discount, xp)",
handler="http",
requires_auth=True,
params=(
body("perk", "Perk key: yield, growth, discount, or xp.", required=True),
),
),
Action(
name="game_claim_quest",
method="POST",
path="/game/quests/claim",
summary="Claim a completed daily Code Farm quest reward",
handler="http",
requires_auth=True,
params=(
body("quest", "Quest kind: plant, harvest, water, or earn.", required=True),
),
),
Action(
name="game_prestige",
method="POST",
path="/game/prestige",
summary="Refactor (prestige) your Code Farm for a permanent coin bonus and Stars (requires level 10)",
handler="http",
requires_auth=True,
),
Action(
name="game_upgrade_legacy",
method="POST",
path="/game/legacy",
summary="Spend Stars on a permanent Legacy upgrade that survives refactor (autoharvest, multiplier, speed, plots, defense)",
handler="http",
requires_auth=True,
params=(
body(
"key",
"Legacy key: autoharvest, multiplier, speed, plots, or defense.",
required=True,
),
),
),
)