Skip to content

feat: a live game feed, and an XP tracker that updates after every fight - #44

Merged
CodySimonds65 merged 28 commits into
mainfrom
feature/live-game-feed-public
Oct 7, 2026
Merged

CodySimonds65 merged 28 commits into
mainfrom
feature/live-game-feed-public

Conversation

@CodySimonds65

Copy link
Copy Markdown
Owner

FourFold now reads each fight as it happens, so the XP tracker, the XP calc card, the overlay cards and plugins update after every fight instead of once a minute. The once-a-minute profile read stays as the fallback, so everything keeps working when the live feed is off or a game update breaks it.

The live game feed

  • Read-only. For each game panel, FourFold listens to the messages the game sends to that panel (WebView2's DevTools protocol, inbound only). It never sends anything to the game, never changes what the game does, and adds no script to the game's page.
  • Only a short allowlist is decoded: fight start and end, the fight's reward, skill hits and misses, scene changes, and login and disconnect. Everything else is dropped unread. Nothing is logged, stored or forwarded: no frames, payloads or other players' data.
  • Strict parsing. A message that doesn't match its expected shape switches the feed to unavailable rather than guessing. So does a login that isn't recognised within 60 s, or, new in this PR, battle results that stop arriving while the poll keeps gaining XP. Everything then falls back to the profile read.
  • Settings → Live game feed, on by default, with counters for frames, events, drops, errors and the XP checks (the feed's XP against the profile read's).

The XP tracker goes live

  • While the feed watches an account, each fight's result gives the exact level and XP for the active class: the level reached and the XP still needed, using the game's 5·L·(L+1) curve. The rate counts XP over real time, so it falls between fights. The panel redraws once a second and shows the last fight's time.
  • The profile read keeps everything the feed doesn't know (other classes, stats, silver, gold, location) and checks the feed's XP. It adds no XP of its own while live, so nothing is counted twice. When live ends (a panel closed, F5, the feed switched off), the next reads start a fresh baseline, and the idle time before the end still counts.
  • Reset XP/hr starts the new rate from the moment you press it.

Plugin API 3

  • battle.onStarted, onEnded, onResult and onSkillResult; location.get and onChanged; session.onLoggedIn and onDisconnected; live.getStatus and onStatusChanged. Plugins get only the fields listed in PLUGIN_AUTHORS.md, for the user's own accounts.
  • xp.get follows each fight while the feed watches the account. xpPerHour is the rate at the time of asking. updatedAt and isStale still describe the last read, and xp.onUpdated fires on a read, a fight or a reset.
  • PLUGIN_AUTHORS.md documents all of it. The template's fourfold.d.ts and the first-party plugins are updated in their own repositories, and their hub updates follow this release.

Testing

  • Unit tests: Core 357 and Desktop 37 pass, and the build has no warnings. The tests cover the decoder against crafted frames (no captured traffic), the feed's privacy boundary, the XP reconciliation, and the live XP engine's transitions: polls during live, the baseline after live, lagging polls, level-ups, class switches, reset, the battle-results-stopped fallback and the 60-second minimum. The Leaderboard tests need Docker and aren't affected.
  • Live test: run by hand on three accounts.
    • XP matched the profile read across level-ups.
    • Skill hits, misses and rejections all came through.
    • A wrong password posted no login.
    • The feed toggle worked.
    • F5 mid-fight and closing a panel caused no double count.
    • The idle decay, Reset and the feed-off fallback all worked.
    • Account overview and the built-in tracker showed the same XP/hr.

Levels have no cap in the game, and the decoder is strict: a level above 999 would have made the account's live feed unavailable. A misread message still fails the end-of-payload check.
A game update that changes only the battle result leaves login and scene
decoding, so the feed stayed active with no results and XP/hr decayed to 0.
Two compared windows in a row with polled XP and no results now mark the
feed unavailable.
…r a live stretch

- EndLive(at) stores the stretch since the last fight as watched time that
  gained nothing, so XP/hr doesn't jump back up after a disconnect or F5.
- ResetRate/ResetAll(now) move a live account's mark to the press.
- The rebase poll uses the live progress as its baseline when the poll
  lags the last fight, so the next poll doesn't count that fight again.
- A poll while live no longer reports a partial interval.
…m crashing the app

Results in one frame share its time, so the session dropped every one but
the first. The feed now sends their sum with the last result's state.
A throwing call queued to the UI thread is swallowed, unlogged, like the
worker's.
…nd start the count over after a skipped window

A stale miss from before a level-up, a reconnect or the feed switching back on could pair with a later ordinary
timing miss, and a class the game spells differently from the website read as every fight missing. Either one
switched the live feed off for every account.
… last fight's time

The panel showed the last poll's time and a rate worked out only at polls and fights, so a live tracker looked
once-a-minute. The rate shown (panel, cards, xp.get) is now the rate at the time of asking, the panel redraws every
5 s while an account is live, and the row shows the last fight's time. Plugins still get xp.updated only for a poll,
a fight or a reset, not for every redraw.
…e tracker redraws

The status now reads from the rate shown beside it, going off live keeps the rate that had fallen with the idle
time, the 5-s redraw skips while a mouse button is down, and the timer stops at shutdown.
The rows are rebuilt every second while an account is live, which disconnected an open menu from its row, so
Reset XP/hr did nothing. The menu now takes its account when it opens.
@CodySimonds65
CodySimonds65 force-pushed the feature/live-game-feed-public branch from c65e0fe to d822948 Compare October 7, 2026 04:33
@CodySimonds65
CodySimonds65 merged commit e8c7cde into main Oct 7, 2026
@CodySimonds65
CodySimonds65 deleted the feature/live-game-feed-public branch October 7, 2026 04:54
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