Skip to content

Show players' parties to each other, keep shared-world saves, and tire parties more slowly - #54

Merged
lagergren merged 4 commits into
mainfrom
lagergren/shared-world-presence
Nov 2, 2026
Merged

lagergren merged 4 commits into
mainfrom
lagergren/shared-world-presence

Conversation

@lagergren

Copy link
Copy Markdown
Owner

Players on one server share a world. With this change, their saves stop undoing each other, and they can see each other's parties in the wilderness. Parties also tire half as late, and installDist works for the bitmap web runtime. One commit per step.

Saves keep what other sessions saved

A session reads the world rows of world.rsave once, when it starts. Until now, every save wrote that copy back whole:

  • Missions: a save brought back as not completed a mission another party had completed in the meantime.
  • NPC places: when two players started a new world together, each session placed the NPCs and the later save won. The other player kept meeting NPCs where the world no longer had them.
  • Clock: logging in put a party at the hour the last player to save had reached.

A save now merges the world rows. Completed missions only grow, and an NPC keeps the place the first save gave it. The save hands the merged world back, so the session start and every save command pick up what other players saved.

Each party keeps its own day, hour and minute. A party saved while the world had one clock starts from that clock.

Parties see each other

  • Game rule: how far a party sees is the new realm { partySight } formula, which can use the party's hour. Rylween's parties see 3 squares by day and 1 at night (hours 0–5). Without the formula, parties never see each other.
  • Runtime: the runtime reports the party's map, square, mode and sight through a new RuntimePresencePort whenever they change. Working out sight never draws from the party's random numbers, so games play out as before.
  • Server: the bitmap server keeps every connected party in one registry, and sends each browser a {"type":"parties"} message whenever the list of parties its player sees changes.

What is seen, and how it is drawn:

  • Who sees whom: a party sees another when both are in the wilderness of one map and the other is within its own sight, diagonals included. At night one party can see another that doesn't see it.
  • Hidden parties: a party in a town, dungeon or castle, or a player on the title screen, is neither seen nor sees.
  • Sharing squares: parties don't block each other, so any number can share a square.
  • Colors: players online together get different colors while the eight last.
  • Drawing: a party alone on a square is a full-size horse in its color. Beside your own horse, or with company, each is drawn small in a corner, and when more than three share a square, the third corner shows how many more ("+2"). The top-right corner stays free for town and castle badges.
  • Order: the list is sorted by square and then name, so a crowded square looks the same every time.
  • Robustness: a slow browser holds up only its own messages, and a session that outlives its socket can't move the account's next party.

The 3D wilderness view doesn't show other parties yet. The runtime systems schema is 15, so the server needs a redeploy.

Parties tire half as late again

A party got tired after 14 moves. A camp, an inn bed and a new party now give 21 rested hours, and the later stages come half as late again too:

Stage Before Now
Exhausted −4 −6
Weak −8 −12
Faint below −8 below −12

The test scenarios keep their own rested hours.

installDist

./gradlew :runtime-bitmap-web:installDist is an alias for installRuntimeBitmapWeb, the project's default distribution.

Tests

  • New tests:
    • A later save keeps another session's missions and NPC places.
    • Each party keeps its own clock, and an old single clock carries over.
    • The runtime reports wilderness → town → wilderness and the sight by day and night.
    • The registry handles sight, maps, towns, crowded squares, colors, hiding, leaving, stale sessions, and sending only on change.
  • Fixed test: TownServiceHoursTest set the world's clock. It now sets the party's.
  • Results: ./gradlew check --rerun-tasks --no-build-cache passes: 257 tests, 0 failures, 0 skipped. ktlintCheck passes, and installDist runs with the configuration cache.
  • Browser: checked against a local server with headless Chromium and several accounts: two parties on one square, one stepping aside, three and then four more crowding a square ("+2"), all seven colors at once, and a player disconnecting.

Not checked: the build has not been deployed, and each commit was not built on its own; the head was.

Every account saves into one world file, but a session reads the world
rows once, when it starts, and each save wrote its whole copy of them
back. A save undid what other sessions had saved in the meantime: a
mission another party completed was no longer completed, and when two
players started a new world together, each session placed the NPCs and
the later save won, while the other player kept meeting NPCs where the
world no longer had them.

A save now merges the world rows. Completed missions only grow, and an
NPC keeps the place the first save gave it. The save hands the merged
world back, and the session plays on in it, so the session start and
every save command pick up what other players saved.

The clock was a world row too, so logging in put a party at whatever
hour the last player to save had reached. Each party keeps its own
day, hour and minute now. A party saved while the world kept one clock
starts from that clock.
Players on one server share a world but never met in it. Now a party
in the wilderness sees the other players' parties near it, each as a
horse in its own color on the square where it stands.

How far a party sees is a game rule, the new realm { partySight }
formula, which can use the hour of the party's day. Rylween's parties
see three squares, and one square at night:

    formula(Formulas.partySight) {
        value = whenValue(hour lt 6, 1, 3)
    }

Without the formula parties never see each other. The runtime systems
schema is 15.

The runtime tells its host where the party is through a new
RuntimePresencePort whenever that changes: the map, the square,
whether the party is out in the wilderness, and its sight. Evaluating
sight never draws from the party's random numbers, so games play out
as before.

The bitmap server keeps every connected party in one registry:

- A party sees another when both are in the wilderness of one map and
  the other is within its sight in any direction, diagonals included.
  Sight is the seeing party's own, so at night one party can see
  another that doesn't see it.
- A party in a town, dungeon or castle, or a player on the title
  screen, is neither seen nor sees.
- Parties don't block each other, so any number can share a square.
- Players online together get different colors while the eight last.
- Each browser is sent the parties its player sees whenever that list
  changes, sorted by square and then name, so a crowded square is drawn
  the same way every time. A slow browser holds up only its own
  messages, and a session that outlives its socket can't move the
  party of the account's next session.

The browser draws a party alone on a square full size. Beside the
player's own horse, or with company, each is drawn small in a corner,
and when more than three share a square, the third corner counts the
rest ("+2"). The 3D wilderness view doesn't show other parties yet.
A party got tired after 14 moves, which players found too soon. Every
move or pass costs a rested hour, and a camp, an inn bed or a new party
gave 14. They give 21 now, and the later stages of tiredness come half
as late again too:

               before  now
    tired       0       0
    exhausted  -4      -6
    weak       -8     -12
    faint     < -8   < -12

A camp still needs the party to be tired, and the test scenarios keep
their own rested hours.
The bitmap web runtime builds its distribution with its own
installRuntimeBitmapWeb task, so the usual
./gradlew :runtime-bitmap-web:installDist failed with "task not
found". installDist is now an alias for it.
@lagergren
lagergren merged commit 0e4700b into main Nov 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant