forked from retoor/devplacepy
feat: add Code Farm cooperative idle game with plot-based crop system and pub/sub notifications
Implement a Farmville-style cooperative idle game mounted at `/game` with member-only play and public farm viewing. The data layer is pure and timestamp-driven with no background tick: plot states are derived from `ready_at` vs current time, never stored. Key features include plantable software projects (shell script through kernel) that build over real time, harvest for coins and XP, CI tier upgrades for faster builds, plot purchasing with doubling cost, watering mechanics for friends' builds, daily quests, and prestige system. All game endpoints negotiate HTML or JSON and return full farm state for single-request client refresh. Pub/sub notifications broadcast farm updates on `public.game.farm.{username}` topics. Database schema adds `game_farms`, `game_plots`, and `game_quests` tables with appropriate indexes.
This commit is contained in:
@@ -1850,6 +1850,138 @@ ACTIONS: tuple[Action, ...] = (
|
||||
requires_admin=True,
|
||||
params=(path("source_model", "Source model name."), confirm()),
|
||||
),
|
||||
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_fertilize",
|
||||
method="POST",
|
||||
path="/game/fertilize",
|
||||
summary="Spend coins to halve a growing build's remaining time 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_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 (requires level 10)",
|
||||
handler="http",
|
||||
requires_auth=True,
|
||||
),
|
||||
)
|
||||
|
||||
PLATFORM_CATALOG = Catalog(actions=ACTIONS)
|
||||
|
||||
Reference in New Issue
Block a user