|
# retoor <retoor@molodetz.nl>
|
|
|
|
from .._shared import endpoint, field
|
|
|
|
GROUP = {
|
|
"slug": "game",
|
|
"title": "Code Farm",
|
|
"intro": """
|
|
# Code Farm
|
|
|
|
The Code Farm is a cooperative idle game. Each member owns a farm of plots, plants software
|
|
projects that build over real time, harvests them for coins and XP, upgrades their CI tier for
|
|
faster builds, and waters other members' growing builds to speed them up and earn coins.
|
|
|
|
All endpoints negotiate HTML or JSON. The action endpoints return the full farm state so a
|
|
client can refresh without a second request.
|
|
""",
|
|
"endpoints": [
|
|
endpoint(
|
|
id="game-home",
|
|
method="GET",
|
|
path="/game",
|
|
title="Code Farm page",
|
|
summary="The player's own farm: HUD, plot grid, shop, and leaderboard.",
|
|
auth="user",
|
|
negotiation=True,
|
|
sample_response={"ok": True, "farm": {"coins": 50, "level": 1, "plots": []}},
|
|
),
|
|
endpoint(
|
|
id="game-state",
|
|
method="GET",
|
|
path="/game/state",
|
|
title="Farm state",
|
|
summary="The signed-in player's full farm state as JSON.",
|
|
auth="user",
|
|
sample_response={
|
|
"ok": True,
|
|
"farm": {
|
|
"coins": 50,
|
|
"level": 1,
|
|
"ci_tier": 1,
|
|
"plot_count": 4,
|
|
"plots": [{"slot": 0, "state": "empty"}],
|
|
"crops": [{"key": "python", "name": "Python Script", "cost": 15}],
|
|
},
|
|
},
|
|
),
|
|
endpoint(
|
|
id="game-leaderboard",
|
|
method="GET",
|
|
path="/game/leaderboard",
|
|
title="Farm leaderboard",
|
|
summary="Top farmers on a chosen board: score (default), prestige, harvests (this week), raids (avg coins per successful raid, min 3 raids), time_to_kernel, fair_play, or era (current Era only, empty when none is running).",
|
|
auth="public",
|
|
params=[field("board", "query", "string", False, "score", "Leaderboard board key.")],
|
|
sample_response={"entries": [{"rank": 1, "username": "alice", "level": 4, "score": 1000}]},
|
|
),
|
|
endpoint(
|
|
id="game-view-farm",
|
|
method="GET",
|
|
path="/game/farm/{username}",
|
|
title="View a farm",
|
|
summary="Another player's farm, with water controls on growing builds.",
|
|
auth="public",
|
|
negotiation=True,
|
|
params=[field("username", "path", "string", True, "alice", "Farm owner's username.")],
|
|
sample_response={"farm": {"owner_username": "alice", "is_owner": False, "plots": []}},
|
|
),
|
|
endpoint(
|
|
id="game-plant",
|
|
method="POST",
|
|
path="/game/plant",
|
|
title="Plant a crop",
|
|
summary="Plant a crop in an empty plot. Costs the crop's coin price.",
|
|
auth="user",
|
|
params=[
|
|
field("slot", "form", "integer", True, "0", "Plot slot index."),
|
|
field("crop", "form", "string", True, "python", "Crop key."),
|
|
],
|
|
sample_response={"ok": True, "farm": {"coins": 35}},
|
|
),
|
|
endpoint(
|
|
id="game-harvest",
|
|
method="POST",
|
|
path="/game/harvest",
|
|
title="Harvest a build",
|
|
summary="Harvest a finished build for coins and XP.",
|
|
auth="user",
|
|
params=[field("slot", "form", "integer", True, "0", "Plot slot index.")],
|
|
sample_response={"ok": True, "farm": {"coins": 86}},
|
|
),
|
|
endpoint(
|
|
id="game-buy-plot",
|
|
method="POST",
|
|
path="/game/buy-plot",
|
|
title="Buy a plot",
|
|
summary="Unlock a new plot. Cost doubles per extra plot.",
|
|
auth="user",
|
|
sample_response={"ok": True, "farm": {"plot_count": 5}},
|
|
),
|
|
endpoint(
|
|
id="game-upgrade",
|
|
method="POST",
|
|
path="/game/upgrade",
|
|
title="Upgrade CI",
|
|
summary="Upgrade the farm CI tier for faster builds.",
|
|
auth="user",
|
|
sample_response={"ok": True, "farm": {"ci_tier": 2}},
|
|
),
|
|
endpoint(
|
|
id="game-water",
|
|
method="POST",
|
|
path="/game/farm/{username}/water",
|
|
title="Water a build",
|
|
summary="Water another player's growing build to speed it up and earn coins.",
|
|
auth="user",
|
|
params=[
|
|
field("username", "path", "string", True, "alice", "Farm owner's username."),
|
|
field("slot", "form", "integer", True, "0", "Plot slot index."),
|
|
],
|
|
sample_response={"farm": {"owner_username": "alice"}},
|
|
),
|
|
endpoint(
|
|
id="game-steal",
|
|
method="POST",
|
|
path="/game/farm/{username}/steal",
|
|
title="Steal a build",
|
|
summary="Steal another player's ready build once its protection window has passed; you receive half the build's coin value. Limited to once per hour per neighbour.",
|
|
auth="user",
|
|
params=[
|
|
field("username", "path", "string", True, "alice", "Farm owner's username."),
|
|
field("slot", "form", "integer", True, "0", "Plot slot index."),
|
|
],
|
|
sample_response={"farm": {"owner_username": "alice"}, "stole_coins": 18},
|
|
),
|
|
endpoint(
|
|
id="game-fertilize",
|
|
method="POST",
|
|
path="/game/fertilize",
|
|
title="Fertilize a build",
|
|
summary="Spend coins to halve a growing build's remaining time. The cost scales with the build's realized harvest value, so fertilizing is a pure time-skip and never a profit at any prestige.",
|
|
auth="user",
|
|
params=[field("slot", "form", "integer", True, "0", "Plot slot index.")],
|
|
sample_response={"ok": True, "farm": {"coins": 12}},
|
|
),
|
|
endpoint(
|
|
id="game-daily",
|
|
method="POST",
|
|
path="/game/daily",
|
|
title="Claim daily bonus",
|
|
summary="Claim the once-per-day coin bonus; consecutive days grow a streak.",
|
|
auth="user",
|
|
sample_response={"ok": True, "farm": {"streak": 3, "coins": 94}},
|
|
),
|
|
endpoint(
|
|
id="game-perk",
|
|
method="POST",
|
|
path="/game/perk",
|
|
title="Upgrade a perk",
|
|
summary="Upgrade a permanent perk: yield, growth, discount, or xp.",
|
|
auth="user",
|
|
params=[field("perk", "form", "string", True, "growth", "Perk key.")],
|
|
sample_response={"ok": True, "farm": {"coins": 0}},
|
|
),
|
|
endpoint(
|
|
id="game-quests-claim",
|
|
method="POST",
|
|
path="/game/quests/claim",
|
|
title="Claim a quest",
|
|
summary="Claim a completed daily quest, or (with scope=weekly, requires the Legacy Contracts Mastery upgrade) the weekly contract, which pays Stars plus a temporary coin boost instead of coins/XP.",
|
|
auth="user",
|
|
params=[
|
|
field("quest", "form", "string", True, "harvest", "Quest kind."),
|
|
field("scope", "form", "string", False, "daily", "daily (default) or weekly."),
|
|
],
|
|
sample_response={"ok": True, "farm": {"coins": 130}},
|
|
),
|
|
endpoint(
|
|
id="game-prestige",
|
|
method="POST",
|
|
path="/game/prestige",
|
|
title="Refactor (prestige)",
|
|
summary="Reset the farm at level 10+ for a permanent +25% coin bonus and earn Stars to spend on Legacy upgrades. From prestige 50 onward, every 10 more prestige also earns a permanent Mastery point.",
|
|
auth="user",
|
|
destructive=True,
|
|
sample_response={"ok": True, "farm": {"prestige": 1}},
|
|
),
|
|
endpoint(
|
|
id="game-legacy",
|
|
method="POST",
|
|
path="/game/legacy",
|
|
title="Buy a Legacy upgrade",
|
|
summary="Spend Stars on a permanent Legacy upgrade that survives every refactor: autoharvest, multiplier, speed, plots, or defense.",
|
|
auth="user",
|
|
params=[field("key", "form", "string", True, "multiplier", "Legacy upgrade key.")],
|
|
sample_response={"ok": True, "farm": {"stars": 1}},
|
|
),
|
|
endpoint(
|
|
id="game-mastery",
|
|
method="POST",
|
|
path="/game/mastery",
|
|
title="Buy a Mastery upgrade",
|
|
summary="Spend Mastery points (earned every 10 prestige past 50) on a permanent Mastery upgrade: autoreplant, analytics, or contracts.",
|
|
auth="user",
|
|
params=[field("key", "form", "string", True, "autoreplant", "Mastery upgrade key.")],
|
|
sample_response={"ok": True, "farm": {"mastery_points": 0}},
|
|
),
|
|
endpoint(
|
|
id="game-infrastructure-buy",
|
|
method="POST",
|
|
path="/game/infrastructure/buy",
|
|
title="Buy Infrastructure",
|
|
summary="Buy a permanent, expensive, prestige-gated Infrastructure building: registry (faster rare crops), canary (double/refund harvest chance), or observability (raises the minimum you keep when raided).",
|
|
auth="user",
|
|
params=[field("key", "form", "string", True, "registry", "Infrastructure key.")],
|
|
sample_response={"ok": True, "farm": {"coins": 0}},
|
|
),
|
|
endpoint(
|
|
id="game-defense-upgrade",
|
|
method="POST",
|
|
path="/game/defense/upgrade",
|
|
title="Upgrade Defense",
|
|
summary="Buy the next Defense tier. Reduces raid losses and adds steal grace, but adds an ongoing daily coin upkeep (proportional to your coin balance) - if unpaid, the tier decays.",
|
|
auth="user",
|
|
sample_response={"ok": True, "farm": {"defense_level": 1}},
|
|
),
|
|
endpoint(
|
|
id="game-cosmetics-buy",
|
|
method="POST",
|
|
path="/game/cosmetics/buy",
|
|
title="Buy a cosmetic",
|
|
summary="Buy a purely cosmetic title or plot skin with coins. No gameplay effect.",
|
|
auth="user",
|
|
params=[field("key", "form", "string", True, "title_architect", "Cosmetic key.")],
|
|
sample_response={"ok": True, "farm": {"coins": 0}},
|
|
),
|
|
endpoint(
|
|
id="game-cosmetics-equip",
|
|
method="POST",
|
|
path="/game/cosmetics/equip",
|
|
title="Equip a title",
|
|
summary="Equip an owned title cosmetic so it shows next to your name on the leaderboard.",
|
|
auth="user",
|
|
params=[field("key", "form", "string", True, "title_architect", "An owned title cosmetic key.")],
|
|
sample_response={"ok": True, "farm": {"active_title": "title_architect"}},
|
|
),
|
|
],
|
|
}
|