Repository navigation
feat(planet): an account changes its flag once an hour - #423
Open
raphoester wants to merge 3 commits into
Open
raphoester wants to merge 3 commits into
raphoester wants to merge 3 commits into
Conversation
Every click and every shield names a flag, and nothing held a player to one: a player could paint for one country and defend another, click to click. The server now keeps the flag each account plays for. The first flag starts no wait and the first change is free; after a change, a click or a shield for another flag within the hour is refused with FailedPrecondition and a planet.v1.Allegiance detail. The check sits outside the throttle and the shadow ban, so a refused click spends no token and a banned caller is refused like any other. ClickService/GetAllegiance tells the client the flag held, and the picker says when another country may be played. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-rate-limit-e2b227 # Conflicts: # apps/backend/CLAUDE.md # apps/backend/generated/proto/planet/v1/planet.pb.go # apps/backend/internal/planet/internal/planetv1controller/click_handler/errors.go # apps/backend/internal/planet/internal/planetv1controller/place_shield_handler/handler.go # apps/frontend/src/app/viewer/globe.test.ts # apps/frontend/src/app/viewer/globe.ts # apps/frontend/src/backends/fakeBackend.ts # apps/frontend/src/backends/planetBackend.test.ts # apps/frontend/src/backends/planetBackend.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An account may change the flag it plays for once an hour.
planet/internal/allegiances): the flag each account plays for, and when it last changed it. The first flag starts no wait, and the first change is free, the way the first username is free: a player who clicked for its time zone's flag can still pick its own. After a change, a click or a shield for another flag within the hour is refused withFailedPreconditionand aplanet.v1.Allegiancedetail (the flag held andchangeable_at_unix_ms).allegiance_click, betweenantibot_attempt_clickandthrottle_click, so a refused click spends no token, and a banned caller is refused exactly like any other (otherwise switching flags would tell it its clicks are dropped).place_shield_usecasechecks before it spends the shield. Bombs, claims, quizzes and refills name a flag only for what they announce, and are not held.ClickService/GetAllegiance(identity token, from memory).planet.allegiances(new migration). A row is never deleted, not even with its account: without the row the next flag is a first flag again, which would hand out a free change. The row names nobody once the account is gone.PlanetBackendreads the allegiance at load, on a new token and after a click for another flag. While the flag is held, the picked country snaps back to it (local storage, share link, another device), and the picker shows "You can play for another country at HH:MM" instead of the list. A refused click rolls back and plays the refusal sound, with no dialog.FakeBackendapplies the same rule, andfakeBackend.unlockFlag()ends the wait in dev.Why
Every click names a flag and nothing held a player to one: a player could paint for one country and defend another, click to click.
For the reviewer
throttle_click. I know decorators are meant for logging only. I kept it there because it has to sit outside the throttle and the shadow ban, and the click chain is where those gates live today. If you want it elsewhere, say where.Tests
make test,make lint,make deadcodeandmake check-formatpass.lockOf, the client's reads and refusal mapping, the globe's quiet refusal, the locked picker. 2043 tests, build and lint pass. Checked in the browser against the fake backend.🤖 Generated with Claude Code