No description
Find a file
WiseDev ea9d9be4c4 cycle the summoner deck on play and draw, RNG-free
audit finding #3 (deck), after verifying the RNG stream is not involved:
addSpellsInRandomOrder shuffles the INITIAL order with a separate
Mersenne Twister, but the server is authoritative (ships the deck in the
snapshot; the client decodes it, never reshuffles), and the in-match
cycle is fully deterministic. so no RNG matching is needed.

play: the command's slot is the DECK index (LogicDoSpellCommand::execute
maps it to a hand slot via getSpellIndex, rejecting if it is not in
hand). play_from_hand finds the hand slot holding that index, moves the
card to the used pile and empties the slot - useSpellFromHand. spawn is
untouched; it already reads the card by the deck index.

draw: cycle_summoner_decks decrements spell_cooldown each tick and, when
it hits 0 with an empty hand slot, slides the front of the draw pile in
(refilling draw from used IN ORDER when it empties) and resets the timer
to NEXT_SPELL_COOLDOWN_MILLISECONDS (2000 / _BOOST / _OVERTIME).
field_240 (reshuffle) just counts down and stays 0 in normal play.

harness: playing hand slot 0 empties it and banks the card in used;
ticking past the cooldown refills the slot with a different card.
2026-08-24 14:26:17 +03:00
assets pull the arena tilemaps out of the ipa 2026-08-23 10:13:37 +03:00
config generate the daily card shop server side 2026-08-23 08:47:55 +03:00
crates cycle the summoner deck on play and draw, RNG-free 2026-08-24 14:26:17 +03:00
.gitignore nuke the tests and the dead code 2026-08-23 07:51:04 +03:00
Cargo.lock move players and accounts into postgres 2026-08-23 08:40:13 +03:00
Cargo.toml supervised mode: run the services as child processes 2026-08-23 09:46:59 +03:00
LICENSE add MIT license 2026-08-23 09:13:19 +03:00
README.md supervised mode: run the services as child processes 2026-08-23 09:46:59 +03:00

scroll-server

A server for the scroll client (Clash Royale 2.0.1306, iOS). Takes a real client from TCP connect to the lobby: login, own home data, chests, card upgrades, the shop.

Requirements

  • Rust 1.75+
  • PostgreSQL 16

Running

createdb scroll
cargo run --release -p scroll-server

Listens on 0.0.0.0:9339, the port the client hardcodes. The schema is created on first boot. DATABASE_URL defaults to postgres:///scroll.

On macOS a Homebrew cluster may need LC_ALL=C to start at all.

That runs everything in one process. For real isolation, SCROLL_MODE=supervised makes it spawn the three services as child processes and restart any that dies, with backoff:

SCROLL_MODE=supervised ./target/release/scroll-server

They can also be started by hand, in any order:

cargo run --release -p auth-service
cargo run --release -p game-service
cargo run --release -p gateway

Checking it without a phone

scroll-probe speaks the same protocol and prints the decoded lobby:

cargo run --release -p gateway --bin scroll-probe -- 127.0.0.1:9339

Flags: --claim-free-chest, --buy-chest <name>, --desync. Pass an account and pass token to reconnect as an existing player: scroll-probe 127.0.0.1:9339 0 1 <passtoken>.

Pointing a client at it

The client hardcodes game.clashroyaleapp.com. Patch that string in the binary inside the ipa to your machine's address, keeping the 23 byte slot NUL padded so nothing around it moves.

Configuration

variable default
DATABASE_URL postgres:///scroll
SCROLL_MODE single, or supervised
SCROLL_BIN_DIR next to the running binary
SCROLL_AUTH_LISTEN 127.0.0.1:9401
SCROLL_GAME_LISTEN 127.0.0.1:9402
SCROLL_GATEWAY_LISTEN 0.0.0.0:9339
SCROLL_CSV_ROOT assets
SCROLL_SHOP config/shop.json
SCROLL_STARTER_PROFILE built in
RUST_LOG info

Shop

config/shop.json lists what the server sells, as Name#count:

{
  "offers": [
    { "id": 1, "give": "Gold#1000" },
    { "id": 5, "give": "chest:Gold#1" },
    { "id": 7, "give": "Diamonds#500", "cost": "Gold#20000" }
  ]
}

Names resolve against the csv tables. cost is optional; without it the server charges the same price the client computes from the game data.