Compare commits

...
10 Commits
Author SHA1 Message Date
waozi 47c065576d Publish a separate Google Play APK and verify Google-free downloads 2026-10-28 14:11:19 -03:00
waozi 8c24471081 Offer ten Dew and show bulk savings in the Play edition 2026-10-28 12:36:38 -03:00
waozi 1a040c0597 Use the shared 10 Dew purchase option in Google Play builds 2026-10-28 11:52:09 -03:00
waozi 1af02f6777 Use the updated shared Profile and hosted keyboard 2026-10-28 03:41:10 -03:00
waozi 4f6ee7fbcf Preserve Apfelwurm account progress and add its Android icon 2026-10-28 03:25:49 -03:00
waozi 8ac690e93f Publish tested browser and Android builds to itch.io 2026-10-27 20:35:37 -03:00
waozi 84ba9bb57f Ignore the image tool's working folder 2026-10-27 19:22:08 -03:00
waozi 40ae522f4b Set up the prebuilt Ziran, cached packages and build tools in CI
The game tests, downloads and Play bundle no longer build the locked
compiler or fetch every package from scratch. The Ziran setup action
downloads the prebuilt compiler, reuses the cached package checkouts and
installs the build tools from the canonical Ubuntu archive, where the
runner mirror once stalled package setup for 14 minutes.
2026-10-27 19:11:19 -03:00
waozi f2622e2b51 Release Apfelwurm 0.2.9: more portal rooms in the mountains
Levels 181, 183, 185, 189 and 191 close a walled corner room with one
doorway (tools/design_levels.py PORTAL_ROOMS), keeping creatures out of it.
Boards in the last landscape that bring portals use their room when they
have one, so seven of the last twenty boards have a portal room. New
certificate cases for the reshaped boards and regenerated previews.
2026-10-27 18:35:06 -03:00
waozi 4f697bb244 Release Apfelwurm 0.2.8: new animals, keys, switch stones and portal rooms after the meadow
Each idea arrives on its own schedule (squirrels 45, hedgehogs 85, keys 101,
frogs 125, switch stones 141, rolling stones 165, portal rooms 181), takes
every other board for ten levels, then mixes with the ideas met so far.
Gates close straight doorways up to four tiles wide; a board without room
for its idea hands it on or takes another one. Codex-drawn sprites fill row
four of every campaign sheet. The campaign certificate keeps 400 wins with
the new animals active, and the toolchain moves to the Ziran fix that keeps
saved IR canonical for calls with widened nested arguments. The browser
preload leaves out the unused old level previews to stay under 25 MiB.
2026-10-27 17:52:52 -03:00
47 changed files with 1320 additions and 508 deletions

No files matched your search

+41 -21
View File
@@ -30,25 +30,24 @@ jobs:
with:
path: waozixyz/wurm
persist-credentials: false
- name: Read the locked compiler and release version
- name: Read the release version
id: version
run: |
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
from pathlib import Path
print('compiler=' + json.loads(Path('ziran.lock').read_text())['toolchain']['commit'])
print('version=' + json.loads(Path('version.json').read_text())['version'])
PY
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@979159a55bcf1f9edb9eb8f26ea10aca421412e2
with:
repository: ziranlang/ziran
ref: ${{ steps.version.outputs.compiler }}
project: waozixyz/wurm
path: ziranlang/ziran
persist-credentials: false
- name: Install native and private-display test tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential cmake pkg-config python3-pil python3-numpy ffmpeg libssl-dev libsdl2-dev libcairo2-dev libfreetype-dev libfontconfig-dev libpango1.0-dev libgtk-3-dev libx11-dev libxcursor-dev libxinerama-dev libxrandr-dev libxi-dev libgl1-mesa-dev xvfb xauth xdotool imagemagick
fetch: true
packages: >-
build-essential cmake pkg-config python3-pil python3-numpy ffmpeg libssl-dev libsdl2-dev libcairo2-dev libfreetype-dev libfontconfig-dev libpango1.0-dev libgtk-3-dev libx11-dev libxcursor-dev libxinerama-dev libxrandr-dev libxi-dev libgl1-mesa-dev xvfb xauth xdotool imagemagick
- uses: actions/setup-node@v4
with:
node-version: '22'
@@ -63,19 +62,14 @@ jobs:
- name: Install the pinned Android SDK tools
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" 'ndk;28.2.13676358' 'build-tools;36.0.0' 'platforms;android-36' 'cmake;3.22.1'
- name: Build the locked compiler
working-directory: ziranlang/ziran
run: |
env -u DISPLAY -u WAYLAND_DISPLAY make -j1
echo "$PWD/build/bin" >> "$GITHUB_PATH"
- name: Fetch only locked packages
run: ziran fetch --locked
- name: Verify release metadata
run: |
sh update_version.sh
git diff --exit-code -- version.json
- name: Run the game and asset tests
run: sh tests/run_local.sh
run: |
python3 tests/android_release_test.py
sh tests/run_local.sh
- name: Exercise the app on its own private display
run: python3 tests/private_ui_test.py
- name: Build and exercise the shared account interface
@@ -103,7 +97,9 @@ jobs:
PY
- name: Build both ARM architectures in one production APK
run: python3 tools/build_android.py --release --abi universal
- name: Sign and verify the standard and F-Droid-style downloads
- name: Build the separate Google Play APK
run: python3 tools/build_android.py --release --abi universal --edition gplay
- name: Sign and verify the Google-free downloads and Google Play APK
env:
KEYSTORE: ${{ secrets.WURM_ANDROID_KEYSTORE }}
PASSWORD: ${{ secrets.WURM_ANDROID_KEYSTORE_PASSWORD }}
@@ -116,14 +112,17 @@ jobs:
printf '%s\n' "$PASSWORD" > "$RUNNER_TEMP/wurm-password"
python3 tools/android_release.py sign build/android/Apfelwurm-universal-release-unsigned.apk \
--keystore "$RUNNER_TEMP/wurm-release.p12" --password-file "$RUNNER_TEMP/wurm-password"
python3 tools/android_release.py sign build/android/Apfelwurm-universal-gplay-release-unsigned.apk --edition gplay \
--keystore "$RUNNER_TEMP/wurm-release.p12" --password-file "$RUNNER_TEMP/wurm-password"
# Publish from this verified workspace: GitHub Actions artifact storage
# is account-wide and must not block the owner's release downloads.
- name: Require both download names and extract release notes
- name: Require all download editions and extract release notes
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
test -f "build/downloads/wurm-v$VERSION.apk"
test -f "build/downloads/wurm-$VERSION-fdroid.apk"
test -f "build/downloads/wurm-v$VERSION-gplay.apk"
test -f "build/downloads/wurm-web-v$VERSION.zip"
cmp "build/downloads/wurm-v$VERSION.apk" "build/downloads/wurm-$VERSION-fdroid.apk"
python3 - <<'PY' > build/release-notes.md
@@ -150,8 +149,29 @@ jobs:
if [ "$state" = missing ]; then
gh release create "$tag" --draft --target "$GITHUB_SHA" --title "Apfelwurm $VERSION" --notes-file build/release-notes.md
fi
gh release upload "$tag" "build/downloads/wurm-v$VERSION.apk" "build/downloads/wurm-$VERSION-fdroid.apk" "build/downloads/wurm-web-v$VERSION.zip" --clobber
gh release upload "$tag" "build/downloads/wurm-v$VERSION.apk" "build/downloads/wurm-$VERSION-fdroid.apk" "build/downloads/wurm-v$VERSION-gplay.apk" "build/downloads/wurm-web-v$VERSION.zip" --clobber
gh release edit "$tag" --draft=false --latest
- name: Install itch.io Butler
run: |
curl --fail --show-error --location --retry 3 \
https://broth.itch.zone/butler/linux-amd64/LATEST/archive/default \
--output "$RUNNER_TEMP/butler.zip"
mkdir -p "$RUNNER_TEMP/butler"
unzip -q "$RUNNER_TEMP/butler.zip" -d "$RUNNER_TEMP/butler"
chmod +x "$RUNNER_TEMP/butler/butler"
echo "$RUNNER_TEMP/butler" >> "$GITHUB_PATH"
- name: Publish the tested browser and Android editions to itch.io
env:
BUTLER_API_KEY: ${{ secrets.ITCH_API_KEY }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
test -n "$BUTLER_API_KEY" || { echo '::error::Set the ITCH_API_KEY repository secret to enable automatic itch.io updates.'; exit 1; }
test -f build/web/index.html
test -f "build/downloads/wurm-v$VERSION.apk"
butler push build/web waozi/wurm:html5 --userversion "$VERSION"
butler push "build/downloads/wurm-v$VERSION.apk" waozi/wurm:android --userversion "$VERSION"
butler status waozi/wurm
# Arcade follows this release now, not at its next timer, and Breeze
# then publishes it to the node. RELEASE_FOLLOW_TOKEN may only start
# workflows in Arcade and Breeze; Game updates takes no input and finds
+9 -17
View File
@@ -28,25 +28,24 @@ jobs:
with:
path: waozixyz/wurm
persist-credentials: false
- name: Read the locked compiler and release version
- name: Read the release version
id: version
run: |
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
from pathlib import Path
print('compiler=' + json.loads(Path('ziran.lock').read_text())['toolchain']['commit'])
print('version=' + json.loads(Path('version.json').read_text())['version'])
PY
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@979159a55bcf1f9edb9eb8f26ea10aca421412e2
with:
repository: ziranlang/ziran
ref: ${{ steps.version.outputs.compiler }}
project: waozixyz/wurm
path: ziranlang/ziran
persist-credentials: false
- name: Install native build tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential cmake pkg-config python3-pil python3-numpy libssl-dev
fetch: true
packages: >-
build-essential cmake pkg-config python3-pil python3-numpy libssl-dev
- uses: actions/setup-java@v4
with:
distribution: temurin
@@ -54,13 +53,6 @@ jobs:
- name: Install the pinned Android SDK tools
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" 'ndk;28.2.13676358' 'build-tools;36.0.0' 'platforms;android-36' 'cmake;3.22.1'
- name: Build the locked compiler
working-directory: ziranlang/ziran
run: |
env -u DISPLAY -u WAYLAND_DISPLAY make -j1
echo "$PWD/build/bin" >> "$GITHUB_PATH"
- name: Fetch only locked packages
run: ziran fetch --locked
- name: Verify release metadata
run: |
sh update_version.sh
+1
View File
@@ -5,3 +5,4 @@ ziran.local.toml
__pycache__/
assets/campaign-levels/
assets/entity.zx
.yue/
+25
View File
@@ -1,5 +1,30 @@
# Changelog
## [0.2.12] - 2026-10-28
- Download the Google Play edition as a separate `-gplay.apk`. The standard and F-Droid APKs exclude Google libraries and keep Monero top-ups.
## [0.2.11] - 2026-10-28
- Buy a small 10 Dew pack in the Google Play edition and see each larger pack’s savings per Dew.
## [0.2.10] - 2026-10-28
- Keep signed-in progress and unfinished runs after closing or updating Apfelwurm inside Arcade and Breeze.
- Restore earned unlocks from older account saves without changing completed levels or the current run.
- Give Apfelwurm its own Android launcher icon.
## [0.2.9] - 2026-10-27
- More portal rooms in the mountains: five more boards have a walled corner room whose doorway closes, so a ring is the only way in, and boards there that bring portals use their room. Seven of the last twenty boards now have a portal room.
## [0.2.8] - 2026-10-27
- After the meadow, a new idea arrives every few dozen levels and keeps coming back: squirrels that dash and sit from level 45, hedgehogs that curl into a spiky ball as you come close from 85, keys that open a gate from 101, frogs that hop two tiles from 125, switch stones that open and close a gate from 141, rolling stones from 165 and portal rooms, reached only through a ring, from 181.
- Each new idea takes every other board for ten levels. After that, the ideas you have met take turns, with no more than two plain boards in a row.
- A gate closes a doorway up to four tiles wide. Its key opens it for good and is worth 2 points; a switch stone flips it each time you arrive on it. Boards with a gate or a portal room score more.
- New pictures for the squirrel, hedgehog, frog, rolling stone, key, switch stone and gate.
## [0.2.7] - 2026-10-27
- On the desktop, Play starts right away with mouse steering; the keyboard always works, and Pause still switches to the direction pad.
+4
View File
@@ -21,6 +21,10 @@ acoustic soundtrack and controls that respond while your finger stays down.
Free to play. All 200 levels can be unlocked through play. No ads. An optional account keeps your
progress and character choices in sync, with cosmetic skins available for Dew.
The standard Android APK and the `-fdroid.apk` download exclude Google libraries.
Choose the separate `-gplay.apk` for Google Play Billing. The standard and
F-Droid editions use Monero for Dew top-ups.
## Five landscapes. Forty levels each.
- **Meadow:** find your rhythm among grass, hedges and orchard paths, with a slower opening pace.
+10
View File
@@ -0,0 +1,10 @@
{
"generator": "built-in image_gen",
"reference": "assets/art-source/head-profile.png",
"purpose": "Android launcher icon",
"prompt": "Use case: logo-brand. Asset type: finished square Android launcher app icon for Apfelwurm, a calm hand-illustrated worm puzzle game. Reference image: assets/art-source/head-profile.png is the existing character: orange worm, big blue eyes, friendly little mouth. Create a new icon, not a sprite sheet: one charming rounded light-orange worm head peeking up over a gentle curved body, a very small red apple tucked beside it, against a simple deep jade green and muted lake-blue garden background. Single strong silhouette, exceptionally legible at 48 pixels, soft hand-painted 2D shading, earth-brown outlines, restrained detail, friendly and playful. Keep the worm and apple within the central two thirds for Android circular/squircle masking. Full square opaque edge-to-edge background; no rounded square border or baked corner mask. No lettering, no numbers, no watermark, no UI, no glossy plastic, no glow. 1024x1024 square.",
"dimensions": [
1254,
1254
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

+16 -3
View File
@@ -174,12 +174,25 @@ Signing uses the preserved private key in ignored `backup/android-signing/`.
Only its public certificate is tracked in `packaging/android/certificate.pem`.
The signing tool verifies the package, version, certificate, both ARM native
libraries, 16 KB ZIP alignment and current game assets. It produces identical
signed `wurm-v<VERSION>.apk` and `wurm-<VERSION>-fdroid.apk` downloads, following
Shovey's naming format. The F-Droid filename is a source-build distribution
signed `wurm-v<VERSION>.apk` and `wurm-<VERSION>-fdroid.apk` downloads. Both exclude
Google libraries, and verification rejects Google or Play Billing classes and
the Play Billing permission in these APKs. The F-Droid filename is a source-build distribution
artifact; it does not imply a listing or approval in the F-Droid catalog.
Build and sign the separate Google Play APK with:
```sh
python3 tools/build_android.py --release --abi universal --edition gplay
python3 tools/android_release.py sign build/android/Apfelwurm-universal-gplay-release-unsigned.apk --edition gplay
```
This produces `wurm-v<VERSION>-gplay.apk`, with Play Billing for Dew purchases.
It never replaces either Google-free download. `--bundle` still builds the
Google Play App Bundle; the separate Google Play bundle workflow signs it for
upload to the Play Console.
On every push to master, the Downloads workflow runs the game and private
display tests, builds a production APK and signs both names using repository
display tests, builds both Android editions and signs all three names using repository
secrets `WURM_ANDROID_KEYSTORE` and `WURM_ANDROID_KEYSTORE_PASSWORD`. A new
changelog version is published only after those jobs succeed. Tags are created
by that workflow. Publishing uploads directly from the verified build to
+25 -4
View File
@@ -749,6 +749,19 @@ DrawBoard :: (session: Session, stage: Rectangle) {
}
DrawGatePosts(session, stage)
DrawPortals(session, stage)
// A closed gate, the key that opens it or the switch stone that flips it.
if game.gate >= 0 && !game.gate_open {
for part: 0..game.gate_span - 1 {
cell := game.gate + cast(s32)part * game.gate_step
Sprite(session, 12110 + cast(u64)part, stage, Point.{(cell % board_columns) * 16 + 8, (cell / board_columns) * 16 + 8},
Rectangle.{(ifx game.gate_step == 1 then 11.0 else 12.0) * 16.0, 64.0, 16.0, 16.0}, sprites)
}
}
if game.key.x >= 0 { Sprite(session, 12101, stage, game.key, Rectangle.{8.0 * 16.0, 64.0, 16.0, 16.0}, sprites) }
if game.switch_stone.x >= 0 {
Sprite(session, 12102, stage, game.switch_stone,
Rectangle.{(ifx game.gate_open then 10.0 else 9.0) * 16.0, 64.0, 16.0, 16.0}, sprites)
}
if game.apples > 0 && game.apple.x >= 0 {
Sprite(session, 1400, stage, game.apple, Rectangle.{0.0, 112.0, 16.0, 16.0}, sprites)
AppleFlash(session, stage)
@@ -776,10 +789,18 @@ DrawBoard :: (session: Session, stage: Rectangle) {
Rectangle.{cast(float32)game.direction * 16.0, 48.0, 16.0, 16.0}, sprites, WORM_HEAD_SIZE)
}
for monster: 0..game.monster_count - 1 {
column := game.monsters[monster].kind - 1
if game.monsters[monster].kind == 1 { column = 6 + enemy_frame }
Sprite(session, 6000 + cast(u64)monster, stage, game.monsters[monster].position,
Rectangle.{cast(float32)column * 16.0, 32.0, 16.0, 16.0}, sprites)
creature := game.monsters[monster]
column := creature.kind - 1
row: float32 = 32.0
if creature.kind == 1 { column = 6 + enemy_frame }
// The animals met after the meadow share row four of every sheet.
if creature.animal != ANIMAL_CLASSIC { row = 64.0 }
if creature.animal == ANIMAL_SQUIRREL { column = (creature.timer / 4) % 2 }
if creature.animal == ANIMAL_HEDGEHOG { column = ifx creature.timer < 0 then 3 else 2 }
if creature.animal == ANIMAL_FROG { column = ifx creature.timer >= 14 && creature.timer % 14 < 4 then 5 else 4 }
if creature.animal == ANIMAL_STONE { column = 6 + (creature.timer / 3) % 2 }
Sprite(session, 6000 + cast(u64)monster, stage, creature.position,
Rectangle.{cast(float32)column * 16.0, row, 16.0, 16.0}, sprites)
}
for particle: 0..99 {
life := game.particles[particle].life
+5 -5
View File
@@ -186,17 +186,17 @@ DesignedLevelText :: (level: s32) -> string {
if level == 177 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100000000000000003311003311001100000000000400003311003311001100000090000011001111001111001100000000000011001111001111001100000000000011000000000000001100000000000011000000000000001100000000000011003311003311001100000000000011003311003311001100000000000011001111001111001100000000000011001111001111001100000000000011000000000000001100000000000011000000000000001100000000000011003311003311001100000000000011003311003311001100000000000011001111001111001100000000000011001111001111001100000000000011000000000000001100000000000011000000000000001100000000000011003311003311001100000000000011003311003311001100000000000011081111001111001100000000000011001111001111001100400000000011000000000000001100000000000011000000000000001100000000000011003311003311001100000000600011003311003311001100000000000011001111001111001100000000000011001111001111001100000000000011000000000000001100000000000011000000007000001100000000000011003311003311001100000000000011003311003311001100000000000000001111001111001100000000000000001111001111001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 178 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100000000400008000000000000001100000000000000000000008000001100000011331100000000000000001100000011331100000000000000001100001133111100000000000000001100001133111100000000000000001100003311113300000000000000001100003311113300000000000000001100001111331100000000000000001100001111331100000000000000001100001133111100000000000000001100001133111100000000000000001100000000007011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100001111111111111111111100001100001111111111111111111100001100000000000011000000000000001100009000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000400000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000011000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 179 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000070000001100000000000000000000000000001100000000000000000900000000001100000000000000000000000000001111111111110000000011111111111111111111110000000011111111111100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100400000000000000000000000001100000000000000000000002200001100000000000000000000002200001100000000000000000000222222221100000000000000000000222222221100000000000000000022222200001100000000000000000022222200001100000000000000802222222200001100000000000000002222222200001100000000000000000000000000001100000000000080000000000000001111111111110000000000000000001111111111110000000040000000001100000000002200000000000000001100000000002200000000000000001100000000222200000000000000001100000000222200000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 180 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100001100000000000000000011001100001109000000000000000011001111400000000000000000000000001111000000000000000000000000001100000000001100000011000000001100000000001100000011000000001100000000000000000000000000111100000000040000000000000000111100000022222222222222220000001100000022222222222222220000001100001111111122002211111100001100001111111122002211111100001100000011111122002211110000001100080011111122002211110000001100000011111122002211110000001100000011111122002211110000001100000033111100001133110000001100009033111100001133110000001100000022222222002222220000001100000022222222002222220000001111001111111122002211110000111111001111111122002211110000111100000011111122002211110000001100000011111122002211110000001100000000000000000000110000001100000000000000000000110000001100000000001100000000000000001100000000001100000000000000001100000000000000000000000000001100000000700000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000011001100000000000000000000000011001100110000000000000000000000001100110000000000000000000000001111111111111111111111111111111" }
if level == 180 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100001100000000000000000011001100001100000000000000000011001111000000000000000000000000001111090000000000000800000000001100000000001100000011000000001100000000001107000011000000001100000000900000000000000000111100000000000000000000000000111100000022222222222222220000001100000022222222222222220000001100001111111122002211111100001100001111111122002211111100001100000011111122002211110000001100000011111122002211110000001100000011111122002211110000001100000011111122002211110000001100000033111100001133110000001100000033111100001133110000001100000022222222002222220000001100000022222222002222220000001111001111111122002211110000111111001111111122002211110000111100000011111122002211110000001100000011111122002211110000001100000000000000000040110000001100000000000000000000110000001111001111001100000000000000001111001111001100000000000000001100000011000000000000000000001100000011000000000000000000001100000011000000000000004000001100000011000000000000000000001100000011000000000000000011001100000011000000000000000011001100000011000000000000000000001100000011000000000000000000001111111111111111111111111111111" }
if level == 181 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111100000000000400001111001100111100700000000000001111001100111111111100111111111111001100111111111100111111111111001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000900000001100001100001100000000000000001100001100001100000400000000001100001100001100000000000000001100001100001100000000000000001100001100000000000000000000000000001100000000000000000000000000001100701100000000000000001100001100001100000000000000001100001100001100000800000000001100001100001100000000000000001100001111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100111111111111111111111111111100001111111111111111111111111100001111111111111111111111111100001111111111111111111111111100001111111111111111111111111111111111111111111" }
if level == 182 { return "111111111111111111111111111111100000000001100000000000000001100000000001100000000000000001100001100001100000040001111001100001100001100000000001111001100001111111100001111111111001100001111111100001111111111001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000040000001100001100000000000000000000001100001100000000000000000000001100001100700000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000000000001100000000000000000000000000001100000000000000000000001100001100000000000800000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000007000000000000001100001100000000000000000000001100001100000000000000000000901100001100000000000000000000001100001100001100111100001111111111001100001100111100001111111111001100001100001100000000001111001100001100001100000000001111001100001100001100000000000000001100001100001100000000000000001111111111111111111111111111111" }
if level == 182 { return "111111111111111111111111111111100000000001100000000110000001100000000001100000000110000001100001100401100000000110000001100001100001100000000110000001100001111111100001100000000001100001111111170001100000000001100000000000000000000110000001100800000000000000000110000001100000000000000000000111111111100000000000000000000111111111100000000000000000000001100001100000000000000000000001100001100070000000400000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000000000001100000000000000000000000000001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100000090000000000000001100001100000000000000000000001100001100000000000000000000001100001100000000000000000000001100001100001100111100001111111111001100001100111100001111111111001100001100001100000000001111001100001100001100000000001111001100001100001100000000000000001100001100001100000000000000001111111111111111111111111111111" }
if level == 183 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100118011001100000000000000001100110011001100000000000000001100000000000000000011000000001100000000000000000011007000001100110011001100110011000000001100110011001100110011000000001100000000000000000011000000001100000000000900000011000000001100110011001100110011000000001100110011001100110011000000001100000000000000000011000000001100000000000000000011000000001100001100110000110011000000001100001100110000114011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110005110011000000001100041100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100001100110000110011000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 184 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000060000000000000001100000022000000000000000000001100000022000000000000000000001100000500000000000000000000001100000000000000000000000000001100000000000000000000002200001100000000000000000000002200001100000000000000000000002200001100000000000000000000002200001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000111100000000000000000000000000111100000000040000000000000000001100009000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100002200000000000011111111111100002200000000000011111111111100000000000000000000000000001100000000000000000000000000001100000000000000111111111111001100000000000000111111111111001100000000000000000000000000001100000000700000000000000000001100000000001111111111111111111100000000001111111111111111111100000000000000000004000000001100000000000000000000000000001100000011111100001111111111001100000011111100001111111111001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 184 { return "111111111111111111111111111111100000011000000000000000000001100000011000000000000000000001100000011000000000000090000001100000011000040000000000000001100000000000000000000000000001100000000000000000000000000001100000011000000000000000000001100000011000000000000000000001111111111070000000000002200001111111111000000000000002200001100000000000000000000002200001100000000000000000000002200001100000000400000000000000000001100000000000000000000000000001100000000000000000000000000111100000000000000000000000000111100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100002200000000000011111111111100002200000000000011111111111100000000000000000600000000001100000000000000000000000000001100000000000000111111111111001100000000000000111111111111001100000000000000000000000000001100000000000000000000000000001100000000001111111111111111111100000000001111111111111111111100000000000000000000000000001100000000000000000000500000001100000011111100001111111111001100000011111100001111111111001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 185 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000007000000001100000000000000000000000000001100000000009000000000000000001111111111111111111100000000001111111111111111111100004000001100000000222222222222221100001100000000222222222222221100001100000000222200000600000000001100000000222200000000000000001100000000222200222222220000001100000000222200222222220000001100000000222240220000000000001100000000222200220000000000001100000000222200220000000000001100000000222200220000000000001100000000222200220000000000001100000000222200220000000000001100000000222200222222220000001100000000222200222222220000001100000000222200000000000000001100000000222200000000000000001100000000000000051111111100001100000000000000001111111100001111111111111111111100000000001111111111111111111100000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 186 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111111000000000000000000001100111111000000000000000000001100116011000000000000000000001100110011000000000000000000001100110011000000000000000000001100110011000000000000000000001100000000000000000005000000001100000000000000000000000000001100000000000000000000000000001100000000000000800000000000001100000000000000001111000000001100000000000000001111000000001100000000000000000011000000001100000000000000000011000000001100000000000000000011000000001100400000000000000011000000001100000000000000000011000000001100000000000000000011000000001100000000000000000011000000001100000000004000000011000000001100000000000000000011000000001100000000000000000011000000001100222200000022220000002222001100222200700022220000002222001100222200000022220000002222001100222200000022220000002222001100222200222222222222222222001100222200222222222222222222001100222200000022220000002222001100222200000022220000002222001100222200000022220000002222001100222200000022220000002222001100222200000000000000002222001100222200000000000000002222001122222222222200002222222222221122222222222200002222222222221111111111111111111111111111111" }
if level == 187 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100001111110000001111111111001100001111110000001111111111001100001150000000001111111111001100001100000000001111111111001100111100001100000000000000001100111100001100000000000000001100001111000000001111111111001100001111000000601111111111001100000511000000001111111111001100000011000000001111111111001100000000000000000000000000001100000000000000000000000000001100000000001111001111111111001100000000001111001111111111001100000000000011001111111111001100000000000011001111111111001100000000111111000000000000001100000000111111000000000000001100000000110011111111111111001100000000110011111111111111001100000011110000001111111111001100000011110000001111111111001100000000000011110000000000001100000040000011110000000000001100000000000000111111111111001100000000000000111111111111001100000011000000001111111111001100000011000000001111111111001100000011000000000000000000001100000011400000000000000000001100111111000000001111111111001100111111000000001111111111001100001100000000001111111111001100081100000000001111111111001133001100000000000000000000001133001100000000000000000000001111111111111111111111111111111" }
if level == 188 { return "111111111111111111111111111111100001122000000000000001100001100001122000000000000001100001100002211000000000000111111001100002211000000000000111111001100000000000000001100001100001100000000000000001100001100001100000000000000001111000000001100050000000000001111000000001100000000000011221100001100001100000000000011221100001100001100000000000022111100111111001100006000000022111100111111001100000000000000001111001100001100000000000000001111001100001100110004110000001100000000001100110000110000001100000000001100000011111100000000110000001100000011111100000000110000001100000000110000000011111100001100000000110000000011111100001100005000000011000000110000001100000000000011000000110000001100001100001111110000001100001100001100001111110000001100001100111111000011000000111111001100111111000011000000111111001100001100000000000000001100001100001100000000000000001100001100000000000011000011000000001100000800000011000011000000001100000000001111111111110000001100000000001111111111110000001100001100000011000011000011001100401100000011000011000011001100111111000000000000001111001100111111000000000000001111001100001100000000000000000011001100001100000000000000000011001111111111111111111111111111111" }
if level == 188 { return "111111111111111111111111111111100001122000000000000001100001100001122000000000000001100001100002211000000000000111111001100002211000000000000111111001100000000005000001100001100001100000000000000001100001100001100000000000000001111000000001100000000000000001111000000001100000000000011221100001100001100080000000011221100001100001100000000000022111100111111001100000000000022111100111111001100000000000000001111001100001100000000000000001111001100001100110000110000001100000000001100110005110000001100000000001100000011111100000000110000001100000011111100000000110000001100400000110000000011111100001100000000110000000011111100001100000000000011000000110000001100000000000011000000110000001100001100001111110000001100001100001100001111110000001100001100111111000011000000111111001100111111000011000000111111001100001100000000000000001100001100001100000000000000001100001100600000000411000011111111111100000000000011000011111111111100000000001111111111110000001100000000001111111111110000001100001100000011000000000000001100001100000011000000000000001100111111000000000000110000001100111111000000000000110000001100001100000000000000110000001100001100000000000000110000001111111111111111111111111111111" }
if level == 189 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111111001100000011001100001100111111001100000011001100001100110000000000117011001100001100110000000000110011001100001100111111001111110011111100001100111111001111110011111100001100110011001100000011001100001100110011001100000011001100001100116011001111110011001100001100110011001111110011001100001100000000000000000000000000001100000000000000000000000000001100111111001111110000000000111100111111001111110000000000111100400011001100110000000000111100000011001100110000000000111100001111001100110000001100001100001111001100110000001100001100050011081100000000111111111100000011001100000000111111111100111111001111110011111111111100111111001111110011111111111100000000000000001111111111111100000000000000001111111111111100110011001111111111111111111100110011001111111111111111111100110011001111111111111111111100110011001111111111111111111100110011000000111111111111111100110011000000111111111111111100110011111100111111111111111100110011111100111111111111111100114011111100001111111111111100110011111100001111111111111100001111111100001111111111111100001111111100001111111111111111111111111111111111111111111" }
if level == 190 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111111001100001111111111001100111111001100001111111111001100112222041100000000900011001100112222001100000000000011001100111111001100000000000011001100111111001100000000000011001100112222001100000000000011001100112222001100000000000011001100111100040000001111110011001100111100000000001111110011001100112200000000000000000011001100112200000000000000000011001100111100000000000000000011001100111100000000000000000011001100112200000000000000000011001100112200000000000000000011001100071100000000000000000000001100001100000000000000000000001100112200000000000000000000001100112200000000000000000000001100111100000000000000000011001100111100000000000000000011001100112200000000000000000011001100112200000000000050000011001100111111001100000000000011001100111111001100000000000011001100112222001100000000000011001100112222001100000008000011001100111111001100000000000011001100111111001100000000000011001100112222001100000000000011001100112222001100000000000011001100111111001100001111111111001100111111001100001111111111001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 190 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111111001100001111111111001100111111001100001111111111001100112222001180000000000011001100112222001100000000000011001100111111901100000400000011001100111111001100000000000011001100112222001100000000000011001100112222001100000000070011001100111100000000001111110011001100111100000000001111110011001100112200000000000000000011001100112200000000000000000011001100111100000000000000000011001100111100500000000000000011001100112200000000000000000011001100112200000000000000000011001100001100000000000000000000001100001104000000000000000000001100112200000000000000000000001100112200000000000000000000001100111100000000000000000011001100111100000000000000000011001100112200000000000000000011001100112200000000000000000011001100111111001100000000000011001100111111001100000000000011001111111111001100000000000011001111111111001100000000000011001100000011001100000000000011001100000011001100000000000011001100000000001100000000000011001100000000001100000000000011001100000011001100001111111111001100000011001100001111111111001100000011000000000000000000001100000011000000000000000000001111111111111111111111111111111" }
if level == 191 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100111111111100002222222222001100111111111100002222222222001100111111111100220090000000001100111111111100220000000000001100000000000000220000000000001100000000000000220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100007000005000220080000000001100000000000000220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100000000000000220000000000001100000000000000220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100111111111100220000000000001100001100000400000000001100001100001100000000000000001100001100001100000000400000001100001100001100000000000000001100001100001100111111111111111100001100001100111111111111111100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001100001100000000000000001100001111111111111111111111111111111" }
if level == 192 { return "111111111111111111111111111111100000000000000000000000000001100000000000000000000000000001100110011001100000000001111001100110011001100000000001111001100000000007000000000111111001100000000000000000000111111001100110011001100110011111100001100110011001100110011111100001100000000000900000000110000001100000000000000000000110000001100110011001100110000000000001100110011001100110000000000001100000000000000000000000000001100000000000000000000000000001100110011001100110000000000001100110011001100110000000000001100000000000000700000000000001100000000000000000000000000001100000011001100110000000000001100000011001100110000000000001100000000000000000000000000001100000000000000000000000000001100110011001100110000000000001100110011051100110000000000001100000000000000000000000000001100000040000000004000000000001100110011001100110000000000001100110011001100110000000000001100000000000000000000110000001100000000000000000000110000001100110011001100110611111100001100110011001100110011111100001100000000000000000000111111001100000000000000000000111111001100110011001100000000001111001100110011001100000000001111001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
if level == 193 { return "111111111111111111111111111111100000000110000001111111111111100000000110000001111111111111100000022000000002222222222001100000022000400002222222222001100000022000011000000000000001100070022000011000000000000001100000000000000220000000000001100000000000007220000000000001100000011600000000000000000001100000011000000000000000000001100220000000022000000000000001100220000000022000000000000001100000000000022000000000000001100000000000022000000000000001100220000000022000000000000001100220000040022000000000000001100220000000022000000000000001100220000000022000000000000001100000000000022000000000000001100004000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000000000000001100220000000022000009000000001100220000000022000000000000001100222222222200002222222222001100222222222200002222222222001100000000000000000000000000001100000000000000000000000000001111111111111111111111111111111" }
+449 -49
View File
@@ -48,9 +48,10 @@ Point :: struct { x: s32; y: s32; }
// Two rings joined: stepping into one comes out of the other.
Portal :: struct { a: Point; b: Point; }
PORTAL_PAIRS :: 2;
// The campaign certificate drives routes that never use a portal.
portals_enabled: bool = true;
Monster :: struct { position: Point; kind: s32; direction: s32; }
// The certificate drives routes on the plain boards; animals stay active.
features_enabled: bool = true;
// animal: one of ANIMAL_*; timer counts the creature's own ticks.
Monster :: struct { position: Point; kind: s32; direction: s32; animal: s32; timer: s32; }
Particle :: struct { position: Point; life: s32; }
Game :: struct {
mode: s32
@@ -75,6 +76,17 @@ Game :: struct {
portal_count: s32
portals: [PORTAL_PAIRS]Portal
portal_wait: s32
// This board's puzzle idea: a gate (a doorway up to four cells across,
// gate_span cells gate_step apart), its key or switch stone.
feature: s32
gate: s32
gate_span: s32
gate_step: s32
gate_tiles: [4]u8
gate_open: bool
key: Point
switch_stone: Point
on_switch: bool
monsters: [MONSTER_LIMIT]Monster
particles: [100]Particle
death_ticks: s32
@@ -190,6 +202,11 @@ LoadLevelData :: (game: *Game, level: s32, now: s64, board: []u8, apples: s32, c
game.monsters[index].position = Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
game.monsters[index].kind = kind
game.monsters[index].direction = ifx kind == 1 then Random(game, 4) else kind - 2
animal: s32 = ANIMAL_CLASSIC
if kind == 1 { animal = RoamerAnimal(level, index) }
else if kind >= 2 && kind <= 5 { animal = PatrolAnimal(level, index) }
game.monsters[index].animal = animal
game.monsters[index].timer = 0
game.monster_count += 1
game.board[Index(x, y)] = tile & 128
}
@@ -199,25 +216,209 @@ LoadLevelData :: (game: *Game, level: s32, now: s64, board: []u8, apples: s32, c
// Carve the entrance before the apple chooses its spot, so it can never
// land on a cell the carving turns into wall.
Respawn(game)
PlacePortals(game)
PlaceIdeas(game)
SpawnApple(game)
game.multiplier = LevelMultiplier(game)
}
// New ideas arrive slowly, one every twenty levels or so. Portals first
// appear at level 61 on every third board, grow to every other board from 81
// and every board from 161, with a second pair from 181.
PORTAL_FIRST :: 60
PortalPairsFor :: (level: s32) -> s32 {
if level < PORTAL_FIRST { return 0 }
if level < 80 { return ifx (level - PORTAL_FIRST) % 3 == 0 then 1 else 0 }
if level < 160 { return ifx level % 2 == 0 then 1 else 0 }
return ifx level >= 180 then PORTAL_PAIRS else 1
// New ideas arrive one at a time, about twenty levels apart, and keep coming
// back afterwards in a clean mix: squirrels from level 45, portals from 61,
// hedgehogs from 85, keys and gates from 101, frogs from 125, switch stones
// from 141, rolling stones from 165 and portal rooms from 181. A board's ideas
// follow from its number and layout alone, so every player meets the same.
IDEA_SQUIRREL :: 44
IDEA_PORTALS :: 60
IDEA_HEDGEHOG :: 84
IDEA_KEY :: 100
IDEA_FROG :: 124
IDEA_SWITCH :: 140
IDEA_STONE :: 164
IDEA_PORTAL_ROOM :: 180
// At most one puzzle idea per board.
FEATURE_NONE :: 0
FEATURE_PORTALS :: 1
FEATURE_KEY :: 2
FEATURE_SWITCH :: 3
FEATURE_PORTAL_ROOM :: 4
ANIMAL_CLASSIC :: 0
ANIMAL_SQUIRREL :: 1
ANIMAL_HEDGEHOG :: 2
ANIMAL_FROG :: 3
ANIMAL_STONE :: 4
HEDGEHOG_CURL :: 60
// A well-spread number for each value, the same on every platform: no step
// overflows 63 bits.
Mix :: (value: s64) -> s32 {
mixed := (value % 2147483648 + 2147483648) % 2147483648
for round: 0..1 {
mixed = (mixed * 1103515245 + 12345) % 2147483648
mixed = mixed ^ (mixed >> 16)
}
return cast(s32)(mixed % 1000003)
}
// Each ring stands in the middle of open floor, so the worm comes out safely
// in any direction and a player can always go around one. The spots follow
// from the board alone, so every player meets the same portals.
// A new puzzle idea takes every other board for its first ten levels; then
// the ideas so far take turns, with up to two plain boards between them.
IdeaIntros: [4]s32 = .[IDEA_PORTALS, IDEA_KEY, IDEA_SWITCH, IDEA_PORTAL_ROOM];
IdeasMet :: (level: s32) -> s32 {
count: s32 = 0
for index: 0..3 { if level >= IdeaIntros[index] { count = cast(s32)index + 1 } }
return count
}
BoardFeature :: (level: s32) -> s32 {
count := IdeasMet(level)
if count == 0 { return FEATURE_NONE }
newest := IdeaIntros[count - 1]
if level - newest < 10 { return ifx (level - newest) % 2 == 0 then count else FEATURE_NONE }
// Never more than two plain boards in a row.
plain := Mix(cast(s64)level) % 10 < 4
if plain && !(PlainMix(level - 1) && PlainMix(level - 2)) { return FEATURE_NONE }
return 1 + Mix(cast(s64)level * 7 + 3) % count
}
PlainMix :: (level: s32) -> bool {
count := IdeasMet(level)
return count == 0 || level - IdeaIntros[count - 1] < 10 || Mix(cast(s64)level) % 10 < 4
}
AnimalIntro :: (animal: s32) -> s32 {
if animal == ANIMAL_SQUIRREL { return IDEA_SQUIRREL }
if animal == ANIMAL_HEDGEHOG { return IDEA_HEDGEHOG }
if animal == ANIMAL_FROG { return IDEA_FROG }
if animal == ANIMAL_STONE { return IDEA_STONE }
return 0
}
// Wanderers: a landscape's own animal fills its first ten boards, then the
// animals met so far mix with the classic flames.
RoamerAnimal :: (level: s32, index: s32) -> s32 {
available: [3]s32
count: s32 = 0
if level >= IDEA_SQUIRREL { available[count] = ANIMAL_SQUIRREL; count += 1 }
if level >= IDEA_HEDGEHOG { available[count] = ANIMAL_HEDGEHOG; count += 1 }
if level >= IDEA_FROG { available[count] = ANIMAL_FROG; count += 1 }
if count == 0 { return ANIMAL_CLASSIC }
stage := StageOf(level)
native: s32 = ifx stage == 1 then ANIMAL_SQUIRREL else ifx stage == 2 then ANIMAL_HEDGEHOG else ifx stage == 3 then ANIMAL_FROG else ANIMAL_CLASSIC
ready := native != ANIMAL_CLASSIC && level >= AnimalIntro(native)
if ready && level - AnimalIntro(native) < 10 { return native }
roll := Mix(cast(s64)level * 131 + cast(s64)index) % 10
if roll < 3 { return ANIMAL_CLASSIC }
if ready && roll < 7 { return native }
return available[Mix(cast(s64)level * 17 + cast(s64)index) % count]
}
// Patrols become rolling stones in the mountains.
PatrolAnimal :: (level: s32, index: s32) -> s32 {
if level < IDEA_STONE { return ANIMAL_CLASSIC }
if level - IDEA_STONE < 10 || Mix(cast(s64)level * 29 + cast(s64)index) % 2 == 0 { return ANIMAL_STONE }
return ANIMAL_CLASSIC
}
Passable :: (game: *Game, at: s32) -> bool {
tile := game.board[at]
return tile < 20 || tile >= 128
}
// Every cell the worm can reach from the entrance with a doorway closed: span
// cells from door, step apart.
FloodFrom :: (game: *Game, start: s32, door: s32, reached: []bool, span: s32 = 1, step: s32 = 1) -> s32 {
closed: [CELLS]bool
for at: 0..CELLS - 1 { reached[at] = false; closed[at] = false }
if door >= 0 { for cell: 0..span - 1 { closed[door + cast(s32)cell * step] = true } }
if !Passable(game, start) || closed[start] { return 0 }
queue: [CELLS]s32
head: s32 = 0
tail: s32 = 1
queue[0] = start
reached[start] = true
while head < tail {
at := queue[head]
head += 1
x := at % board_columns
y := at / board_columns
neighbours: [4]s32 = .[ifx x > 0 then at - 1 else -1, ifx x < board_columns - 1 then at + 1 else -1,
ifx y > 0 then at - board_columns else -1, ifx y < board_rows - 1 then at + board_columns else -1]
for next: neighbours {
if next < 0 || closed[next] || reached[next] || !Passable(game, next) { continue }
reached[next] = true
queue[tail] = next
tail += 1
}
}
return tail
}
// A doorway: a straight run of one to four floor cells across a corridor,
// walled at both ends and open on both sides, that once closed cuts the board
// into two sizable halves, the far one holding the exit when the board allows.
// reached marks the entrance side.
Floor :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && Passable(game, Index(x, y)) && game.board[Index(x, y)] < 128 }
Solid :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && !Passable(game, Index(x, y)) }
DoorwaySpan :: (game: *Game, x: s32, y: s32, dx: s32, dy: s32) -> s32 {
half := board_columns / 2
if !Solid(game, x - dx, y - dy) { return 0 }
for span: 1..4 {
cx := x + dx * cast(s32)(span - 1)
cy := y + dy * cast(s32)(span - 1)
if cy < 2 || cy > board_rows - 4 || (Abs(cx - half) <= 3 && (cy <= 3 || cy >= board_rows - 4)) { return 0 }
if !Floor(game, cx, cy) || !Floor(game, cx - dy, cy - dx) || !Floor(game, cx + dy, cy + dx) { return 0 }
if Solid(game, cx + dx, cy + dy) { return cast(s32)span }
}
return 0
}
FindDoorway :: (game: *Game, reached: []bool, span: *s32, step: *s32, feature: s32) -> s32 {
half := board_columns / 2
start := Index(half, board_rows - 2)
exit := Index(half, 1)
firsts: [2 * CELLS]s32
spans: [2 * CELLS]s32
steps: [2 * CELLS]s32
count: s32 = 0
for y: 2..board_rows - 4 {
for x: 1..board_columns - 2 {
across := DoorwaySpan(game, cast(s32)x, cast(s32)y, 1, 0)
if across > 0 { firsts[count] = Index(x, y); spans[count] = across; steps[count] = 1; count += 1 }
down := DoorwaySpan(game, cast(s32)x, cast(s32)y, 0, 1)
if down > 0 { firsts[count] = Index(x, y); spans[count] = down; steps[count] = board_columns; count += 1 }
}
}
if count == 0 { return -1 }
total: s32 = 0
for at: 0..CELLS - 1 { if Passable(game, cast(s32)at) { total += 1 } }
fallback: s32 = -1
offset := Mix(cast(s64)game.level) % count
for attempt: 0..count - 1 {
pick := (offset + cast(s32)attempt) % count
near := FloodFrom(game, start, firsts[pick], reached, spans[pick], steps[pick])
far := total - near - spans[pick]
if near < 24 || far < 24 { continue }
exit_beyond := Passable(game, exit) && !reached[exit]
if !exit_beyond && fallback >= 0 { continue }
if !IdeaFits(game, reached, firsts[pick], feature) { continue }
if exit_beyond { span.* = spans[pick]; step.* = steps[pick]; return firsts[pick] }
fallback = pick
}
if fallback < 0 { return -1 }
unused FloodFrom(game, start, firsts[fallback], reached, spans[fallback], steps[fallback])
span.* = spans[fallback]
step.* = steps[fallback]
return firsts[fallback]
}
// Whether this board's idea has its spots once the doorway closes: a key or
// switch stone before it, a portal on each side of a portal room.
IdeaFits :: (game: *Game, reached: []bool, door: s32, feature: s32) -> bool {
if feature == FEATURE_PORTAL_ROOM {
spots: [CELLS]s32
return OpenSpots(game, reached, 1, spots[:]) > 0 && OpenSpots(game, reached, 0, spots[:]) > 0
}
return SideSpot(game, reached, door, feature == FEATURE_KEY).x >= 0
}
// Open spots for portals, keys and switch stones: the middle of open floor,
// clear of the entrance and exit lanes and of the board's creatures. A key
// or switch stone may also lie in a corridor (loose).
OpenAround :: (game: *Game, x: s32, y: s32) -> bool {
for dy: -1..1 {
for dx: -1..1 {
@@ -226,49 +427,65 @@ OpenAround :: (game: *Game, x: s32, y: s32) -> bool {
}
return true
}
OpenFloor :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && game.board[Index(x, y)] < 20 }
InCorridor :: (game: *Game, x: s32, y: s32) -> bool {
if !OpenFloor(game, x, y) { return false }
open: s32 = 0
if OpenFloor(game, x - 1, y) { open += 1 }
if OpenFloor(game, x + 1, y) { open += 1 }
if OpenFloor(game, x, y - 1) { open += 1 }
if OpenFloor(game, x, y + 1) { open += 1 }
return open >= 3
}
// side: 1 only the entrance side, 0 only the far side, -1 anywhere.
OpenSpots :: (game: *Game, reached: []bool, side: s32, output: []s32, loose: bool = false) -> s32 {
count: s32 = 0
half := board_columns / 2
for y: 3..board_rows - 4 {
for x: 2..board_columns - 3 {
if Abs(cast(s32)x - half) <= 2 && (y <= 5 || y >= board_rows - 6) { continue }
if !OpenAround(game, cast(s32)x, cast(s32)y) && !(loose && InCorridor(game, cast(s32)x, cast(s32)y)) { continue }
at := Index(x, y)
if side >= 0 && reached[at] != (side == 1) { continue }
centre := Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
crowded := false
for index: 0..game.monster_count - 1 {
if Near(centre, game.monsters[index].position, 32) { crowded = true }
}
if !crowded { output[count] = at; count += 1 }
}
}
return count
}
PortalCentre :: (cell: s32) -> Point {
return Point.{(cell % board_columns) * 16 + 8, (cell / board_columns) * 16 + 8}
}
CellsApart :: (first: s32, second: s32) -> s32 {
return Abs(first % board_columns - second % board_columns) + Abs(first / board_columns - second / board_columns)
}
PlacePortals :: (game: *Game) {
game.portal_count = 0
game.portal_wait = 0
pairs := PortalPairsFor(game.level)
if !portals_enabled || pairs == 0 { return }
candidates: [CELLS]s32
count: s32 = 0
half := board_columns / 2
for y: 3..board_rows - 4 {
for x: 2..board_columns - 3 {
// Clear of the entrance and the exit lanes.
if Abs(cast(s32)x - half) <= 2 && (y <= 5 || y >= board_rows - 6) { continue }
if !OpenAround(game, cast(s32)x, cast(s32)y) { continue }
centre := Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
crowded := false
for index: 0..game.monster_count - 1 {
if Near(centre, game.monsters[index].position, 48) { crowded = true }
}
if !crowded { candidates[count] = Index(x, y); count += 1 }
}
}
if count < 2 { return }
// Pairs far apart in the open; a portal room joins one spot on each side.
PlacePortals :: (game: *Game, pairs: s32, reached: []bool, room: bool) -> bool {
near_spots: [CELLS]s32
far_spots: [CELLS]s32
near := OpenSpots(game, reached, ifx room then 1 else -1, near_spots[:])
far := ifx room then OpenSpots(game, reached, 0, far_spots[:]) else 0
if !room { far_spots = near_spots; far = near }
if near < 1 || far < 1 { return false }
taken: [4]s32
taken_count: s32 = 0
for pair: 0..pairs - 1 {
first: s32 = -1
for attempt: 0..count - 1 {
cell := candidates[(cast(s64)game.level * 7919 + cast(s64)attempt * 104729 + cast(s64)pair * 31) % cast(s64)count]
for attempt: 0..near - 1 {
cell := near_spots[(Mix(cast(s64)game.level * 7919 + cast(s64)pair * 31) + cast(s32)attempt) % near]
free := true
for index: 0..taken_count - 1 { if CellsApart(cell, taken[index]) < 6 { free = false } }
if free { first = cell; break }
}
if first < 0 { break }
second: s32 = -1
farthest: s32 = 13
for index: 0..count - 1 {
cell := candidates[index]
farthest: s32 = ifx room then 0 else 13
for index: 0..far - 1 {
cell := far_spots[index]
apart := CellsApart(cell, first)
if apart <= farthest { continue }
free := true
@@ -282,12 +499,126 @@ PlacePortals :: (game: *Game) {
taken_count += 2
game.portal_count += 1
}
return game.portal_count > 0
}
// The spot on the entrance side farthest from the entrance, for a key; a
// switch stone takes a spot partway there.
SideSpot :: (game: *Game, reached: []bool, door: s32, farthest: bool) -> Point {
spots: [CELLS]s32
count := OpenSpots(game, reached, 1, spots[:], true)
start := Index(board_columns / 2, board_rows - 2)
best: s32 = -1
best_apart: s32 = -1
for index: 0..count - 1 {
cell := spots[index]
if CellsApart(cell, door) < 4 || CellsApart(cell, start) < 6 { continue }
apart := CellsApart(cell, start)
if !farthest { apart = 100 - Abs(apart - 14) }
if apart > best_apart { best = cell; best_apart = apart }
}
if best < 0 { return Point.{-1, -1} }
return PortalCentre(best)
}
OpenGate :: (game: *Game, open: bool) {
if game.gate < 0 { return }
for cell: 0..game.gate_span - 1 {
game.board[game.gate + cast(s32)cell * game.gate_step] = ifx open then game.gate_tiles[cell] else 20
}
game.gate_open = open
}
PlaceIdeas :: (game: *Game) {
game.portal_count = 0
game.portal_wait = 0
game.feature = FEATURE_NONE
game.gate = -1
game.gate_span = 0
game.gate_step = 1
game.gate_open = false
game.key = Point.{-1, -1}
game.switch_stone = Point.{-1, -1}
game.on_switch = false
if !features_enabled { return }
feature := BoardFeature(game.level)
reached: [CELLS]bool
if feature == FEATURE_PORTALS {
// In the last landscape a board with a closed room puts its portal
// there.
if game.level >= IDEA_PORTAL_ROOM && PlaceGate(game, FEATURE_PORTAL_ROOM, reached[:]) {
game.feature = FEATURE_PORTAL_ROOM
return
}
pairs: s32 = ifx game.level >= IDEA_PORTAL_ROOM && Mix(cast(s64)game.level * 3) % 2 == 1 then PORTAL_PAIRS else 1
if PlacePortals(game, pairs, reached[:], false) { game.feature = feature }
return
}
if feature == FEATURE_NONE {
// A new gate idea that found no doorway on the board before moves
// on to this one.
newest := IdeasMet(game.level)
if newest < FEATURE_KEY || game.level - IdeaIntros[newest - 1] >= 10 || HostsIdea(game.level - 1, newest) { return }
if PlaceGate(game, newest, reached[:]) { game.feature = newest }
return
}
// A board without a doorway for its idea takes another gate idea met
// so far, or else portals.
ideas: [3]s32 = .[feature, FEATURE_SWITCH, FEATURE_KEY]
intros: [3]s32 = .[0, IDEA_SWITCH, IDEA_KEY]
for index: 0..2 {
idea := ideas[index]
if (index > 0 && idea == feature) || game.level < intros[index] { continue }
if PlaceGate(game, idea, reached[:]) { game.feature = idea; return }
}
if PlacePortals(game, 1, reached[:], false) { game.feature = FEATURE_PORTALS }
}
// Whether a level's board has a doorway for a gate idea, loaded aside.
HostsIdea :: (level: s32, feature: s32) -> bool {
columns := board_columns
rows := board_rows
enabled := features_enabled
features_enabled = false
aside: Game
aside.random = 1
LoadLevel(*aside, level, 0)
reached: [CELLS]bool
span: s32 = 0
step: s32 = 1
hosts := FindDoorway(*aside, reached[:], *span, *step, feature) >= 0
features_enabled = enabled
BoardSize(columns, rows)
return hosts
}
PlaceGate :: (game: *Game, feature: s32, reached: []bool) -> bool {
span: s32 = 0
step: s32 = 1
door := FindDoorway(game, reached, *span, *step, feature)
if door < 0 { return false }
game.gate = door
game.gate_span = span
game.gate_step = step
for cell: 0..span - 1 { game.gate_tiles[cell] = game.board[door + cast(s32)cell * step] }
OpenGate(game, false)
if feature == FEATURE_KEY { game.key = SideSpot(game, reached, door, true) }
if feature == FEATURE_SWITCH { game.switch_stone = SideSpot(game, reached, door, false) }
placed := (feature == FEATURE_KEY && game.key.x >= 0) || (feature == FEATURE_SWITCH && game.switch_stone.x >= 0) ||
(feature == FEATURE_PORTAL_ROOM && PlacePortals(game, 1, reached, true))
if !placed {
OpenGate(game, true)
game.gate = -1
game.gate_span = 0
game.key = Point.{-1, -1}
game.switch_stone = Point.{-1, -1}
game.portal_count = 0
return false
}
// A portal room's doorway stays a plain hedge for good.
if feature == FEATURE_PORTAL_ROOM { game.gate = -1; game.gate_span = 0 }
return true
}
OnPortal :: (game: *Game, position: Point) -> bool {
for pair: 0..game.portal_count - 1 {
if Near(position, game.portals[pair].a, 12) || Near(position, game.portals[pair].b, 12) { return true }
}
return false
return Near(position, game.key, 12) || Near(position, game.switch_stone, 12)
}
// The complete playable campaign is designed and certified. The recovered
// 99-level archive stays an independent, untouched historical reference.
@@ -552,13 +883,65 @@ MoveMonster :: (game: *Game, index: s32) {
if !MonsterBlocked(game, index, candidate) { monster.position = candidate }
return
}
monster.timer += 1
if monster.animal == ANIMAL_STONE {
// A rolling stone keeps its patrol at twice the pace.
PatrolStep(game, index)
PatrolStep(game, index)
return
}
if monster.kind == 1 && monster.animal == ANIMAL_SQUIRREL {
// A squirrel dashes at twice the pace for a moment, then sits still.
phase := monster.timer % 16
if phase >= 8 { return }
if phase == 0 { monster.direction = Random(game, 4) }
for step: 0..1 {
candidate := MonsterNext(monster.position, monster.direction)
if MonsterBlocked(game, index, candidate) || candidate.y < 16 {
monster.direction = Random(game, 4)
return
}
monster.position = candidate
}
return
}
if monster.kind == 1 && monster.animal == ANIMAL_HEDGEHOG {
// A hedgehog ambles at half pace and curls into a still, spiky ball
// for a while when the worm's head comes close.
if monster.timer < 0 { return }
if game.length > 0 && Near(game.worm[0], monster.position, 40) { monster.timer = -HEDGEHOG_CURL; return }
if monster.timer % 2 == 1 { return }
RoamerStep(game, index)
return
}
if monster.kind == 1 && monster.animal == ANIMAL_FROG {
// A frog sits, then hops two tiles at once, even over a hedge.
if monster.timer % 14 != 0 { return }
direction := Random(game, 4)
landing := monster.position
for step: 0..31 { landing = MonsterNext(landing, direction) }
if landing.y >= 16 && landing.x >= 16 && landing.x < (board_columns - 1) * 16 && landing.y < (board_rows - 1) * 16 &&
!MonsterBlocked(game, index, landing) {
monster.position = landing
monster.direction = direction
}
return
}
if monster.kind == 1 { RoamerStep(game, index) }
else { PatrolStep(game, index) }
}
RoamerStep :: (game: *Game, index: s32) {
monster := *game.monsters[index]
candidate := MonsterNext(monster.position, monster.direction)
blocked := MonsterBlocked(game, index, candidate)
if monster.kind == 1 {
if !blocked { blocked = Random(game, 25) == 0 || candidate.y < 16 }
if blocked { monster.direction = Random(game, 4) }
else { monster.position = candidate }
} else if blocked {
if !blocked { blocked = Random(game, 25) == 0 || candidate.y < 16 }
if blocked { monster.direction = Random(game, 4) }
else { monster.position = candidate }
}
PatrolStep :: (game: *Game, index: s32) {
monster := *game.monsters[index]
candidate := MonsterNext(monster.position, monster.direction)
if MonsterBlocked(game, index, candidate) {
monster.direction = (monster.direction + 2) % 4
monster.kind = monster.direction + 2
} else { monster.position = candidate }
@@ -577,6 +960,7 @@ LevelMultiplier :: (game: *Game) -> s32 {
tightness := ifx walls > 300 then (walls - 300) * 10 / 150 else 0
difficulty := 10 * game.monster_count + 10 * roamers + 5 * (game.apples - 5) + tightness +
5 * (32 - cast(s32)TickInterval(game.level))
if game.feature >= FEATURE_KEY { difficulty += 10 }
if difficulty < 0 { difficulty = 0 }
return 1 + difficulty / 20
}
@@ -654,6 +1038,22 @@ Tick :: (game: *Game) {
break
}
}
// The key opens its gate for good; a switch stone flips it each time the
// head arrives on it.
if game.key.x >= 0 && Near(next, game.key, 10) {
for spark: 0..5 { AddParticle(game, game.key) }
game.key = Point.{-1, -1}
OpenGate(game, true)
AddScore(game, 2)
}
if game.switch_stone.x >= 0 {
over := Near(next, game.switch_stone, 8)
if over && !game.on_switch {
OpenGate(game, !game.gate_open)
for spark: 0..3 { AddParticle(game, game.switch_stone) }
}
game.on_switch = over
}
if game.apples == 0 && next.y < 0 {
count := game.length
if count > 100 { count = 100 }
+17 -5
View File
@@ -28,7 +28,14 @@ reported_score: s32 = -1;
RecordName :: (name: string) -> string {
if owner[0] == 0 { return name }
at: s64 = 0
for byte: TextUntilNul(owner[:]) { record_name[at] = byte; at += 1 }
identity := TextUntilNul(owner[:])
#if #defined(WURM_PORTABLE) {
// The host already scopes records to the account and game. Keep a
// 128-bit account prefix to distinguish its guest/connected saves
// within the host's 64-byte record-name limit.
if identity.count > 32 { identity = identity[:32] }
}
for byte: identity { record_name[at] = byte; at += 1 }
record_name[at] = #char "."; at += 1
for byte: name { record_name[at] = byte; at += 1 }
record_name[at] = 0
@@ -97,7 +104,7 @@ RecordRun :: (reached: s32, run_score: s32) {
if level_reached > best_level { best_level = level_reached }
if run_score > best_score { best_score = run_score }
bytes: [8]u8 = .[cast(u8)(best_level & 255), cast(u8)((best_level >> 8) & 255), 0, 0,
cast(u8)(best_score & 255), cast(u8)((best_score >> 8) & 255), cast(u8)((best_score >> 16) & 255), cast(u8)((best_score >> 24) & 127)]
cast(u8)(best_score & 255), cast(u8)((best_score >> 8) & 255), cast(u8)((best_score >> 16) & 255), cast(u8)((best_score >> 24) & 127)]
unused Records.WriteRecord(RecordName("best.dat"), bytes[:])
Report()
}
@@ -129,7 +136,7 @@ Save :: () -> bool {
if !SaveUnlocked() { return false }
kept := ifx lives > 255 then 255 else lives
bytes: [6]u8 = .[cast(u8)level, cast(u8)kept, cast(u8)(score & 255), cast(u8)((score >> 8) & 255),
cast(u8)((score >> 16) & 255), cast(u8)((score >> 24) & 127)]
cast(u8)((score >> 16) & 255), cast(u8)((score >> 24) & 127)]
return Records.WriteRecord(RecordName("run.dat"), bytes[:])
}
@@ -209,12 +216,17 @@ Pump :: (now: s64) -> bool {
}
unused Records.WriteRecord(RecordName("completed.dat"), completed[:])
}
// Older account saves can have earned unlocks without completion marks
// or a pending-sync marker. Migrate those unlocks without inventing wins.
if unlocked + 1 > record.unlocked { dirty = true }
if !dirty { return changed }
unused CopyCString("wurm", record.game[:])
record.unlocked = 1
record.unlocked = unlocked + 1
for index: 0..199 {
record.completed[index] = ifx completed[index] == 1 then #char "1" else #char "0"
if completed[index] == 1 { record.unlocked = cast(s32)index + 2 }
if completed[index] == 1 && cast(s32)index + 2 > record.unlocked {
record.unlocked = cast(s32)index + 2
}
}
record.completed[200] = 0
if record.unlocked > LEVELS { record.unlocked = LEVELS }
+16
View File
@@ -1,4 +1,5 @@
Progress :: #import, file "../src/progress.zi";
Shared :: #import "entity/game_progress";
Wardrobe :: #import, file "../src/wardrobe.zi";
Custom :: #import, file "../src/custom_levels.zi";
Controls :: #import, file "../src/controls.zi";
@@ -104,6 +105,21 @@ main :: () -> s32 {
Expect(Progress.Pump(20000), "switching accounts reloads the new account")
Expect(Progress.Completed(0) && !Progress.Completed(39) && !Progress.Completed(41), "completion masks stay isolated")
Expect(writes == 1, "switching does not publish dirty marks under another identity")
// An older account save has unlocks and a run, but no completion or
// pending-sync file. It must migrate without creating completion marks.
unused Progress.Begin(57, 6, 1234)
Progress.loaded = false
Progress.dirty = false
Progress.unlocked = 0
remote = ""
Progress.poll_at = 0
unused Progress.Pump(20500)
migrated: Shared.GameProgressRecord
json := TextUntilNul(last_write[:])
at := FieldAt(json, 0, "document")
Expect(Shared.GameProgressRead(json[at:ValueEnd(json, at, 0)], *migrated), "older account save migrates to a shared record")
Expect(migrated.unlocked == 58 && migrated.completed[56] != #char "1", "migration keeps earned unlocks without inventing completed levels")
Expect(Progress.level == 57 && Progress.lives == 6 && Progress.score == 1234, "migration preserves the unfinished local run")
Wardrobe.Reset()
Wardrobe.played = 17999000
Wardrobe.Pump(21000, false)
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
"""Local tests for the Google-free and Google Play release boundary."""
import io
from pathlib import Path
import sys
import unittest
import zipfile
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
from android_release import verify_edition
class AndroidEditionTest(unittest.TestCase):
def verify(self, files, edition='direct', bundle=False):
output = io.BytesIO()
with zipfile.ZipFile(output, 'w') as archive:
for name, data in files.items():
archive.writestr(name, data)
output.seek(0)
with zipfile.ZipFile(output) as archive:
verify_edition(archive, edition, bundle)
def test_google_free_apk(self):
self.verify({'classes.dex': b'Lxyz/waozi/wurm/MainActivity;'})
def test_google_code_in_any_dex_is_rejected(self):
for marker in (b'Lcom/google/android/gms/', b'Lcom/android/billingclient/api/BillingClient;',
b'Lcom/android/vending/', b'Lorg/kryonlabs/play/PlayBilling;'):
with self.subTest(marker=marker), self.assertRaisesRegex(AssertionError, 'exclude Google libraries'):
self.verify({'classes.dex': b'Lxyz/waozi/wurm/MainActivity;', 'classes2.dex': marker})
def test_marker_crossing_read_boundary_is_rejected(self):
with self.assertRaisesRegex(AssertionError, 'exclude Google libraries'):
self.verify({'classes.dex': b'\0' * (1024 * 1024 - 4) + b'Lcom/google/android/gms/'})
def test_play_apk_requires_both_billing_and_bridge(self):
for code in (b'Lcom/android/billingclient/api/BillingClient;', b'Lorg/kryonlabs/play/PlayBilling;'):
with self.subTest(code=code), self.assertRaisesRegex(AssertionError, 'must include Play Billing'):
self.verify({'classes.dex': code}, 'gplay')
def test_play_apk_supports_multidex(self):
self.verify({'classes.dex': b'Lorg/kryonlabs/play/PlayBilling;',
'classes2.dex': b'Lcom/android/billingclient/api/BillingClient;'}, 'gplay')
def test_play_bundle(self):
self.verify({'base/dex/classes.dex': b'Lorg/kryonlabs/play/PlayBilling;',
'base/dex/classes2.dex': b'Lcom/android/billingclient/api/BillingClient;'}, 'gplay', True)
def test_missing_dex_is_rejected(self):
with self.assertRaisesRegex(AssertionError, 'must include DEX'):
self.verify({'assets/readme': b'No code'})
def test_asset_text_does_not_count_as_google_code(self):
self.verify({'classes.dex': b'Lxyz/waozi/wurm/MainActivity;',
'assets/readme': b'Lcom/google/android/gms/'})
if __name__ == '__main__':
unittest.main()
+331 -331
View File
File diff suppressed because it is too large. Load diff
+6 -5
View File
@@ -1,9 +1,9 @@
#import, file "../src/game.zi";
// campaign-cases:begin
// Generated from campaign_cases.json by tools/design_levels.py.
CampaignSeeds: [400]u32 = .[1, 1, 65538, 65538, 131075, 131075, 196612, 196612, 262149, 262149, 327686, 327686, 393223, 401142, 466679, 458760, 532216, 540135, 589834, 597753, 655371, 679128, 728827, 720908, 786445, 786445, 867820, 851982, 917519, 917519, 1014732, 983056, 1064431, 1064431, 1114130, 1114130, 1195505, 1211343, 1245204, 1261042, 1318660, 1326579, 1384197, 1392116, 1441815, 1544762, 1586542, 1546947, 1596646, 1572889, 1638426, 1638426, 1703963, 1703963, 2070422, 1824933, 1898389, 1850875, 1932250, 1900574, 1966111, 1974030, 2039567, 2047486, 2303079, 2105104, 2202317, 2210236, 2252016, 2236178, 2293796, 2301715, 2367252, 2391009, 2440708, 2456546, 4525590, 3155603, 2595539, 2650972, 2637319, 2621481, 2726613, 2900831, 2752555, 2752555, 2857687, 2826011, 2891548, 2891548, 3178817, 2996680, 3014703, 3244354, 3080240, 3088159, 3201210, 3145777, 3401370, 3211314, 3292689, 3276851, 3342388, 3350307, 3439601, 3423763, 3473462, 3631842, 3538999, 3538999, 3612455, 3762916, 3773020, 3677992, 3751448, 3751448, 3848661, 5677950, 3874603, 3866684, 5975323, 4051006, 4005677, 4013596, 4118728, 4205837, 4279293, 4366402, 4194369, 4233964, 6350522, 4378691, 4420471, 4388795, 4390980, 4438494, 4464436, 4496112, 4577487, 4545811, 4619267, 4643024, 4668966, 4661047, 4766179, 4750341, 4879230, 4807959, 5895047, 4857658, 6966297, 6950459, 5004570, 5099598, 5062188, 5101783, 5135644, 5230672, 5391237, 5185343, 5290475, 5290475, 5356012, 5332255, 5389873, 5405711, 5534600, 5447491, 5600137, 5766436, 5934920, 6623873, 5652021, 5644102, 5883857, 5780910, 5870204, 6060260, 6189149, 10441652, 6056711, 6032954, 5971787, 6019301, 6061081, 6037324, 6316674, 6213727, 6231750, 6215912, 6233935, 6249773, 6331148, 8516792, 7299451, 8479382, 15513639, 59852120, 9006406, 7691852, 7084274, 6846704, 6666752, 6761780, 7128239, 7452918, 6845340, 6766150, 6831687, 6895039, 6889305, 8916569, 7129060, 6970680, 11177854, 8358690, 7648165, 7426433, 7484051, 8022543, 7470398, 8230622, 7551773, 8098184, 8203316, 7474768, 13146957, 8070878, 7494976, 7502895, 7766407, 8882986, 7784430, 7697321, 7675749, 7699506, 7772962, 7780881, 18988451, 9778654, 7872360, 7959469, 7929978, 8032925, 8066786, 8415222, 8076890, 8061052, 8142427, 8134508, 8809808, 8390101, 8265582, 8257663, 8505337, 8766664, 20655268, 10012132, 8470112, 8517626, 8575244, 8551487, 8585348, 8617024, 8650885, 8650885, 8763936, 8756017, 8797797, 8924501, 8918767, 8990038, 8913033, 9055575, 9802146, 16176941, 19924813, 9059945, 9212591, 9117563, 9183100, 9191019, 9280313, 9248637, 9322093, 9314174, 9561848, 9443063, 9524438, 9453167, 9613732, 9518704, 9576322, 9568403, 9689373, 10132837, 9739072, 9723234, 9907556, 9883799, 9830551, 9838470, 9911926, 9927764, 9977463, 9969544, 10027162, 10074676, 10092699, 10092699, 10166155, 10229507, 10295044, 10247530, 10471447, 10368500, 11685239, 10925015, 10436222, 10523331, 10485921, 10565111, 11034517, 10630648, 10616995, 10807051, 10682532, 10682532, 11056910, 10779745, 10813606, 10837363, 11417635, 11385959, 10960518, 10960518, 11224030, 11026055, 11535056, 11297486, 11204643, 11165048, 11761158, 11222666, 11367393, 11454502, 11345821, 11432930, 11870660, 11949850, 11849088, 11540247, 11582027, 11621622, 12486978, 12629520, 11673506, 11689344, 11739043, 11739043, 13261676, 11796661, 12004740, 11917631, 11951492, 11935654, 12143733, 12207085, 12122161, 12082566, 12298564, 13399305, 12237397, 12189883, 12255420, 12271258, 12352633, 12368471, 13518911, 16258885, 12483707, 12491626, 12541325, 13087736, 12614781, 12844432, 12672399, 12648642, 17323037, 76295830, 12779716, 12827230, 12900686, 12861091, 13924422, 13781880, 135023955, 87216952, 17452747, 13984225];
CampaignRoutes: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 52, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 4, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 4, 62, 0, 0, 0, 0, 1, 0, 120, 73, 4, 0];
CampaignReverse: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1];
CampaignSeeds: [400]u32 = .[1, 1, 65538, 65538, 131075, 131075, 196612, 196612, 262149, 262149, 327686, 327686, 393223, 401142, 466679, 458760, 532216, 540135, 589834, 597753, 655371, 679128, 728827, 720908, 786445, 786445, 867820, 851982, 917519, 917519, 1014732, 983056, 1064431, 1064431, 1114130, 1114130, 1195505, 1211343, 1245204, 1261042, 1318660, 1326579, 1384197, 1392116, 1441815, 1544762, 1586542, 1546947, 1596646, 1572889, 1638426, 1638426, 1703963, 1703963, 2070422, 1824933, 1898389, 1850875, 1932250, 1900574, 1966111, 1974030, 2039567, 2047486, 2303079, 2105104, 2202317, 2210236, 2252016, 2236178, 2293796, 2301715, 2367252, 2391009, 2440708, 2456546, 4525590, 3155603, 2595539, 2650972, 2637319, 2621481, 2726613, 2900831, 2752555, 2752555, 2857687, 2826011, 2891548, 2891548, 2949166, 2949166, 3030541, 3022622, 3080240, 3088159, 3201210, 3153696, 3211314, 3235071, 3292689, 3276851, 3342388, 3350307, 3439601, 3423763, 3473462, 3631842, 3538999, 3538999, 3604536, 3762916, 3670073, 3670073, 3751448, 3767286, 3809066, 3816985, 3874603, 3866684, 4003492, 4003492, 4005677, 3997758, 4118728, 4205837, 4279293, 4366402, 4210207, 4233964, 4299501, 4299501, 4349200, 4325443, 4390980, 4406818, 4464436, 4496112, 4577487, 4545811, 4619267, 4643024, 4668966, 4661047, 4766179, 4750341, 4879230, 4815878, 5895047, 4849739, 6966297, 6950459, 5004570, 4980813, 5062188, 5101783, 5135644, 5230672, 5256614, 5399156, 5250880, 5242961, 5356012, 5332255, 5389873, 5405711, 5534600, 5463329, 5505109, 5560542, 5633998, 5784459, 5652021, 5652021, 5717558, 5812586, 5767257, 5767257, 6315853, 6426719, 5898331, 5953764, 5979706, 6019301, 6061081, 6037324, 6094942, 6094942, 6168398, 6160479, 6233935, 6241854, 6845883, 7827839, 7299451, 6626336, 6478060, 7103661, 6543597, 6488164, 7084274, 6846704, 6619238, 6761780, 7128239, 7452918, 6845340, 6766150, 6831687, 6926715, 6889305, 6936819, 7129060, 6970680, 8627936, 8279500, 7173025, 7196782, 7689945, 7872082, 7612940, 7351613, 7298365, 7892290, 7411416, 7474768, 8633127, 10715824, 7487057, 7502895, 7560513, 8106924, 7736916, 7602293, 7675749, 7683668, 7772962, 8160993, 11085289, 12455276, 7911955, 8054497, 8025006, 8436794, 8027191, 8145976, 8076890, 8068971, 8134508, 8158265, 8643509, 8564319, 8281420, 8257663, 8394471, 8552851, 12783782, 9980456, 8454274, 8881900, 8527730, 8535649, 8617024, 8617024, 8658804, 8872617, 8866883, 8771855, 8797797, 8813635, 8918767, 9203851, 8944709, 9055575, 13294425, 14632736, 11491078, 9107459, 9220510, 9172996, 9191019, 9175181, 9280313, 9565397, 9306255, 9314174, 9514334, 9743985, 9476924, 9508600, 9613732, 9708760, 9576322, 9584241, 9816077, 9903186, 9865776, 9762829, 9947151, 10343101, 9830551, 9838470, 9911926, 9911926, 10009139, 9977463, 10027162, 10130109, 10092699, 10092699, 10205750, 10308697, 10683075, 10302963, 10344743, 10289310, 10536984, 10639931, 10444141, 10555007, 10485921, 10604706, 10717757, 10630648, 11092135, 10862484, 10706289, 10690451, 10819340, 10803502, 10861120, 10971986, 11417635, 11758152, 11047627, 11023870, 11176516, 11422005, 11083673, 11202458, 11212562, 11141291, 11222666, 11262261, 11351555, 11723748, 11417092, 11377497, 11466791, 11680604, 11532328, 11500652, 11550351, 11558270, 12447383, 11972243, 11681425, 11665587, 11739043, 11826152, 12303477, 11812499, 12424447, 12273986, 11927735, 11967330, 12001191, 12207085, 12454759, 12066728, 12251050, 13486414, 12221559, 12197802, 12287096, 12271258, 12320957, 12423904, 12608226, 19949139, 13038037, 12650006, 12580920, 12881842, 12662295, 13002812, 12775346, 12648642, 15002770, 17291361, 12795554, 12803473, 12861091, 12845253, 12926628, 13243388, 131452486, 33446942, 13659546, 15124561];
CampaignRoutes: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 116, 20, 0, 2];
CampaignReverse: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0];
// campaign-cases:end
libc :: #system_library "libc";
ParseNumber :: (text: *u8) -> s32 #foreign libc "atoi";
@@ -235,8 +235,9 @@ Replay :: (level: s32, portrait: bool, seed: u32, route: []Point) -> bool {
replay_deaths: s32;
#program_export
main :: (argc: s32, argv: **u8) -> s32 {
// The certificate proves every board can be won without a portal.
portals_enabled = false
// The certificate proves every board can be won without its puzzle idea
// (portals, gates and switches); the animals stay active.
features_enabled = false
search := argc > 1
first: s32 = ifx argc > 2 then ParseNumber(argv[2]) - 1 else 0
last: s32 = ifx argc > 3 then ParseNumber(argv[3]) - 1 else LEVEL_COUNT - 1
+105 -16
View File
@@ -123,29 +123,83 @@ main :: () -> s32 {
Tick(*game)
Expect(game.lives == 3 && game.worm[0].y == 496, "death consumes a life and respawns")
// Portals arrive slowly from level 61, then rings in open floor carry
// the head across.
for level: 0..PORTAL_FIRST - 1 {
StartGame(*game, cast(s32)level, 0)
Expect(game.portal_count == 0, "no portals before level 61")
}
Expect(PortalPairsFor(60) == 1 && PortalPairsFor(61) == 0 && PortalPairsFor(81) == 0 && PortalPairsFor(82) == 1 &&
PortalPairsFor(170) == 1 && PortalPairsFor(199) == 2, "portals spread out over the journey")
portal_boards: s32 = 0
// New ideas open one at a time and come back in a mix.
for level: 0..IDEA_PORTALS - 1 { Expect(BoardFeature(cast(s32)level) == FEATURE_NONE, "no puzzle idea before level 61") }
Expect(BoardFeature(IDEA_PORTALS) == FEATURE_PORTALS && BoardFeature(IDEA_PORTALS + 1) == FEATURE_NONE &&
BoardFeature(IDEA_KEY) == FEATURE_KEY && BoardFeature(IDEA_SWITCH) == FEATURE_SWITCH &&
BoardFeature(IDEA_PORTAL_ROOM) == FEATURE_PORTAL_ROOM, "each puzzle idea opens on its own board")
for level: 0..IDEA_SQUIRREL - 1 { Expect(RoamerAnimal(cast(s32)level, 0) == ANIMAL_CLASSIC, "no new animals in the meadow") }
Expect(RoamerAnimal(IDEA_SQUIRREL, 0) == ANIMAL_SQUIRREL && RoamerAnimal(IDEA_HEDGEHOG, 0) == ANIMAL_HEDGEHOG &&
RoamerAnimal(IDEA_FROG, 0) == ANIMAL_FROG && PatrolAnimal(IDEA_STONE, 0) == ANIMAL_STONE &&
PatrolAnimal(IDEA_STONE - 1, 0) == ANIMAL_CLASSIC, "each animal opens in its own landscape")
placed: [5]s32
later_animals: [5]s32
key_level: s32 = -1
switch_level: s32 = -1
room_level: s32 = -1
portal_level: s32 = -1
for level: 40..LEVEL_COUNT - 1 {
reached: [CELLS]bool
for level: 0..LEVEL_COUNT - 1 {
StartGame(*game, cast(s32)level, 0)
if game.portal_count > 0 { portal_boards += 1 }
if game.portal_count > 0 && portal_level < 0 { portal_level = cast(s32)level }
placed[game.feature] += 1
for index: 0..game.monster_count - 1 {
if level >= IDEA_PORTAL_ROOM { later_animals[game.monsters[index].animal] += 1 }
}
start := Index(board_columns / 2, board_rows - 2)
unused FloodFrom(*game, start, -1, reached[:])
if game.feature == FEATURE_PORTALS && portal_level < 0 { portal_level = cast(s32)level }
for pair: 0..game.portal_count - 1 {
a := game.portals[pair].a
b := game.portals[pair].b
Expect(OpenAround(*game, a.x / 16, a.y / 16) && OpenAround(*game, b.x / 16, b.y / 16) &&
CellsApart(Index(a.x / 16, a.y / 16), Index(b.x / 16, b.y / 16)) >= 14, "portals stand in open floor, far apart")
Expect(OpenAround(*game, a.x / 16, a.y / 16) && OpenAround(*game, b.x / 16, b.y / 16), "portals stand in open floor")
Expect(!Near(game.apple, a, 12) && !Near(game.apple, b, 12), "apples never land on a portal")
}
if game.feature == FEATURE_KEY || game.feature == FEATURE_SWITCH {
Expect(game.gate >= 0 && !game.gate_open && game.board[game.gate] == 20, "a gate starts closed")
spot := ifx game.feature == FEATURE_KEY then game.key else game.switch_stone
Expect(reached[Index(spot.x / 16, spot.y / 16)], "its key or switch lies on the entrance side")
if game.feature == FEATURE_KEY && key_level < 0 { key_level = cast(s32)level }
if game.feature == FEATURE_SWITCH && switch_level < 0 { switch_level = cast(s32)level }
}
if game.feature == FEATURE_PORTAL_ROOM {
a := game.portals[0].a
b := game.portals[0].b
Expect(reached[Index(a.x / 16, a.y / 16)] && !reached[Index(b.x / 16, b.y / 16)], "a portal room is reached only through its portal")
if room_level < 0 { room_level = cast(s32)level }
}
}
Expect(portal_boards >= 70 && portal_level >= PORTAL_FIRST, "portals grow common after level 61")
print("Ideas placed: portals % keys % switches % rooms %; animals after 180: flames % squirrels % hedgehogs % frogs % stones %\n",
placed[1], placed[2], placed[3], placed[4], later_animals[0], later_animals[1], later_animals[2], later_animals[3], later_animals[4])
Expect(placed[FEATURE_PORTALS] >= 20 && placed[FEATURE_KEY] >= 8 && placed[FEATURE_SWITCH] >= 6 && placed[FEATURE_PORTAL_ROOM] >= 7,
"every puzzle idea comes back in later levels")
Expect(later_animals[1] > 0 && later_animals[2] > 0 && later_animals[3] > 0 && later_animals[4] > 0, "the last boards mix every animal")
Expect(key_level >= 0 && switch_level >= 0 && room_level >= 0 && portal_level >= 0, "every puzzle idea is placed somewhere")
if key_level < 0 || switch_level < 0 || portal_level < 0 { print("Gameplay failures: %\n", failures); return failures }
// The key opens its gate for good.
StartGame(*game, key_level, 0)
game.apples = 3
game.worm[0] = Point.{game.key.x, game.key.y + 4}
game.direction = DIR_UP
game.next_direction = DIR_UP
Tick(*game)
Expect(game.key.x < 0 && game.gate_open && game.board[game.gate] == game.gate_tiles[0], "the key opens its gate")
// A switch stone flips its gate each time the head arrives on it.
StartGame(*game, switch_level, 0)
game.apples = 3
stone := game.switch_stone
game.worm[0] = Point.{stone.x, stone.y + 8}
game.direction = DIR_UP
game.next_direction = DIR_UP
Tick(*game)
Expect(game.gate_open, "a switch stone opens its gate")
Tick(*game)
Tick(*game)
Tick(*game)
Expect(game.gate_open && game.on_switch == false, "it stays open as the head moves on")
game.worm[0] = Point.{stone.x, stone.y + 8}
Tick(*game)
Expect(!game.gate_open && game.board[game.gate] == 20, "arriving again closes it")
// A head stepping into a ring comes out of its partner.
StartGame(*game, portal_level, 0)
portal := game.portals[0]
game.apples = 3
@@ -156,6 +210,41 @@ main :: () -> s32 {
Expect(game.worm[0].x == portal.b.x && game.worm[0].y == portal.b.y, "the worm comes out of the partner ring")
Tick(*game)
Expect(game.worm[0].x == portal.b.x && game.worm[0].y == portal.b.y - 4 && game.death_ticks == 0, "it keeps its course out of the ring")
// A squirrel sits between dashes; a frog hops two tiles or not at all.
StartGame(*game, IDEA_SQUIRREL, 0)
for index: 0..game.monster_count - 1 {
if game.monsters[index].animal != ANIMAL_SQUIRREL { continue }
game.monsters[index].timer = 8
before := game.monsters[index].position
MoveMonster(*game, cast(s32)index)
Expect(game.monsters[index].position.x == before.x && game.monsters[index].position.y == before.y, "a squirrel sits between dashes")
}
// A hedgehog curls into a still ball as the worm's head comes close.
StartGame(*game, IDEA_HEDGEHOG, 0)
curled := false
for index: 0..game.monster_count - 1 {
if game.monsters[index].animal != ANIMAL_HEDGEHOG { continue }
curled = true
before := game.monsters[index].position
game.worm[0] = Point.{before.x + 24, before.y}
for tick: 0..HEDGEHOG_CURL - 2 { MoveMonster(*game, cast(s32)index) }
Expect(game.monsters[index].timer < 0 && game.monsters[index].position.x == before.x &&
game.monsters[index].position.y == before.y, "a hedgehog curls up and keeps still")
game.worm[0] = Point.{-100, -100}
for tick: 0..3 { MoveMonster(*game, cast(s32)index) }
Expect(game.monsters[index].timer >= 0, "it uncurls once the worm has gone")
break
}
Expect(curled, "the first hedgehog board has a hedgehog")
StartGame(*game, IDEA_FROG, 0)
for index: 0..game.monster_count - 1 {
if game.monsters[index].animal != ANIMAL_FROG { continue }
game.monsters[index].timer = 13
before := game.monsters[index].position
MoveMonster(*game, cast(s32)index)
moved := Abs(game.monsters[index].position.x - before.x) + Abs(game.monsters[index].position.y - before.y)
Expect(moved == 0 || moved == 32, "a frog hops two tiles")
}
game.lives = 1
game.death_ticks = 1
Tick(*game)
@@ -176,7 +265,7 @@ main :: () -> s32 {
StartGame(*game, 0, 0)
game.monster_count = 1
game.monsters[0] = Monster.{Point.{168, 168}, 3, 1}
game.monsters[0] = Monster.{Point.{168, 168}, 3, 1, 0, 0}
game.board[Index(10, 10)] = 0
MoveMonster(*game, 0)
Expect(game.monsters[0].position.x == 169, "monster moves one pixel")
+34 -2
View File
@@ -9,6 +9,7 @@
#import "apps/node_types"
#import "std/text_buffer"
#import "std/vec"
#import "std/c_string"
Portable :: #import, file "../src/portable.zi";
Account :: #import, file "../src/account.zi";
Progress :: #import, file "../src/progress.zi";
@@ -23,6 +24,10 @@ connected: bool = true;
host_account :: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
answer: [256]u8;
pointer: PointerFrame;
record_names: [32][65]u8;
record_values: [32][4803]u8;
record_count: s32;
invalid_record_names: s32;
#program_export
ReadAppHost :: () -> AppMessage { return message }
@@ -37,9 +42,23 @@ PollPointer :: () -> PointerFrame { return pointer }
#program_export
AppSoundHost :: (name: string) -> bool { unused name; return true }
#program_export
AppRecordHost :: (name: string) -> string { unused name; return "" }
AppRecordHost :: (name: string) -> string {
for index: cast(s32)0..record_count - 1 {
if TextUntilNul(record_names[index][:]) == name { return TextUntilNul(record_values[index][:]) }
}
return ""
}
#program_export
SaveAppRecordHost :: (name: string, value: string) -> bool { unused name; unused value; return true }
SaveAppRecordHost :: (name: string, value: string) -> bool {
if name.count < 1 || name.count > 64 { invalid_record_names += 1; return false }
for index: cast(s32)0..record_count - 1 {
if TextUntilNul(record_names[index][:]) == name { return CopyCString(value, record_values[index][:]) }
}
if record_count >= 32 || !CopyCString(name, record_names[record_count][:]) ||
!CopyCString(value, record_values[record_count][:]) { return false }
record_count += 1
return true
}
#program_export
AppServiceHost :: (name: string, request: string) -> string {
if name == "entity.profile" && request == "open" { profile_opens += 1; return "available" }
@@ -123,6 +142,19 @@ main :: () -> s32 {
Expect(message.succeeded, "shop Back returns inside the game")
Draw()
}
Expect(Progress.Begin(57, 6, 123456), "connected hosted run saves within host record limits")
Progress.Complete(56)
Progress.loaded = false
Progress.unlocked = 0
Progress.level = 0
Progress.lives = 3
Progress.score = 0
Progress.dirty = false
Progress.Load()
Expect(Progress.unlocked == 57 && Progress.level == 57 && Progress.lives == 6 && Progress.score == 123456,
"connected hosted run and unlocked progress survive restart")
Expect(Progress.Completed(56) && Progress.dirty, "connected hosted completion and sync retry survive restart")
Expect(invalid_record_names == 0, "every hosted save uses an accepted record name")
connected = false
Progress.poll_at = 0
Draw()
+24
View File
@@ -0,0 +1,24 @@
"""Write the Android launcher resources from the game's reviewed bitmap."""
from pathlib import Path
from PIL import Image
def install_icon(root: Path):
resources = root / 'droid/app/src/main/res'
with Image.open(root / 'assets/app/icon.png') as source:
artwork = resources / 'drawable-nodpi'
artwork.mkdir(parents=True, exist_ok=True)
source.convert('RGB').resize((432, 432), Image.Resampling.LANCZOS).save(artwork / 'ic_launcher_art.png')
for density, size in [('mdpi', 48), ('hdpi', 72), ('xhdpi', 96),
('xxhdpi', 144), ('xxxhdpi', 192)]:
folder = resources / ('mipmap-' + density)
folder.mkdir(parents=True, exist_ok=True)
source.convert('RGB').resize((size, size), Image.Resampling.LANCZOS).save(folder / 'ic_launcher.png')
adaptive = resources / 'mipmap-anydpi-v26'
adaptive.mkdir(parents=True, exist_ok=True)
(adaptive / 'ic_launcher.xml').write_text('''<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_art" />
<foreground android:drawable="@android:color/transparent" />
</adaptive-icon>
''')
+48 -14
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Sign and verify both Apfelwurm Android download names and the Google Play bundle, as Shovey does."""
"""Sign and verify Google-free Android downloads and the separate Google Play APK and bundle."""
import argparse
import hashlib
import json
@@ -22,7 +22,34 @@ def build_tools():
return tools
def verify(apk):
def verify_edition(archive, edition, bundle=False):
"""Inspect every DEX, including multidex, without loading the whole archive."""
markers = {
'Google': b'Lcom/google/',
'Play Billing': b'Lcom/android/billingclient/',
'Play Store': b'Lcom/android/vending/',
'Play bridge': b'Lorg/kryonlabs/play/PlayBilling;',
}
found = set()
overlap = max(map(len, markers.values())) - 1
pattern = r'base/dex/classes(?:\d+)?\.dex' if bundle else r'classes(?:\d+)?\.dex'
dex_names = [name for name in archive.namelist() if re.fullmatch(pattern, name)]
assert dex_names, 'Android releases must include DEX code'
for name in dex_names:
tail = b''
with archive.open(name) as dex:
while chunk := dex.read(1024 * 1024):
data = tail + chunk
found.update(label for label, marker in markers.items() if marker in data)
tail = data[-overlap:]
if edition == 'gplay':
assert {'Play Billing', 'Play bridge'} <= found, 'The Google Play edition must include Play Billing and its bridge'
else:
assert edition == 'direct', 'Unknown Android edition'
assert not found, 'Standard and F-Droid APKs must exclude Google libraries: ' + ', '.join(sorted(found))
def verify(apk, edition='direct'):
version = json.loads((ROOT / 'version.json').read_text())
tools = build_tools()
badging = subprocess.check_output([str(tools / 'aapt'), 'dump', 'badging', str(apk)], text=True)
@@ -31,6 +58,7 @@ def verify(apk):
assert int(package[2]) == version['version_code']
assert 'application-debuggable' not in badging, 'A debug APK cannot be released'
assert 'android.permission.INTERNET' in badging, 'Optional account sync and Dew require network access'
assert ('com.android.vending.BILLING' in badging) == (edition == 'gplay'), 'Play Billing permission must match the edition'
certificate = subprocess.check_output(['openssl', 'x509', '-in', str(ROOT / 'packaging/android/certificate.pem'), '-outform', 'DER'])
expected = hashlib.sha256(certificate).hexdigest()
signature = subprocess.check_output([str(tools / 'apksigner'), 'verify', '--verbose', '--print-certs', str(apk)], text=True)
@@ -38,6 +66,7 @@ def verify(apk):
assert 'Number of signers: 1' in signature and set(actual) == {expected}, 'Unexpected release certificate'
subprocess.run([str(tools / 'zipalign'), '-c', '-P', '16', '4', str(apk)], check=True, capture_output=True)
with zipfile.ZipFile(apk) as archive:
verify_edition(archive, edition)
abis = sorted(p.split('/')[1] for p in archive.namelist() if re.fullmatch(r'lib/[^/]+/libmain\.so', p))
assert abis == ['arm64-v8a', 'armeabi-v7a'], 'Both ARM architectures are required'
with tempfile.TemporaryDirectory(dir=ROOT / 'build') as directory:
@@ -63,7 +92,7 @@ def verify(apk):
assert archive.read('assets/' + name) == (ROOT / name).read_bytes(), name
assert archive.read('assets/assets/sounds/garden.pcm') == (ROOT / 'assets/sounds/garden.pcm').read_bytes()
assert archive.read('assets/assets/entity.zx') == (ROOT / 'build/profile/entity.zx').read_bytes(), 'The shared Profile must be packaged'
return dict(version=version['version'], version_code=version['version_code'], package=package[1], abis=abis,
return dict(version=version['version'], version_code=version['version_code'], edition=edition, package=package[1], abis=abis,
sha256=hashlib.sha256(apk.read_bytes()).hexdigest(), certificate_sha256=expected)
@@ -102,8 +131,7 @@ def verify_bundle(bundle, bundletool):
assert archive.read('base/assets/assets/art/' + name) == (ROOT / 'assets/art' / name).read_bytes(), name
assert not any(name.startswith('base/assets/assets/campaign-levels/') for name in archive.namelist()), 'Personal campaign edits must stay private'
assert archive.read('base/assets/assets/entity.zx') == (ROOT / 'build/profile/entity.zx').read_bytes(), 'The shared Profile must be packaged'
dex = b''.join(archive.read(name) for name in archive.namelist() if name.startswith('base/dex/'))
assert b'Lorg/kryonlabs/play/PlayBilling;' in dex, 'The Google Play edition must include Play Billing'
verify_edition(archive, 'gplay', bundle=True)
return dict(version=version['version'], version_code=version['version_code'], package='xyz.waozi.wurm', abis=abis,
sha256=hashlib.sha256(bundle.read_bytes()).hexdigest(), certificate_sha256=expected)
@@ -116,8 +144,11 @@ def main():
parser.add_argument('--password-file', type=Path, default=ROOT / 'backup/android-signing/password')
parser.add_argument('--output', type=Path, default=ROOT / 'build/downloads')
parser.add_argument('--bundletool', type=Path, help='Google bundletool JAR, required for .aab files')
parser.add_argument('--edition', choices=('direct', 'gplay'),
help='direct (default for APKs) or gplay; App Bundles always use gplay')
args = parser.parse_args()
if args.apk.suffix == '.aab':
assert args.edition != 'direct', 'App Bundles require the gplay edition'
assert args.bundletool, '--bundletool is required for a Google Play bundle'
bundle = args.apk.resolve(strict=True)
if args.action == 'sign':
@@ -141,32 +172,35 @@ def main():
print(f'Apfelwurm {result["version"]} ({result["version_code"]}): Google Play bundle identity, version, '
'both ARM architectures, upload signature, alignment and current assets verified.')
return
edition = args.edition or 'direct'
if args.action == 'verify':
verify(args.apk)
verify(args.apk, edition)
else:
args.output.mkdir(parents=True, exist_ok=True)
version = json.loads((ROOT / 'version.json').read_text())['version']
tools = build_tools()
aligned = args.output / 'aligned-unsigned.apk'
temporary = args.output / 'wurm.new.apk'
target = args.output / f'wurm-v{version}.apk'
suffix = '-gplay' if edition == 'gplay' else ''
aligned = args.output / f'aligned{suffix}-unsigned.apk'
temporary = args.output / f'wurm{suffix}.new.apk'
target = args.output / f'wurm-v{version}{suffix}.apk'
fdroid = args.output / f'wurm-{version}-fdroid.apk'
try:
subprocess.run([str(tools / 'zipalign'), '-P', '16', '-f', '4', str(args.apk.resolve()), str(aligned)], check=True)
subprocess.run([str(tools / 'apksigner'), 'sign', '--alignment-preserved', '--ks', str(args.keystore.resolve(strict=True)),
'--ks-key-alias', 'wurm', '--ks-pass', 'file:' + str(args.password_file.resolve(strict=True)),
'--out', str(temporary), str(aligned)], check=True)
result = verify(temporary)
result = verify(temporary, edition)
temporary.replace(target)
shutil.copyfile(target, fdroid)
assert verify(fdroid) == result
if edition == 'direct':
shutil.copyfile(target, fdroid)
assert verify(fdroid) == result
records = ROOT / 'backup/android-release'
records.mkdir(parents=True, exist_ok=True)
(records / 'verification.json').write_text(json.dumps(result, indent=2) + '\n')
(records / ('gplay-verification.json' if edition == 'gplay' else 'verification.json')).write_text(json.dumps(result, indent=2) + '\n')
finally:
aligned.unlink(missing_ok=True)
temporary.unlink(missing_ok=True)
print('Apfelwurm release APK: identity, version, both ARM architectures, signature, alignment and current assets verified.')
print(f'Apfelwurm {edition} release APK: edition, identity, version, both ARM architectures, signature, alignment and current assets verified.')
if __name__ == '__main__':
+13 -4
View File
@@ -8,6 +8,7 @@ import shutil
import subprocess
import re
from account_build import profile
from android_icon import install_icon
ROOT = Path(__file__).resolve().parents[1]
@@ -25,9 +26,14 @@ def main():
parser.add_argument('--release', action='store_true', help='build the unsigned production APK for signing')
parser.add_argument('--bundle', action='store_true',
help="build the unsigned Google Play edition's App Bundle for signing")
parser.add_argument('--edition', choices=('direct', 'gplay'),
help='direct (default) excludes Google libraries; gplay includes Play Billing')
parser.add_argument('--verification', action='store_true',
help='build a separate test install without replacing the normal game')
args = parser.parse_args()
edition = args.edition or ('gplay' if args.bundle else 'direct')
if args.bundle and edition != 'gplay':
parser.error('--bundle requires the gplay edition')
version = json.loads((ROOT / 'version.json').read_text())
current = re.search(r'^## \[([0-9.]+)\]', (ROOT / 'CHANGELOG.md').read_text(), re.M)
assert current and current[1] == version['version'], 'Run update_version.sh first'
@@ -54,7 +60,10 @@ def main():
'android:targetActivity="xyz.waozi.wurm.MainActivity"')
if 'android.permission.INTERNET' not in text:
text = text.replace(' <application', ' <uses-permission android:name="android.permission.INTERNET" />\n\n <application', 1)
if 'android:icon=' not in text:
text = text.replace(' <application', ' <application\n android:icon="@mipmap/ic_launcher"\n android:roundIcon="@mipmap/ic_launcher"', 1)
manifest.write_text(text)
install_icon(ROOT)
# The account provider uses the same native cryptography on both ABIs.
# These changes belong to this app's generated scaffold, never Kryon's.
cmake = ROOT / 'droid/app/src/main/cpp/CMakeLists.txt'
@@ -100,11 +109,11 @@ target_link_libraries(main oqs)
task = 'bundleRelease' if args.bundle else 'assembleRelease' if args.release else 'assembleDebug'
command = ['sh', 'droid/gradlew', '-p', 'droid', '--no-daemon', '--max-workers=1', task,
'-Pkryon.dir=' + str(kryon), '-Pziran.dir=' + str(ziran), '-Praylib.dir=' + str(raylib / 'src'),
'-Papp.abis=' + abis, '-Papp.minSdk=21', '-Papp.codegen=c99',
'-Papp.abis=' + abis, '-Papp.minSdk=21', '-Papp.codegen=c99', '-Papp.edition=' + edition,
'-Pandroid.aapt2FromMavenOverride=' + str(aapt)]
# Kryon's Google Play edition adds Play Billing, so Dew is bought through Play.
if args.bundle:
command += ['-Papp.edition=gplay', '-Pandroid.useAndroidX=true']
if edition == 'gplay':
command += ['-Pandroid.useAndroidX=true']
install_id = 'xyz.waozi.wurm.verification' if args.verification else 'xyz.waozi.wurm'
command.append('-Papp.installId=' + install_id)
subprocess.run(command, cwd=ROOT, env=environment, check=True)
@@ -117,7 +126,7 @@ target_link_libraries(main oqs)
label = 'Apfelwurm-verification-' if args.verification else 'Apfelwurm-'
variant = 'release' if args.release else 'debug'
suffix = '-release-unsigned.apk' if args.release else '-debug.apk'
target = ROOT / 'build/android' / (label + args.abi + suffix)
target = ROOT / 'build/android' / (label + args.abi + ('-gplay' if edition == 'gplay' else '') + suffix)
target.parent.mkdir(parents=True, exist_ok=True)
source = 'app-release-unsigned.apk' if args.release else 'app-debug.apk'
shutil.copy2(ROOT / 'droid/app/build/outputs/apk' / variant / source, target)
+4 -2
View File
@@ -43,13 +43,15 @@ def main():
subprocess.run([str(compiler / 'build/bin/zi2c'), '--define', 'PLATFORM_WEB', '--root', str(ir),
'-o', str(code), *map(str, ir.glob('*.zir'))], cwd=ROOT, env=env, check=True)
art = OUT / 'assets/art'
# Legacy cover studies are not used by the game. Keep the browser preload
# Legacy cover studies and the old level previews (the game shows
# campaign-previews) are not used by the game. Keep the browser preload
# below Pages' per-file limit without changing the published artwork.
unused_art = ('*.argb', 'garden-cover.png', 'space-cover.png', 'factory-cover.png', 'stage-covers.png')
shutil.copytree(ROOT / 'assets/art', art, dirs_exist_ok=True,
ignore=shutil.ignore_patterns(*unused_art))
ignore=shutil.ignore_patterns(*unused_art, 'previews'))
for name in unused_art[1:]:
(art / name).unlink(missing_ok=True)
shutil.rmtree(art / 'previews', ignore_errors=True)
emcc = (env.get('EMCC') or shutil.which('emcc', path=env.get('PATH'))
or str(Path.home() / 'emsdk/upstream/emscripten/emcc'))
subprocess.run([emcc, '-O2', '-Wno-parentheses-equality', '-I' + str(compiler / 'include'),
+42 -1
View File
@@ -164,6 +164,41 @@ def layout(stage,within,attempt):
return source,accent,walls
# Mountain boards that close a corner room with a single doorway. The game
# seals that doorway, so a portal is the only way in; with the doorway open
# the room is ordinary floor for the certificate.
PORTAL_ROOMS=(181,183,185,189,191)
def portal_room(walls,number):
# Each corner room is 4x3 blocks, walled toward the middle, with its door
# on the side or the bottom; the boards try them in a per-level order.
corners=[]
for right in (False,True):
for bottom in (False,True):
xs=range(15,19) if right else range(0,4)
ys=range(11,14) if bottom else range(0,3)
wall_x=14 if right else 4
wall_y=10 if bottom else 3
ring=[(wall_x,y) for y in (range(10,14) if bottom else range(0,4))]+[(x,wall_y) for x in (range(14,19) if right else range(0,5))]
side=(wall_x,12 if bottom else 1);outside_side=(wall_x+(-1 if right else 1),side[1])
below=(16 if right else 2,wall_y);outside_below=(below[0],wall_y+(-1 if bottom else 1))
for door,outside in ((side,outside_side),(below,outside_below)):
corners.append(({(x,y) for x in xs for y in ys},ring,door,outside))
tile=Counter(walls.values()).most_common(1)[0][0] if walls else 20
order=list(range(len(corners)));random.Random(number*977).shuffle(order)
for index in order:
room,ring,door,outside=corners[index]
shaped=dict(walls)
for p in room:shaped.pop(p,None)
for p in ring:shaped[p]=tile
shaped.pop(door,None);shaped.pop(outside,None)
allowed=ALL-set(shaped)
if reachable(allowed,(9,13))==allowed and not (set(shaped)&GATES):
return shaped,room
return None,set()
def campaign():
levels=[];known=set()
for stage,(stage_name,first,end) in enumerate(STAGES):
@@ -171,6 +206,10 @@ def campaign():
number=first+within+1
for attempt in range(512):
source,accent,walls=layout(stage,within,attempt)
room=set()
if number in PORTAL_ROOMS:
walls,room=portal_room(walls,number)
if walls is None:continue
floors=ALL-set(walls);key=signature(walls)
if key in known or len(floors)<88 or (within>=6 and len(walls)<8):continue
known.add(key);break
@@ -181,8 +220,10 @@ def campaign():
for dy in range(2):grid[1+mx*2+dx][1+my*2+dy]=tile
cycle=safe_cycle(floors,number*4099)
count=0 if stage==0 and within<6 else min(8,1+stage+within//16)
# Creatures stay out of a portal room, leaving it room for the ring.
candidates=[p for p in cycle if 3<=p[0]<=36 and 3<=p[1]<=23 and
abs(p[0]-20)+abs(p[1]-27)>=14 and abs(p[0]-37)+abs(p[1]-14)>=10]
abs(p[0]-20)+abs(p[1]-27)>=14 and abs(p[0]-37)+abs(p[1]-14)>=10 and
((p[0]-1)//2,(p[1]-1)//2) not in room]
rng=random.Random(number*65537);rng.shuffle(candidates);placed=[];kinds=[]
for x,y in candidates:
if len(placed)>=count:break
+7
View File
@@ -139,11 +139,18 @@ def main():
# keep the previous campaign and its cached art while development runs.
fire = cells(SOURCE / 'fire.png', 2, 2)
assert Image.open(SOURCE / 'fire.png').getchannel('A').getextrema()[0] == 0
# Row four: squirrel, hedgehog, frog and rolling stone frames, then the
# key, the switch stone off and on, and the gate across and down.
creatures = cells(SOURCE / 'journey-creatures.png', 4, 3)
assert Image.open(SOURCE / 'journey-creatures.png').getchannel('A').getextrema()[0] == 0
creatures.append(creatures[11].rotate(90))
for row, (stage, _, _) in enumerate(STAGES):
sheet = journey_sheet(base, journey[row * 4:row * 4 + 4])
sheet.paste(fire[0], (0, 2 * CELL))
for frame, image in enumerate(fire):
sheet.paste(image, ((6 + frame) * CELL, 2 * CELL))
for column, image in enumerate(creatures):
sheet.paste(image, (column * CELL, 4 * CELL))
save(sheet, ART / ('campaign-' + stage + '.png'), args.check)
covers = Image.open(SOURCE / 'stage-covers.png').convert('RGBA').resize((960, 1600), Image.Resampling.LANCZOS)
save(covers, ART / 'stage-covers.png', args.check)
+2 -2
View File
@@ -1,4 +1,4 @@
{
"version": "0.2.7",
"version_code": 17
"version": "0.2.12",
"version_code": 22
}
+27 -27
View File
@@ -3,7 +3,7 @@
"packages": [
{
"commit": "dc1cfe389905c63c0bb453727d06d72afc1fa0b0",
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p974af619ca377b85"},
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p7213416dd56f3a5c"},
"id": "p00b93f1ddcd2802f",
"name": "Apps",
"ref": "master",
@@ -18,13 +18,12 @@
"url": "https://github.com/ziranlang/qrcode.git"
},
{
"commit": "e1f480f382d9443c4412133b55948374c77a5c21",
"dependencies": {},
"id": "p4b0a50b49959e674",
"name": "liboqs",
"ref": "main",
"source": true,
"url": "https://github.com/open-quantum-safe/liboqs.git"
"commit": "2062597cecba5ce1bf54a20e6d5a2bdda148a06b",
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p7213416dd56f3a5c", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "p523d96ecdb68b57a",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e",
@@ -37,12 +36,20 @@
},
{
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
"dependencies": {"liboqs": "p4b0a50b49959e674"},
"dependencies": {"liboqs": "pecdb097af6ab16f7"},
"id": "p7098ac9cd92f7e5f",
"name": "Oqs",
"ref": "master",
"url": "https://github.com/ziranlang/oqs.git"
},
{
"commit": "5b2bfb71fef6111fcbaeb0446ba02ab6b0cd8f89",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p7213416dd56f3a5c",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "f5f0a19a5dc6c14a49adb3cd63ea79a60f6ba77b",
"dependencies": {},
@@ -52,14 +59,6 @@
"source": true,
"url": "https://github.com/LoupVaillant/Monocypher.git"
},
{
"commit": "3fad22341997f7c58ed1b11b1e88217358e51af5",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p974af619ca377b85",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "25d9f649c43a8de44a5fea602d2835e33e6ca999",
"dependencies": {"crypto": "pc23fbf455e97614d", "oqs": "p7098ac9cd92f7e5f"},
@@ -68,14 +67,6 @@
"ref": "master",
"url": "https://github.com/ziranlang/daochi-client.git"
},
{
"commit": "dc4946f0be5c15c15f79bd7cd69df8222e6c1b0d",
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p974af619ca377b85", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "pa3f5fd1ab5a1f780",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "944826f70779a6b6cd53f6b06a75b36f4d8a2558",
"dependencies": {},
@@ -91,14 +82,23 @@
"name": "mingcute",
"ref": "master",
"url": "https://github.com/kryonlabs/mingcute.git"
},
{
"commit": "4778aa5044bf119c30df54219fa89357080af27f",
"dependencies": {},
"id": "pecdb097af6ab16f7",
"name": "liboqs",
"ref": "main",
"source": true,
"url": "https://github.com/open-quantum-safe/liboqs.git"
}
],
"root": {
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "pa3f5fd1ab5a1f780", "kryon": "p974af619ca377b85", "mingcute": "pe1027b9d16704793"},
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p523d96ecdb68b57a", "kryon": "p7213416dd56f3a5c", "mingcute": "pe1027b9d16704793"},
"name": "Apfelwurm"
},
"toolchain": {
"commit": "79ad8431baaa8d3c948ade12909fe721c551e217",
"commit": "7c883e8458f9a728ff390d40e9c8b094a2683bab",
"ref": "master",
"url": "https://github.com/ziranlang/ziran.git"
}