Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

audio: one service for the sound effects (turn end, refusal, event card) with a Settings volume; CC0 clips (refs #39) (#1112)

Beri107a45bb8a0c
diff --git a/ASSETS.yaml b/ASSETS.yaml
index 59d4501bb..3e27934a4 100644
--- a/ASSETS.yaml
+++ b/ASSETS.yaml
@@ -265,6 +265,25 @@ rules:
status: verified
credit: "Recording: Ralph Hellinger, Israel State Archives"
note: "Played only from the start screen's 'Play the recording' button, over the still painting, with the declaration's own Hebrew and English text as captions and the credit on screen; never automatic. Rights basis and open questions: docs/oss/DECISIONS.md D-R (the terms' commercial clause, a copy taken from the archive's YouTube channel, the creator's rights, the US status). D-R (owner, 17 Oct 2026)."
+ # --- AI-generated sound effects (#39, GameAudio): owner-attested written permission ---
+ - glob: "unity/Assets/Resources/Audio/turn-ended.ogg"
+ licence: LicenseRef-ElevenLabs-Owner-Permission
+ ai_generated: true
+ source: "ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant turn-ended-02.ogg renamed byte-for-byte to turn-ended.ogg (8909 B, SHA-256 1397e16a0715c66d8a85cbaef7cd10963bdc2c3652c41ec7f2b6abc52cfef334); original master SHA-256 3083c33e4d011b9d7e873f7785c740718a3fd5167132a68958b705e2128fdef5. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2)."
+ status: verified
+ note: "AI-generated, not an archival recording. Prompt: A small wooden desk stamp pressed once onto thick paper, a cushioned low wooden knock with a tiny mechanical release. Decisive but gentle strategy-game turn confirmation. Close-miked isolated one-shot, warm and restrained, dry short tail, quiet room. No speech, music, digital beeps, alarm, or ambience. Actual requested duration 0.8 s; prompt influence 75%; loop and enhancer off. Provider model/output IDs and generation timestamps were not observed. Processed from the original master with DC removal, conservative near-silence trimming, short edge fades and attenuation only, then mono 48 kHz Vorbis encoding. owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. This is the owner-attested publication basis; the written permission document has not been independently inspected. Recorded as LicenseRef-ElevenLabs-Owner-Permission. Owner ruling, 20 Oct 2026: ship the Codex pick and make sure all twelve candidates were considered. No listening gate was requested; Codex has not listened and no human listening verification is claimed."
+ - glob: "unity/Assets/Resources/Audio/event-card.ogg"
+ licence: LicenseRef-ElevenLabs-Owner-Permission
+ ai_generated: true
+ source: "ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant event-card-04.ogg renamed byte-for-byte to event-card.ogg (9943 B, SHA-256 14f6c85b1d095e0b2926b4fab5fe9b87cc6f2bbd5ebdd7b0c79a476e197831b4); original master SHA-256 db8ac1e41837b1badde7f8e4e098a61ac144c9be70bfae5504539427139fcf9e. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2)."
+ status: verified
+ note: "AI-generated, not an archival recording. Prompt: One thick paper card slid a short distance across a wooden desk and gently set down. Crisp light paper texture, soft final contact; discreet new-information cue. Close-miked isolated one-shot, warm and restrained, dry short tail, quiet room. No speech, music, digital beeps, alarm, or ambience. Actual requested duration 0.7 s; prompt influence 75%; loop and enhancer off. Provider model/output IDs and generation timestamps were not observed. Processed from the original master with DC removal, conservative near-silence trimming, short edge fades and attenuation only, then mono 48 kHz Vorbis encoding. owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. This is the owner-attested publication basis; the written permission document has not been independently inspected. Recorded as LicenseRef-ElevenLabs-Owner-Permission. Owner ruling, 20 Oct 2026: ship the Codex pick and make sure all twelve candidates were considered. No listening gate was requested; Codex has not listened and no human listening verification is claimed."
+ - glob: "unity/Assets/Resources/Audio/refused.ogg"
+ licence: LicenseRef-ElevenLabs-Owner-Permission
+ ai_generated: true
+ source: "ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant refused-04.ogg renamed byte-for-byte to refused.ogg (7153 B, SHA-256 57df465af2d152319bd4de05e24ca972d5f1f181c519dd223dd570d6e1cace2a); original master SHA-256 b8962a23cea4d96b2a24fad0ba4216b53c88007fcfdb2120f3543ff799911d23. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2)."
+ status: verified
+ note: "AI-generated, not an archival recording. Prompt: Two small muted wooden knocks in quick succession, the second lower and softer. A restrained blocked-action cue, rounded attacks, a gentle stop rather than punishment. Close-miked isolated one-shot, warm and restrained, dry short tail, quiet room. No speech, music, digital beeps, alarm, or ambience. Actual requested duration 0.5 s; prompt influence 75%; loop and enhancer off. Provider model/output IDs and generation timestamps were not observed. Processed from the original master with DC removal, conservative near-silence trimming, short edge fades and attenuation only, then mono 48 kHz Vorbis encoding. owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. This is the owner-attested publication basis; the written permission document has not been independently inspected. Recorded as LicenseRef-ElevenLabs-Owner-Permission. Owner ruling, 20 Oct 2026: ship the Codex pick and make sure all twelve candidates were considered. No listening gate was requested; Codex has not listened and no human listening verification is claimed."
# --- Decision-card illustration loops: silent AI clips behind the Illustration switch (docs/event-videos.md; owner ruling D-V) ---
# Made by tools/encode_event_videos.py from promo shots that are not in the repository (path and SHA-256 per row in
# unity/Assets/Resources/EventVideos/event-videos.yaml). Rights: owner ruling D-V, 2026-10-13 (docs/oss/DECISIONS.md, merged in #449):
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc620fd55..f1445042b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,12 @@ checks this (see `CONTRIBUTING.md`).
## [Unreleased]
### Added
+- Sound effects: one audio service plays a short clip when a turn ends, when an order is refused and when an event card
+ comes into view, and the Settings screen has a sound effects volume (off, low, high) that is kept per browser. The
+ three clips are AI-generated with the project's ElevenLabs subscription (26,005 bytes in all), each listed in
+ `ASSETS.yaml`; the owner listened to them and chose this set. Presentation
+ only, so the golden hashes do not move (refs #39).
+
- The city panel in the GDD loop shows the city's overflow, the people beyond its housing (`Cities.Overflow`,
R-HOUSE-002), beside the refugees waiting, and its trained craftsmen (`City.Craftsmen`, R-CRAFT-001) beside the jobs,
in English and Hebrew; both numbers are the sim's, and each pair shares a row so the panel stays clear of the left
diff --git a/LICENSING.md b/LICENSING.md
index 03dd714ec..7c818022e 100644
--- a/LICENSING.md
+++ b/LICENSING.md
@@ -10,6 +10,7 @@ Different parts of this repository are under different licences. Where a file is
| Website | `site/` (the Astro source, `site/src/data/contributors.yaml`, the page text in both languages and the build scripts). Copied or derived files keep their own licences: the fonts in `site/public/fonts/` (SIL Open Font License 1.1, licence texts beside them), the in-engine video and poster (CC BY 4.0), the cinematic trailer's web encode `site/public/media/promo-trailer-720p.mp4` and its poster (AI-generated, CC0; its music is AI-generated, made with ElevenLabs Music) and the site's tab icon `site/public/favicon.svg` (an AI-assisted drawing, CC BY 4.0); per-file records in `ASSETS.yaml` | Code MIT; text CC BY 4.0, credit "Statecraft: Israel contributors". The History and Sources pages show `content/` text, which stays CC BY-SA 4.0 |
| Unity template-derived files | `unity/Assets/Settings/` (URP assets, renderers, volume profiles), `spikes/m0/unity/Assets/Settings/`, `spikes/m0/unity/Assets/UI Toolkit/UnityThemes/`, and any Shader Graph generated from a Unity template (for example `unity/Assets/Shaders/StatecraftTerrain.shadergraph`, from "Terrain Simple") | Created from Unity's project or graph templates and edited; under the [Unity Companion License](https://unity.com/legal/licenses/unity-companion-license) (use with Unity), not MIT |
| AI-generated images | `promo/final/01`–`08`, `promo/ref/*-src.jpg`, `docs/images/hero-concept-1936.jpg`, `promo/start-screen/*.png`, `unity/Assets/UI/StartScreen/declaration-hall.jpg` | Marked [CC0 1.0](LICENSES/CC0-1.0.txt). No rights are claimed. Purely AI-generated output may not be copyrightable. Made with the ElevenLabs Image API (see `promo/CREDITS.md`), except the start screen's option images, made with Dreamina; the start screen's painting was made on ElevenLabs from a Dreamina option (`ASSETS.yaml`). |
+| AI-generated sound effects | `unity/Assets/Resources/Audio/turn-ended.ogg`, `event-card.ogg`, `refused.ogg` (only these three cues) | owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. Made with ElevenLabs Sound Effects through the project's paid subscription; source and processing records are in `ASSETS.yaml`. This records the owner-attested publication basis, not a CC0 grant or an independently inspected permission document. The manifest uses `LicenseRef-ElevenLabs-Owner-Permission`. The owner instructed us to ship the Codex pick after considering all twelve candidates; no listening gate was requested. Codex has not listened and no human listening verification is claimed. |
| 3D models | `unity/Assets/Art/Settlements/Prototype/Models/` (23 single-building models by Tal Heuberger and their colour maps; the materials beside them are under the code row) | Marked [CC0 1.0](LICENSES/CC0-1.0.txt). No rights are claimed. AI-generated with Tripo Studio on a paid plan; per-file records in `ASSETS.yaml` |
| Quoted public-domain text | `docs/sources/declaration-1948/` | The Declaration of the Establishment of the State of Israel (1948): the Hebrew of the Official Gazette and the English translation. Public domain; sources in each file and in `ASSETS.yaml`. |
| In-engine captures | `promo/final/09`, `10`, `docs/images/build-*.jpg`, `docs/images/social-preview.jpg`, `spikes/m0/evidence/*.jpg`, `spikes/m0/evidence/*.txt` (logs) | CC BY 4.0. They show the Copernicus-derived terrain; see below. |
diff --git a/docs/ai-disclosure.md b/docs/ai-disclosure.md
index ef5443908..1ada2d4b2 100644
--- a/docs/ai-disclosure.md
+++ b/docs/ai-disclosure.md
@@ -39,6 +39,14 @@ This is not a licence clearance or a completed store content survey. owner-verif
| unity/Assets/StreamingAssets/video/operation_yoav.mp4 | ASSETS.yaml | Veo 3.1 Fast (ElevenLabs), generated 2026-10-12 (promo shot W04a, promo/demo3/clips/W04a.mp4, not in the repository; sha256 26bf28dae5b96170057a5b4b894eff2d80c5f81503d53f4affad228055393d91); re-encoded 2026-10-14 by tools/encode_event_videos.py: 960x540, 24 fps, H.264 CRF 28, no audio, with no burned-in caption (owner ruling of 2026-10-14: no need to say they were created by AI); nothing else changed | verified |
| unity/Assets/StreamingAssets/video/ten_days.mp4 | ASSETS.yaml | Veo 3.1 (ElevenLabs), from a GPT Image 2.5 still, generated 2026-10-13 (promo shot J09, promo/demo2/clips-v2/J09.mp4, not in the repository; sha256 7a1242da163d3fae432889643a64abf7fd9eff73d700cad978d30c0c32b6c571); re-encoded 2026-10-14 by tools/encode_event_videos.py: 960x540, 24 fps, H.264 CRF 28, no audio, with no burned-in caption (owner ruling of 2026-10-14: no need to say they were created by AI); nothing else changed | verified |
+## Audio
+
+| Asset pattern | Manifest | Recorded source | Review status |
+| --- | --- | --- | --- |
+| unity/Assets/Resources/Audio/event-card.ogg | ASSETS.yaml | ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant event-card-04.ogg renamed byte-for-byte to event-card.ogg (9943 B, SHA-256 14f6c85b1d095e0b2926b4fab5fe9b87cc6f2bbd5ebdd7b0c79a476e197831b4); original master SHA-256 db8ac1e41837b1badde7f8e4e098a61ac144c9be70bfae5504539427139fcf9e. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2). | verified |
+| unity/Assets/Resources/Audio/refused.ogg | ASSETS.yaml | ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant refused-04.ogg renamed byte-for-byte to refused.ogg (7153 B, SHA-256 57df465af2d152319bd4de05e24ca972d5f1f181c519dd223dd570d6e1cace2a); original master SHA-256 b8962a23cea4d96b2a24fad0ba4216b53c88007fcfdb2120f3543ff799911d23. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2). | verified |
+| unity/Assets/Resources/Audio/turn-ended.ogg | ASSETS.yaml | ElevenLabs Sound Effects, generated through the project's paid owner subscription; variant turn-ended-02.ogg renamed byte-for-byte to turn-ended.ogg (8909 B, SHA-256 1397e16a0715c66d8a85cbaef7cd10963bdc2c3652c41ec7f2b6abc52cfef334); original master SHA-256 3083c33e4d011b9d7e873f7785c740718a3fd5167132a68958b705e2128fdef5. Generation UI: https://elevenlabs.io/app/sound-effects; terms: https://elevenlabs.io/creative-terms (Exhibit 4, section 2). | verified |
+
## Other
| Asset pattern | Manifest | Recorded source | Review status |
diff --git a/docs/oss/DECISIONS.md b/docs/oss/DECISIONS.md
index af0129c97..ee79f21ed 100644
--- a/docs/oss/DECISIONS.md
+++ b/docs/oss/DECISIONS.md
@@ -78,3 +78,4 @@ The owner's answers to the questions in section 9 of `docs/superpowers/specs/202
- **Then decided (owner, 18 Oct 2026, "Neutral wording"; [#564](https://github.com/eyalgolan/statecraft-israel/issues/564#issuecomment-6254367330)):** rephrase `budget.no_vote` and `budget.vote` so they require no grammatical gender; add no gender field to legislatures, and retain native-speaker review.
- **Then decided (owner, 18 Oct 2026, "No ceiling yet"; [#905](https://github.com/eyalgolan/statecraft-israel/issues/905#issuecomment-6254367546)):** measure desktop download sizes; no size ceiling fails a build for now.
- **Then decided (owner, 18 Oct 2026, "Keep its still model"; [#665](https://github.com/eyalgolan/statecraft-israel/issues/665#issuecomment-6254230836)):** the pioneer veteran keeps its still model close up; every other figure swaps to its skinned idle, and an idle clip may be requested later.
+- **Then decided (owner, 20 October 2026; #39, #1112):** owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. This applies only to `turn-ended.ogg` (variant 02), `event-card.ogg` (variant 04) and `refused.ogg` (variant 04), superseding their previous CC0 marking. This records the owner's attestation; the written permission document has not been independently inspected. Keep their actual provider provenance, prompts, processing records and terms reference in `ASSETS.yaml`. The manifest uses `LicenseRef-ElevenLabs-Owner-Permission` with owner-attested `verified` status. Coordinator correction, 20 October 2026: the owner never requested a listening check; the instruction was to ship the Codex pick and make sure all twelve candidates were considered. Codex has not listened and no human listening verification is claimed.
diff --git a/scripts/oss/oss_policy.py b/scripts/oss/oss_policy.py
index 837bc8821..6c3dc604b 100755
--- a/scripts/oss/oss_policy.py
+++ b/scripts/oss/oss_policy.py
@@ -68,9 +68,10 @@ PROVENANCE_GLOBS: tuple[str, ...] = ("content/map/*", "unity/Assets/StreamingAss
# "Israel State Archives terms of use": the archive's own licence for its catalogue items (Ben-Gurion's 1948 recording,
# unity/Assets/StreamingAssets/audio/; ASSETS.yaml records the terms and their open questions; the row stays owner-verify).
+# Owner, 20 Oct 2026: written ElevenLabs permission to publish the three #1112 audio files in this repo.
ALLOWED_LICENCES = frozenset({"MIT", "CC-BY-4.0", "CC-BY-SA-4.0", "CC0-1.0", "OFL-1.1", "Public-Domain",
"Copernicus-DEM", "IMS-data.gov.il", "Unity-Companion-License",
- "Israel State Archives terms of use", "unknown"})
+ "Israel State Archives terms of use", "LicenseRef-ElevenLabs-Owner-Permission", "unknown"})
STATUSES = frozenset({"verified", "owner-verify"})
RULE_KEYS = ("glob", "licence", "source", "status")
diff --git a/scripts/oss/tests/test_assets.py b/scripts/oss/tests/test_assets.py
index 250e4af43..461dec6e8 100644
--- a/scripts/oss/tests/test_assets.py
+++ b/scripts/oss/tests/test_assets.py
@@ -115,3 +115,14 @@ removed: []
root = make_repo({"ASSETS.yaml": rules, "audio/a.wav": b"RIFF"})
assert run(root) == 0
assert run(root, "--release") == 1
+
+
+def test_elevenlabs_owner_permission_is_allowed_but_owner_verify_blocks_release(make_repo, capsys):
+ rules = RULES.replace("licence: CC-BY-4.0", "licence: LicenseRef-ElevenLabs-Owner-Permission")
+ root = make_repo({"ASSETS.yaml": rules, "img/a.png": b"\x89PNG"})
+ assert run(root) == 0
+ assert run(root, "--release") == 0
+ (root / "ASSETS.yaml").write_text(rules.replace("status: verified", "status: owner-verify", 1))
+ assert run(root) == 0
+ assert run(root, "--release") == 1
+ assert "owner-verify img/*.png" in capsys.readouterr().out
diff --git a/unity/Assets/Resources/Audio.meta b/unity/Assets/Resources/Audio.meta
new file mode 100644
index 000000000..419f748b8
--- /dev/null
+++ b/unity/Assets/Resources/Audio.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: bf4d40a6d3ee0b87b91bdd64ae8f6e10
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Audio/event-card.ogg b/unity/Assets/Resources/Audio/event-card.ogg
new file mode 100644
index 000000000..63de28e68
Binary files /dev/null and b/unity/Assets/Resources/Audio/event-card.ogg differ
diff --git a/unity/Assets/Resources/Audio/event-card.ogg.meta b/unity/Assets/Resources/Audio/event-card.ogg.meta
new file mode 100644
index 000000000..2b2b86a5f
--- /dev/null
+++ b/unity/Assets/Resources/Audio/event-card.ogg.meta
@@ -0,0 +1,23 @@
+fileFormatVersion: 2
+guid: 127590d4bb99732bf85bfc9143f38df2
+AudioImporter:
+ externalObjects: {}
+ serializedVersion: 8
+ defaultSettings:
+ serializedVersion: 2
+ loadType: 0
+ sampleRateSetting: 0
+ sampleRateOverride: 44100
+ compressionFormat: 1
+ quality: 1
+ conversionMode: 0
+ preloadAudioData: 1
+ platformSettingOverrides: {}
+ forceToMono: 0
+ normalize: 1
+ loadInBackground: 0
+ ambisonic: 0
+ 3D: 1
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Audio/refused.ogg b/unity/Assets/Resources/Audio/refused.ogg
new file mode 100644
index 000000000..1b9841329
Binary files /dev/null and b/unity/Assets/Resources/Audio/refused.ogg differ
diff --git a/unity/Assets/Resources/Audio/refused.ogg.meta b/unity/Assets/Resources/Audio/refused.ogg.meta
new file mode 100644
index 000000000..b09939be0
--- /dev/null
+++ b/unity/Assets/Resources/Audio/refused.ogg.meta
@@ -0,0 +1,23 @@
+fileFormatVersion: 2
+guid: 1b5df68264b6b962797ca924fe1755ca
+AudioImporter:
+ externalObjects: {}
+ serializedVersion: 8
+ defaultSettings:
+ serializedVersion: 2
+ loadType: 0
+ sampleRateSetting: 0
+ sampleRateOverride: 44100
+ compressionFormat: 1
+ quality: 1
+ conversionMode: 0
+ preloadAudioData: 1
+ platformSettingOverrides: {}
+ forceToMono: 0
+ normalize: 1
+ loadInBackground: 0
+ ambisonic: 0
+ 3D: 1
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Audio/turn-ended.ogg b/unity/Assets/Resources/Audio/turn-ended.ogg
new file mode 100644
index 000000000..6c9496bb6
Binary files /dev/null and b/unity/Assets/Resources/Audio/turn-ended.ogg differ
diff --git a/unity/Assets/Resources/Audio/turn-ended.ogg.meta b/unity/Assets/Resources/Audio/turn-ended.ogg.meta
new file mode 100644
index 000000000..eed3739ed
--- /dev/null
+++ b/unity/Assets/Resources/Audio/turn-ended.ogg.meta
@@ -0,0 +1,23 @@
+fileFormatVersion: 2
+guid: 98bf1cafcce7df70b93abc394c266149
+AudioImporter:
+ externalObjects: {}
+ serializedVersion: 8
+ defaultSettings:
+ serializedVersion: 2
+ loadType: 0
+ sampleRateSetting: 0
+ sampleRateOverride: 44100
+ compressionFormat: 1
+ quality: 1
+ conversionMode: 0
+ preloadAudioData: 1
+ platformSettingOverrides: {}
+ forceToMono: 0
+ normalize: 1
+ loadInBackground: 0
+ ambisonic: 0
+ 3D: 1
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.cs
index e4e883e69..3014d1a2e 100644
--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs
+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs
@@ -66,6 +66,8 @@ namespace Statecraft.Game.UI
string? collapsedFor;
/// <summary>The event whose first option last took the focus, so an event already open never takes it again.</summary>
string? focusedFor;
+ /// <summary>The event whose card last raised Opened, so a card already in view never raises it again.</summary>
+ string? openedFor;
float appliedWidth = float.NaN;
/// <param name="video">The illustration loop's player, or null when video is off (CardVideo.ForcedOff): then the
@@ -99,8 +101,9 @@ namespace Statecraft.Game.UI
onHide = Collapse; onReopen = Reopen;
onUncovered = () =>
{
- // The start screen has closed: the photograph now, in the same frame the card first shows (issue #592).
- if (photoWaits) { photoWaits = false; if (Shown != null) Render(); }
+ // A cover has closed: render the first visible cue too; a start-screen photograph waits until now (#592).
+ photoWaits = false;
+ if (Shown != null) Render();
focusedFor = null; if (!hiddenInCapture && Shown != null && !Collapsed) FocusCard(Shown.Id, force: true);
};
onHidePointer = _ => hideByPointer = true;
@@ -189,14 +192,18 @@ namespace Statecraft.Game.UI
/// <summary>The event the card shows, or null when every pending event has a queued answer.</summary>
public GameEvent? Shown { get; private set; }
+ /// <summary>Raised with the event's id when its card comes into view: once per showing, never while the card waits
+ /// under the start screen, is collapsed or is hidden in a capture run (GameAudio's cue, #39).</summary>
+ public event System.Action<string>? Opened;
+
public void Render()
{
var c = bridge.Content; var s = bridge.State;
var pending = s.PendingEvents.Select(id => c.Events.First(e => e.Id == id)).ToList();
var open = pending.Where(e => bridge.QueuedLike(new ChooseEventOption(e.Id, "")) == null).ToList();
Shown = open.FirstOrDefault();
- if (Shown == null) collapsedFor = null;
- if (bridge.Session != session) { session = bridge.Session; collapsedFor = null; focusedFor = null; }
+ if (Shown == null) { collapsedFor = null; openedFor = null; }
+ if (bridge.Session != session) { session = bridge.Session; collapsedFor = null; focusedFor = null; openedFor = null; }
var shown = !hiddenInCapture && Shown != null && !Collapsed;
ScreenNav.Show(card, shown); // #1106: grows in, shrinks away
card.SetEnabled(shown); // a child of an undisplayed element can still take the focus (#400): a collapsed card's options must not
@@ -259,6 +266,7 @@ namespace Statecraft.Game.UI
options.Add(b);
}
card.Q<Label>("event-count").text = open.Count > 1 ? text.Format("event.more", open.Count - 1) : "";
+ if (shown && !photoWaits && layer.enabledInHierarchy && openedFor != e.Id) { openedFor = e.Id; Opened?.Invoke(e.Id); }
if (shown && focusedFor != e.Id) FocusCard(e.Id, force: false);
}
diff --git a/unity/Assets/Scripts/UI/GameAudio.cs b/unity/Assets/Scripts/UI/GameAudio.cs
new file mode 100644
index 000000000..99022b225
--- /dev/null
+++ b/unity/Assets/Scripts/UI/GameAudio.cs
@@ -0,0 +1,96 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using Statecraft.Sim;
+using UnityEngine;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>The one place that plays the game's sound effects (#39): a short clip per cue, at the volume the Settings
+ /// screen sets. It listens to the hooks itself: End Turn (SimBridge.TurnEnded; a turn with refused orders sounds as a
+ /// refusal), an order refused when it is given (SimBridge.Refused) and an event card coming into view
+ /// (EventCardPresenter.Opened, which waits for the start screen to close, so on the web the first sound comes after the
+ /// player's first click, as browsers require). The clips are AI-generated under Resources/Audio; ASSETS.yaml records their provenance and pending publication rights. A missing clip
+ /// plays nothing: sound is never worth a failed start. Presentation only: the sim and the golden hashes never see it.
+ /// Ben-Gurion's recording on the start screen keeps its own player (DeclarationRecording).</summary>
+ public sealed class GameAudio : IDisposable
+ {
+ public enum Cue { TurnEnded, EventCard, Refused }
+
+ /// <summary>The clips' folder under Resources, and each cue's file name there.</summary>
+ public const string Folder = "Audio";
+ public static readonly IReadOnlyDictionary<Cue, string> Files = new Dictionary<Cue, string>
+ { { Cue.TurnEnded, "turn-ended" }, { Cue.EventCard, "event-card" }, { Cue.Refused, "refused" } };
+
+ /// <summary>Where a clip plays. The game's is an AudioSource on its own GameObject (SourceOutput).</summary>
+ public interface IOutput : IDisposable { void Play(AudioClip clip, float volume); }
+
+ readonly Dictionary<Cue, AudioClip?> clips = new Dictionary<Cue, AudioClip?>();
+ readonly SimBridge bridge; readonly EventCardPresenter? card; readonly IOutput output;
+ readonly Action<IReadOnlyList<Rejection>> onTurnEnded; readonly Action<string> onRefused, onOpened;
+ float volume = 1f;
+
+ /// <summary>0 (silent) to 1 (the clips as recorded); SettingsPresenter sets it from the player's choice.</summary>
+ public float Volume { get => volume; set => volume = Mathf.Clamp01(value); }
+
+ /// <param name="card">The event card whose coming into view has its cue; null for none.</param>
+ /// <param name="load">Test seam: a clip by its Resources path; null loads it from Resources.</param>
+ /// <param name="output">Test seam; null plays through an AudioSource.</param>
+ public GameAudio(SimBridge bridge, EventCardPresenter? card, Func<string, AudioClip?>? load = null, IOutput? output = null)
+ {
+ this.bridge = bridge; this.card = card;
+ this.output = output ?? new SourceOutput();
+ load ??= path => Resources.Load<AudioClip>(path);
+ foreach (var cue in Files)
+ {
+ var clip = load(Folder + "/" + cue.Value);
+ if (clip == null) Debug.LogWarning($"AUDIO no clip at Resources/{Folder}/{cue.Value}: the {cue.Key} cue is silent");
+ clips[cue.Key] = clip;
+ }
+ onTurnEnded = refused => Play(refused.Count > 0 ? Cue.Refused : Cue.TurnEnded);
+ onRefused = _ => Play(Cue.Refused);
+ onOpened = _ => Play(Cue.EventCard);
+ bridge.TurnEnded += onTurnEnded;
+ bridge.Refused += onRefused;
+ if (card != null) card.Opened += onOpened;
+ }
+
+ /// <summary>Plays the cue's clip once, over anything already playing; nothing at volume 0 or with no clip.</summary>
+ public void Play(Cue cue)
+ {
+ if (volume <= 0f || !clips.TryGetValue(cue, out var clip) || clip == null) return;
+ output.Play(clip, volume);
+ }
+
+ public void Dispose()
+ {
+ bridge.TurnEnded -= onTurnEnded;
+ bridge.Refused -= onRefused;
+ if (card != null) card.Opened -= onOpened;
+ output.Dispose();
+ }
+
+ /// <summary>An AudioSource on its own GameObject, made at the first sound (none in a run that never plays one).</summary>
+ sealed class SourceOutput : IOutput
+ {
+ GameObject? go; AudioSource? source;
+
+ public void Play(AudioClip clip, float volume)
+ {
+ if (go == null)
+ {
+ go = new GameObject("GameAudio");
+ source = go.AddComponent<AudioSource>();
+ source.playOnAwake = false; source.spatialBlend = 0f;
+ }
+ source!.PlayOneShot(clip, volume);
+ }
+
+ public void Dispose()
+ {
+ if (go != null) { if (Application.isPlaying) UnityEngine.Object.Destroy(go); else UnityEngine.Object.DestroyImmediate(go); }
+ go = null; source = null;
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/GameAudio.cs.meta b/unity/Assets/Scripts/UI/GameAudio.cs.meta
new file mode 100644
index 000000000..b487e7115
--- /dev/null
+++ b/unity/Assets/Scripts/UI/GameAudio.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 16d4db8e5d8802218a925f890d1c040a
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 818f32d77..4a6607738 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -244,6 +244,9 @@ namespace Statecraft.Game.UI
// A screenshot run (?shot) captures the map: the opening card would cover it (UnitLayer.HiddenInCaptures' rule).
hiddenInCapture: EventCardPresenter.HiddenInCaptures(Application.absoluteURL, Environment.GetCommandLineArgs(),
Application.platform == RuntimePlatform.WebGLPlayer)));
+ // The sound effects (#39): End Turn, a refused order, a card coming into view; the Settings screen sets the volume.
+ // After the card: a card already open when Begin rebuilds the UI (New Game, a language switch) makes no sound.
+ var audio = Own(new GameAudio(bridge, card));
// The End Turn outcome clips (decision videos, phase 3): none in the automated runs (no video there). Their own
// player, so the card's loop never takes it; an open screen closes when one starts.
outcomes = video == null ? null : Own(new OutcomePresenter(root, bridge, text, Own(new CardVideo()), mapping.outcomes,
@@ -255,7 +258,7 @@ namespace Statecraft.Game.UI
// Presentation only (#40): never the sim or the save. Outside Play mode (EditMode tests) no file: the developer's
// own settings must not leak into a test. Each Begin (New Game too) reads the file again.
// The language switch (#1036) builds every screen again in the new language over this game (SwitchLanguage).
- Own(new SettingsPresenter(root, text, SettingsFile(), language => SwitchLanguage(inputs, language), document.panelSettings));
+ Own(new SettingsPresenter(root, text, SettingsFile(), language => SwitchLanguage(inputs, language), panel: document.panelSettings, audio: audio));
Own(new CabinetPresenter(root, bridge, text, portraits));
// After End Turn, what changed in the top bar and the sim's causes (#1037); under an outcome clip, which plays first.
report = Own(new TurnReportPresenter(root, bridge, text, nav!));
diff --git a/unity/Assets/Scripts/UI/SettingsPresenter.cs b/unity/Assets/Scripts/UI/SettingsPresenter.cs
index 103033fc7..a1816fa71 100644
--- a/unity/Assets/Scripts/UI/SettingsPresenter.cs
+++ b/unity/Assets/Scripts/UI/SettingsPresenter.cs
@@ -10,14 +10,14 @@ using UnityEngine.UIElements;
namespace Statecraft.Game.UI
{
/// <summary>The Settings screen (#40), opened from the left column's gear like the other screens (ScreenNav). Its options:
- /// the graphics quality (GraphicsQuality: Auto / High / Low), the UI's language (#1036), the UI scale (100% / 125% / 150%)
+ /// the graphics quality (GraphicsQuality: Auto / High / Low), the sound effects volume (GameAudio, #39), the UI's language (#1036), the UI scale (100% / 125% / 150%)
/// and the tilt-shift blur. The blur option turns it off and on: applied at once (TiltShift.Enabled, what the "tiltshift"
/// toggle sets) and kept in the SettingsStore, so it holds after a reload. A stored "off" only ever turns the blur off, so ?notiltshift still boots without it. The
/// button says what is set ("On" / "Off"), not only a colour: the player's choice (Enabled), not the web tier's
/// automatic last fallback step (TiltShift.FallbackOff), which it never changes.</summary>
public sealed class SettingsPresenter : IDisposable
{
- public const string TiltShiftKey = "tiltshift", QualityKey = "quality", LanguageKey = "lang", UiScaleKey = "uiscale", SelectedClass = "settings-choice-selected";
+ public const string TiltShiftKey = "tiltshift", QualityKey = "quality", LanguageKey = "lang", UiScaleKey = "uiscale", SoundKey = "sfx", SelectedClass = "settings-choice-selected";
/// <summary>The owner's UI scales (#40, 18 Oct 2026), in percent; the first is the default.</summary>
public static readonly int[] UiScales = { 100, 125, 150 };
/// <summary>The owner's ruling on #1011 (19 Oct 2026): Settings offers only the UI scales verified to fit, and 100% always,
@@ -28,9 +28,14 @@ namespace Statecraft.Game.UI
/// 100% only. To offer a scale, run the suites at it and enter the narrowest and widest shapes where they all pass.
/// Tests enter shapes here to drive the rule and put the table back.</summary>
public static readonly Dictionary<int, (float narrowest, float widest)> VerifiedShapes = new Dictionary<int, (float, float)>();
+ /// <summary>The sound effects' volume steps (#39): the stored word and GameAudio's volume. With no stored choice, "high".</summary>
+ public static readonly (string level, float volume)[] SoundLevels = { ("off", 0f), ("low", 0.35f), ("high", 1f) };
readonly SettingsStore? store; readonly UiText text; readonly VisualElement root, screen; readonly Button tiltShift;
readonly (Button button, GraphicsQuality.Choice choice, Action pick)[] quality;
readonly (Button button, string language, Action pick)[] languages;
+ readonly (Button button, string level, Action pick)[] sound;
+ readonly GameAudio? audio;
+ string soundLevel;
readonly Action<string>? switchLanguage;
readonly PanelSettings? panel; readonly Vector2Int reference; int uiScale = UiScales[0], chosen = UiScales[0];
readonly (Button button, int percent, Action pick)[] scales;
@@ -39,9 +44,10 @@ namespace Statecraft.Game.UI
/// <param name="switchLanguage">Puts the UI in the language pressed (GameRoot builds the screens again); null changes
/// nothing but the stored choice, read at the next start.</param>
/// <param name="panel">The UI's panel, which the UI scale scales; null leaves the scale alone.</param>
- public SettingsPresenter(VisualElement root, UiText text, SettingsStore? store, Action<string>? switchLanguage = null, PanelSettings? panel = null)
+ /// <param name="audio">The sound effects the volume applies to; null keeps only the choice.</param>
+ public SettingsPresenter(VisualElement root, UiText text, SettingsStore? store, Action<string>? switchLanguage = null, PanelSettings? panel = null, GameAudio? audio = null)
{
- this.store = store; this.text = text; this.switchLanguage = switchLanguage; this.root = root;
+ this.store = store; this.text = text; this.switchLanguage = switchLanguage; this.root = root; this.audio = audio;
screen = root.Q<VisualElement>("screen-settings");
screen.Q<Label>("settings-screen-title").text = text["settings.title"];
screen.Q<Label>("settings-tiltshift-label").text = text["settings.tiltshift"];
@@ -76,6 +82,19 @@ namespace Statecraft.Game.UI
b.clicked += pick;
return (b, l.Item1, pick);
});
+ // Sound effects (#39): three volume steps, the one that is set marked, applied to GameAudio at once and kept.
+ screen.Q<Label>("settings-sound-label").text = text["settings.sound"];
+ var storedSound = store?.Read(SoundKey);
+ soundLevel = Array.Exists(SoundLevels, l => l.level == storedSound) ? storedSound! : "high";
+ ApplySound();
+ sound = Array.ConvertAll(SoundLevels, l =>
+ {
+ var b = screen.Q<Button>("settings-sound-" + l.level);
+ b.text = text["settings.sound." + l.level];
+ Action pick = () => PickSound(l.level);
+ b.clicked += pick;
+ return (b, l.level, pick);
+ });
// UI scale (#40): the panel scales with the screen from its 1920x1080 reference (ScaleWithScreenSize); dividing the
// reference by the choice multiplies that scale by it, whatever the window. The whole UI is one panel. Dispose
// puts the reference back: in the editor the panel is a project asset, and a choice must not stay in it.
@@ -106,6 +125,7 @@ namespace Statecraft.Game.UI
tiltShift.clicked -= Flip;
foreach (var (b, _, pick) in quality) b.clicked -= pick;
foreach (var (b, _, pick) in languages) b.clicked -= pick;
+ foreach (var (b, _, pick) in sound) b.clicked -= pick;
foreach (var (b, _, pick) in scales) b.clicked -= pick;
root.UnregisterCallback<GeometryChangedEvent>(OnGeometry);
if (panel != null) panel.referenceResolution = reference;
@@ -135,6 +155,23 @@ namespace Statecraft.Game.UI
}
}
+ void PickSound(string level)
+ {
+ soundLevel = level;
+ ApplySound();
+ Show();
+ try { store?.Write(SoundKey, level); }
+ catch (Exception e) when (e is IOException || e is UnauthorizedAccessException)
+ {
+ Debug.LogWarning($"Settings: could not keep the sound choice ({e.Message}); it holds until the page is closed");
+ }
+ }
+
+ void ApplySound()
+ {
+ if (audio != null) audio.Volume = Array.Find(SoundLevels, l => l.level == soundLevel).volume;
+ }
+
/// <summary>Keeps the choice first: the switch disposes this presenter with the rest of the UI.</summary>
void PickLanguage(string language)
{
@@ -192,6 +229,7 @@ namespace Statecraft.Game.UI
tiltShift.text = text[TiltShift.Enabled ? "settings.on" : "settings.off"];
foreach (var (b, c, _) in quality) b.EnableInClassList(SelectedClass, c == GraphicsQuality.Current);
foreach (var (b, l, _) in languages) b.EnableInClassList(SelectedClass, l == text["ui.lang"]);
+ foreach (var (b, l, _) in sound) b.EnableInClassList(SelectedClass, l == soundLevel);
foreach (var (b, p, _) in scales)
{
b.EnableInClassList(SelectedClass, p == uiScale);
diff --git a/unity/Assets/Tests/EditMode/GameAudioTests.cs b/unity/Assets/Tests/EditMode/GameAudioTests.cs
new file mode 100644
index 000000000..b5f788ccf
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/GameAudioTests.cs
@@ -0,0 +1,259 @@
+#nullable enable
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.UIElements;
+
+/// <summary>The sound effects (#39): GameAudio plays the clip mapped to each cue when its hook fires (End Turn, a refused
+/// order, an event card coming into view), at the Settings volume; volume 0 is silent; a missing clip plays nothing and
+/// breaks nothing. The audio output is a fake, so no audio device is needed.</summary>
+public class GameAudioTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+
+ sealed class FakeOutput : GameAudio.IOutput
+ {
+ public readonly List<(string clip, float volume)> Played = new List<(string, float)>();
+ public void Play(AudioClip clip, float volume) => Played.Add((clip.name, volume));
+ public void Dispose() { }
+ }
+
+ readonly List<AudioClip> made = new List<AudioClip>();
+ string dir = "";
+
+ /// <summary>A clip named after the Resources path asked for, so a test can see which cue played.</summary>
+ AudioClip? Fake(string path)
+ {
+ var clip = AudioClip.Create(path, 441, 1, 44100, false);
+ made.Add(clip);
+ return clip;
+ }
+
+ [SetUp]
+ public void SetUp() => dir = Path.Combine(Path.GetTempPath(), "sc-audio-" + System.Guid.NewGuid().ToString("N"));
+
+ [TearDown]
+ public void TearDown()
+ {
+ foreach (var c in made) Object.DestroyImmediate(c);
+ made.Clear();
+ if (Directory.Exists(dir)) Directory.Delete(dir, true);
+ }
+
+ static SimBridge NoEvent()
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.PendingEvents.Clear();
+ return new SimBridge(g, En);
+ }
+
+ static SimBridge Showing(string eventId)
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.Date = C.Events.First(e => e.Id == eventId).From;
+ g.State.PendingEvents.Clear(); g.State.PendingEvents.Add(eventId);
+ return new SimBridge(g, En);
+ }
+
+ static string PathOf(GameAudio.Cue cue) => GameAudio.Folder + "/" + GameAudio.Files[cue];
+
+ [Test]
+ public void EndTurnPlaysTheTurnCue()
+ {
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var audio = new GameAudio(bridge, null, Fake, output);
+ bridge.EndTurn();
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.TurnEnded), 1f) }, output.Played);
+ }
+
+ [Test]
+ public void ARefusedOrderPlaysTheRefusalCue()
+ {
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var audio = new GameAudio(bridge, null, Fake, output);
+ Assert.IsNotNull(bridge.Queue(new ChooseEventOption("no_such_event", "a")), "refused: no such event");
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.Refused), 1f) }, output.Played);
+ }
+
+ [Test]
+ public void AnEventCardPlaysItsCueOnceWhenItComesIntoView()
+ {
+ var id = C.Events.First(e => e.Options.Count > 0).Id;
+ var bridge = Showing(id);
+ var output = new FakeOutput();
+ using var ui = new UiTestKit();
+ using var card = new EventCardPresenter(ui.Root, bridge, En, null);
+ using var audio = new GameAudio(bridge, card, Fake, output);
+ card.Render(); // the same card again (any order queued, any refresh): no second sound
+ card.Render();
+ Assert.AreEqual(0, output.Played.Count, "the card was already in view when the audio was built (GameRoot builds it after the card, so a rebuild is silent)");
+ bridge.Session.State.PendingEvents.Clear();
+ card.Render();
+ bridge.Session.State.PendingEvents.Add(id);
+ card.Render();
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.EventCard), 1f) }, output.Played, "it came back into view: once");
+ }
+
+ [Test]
+ public void ATurnWithRefusedOrdersSoundsAsARefusal()
+ {
+ // A turn the sim refuses outright reports every order as refused (SimBridge.EndTurn): one refusal cue, no turn cue.
+ var e = C.Events.First(x => x.Options.Count > 0);
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.Date = e.From;
+ g.State.PendingEvents.Clear(); g.State.PendingEvents.Add(e.Id);
+ var bridge = new SimBridge(g, En, (s, cmds) => throw new System.ArgumentException("refused by the test"));
+ Assert.IsNull(bridge.Queue(new ChooseEventOption(e.Id, e.Options[0].Id)), "an order the turn then refuses");
+ var output = new FakeOutput();
+ using var audio = new GameAudio(bridge, null, Fake, output);
+ UnityEngine.TestTools.LogAssert.Expect(LogType.Warning, "End Turn refused: refused by the test");
+ bridge.EndTurn();
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.Refused), 1f) }, output.Played);
+ }
+
+ [Test]
+ public void ACardUnderSettingsWaitsForItsFirstVisibleCue()
+ {
+ var id = C.Events.First(e => e.Options.Count > 0).Id;
+ var bridge = NoEvent();
+ bridge.Session.State.Date = C.Events.First(e => e.Id == id).From;
+ var output = new FakeOutput();
+ using var ui = new UiTestKit();
+ using var nav = new ScreenNav(ui.Root);
+ using var card = new EventCardPresenter(ui.Root, bridge, En, null);
+ using var audio = new GameAudio(bridge, card, Fake, output);
+ var layer = ui.Q<VisualElement>("event-layer");
+ Assert.IsNull(card.Shown, "no card was already visible when audio subscribed");
+ Assert.AreEqual(0, output.Played.Count);
+ nav.Toggle("settings");
+ Assert.AreEqual("settings", nav.Current);
+ Assert.IsFalse(layer.enabledInHierarchy, "Settings really covers the event layer");
+ bridge.Session.State.PendingEvents.Add(id);
+ card.Render();
+ Assert.AreEqual(id, card.Shown?.Id);
+ Assert.IsFalse(card.Collapsed);
+ Assert.IsFalse(layer.enabledInHierarchy, "rendering retains the Settings cover");
+ var coveredCount = output.Played.Count;
+ Assert.IsTrue(nav.Close());
+ Assert.IsNull(nav.Current);
+ Assert.IsTrue(layer.enabledInHierarchy, "closing Settings uncovers the pending card");
+ Assert.AreEqual(id, card.Shown?.Id);
+ var firstVisibleCount = output.Played.Count;
+ card.Render();
+ var repeatedCount = output.Played.Count;
+ TestContext.WriteLine($"COVERED_CARD cue counts covered={coveredCount} firstVisible={firstVisibleCount} repeated={repeatedCount}");
+ Assert.AreEqual(0, coveredCount, "a card covered by Settings has not come into view");
+ Assert.AreEqual(1, firstVisibleCount, "the first uncovered view sounds once");
+ Assert.AreEqual(1, repeatedCount, "another render does not replay the cue");
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.EventCard), 1f) }, output.Played);
+ }
+
+ [Test]
+ public void ACardHiddenInACaptureRunMakesNoSound()
+ {
+ var id = C.Events.First(e => e.Options.Count > 0).Id;
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var ui = new UiTestKit();
+ using var card = new EventCardPresenter(ui.Root, bridge, En, null, hiddenInCapture: true);
+ using var audio = new GameAudio(bridge, card, Fake, output);
+ bridge.Session.State.PendingEvents.Add(id);
+ card.Render();
+ Assert.AreEqual(0, output.Played.Count);
+ }
+
+ [Test]
+ public void ACardUnderTheStartScreenMakesNoSound()
+ {
+ var id = C.Events.First(e => e.Options.Count > 0).Id;
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var ui = new UiTestKit();
+ using var card = new EventCardPresenter(ui.Root, bridge, En, null, underStartScreen: true);
+ using var audio = new GameAudio(bridge, card, Fake, output);
+ bridge.Session.State.PendingEvents.Add(id);
+ card.Render();
+ Assert.AreEqual(0, output.Played.Count, "not heard until the start screen closes (and the browser has had a gesture)");
+ }
+
+ [Test]
+ public void VolumeZeroIsSilentAndLowIsQuieter()
+ {
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var audio = new GameAudio(bridge, null, Fake, output);
+ audio.Volume = 0f;
+ bridge.EndTurn();
+ bridge.Queue(new ChooseEventOption("no_such_event", "a"));
+ Assert.AreEqual(0, output.Played.Count, "volume 0 plays nothing");
+ audio.Volume = 0.35f;
+ bridge.EndTurn();
+ CollectionAssert.AreEqual(new[] { (PathOf(GameAudio.Cue.TurnEnded), 0.35f) }, output.Played);
+ }
+
+ [Test]
+ public void AMissingClipPlaysNothingAndBreaksNothing()
+ {
+ var bridge = NoEvent();
+ var output = new FakeOutput();
+ using var audio = new GameAudio(bridge, null, _ => null, output);
+ Assert.DoesNotThrow(() => bridge.EndTurn());
+ Assert.DoesNotThrow(() => bridge.Queue(new ChooseEventOption("no_such_event", "a")));
+ Assert.AreEqual(0, output.Played.Count);
+ }
+
+ [Test]
+ public void EveryCueHasAShippedClipThatIsSmall()
+ {
+ foreach (GameAudio.Cue cue in System.Enum.GetValues(typeof(GameAudio.Cue)))
+ {
+ var clip = Resources.Load<AudioClip>(PathOf(cue));
+ Assert.IsNotNull(clip, cue + ": Resources/" + PathOf(cue));
+ Assert.Less(clip.length, 1f, cue + ": a short effect");
+ Assert.IsTrue(clip.preloadAudioData, cue + ": loaded with the scene, so the first cue is not late (the web decodes asynchronously)");
+ var file = Directory.GetFiles(Path.Combine(Application.dataPath, "Resources", GameAudio.Folder), GameAudio.Files[cue] + ".*")
+ .Single(f => !f.EndsWith(".meta"));
+ Assert.Less(new FileInfo(file).Length, 16 * 1024, cue + ": " + file + " stays small (WebGL download)");
+ }
+ }
+
+ [Test]
+ public void TheSoundOptionSetsTheVolumeAtOnceAndSurvivesAReload([Values(false, true)] bool hebrew)
+ {
+ var text = hebrew ? He : En;
+ var bridge = NoEvent();
+ using (var ui = new UiTestKit())
+ using (var audio = new GameAudio(bridge, null, Fake, new FakeOutput()))
+ using (new SettingsPresenter(ui.Root, text, new SettingsStore(dir), audio: audio))
+ {
+ Assert.AreEqual(1f, audio.Volume, "full by default, with no file");
+ Assert.AreEqual(text["settings.sound"], ui.Q<Label>("settings-sound-label").text);
+ foreach (var level in new[] { "off", "low", "high" })
+ Assert.AreEqual(text["settings.sound." + level], ui.Q<Button>("settings-sound-" + level).text);
+ Assert.IsTrue(ui.Q<Button>("settings-sound-high").ClassListContains(SettingsPresenter.SelectedClass));
+ UiTestKit.Press(ui.Q<Button>("settings-sound-off"));
+ Assert.AreEqual(0f, audio.Volume, "off at once");
+ Assert.IsTrue(ui.Q<Button>("settings-sound-off").ClassListContains(SettingsPresenter.SelectedClass));
+ Assert.IsFalse(ui.Q<Button>("settings-sound-high").ClassListContains(SettingsPresenter.SelectedClass));
+ UiTestKit.Press(ui.Q<Button>("settings-sound-low"));
+ Assert.AreEqual(0.35f, audio.Volume, 1e-6f);
+ }
+ using (var ui = new UiTestKit())
+ using (var audio = new GameAudio(bridge, null, Fake, new FakeOutput()))
+ using (new SettingsPresenter(ui.Root, text, new SettingsStore(dir), audio: audio))
+ {
+ Assert.AreEqual(0.35f, audio.Volume, 1e-6f, "the stored choice is applied at the next start");
+ Assert.IsTrue(ui.Q<Button>("settings-sound-low").ClassListContains(SettingsPresenter.SelectedClass));
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/GameAudioTests.cs.meta b/unity/Assets/Tests/EditMode/GameAudioTests.cs.meta
new file mode 100644
index 000000000..86ffa8ffd
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/GameAudioTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: cf64492ab5414e4b685db658afac3832
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index a5ea59b48..3def73a9f 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -290,6 +290,8 @@ public class HebrewUiTests
("nav-settings", "hud.nav.settings"), ("settings-screen-title", "settings.title"), ("settings-tiltshift-label", "settings.tiltshift"),
("settings-quality-label", "settings.quality"), ("settings-quality-auto", "settings.quality.auto"),
("settings-quality-high", "settings.quality.high"), ("settings-quality-low", "settings.quality.low"),
+ ("settings-sound-label", "settings.sound"), ("settings-sound-off", "settings.sound.off"),
+ ("settings-sound-low", "settings.sound.low"), ("settings-sound-high", "settings.sound.high"),
("settings-language-label", "settings.language"), ("settings-language-note", "settings.language.note"),
("settings-uiscale-label", "settings.uiscale"),
("start-source", "start.source"), ("start-recording-credit", "start.recording_credit"),
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 4d515e0f7..2f9bd5213 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -340,6 +340,15 @@
<ui:Button name="settings-quality-low" text="Low" class="settings-switch" />
</ui:VisualElement>
</ui:VisualElement>
+ <!-- Sound effects (#39, GameAudio): three volume steps, the one that is set carries .settings-choice-selected. -->
+ <ui:VisualElement class="row settings-row">
+ <ui:Label name="settings-sound-label" text="Sound effects" class="settings-name" />
+ <ui:VisualElement class="row settings-choices">
+ <ui:Button name="settings-sound-off" text="Off" class="settings-switch" />
+ <ui:Button name="settings-sound-low" text="Low" class="settings-switch" />
+ <ui:Button name="settings-sound-high" text="High" class="settings-switch" />
+ </ui:VisualElement>
+ </ui:VisualElement>
<!-- The UI's language (#1036): SettingsPresenter names each language in itself; the one in use carries .settings-choice-selected. -->
<ui:VisualElement class="row settings-row">
<ui:Label name="settings-language-label" text="Language" class="settings-name" />
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 8ecdea32b..1762248f5 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -71,6 +71,11 @@ settings.quality: "Quality"
settings.quality.auto: "Automatic"
settings.quality.high: "High"
settings.quality.low: "Low"
+# The sound effects' volume (#39, GameAudio), in three steps.
+settings.sound: "Sound effects"
+settings.sound.off: "Off"
+settings.sound.low: "Low"
+settings.sound.high: "High"
# The language choice (#1036). The two languages are named on their buttons in themselves ("English", "עברית"), set in
# SettingsPresenter, not here. The note says what is not translated yet (#55).
settings.language: "Language"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 00d42f0da..d6f6dc0d5 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -65,6 +65,12 @@ settings.quality: "איכות גרפית"
settings.quality.auto: "אוטומטית"
settings.quality.high: "גבוהה"
settings.quality.low: "נמוכה"
+# The sound effects' volume (#39, GameAudio), in three steps. Singular, as the native reviewer (Beri) chose on
+# 19 Oct 2026. For the native reviewer (#564).
+settings.sound: "צליל"
+settings.sound.off: "כבוי"
+settings.sound.low: "חלש"
+settings.sound.high: "חזק"
# The language choice (#1036); the languages' names are on their buttons, in themselves (SettingsPresenter). The note
# says that the event cards are not translated yet (#55). For the native reviewer (#564).
settings.language: "שפה"