A new post attachment type beside polls: the composer gains a Start
Opinion War builder (same disabled-inputs opt-in as the poll builder)
that names exactly two factions; the battle runs for exactly 7 days
from post creation. Members join a side, may defect at any time
(damage already dealt stays with the faction it was dealt to), and
fight once per 24 hours per battle. A fight spends 25 Code Farm coins
and deals deterministic level-weighted damage: 100 + 10 * min(level,
20) HP, so a newcomer deals 110 and a veteran caps at 300 - no
randomness anywhere.
The battle renders on the post card as a CSS pixel-art battlefield
(box-shadow sprites: castles, faction flags, marching soldiers, a
flickering campfire; steps() animation, disabled under reduced motion)
with live HP bars, a countdown, the viewer's faction strip, top
contributors and an event ticker. Live frames ride pub/sub on
public.battle.{uid} via a relay on the service-lock owner, with the
durable opinion_war_events trail (per-war atomic seq) as the source of
truth and a 15s incremental poller as fallback. /battles lists battles
with active/ended/mine filters, search and pagination.
Every mutation is a conditional UPDATE via conditional_update_row: the
fight sequence claims the cooldown first, then spends coins, then lands
the damage, compensating earlier steps on any later refusal so a crash
costs a turn, never coins. Resolution is lazy on read (no cron):
an exactly-once CAS computes the winner in the statement, awards XP
(participation, winner bonus, top damage dealer bonus; draws pay
participation only), emits the result event and notifies fighters. The
OpinionWarService backstop resolves unviewed wars and sends
fight-ready notifications, exactly-once via a marker CAS.
Fan-out: battle notification type, four badges, audit keys
(battle.create/join/switch/fight/resolve), Devii actions (join/fight
confirm-gated), API docs group, docs prose page, sitemap and topnav
entries, REPORTABLE_TARGETS registration, post-delete cascades,
README and nested CLAUDE.md documentation.
Verified with the four-layer procedure: property checks over the full
damage domain, 1200-step stateful fuzz (hp-sum invariant, coins never
negative, resolved totals frozen), and real 8-process races proving
exactly-once semantics for concurrent fights, double-spends across two
wars, resolution XP and double-joins. Persisted tests in
tests/unit/services/opinionwar, tests/api/battles, tests/e2e/battles
and tests/api/posts/create.py.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
52 lines
2.3 KiB
HTML
52 lines
2.3 KiB
HTML
<div class="docs-content" data-render>
|
|
# Opinion Wars
|
|
|
|
An Opinion War is a week-long battle between two factions, attached to a post. It is the
|
|
place to settle the eternal debates - tabs versus spaces, Python versus Rust - by showing
|
|
up every day and fighting for your side.
|
|
|
|
## Starting a war
|
|
|
|
Open **Create New Post** on the feed and press **Start Opinion War** (next to **Add
|
|
poll**). Name the two factions, write your post, and publish. The battle starts
|
|
immediately and runs for exactly **7 days**. A post carries at most one war, and it can
|
|
only be started when the post is created.
|
|
|
|
## Joining and fighting
|
|
|
|
Any signed-in member picks a side with the **Join** buttons on the battle card. Once
|
|
joined, the **Fight** button becomes yours:
|
|
|
|
- A fight costs **25 Code Farm coins** - earn them by playing [Code Farm]({{ base }}/game).
|
|
- Each fight deals damage for your faction: a base of 100 HP plus 10 HP per site level,
|
|
capped at level 20. A brand new member deals 110 HP; a veteran caps out at 300 HP.
|
|
There is no randomness - showing up daily beats everything else.
|
|
- You can fight **once every 24 hours** per battle. A notification tells you when your
|
|
next fight is ready.
|
|
|
|
You may switch factions at any time, but damage you already dealt stays with the faction
|
|
it was dealt to - defecting does not move your HP.
|
|
|
|
## Winning
|
|
|
|
When the week is over, the faction with more HP wins. Every fighter who fought at least
|
|
once earns XP, the winning side earns a bonus, and the single top damage dealer earns an
|
|
extra bonus. Equal totals are a draw with participation XP only. The card freezes into a
|
|
victory banner with the final totals and top contributors.
|
|
|
|
The battle card shows everything live: the HP bars, the countdown, your faction and rank,
|
|
the top contributors, and a ticker of joins, defections, fights and lead changes.
|
|
|
|
## The battle listing
|
|
|
|
Every battle - active and ended - is listed at [{{ base }}/battles]({{ base }}/battles),
|
|
searchable by faction name or creator, with an **Active**, **Ended** and **Mine** filter.
|
|
|
|
## The API
|
|
|
|
The full REST surface is documented in the [Opinion Wars API group]({{ base }}/docs/battles.html):
|
|
list battles, read one battle's state and event log, join a faction, and fight. Devii can
|
|
do all of it for you conversationally - it will ask for confirmation before joining or
|
|
spending your coins.
|
|
</div>
|