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.

6.0 KB
Raw Blame
<!DOCTYPE html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
    <title>{{{ PRODUCT_NAME }}}</title>
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <style>
      html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #0e1626; }
      #unity-canvas { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: #0e1626; display: block; }
      #loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #ece4d2;
                 font: 20px Georgia, "Times New Roman", serif; text-align: center; }
      #bar { width: 320px; height: 4px; margin-top: 12px; border: 1px solid #c4a05c; }
      #fill { width: 0; height: 100%; background: #c4a05c; }
      #error { display: none; position: fixed; left: 10%; right: 10%; top: 40%; color: #de7868; background: #0e1626;
               border: 1px solid #c4a05c; padding: 16px; font: 16px Georgia, serif; white-space: pre-wrap; }
      /* Issue #1119: the read-only companion is in the page from load, hidden: it is opt-in, and off keeps it out of the
         accessibility tree. WebCompanion.jslib shows and styles it once the game publishes, and writes its first status
         in a later task, so the status region is in the tree before its first announcement. */
      body:not(.has-companion) #companion { position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip-path: inset(50%); white-space: nowrap; }
    </style>
  </head>
  <body>
    <canvas id="unity-canvas" tabindex="-1"></canvas>
    <div id="loading">Statecraft: Israel<div id="bar"><div id="fill"></div></div></div>
    <div id="error"></div>
    <aside id="companion" aria-labelledby="companion-heading" tabindex="-1" dir="auto" hidden>
      <h2 id="companion-heading" dir="auto"></h2>
      <p id="companion-help" dir="auto"></p>
      <section id="companion-event" dir="auto">
        <h3 id="companion-title" dir="auto"></h3>
        <div id="companion-body" dir="auto"></div>
        <div id="companion-choice-group" dir="auto">
          <h3 id="companion-choice-heading" dir="auto"></h3>
          <ol id="companion-choices" dir="auto"></ol>
        </div>
      </section>
      <h3 id="companion-focus-heading" dir="auto"></h3>
      <p id="companion-focus" dir="auto"></p>
      <h3 id="companion-status-heading" dir="auto"></h3>
      <p id="companion-status" role="status" aria-atomic="true" dir="auto"></p>
      <section id="companion-report" dir="auto">
        <h3 id="companion-report-title" dir="auto"></h3>
        <div id="companion-report-rows" dir="auto"></div>
      </section>
    </aside>
    <script>
      // Full-window canvas: Unity keeps the render size matched to the canvas's CSS size, so the UI Toolkit panel
      // (ScaleWithScreenSize, 1920x1080, match 0.5) rescales on every browser resize.
      var loaderUrl = "Build/{{{ LOADER_FILENAME }}}";
      var config = {
        arguments: [],
        dataUrl: "Build/{{{ DATA_FILENAME }}}",
        frameworkUrl: "Build/{{{ FRAMEWORK_FILENAME }}}",
#if USE_THREADS
        workerUrl: "Build/{{{ WORKER_FILENAME }}}",
#endif
#if USE_WASM
        codeUrl: "Build/{{{ CODE_FILENAME }}}",
#endif
#if SYMBOLS_FILENAME
        symbolsUrl: "Build/{{{ SYMBOLS_FILENAME }}}",
#endif
        streamingAssetsUrl: "StreamingAssets",
        companyName: {{{ JSON.stringify(COMPANY_NAME) }}},
        productName: {{{ JSON.stringify(PRODUCT_NAME) }}},
        productVersion: {{{ JSON.stringify(PRODUCT_VERSION) }}},
        // Queue IndexedDB persistence when a file under /idbfs closes; completion is asynchronous.
        // GameStart's save receipt observes that commit, without starting a concurrent manual sync.
        autoSyncPersistentDataPath: true,
      };
      // Issue #437: the Build/ files are named by their content hash, and this page names its build's files. A browser may
      // show this page from its cache after a newer build replaced them (a server that sends no Cache-Control, such as
      // python3 -m http.server, lets it), so ask the server for the current page and load the files that one names. The
      // fetch skips the cache and stores the copy it gets ("reload"), so the next visit runs the current page. When it
      // fails (file://, offline, or not this template), keep this page's own names.
      var FRESH_KEYS = ["loaderUrl", "dataUrl", "frameworkUrl", "workerUrl", "codeUrl", "symbolsUrl"];
      function useCurrentPage(html) {
        var found = {};
        FRESH_KEYS.forEach(function (key) {
          var m = html.match(new RegExp("\\b" + key + '\\s*[:=]\\s*"(Build/[^"]+)"'));
          if (m) found[key] = m[1];
        });
        if (!found.loaderUrl || !found.dataUrl) return;
        loaderUrl = found.loaderUrl;
        FRESH_KEYS.slice(1).forEach(function (key) {
          if (found[key]) config[key] = found[key]; else delete config[key];
        });
      }
      function fail(message) {
        var e = document.getElementById("error");
        e.textContent = "Statecraft could not start:\n" + message;
        e.style.display = "block";
        console.error("BOOT FAIL " + message);
      }
      function start() {
        var script = document.createElement("script");
        script.src = loaderUrl;
        script.onerror = function () { fail("could not load " + loaderUrl); };
        script.onload = function () {
          createUnityInstance(document.querySelector("#unity-canvas"), config, function (progress) {
            document.getElementById("fill").style.width = (100 * progress) + "%";
          }).then(function () {
            document.getElementById("loading").style.display = "none";
          }).catch(fail);
        };
        document.body.appendChild(script);
      }
      fetch(location.href.split("#")[0], { cache: "reload" })
        .then(function (r) { return r.ok ? r.text() : ""; })
        .then(useCurrentPage)
        .catch(function () {})
        .then(start);
    </script>
  </body>
</html>