SOURCE / PINNED RELEASE
Made of little things.
Underwatch Rescue Run
- Release
- 316517df5dea…
- Author-recorded commit
- Not provided
- License
- Check the original source
The hash-verified playable HTML, which may contain bundled or minified code. This view does not execute it.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Underwatch Rescue Run</title>
<meta name="description" content="Get Brakka through three dungeon fights. Keep her alive with one tonic, one training scroll and one charm.">
<link rel="canonical" href="https://underwatch-the-hollow.dchilds64.chatgpt.site/rescue-run.html">
<meta property="og:type" content="website">
<meta property="og:title" content="Underwatch Rescue Run">
<meta property="og:description" content="Three fights, three supplies. Get Brakka to the stairs.">
<meta property="og:image" content="https://underwatch-the-hollow.dchilds64.chatgpt.site/assets/rescue-run-preview.jpg">
<link rel="icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSI+CiAgPHBhdGggZmlsbD0iIzI0MTczNCIgc3Ryb2tlPSIjNjI0Mzg2IiBkPSJNMjAgMS41IDM4LjUgMjAgMjAgMzguNSAxLjUgMjB6Ii8+CiAgPHBhdGggc3Ryb2tlPSIjYjU4Y2U5IiBzdHJva2Utd2lkdGg9IjEuNiIgZD0iTTguNSAyMHM0LjktNiAxMS41LTYgMTEuNSA2IDExLjUgNi00LjkgNi0xMS41IDYtMTEuNS02LTExLjUtNloiLz4KICA8cGF0aCBmaWxsPSIjZGZjOWZmIiBkPSJtMjAgMTUuNSAzLjcgNC41LTMuNyA0LjUtMy43LTQuNXoiLz4KICA8cGF0aCBzdHJva2U9IiNhMzc4ZGYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgZD0iTTIwIDh2M20wIDE4djMiLz4KPC9zdmc+Cg==" type="image/svg+xml">
<meta name="napplet-id" content="underwatch-rescue-run">
<style>
:root {
color-scheme: dark;
--bg: #100d17;
--panel: #191424;
--border: #31263e;
--text: #f0e9f5;
--muted: #aca0b7;
--soft: #857690;
--accent: #c6a2f4;
--accent-deep: #9460d1;
--green: #76d9ae;
--serif: Georgia, 'Times New Roman', serif;
--mono: 'Cascadia Mono', Consolas, monospace;
font: 15px/1.5 'Segoe UI', system-ui, sans-serif;
background: var(--bg);
color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 300px; background: radial-gradient(ellipse at 47% 4%, #1c1329 0, transparent 56%); }
button, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .54; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid #d8b4ff; outline-offset: 3px; }
button, select, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, ol { margin: 0; }
svg { vertical-align: middle; display: inline-block; flex-shrink: 0; }
.wrap { width: min(calc(100% - 72px), 1328px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; }
.mono { font-family: var(--mono); }
.site-head { border-bottom: 1px solid #2c2237; background: #110e19f5; }
.head-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 24px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: .11em; white-space: nowrap; }
.wordmark img { flex: 0 0 auto; }
.head-inner nav { display: flex; gap: 34px; align-self: stretch; }
.head-inner nav a { display: grid; place-items: center; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; padding: 2px 1px 0; }
.head-inner nav a:hover, .head-inner nav .current { color: var(--text); }
.head-inner nav .current { border-bottom-color: #ba88f5; }
.wallet { display: flex; align-items: center; gap: 7px; border: 1px solid #4b3564; background: #241833; padding: 7px 12px; border-radius: 6px; color: #d4b3fb; font-size: 12px; white-space: nowrap; }
.wallet:hover { background: #38244c; }
.wallet strong { color: #f1ddff; }
.wallet svg { width: 15px; height: 15px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: #d6b5ff; font: 650 11px/1.5 var(--mono); letter-spacing: .18em; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.run-wrap { width: min(calc(100% - 32px), 870px); margin-inline: auto; }
.run-main { padding-block: clamp(24px, 4vw, 48px); font-size: 16px; }
.run-heading { margin-bottom: 20px; }
.run-heading h1 { font: 400 clamp(2.6rem, 7vw, 4.6rem)/1 var(--serif); letter-spacing: -.05em; margin-bottom: 10px; }
.run-heading p, #room-story { color: #d3c6dd; }
.run-panel { border-color: #483458; }
.run-room { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 18px; }
.run-room h2 { font: 400 clamp(1.55rem, 4vw, 2rem)/1.1 var(--serif); margin-block: 4px 8px; }
.run-room .eyebrow { font-size: .82rem; }
.run-hp { min-width: max-content; color: #ffadc1; font: 700 1.15rem/1.2 var(--mono); font-variant-numeric: tabular-nums; }
#run-canvas { display: block; width: 100%; height: auto; aspect-ratio: 30 / 11; background: #181022; border-block: 1px solid #3e2b50; }
.run-interaction { min-height: 172px; padding: 16px 18px 20px; }
.run-warning { color: #ebcfef; }
.run-status { color: #ffe0b4; font-weight: 650; }
.run-status:not(:empty) { margin-block: 8px 12px; }
.run-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.run-choices button, .run-actions button, .run-secondary { min-height: 44px; padding: 9px 11px; border: 1px solid #71508c; border-radius: 6px; background: #34234a; }
.run-choices button { display: grid; align-content: start; gap: 3px; text-align: left; }
.run-choices button span { font-size: .9rem; line-height: 1.35; color: #e3cfee; }
.run-choices button:not(:disabled):hover, .run-actions button:hover, .run-secondary:hover { background: #513567; }
.run-choices button:disabled { opacity: .6; }
.run-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.run-actions button { background: #52326e; font-weight: 650; }
.run-secondary { display: inline-flex; align-items: center; }
@media (max-width: 630px) {
.run-wrap.head-inner { gap: 10px; }
.run-wrap.head-inner nav { gap: 12px; }
.run-wrap .wordmark { font-size: 15px; letter-spacing: .04em; }
.run-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.run-room, .run-interaction { padding-inline: 12px; }
}
#open-live-address { width: 100%; padding: 8px; font: inherit; }
</style>
</head>
<body>
<header class="site-head">
<div class="run-wrap head-inner">
<a class="wordmark" href="https://underwatch-the-hollow.dchilds64.chatgpt.site/?from=gamegrid" target="_blank" rel="noopener" data-open-underwatch><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSI+CiAgPHBhdGggZmlsbD0iIzI0MTczNCIgc3Ryb2tlPSIjNjI0Mzg2IiBkPSJNMjAgMS41IDM4LjUgMjAgMjAgMzguNSAxLjUgMjB6Ii8+CiAgPHBhdGggc3Ryb2tlPSIjYjU4Y2U5IiBzdHJva2Utd2lkdGg9IjEuNiIgZD0iTTguNSAyMHM0LjktNiAxMS41LTYgMTEuNSA2IDExLjUgNi00LjkgNi0xMS41IDYtMTEuNS02LTExLjUtNloiLz4KICA8cGF0aCBmaWxsPSIjZGZjOWZmIiBkPSJtMjAgMTUuNSAzLjcgNC41LTMuNyA0LjUtMy43LTQuNXoiLz4KICA8cGF0aCBzdHJva2U9IiNhMzc4ZGYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgZD0iTTIwIDh2M20wIDE4djMiLz4KPC9zdmc+Cg==" width="26" height="26" alt=""> Underwatch</a>
<nav aria-label="Main navigation">
<a href="https://underwatch-the-hollow.dchilds64.chatgpt.site/daily-rescue.html?from=gamegrid" target="_blank" rel="noopener" data-open-underwatch>Daily Rescue</a>
<a href="https://underwatch-the-hollow.dchilds64.chatgpt.site/?watch=fight&from=gamegrid" target="_blank" rel="noopener" data-open-underwatch>Live dungeon</a>
</nav>
</div>
</header>
<main class="run-wrap run-main">
<header class="run-heading">
<h1>Rescue Run</h1>
<p>Get Brakka out of the Hollow. Her health and unused supplies carry through all three fights.</p>
</header>
<section class="panel run-panel" aria-labelledby="room-title">
<div class="run-room">
<div>
<p class="eyebrow" id="room-number"></p>
<h2 id="room-title" tabindex="-1">The Toll Gate</h2>
<p id="room-story"></p>
</div>
<p class="run-hp" id="run-health" aria-label="Brakka’s health"></p>
</div>
<canvas id="run-canvas" width="900" height="330" role="img" aria-label="Brakka faces the next enemy. The warning and outcome appear below the map."></canvas>
<div class="run-interaction">
<p class="run-warning" id="run-warning"></p>
<p id="run-status" class="run-status" role="status" aria-live="polite"></p>
<div class="run-choices" id="run-choices" role="group" aria-label="Choose one supply or save them for later">
<button type="button" data-gift="tonic" disabled><strong>Vitality tonic</strong><span>Restore up to 30 HP.</span></button>
<button type="button" data-gift="training" disabled><strong>Field training</strong><span>Gain 7 HP and 2 attack this room.</span></button>
<button type="button" data-gift="relic" disabled><strong>Runeforged charm</strong><span>Gain 8 HP and 3 attack this room.</span></button>
<button type="button" data-gift="hold" disabled><strong>Save supplies</strong><span>Let Brakka face this fight unaided.</span></button>
</div>
<div class="run-actions" id="run-actions" hidden>
<button type="button" id="run-next"></button>
<a class="run-secondary" id="run-watch" href="https://underwatch-the-hollow.dchilds64.chatgpt.site/?watch=fight&from=gamegrid" target="_blank" rel="noopener" data-open-underwatch hidden>Watch a live fight</a>
</div>
<noscript>Enable JavaScript to play Rescue Run.</noscript>
</div>
</section>
<div class="run-interaction" id="open-live-fallback" hidden><p id="open-live-notice" role="status"></p>
<input id="open-live-address" aria-label="Underwatch address" readonly></div>
</main>
<script>
(()=>{function ke(){return()=>{}}var b=[{id:"brakka",name:"Brakka Ironhand",role:"Warrior",style:"Bold",color:"#f1a16f",hp:110,attack:16,bio:"A forge guard who volunteered after her crew vanished below. She takes the first hit and remembers who stood beside her."},{id:"nyx",name:"Nyx the Unlucky",role:"Rogue",style:"Opportunist",color:"#75dfc3",hp:85,attack:14,bio:"A lockpicker with a talent for opening the wrong door. She eyes every supply cache, especially the ones someone else reached first."},{id:"vesper",name:"Vesper Hollow",role:"Mystic",style:"Cautious",color:"#bf9cf7",hp:90,attack:18,bio:"The only contestant who heard the Hollow calling by name. Behind a mask of bronze, he weighs every fight against the way out."},{id:"rook",name:"Rook Gamble",role:"Rogue",style:"Opportunist",color:"#efd17c",hp:85,attack:14,bio:"A cardsharp who treats every room like a wager. A good supply cache can make him forget which side he was on."},{id:"kestrel",name:"Kestrel Vane",role:"Warrior",style:"Loyal",color:"#8fb8f6",hp:105,attack:15,bio:"A caravan sentinel on his last tour. He gets between danger and an ally whenever he can reach them."},{id:"ilyra",name:"Ilyra of Ash",role:"Mystic",style:"Bold",color:"#ac9be8",hp:90,attack:17,bio:"An apprentice exorcist collecting proof that the Hollow can be killed. She prefers a decisive blow to a safe retreat."},{id:"sable",name:"Sable Renn",role:"Rogue",style:"Cautious",color:"#ed8a9c",hp:85,attack:15,bio:"A courier who crossed the salt desert alone. She keeps a clear route to the stairs and trusts anyone who shares their last tonic."},{id:"moss",name:"Moss Flint",role:"Warrior",style:"Loyal",color:"#a3d598",hp:105,attack:15,bio:"A veteran of the deep roads. He watches the wounded and would rather spend a tonic than leave someone behind."}],C=[{name:"The Gatehouse",color:"#a07be8",exit:[23,2]},{name:"The Drowned Vault",color:"#62a8cb",exit:[2,11]},{name:"The Bone Orchard",color:"#8fb481",exit:[23,11]},{name:"The Cinder Court",color:"#ce8c66",exit:[2,2]},{name:"The Hollow Heart",color:"#cc71ac",exit:[23,2]}],J=[{id:"tonic",title:"Vitality tonic",desc:"Restore up to 30 health immediately.",cost:2,icon:"tonic"},{id:"training",title:"Field training",desc:"Grant 45 XP toward the next level.",cost:3,icon:"level"},{id:"relic",title:"Runeforged charm",desc:"Add 3 attack and 8 maximum health.",cost:5,icon:"diamond"}],je=[[1,1,6,5],[9,1,15,4],[19,1,24,5],[2,8,8,12],[11,7,16,12],[20,8,24,12]],z=Array.from({length:14},()=>Array(26).fill(!1));function Re(e,t,o,a){for(let n=t;n<=a;n++)for(let i=e;i<=o;i++)z[n][i]=!0}for(let e of je)Re(...e);for(let e of[[6,3,9,3],[15,2,19,2],[4,5,4,8],[12,4,12,7],[22,5,22,8],[8,10,11,10],[16,9,20,9]])Re(...e);var Q=C.map((e,t)=>z.map((o,a)=>o.map((n,i)=>z[t%2?14-a-1:a][t===2||t===3?26-i-1:i])));function F(e){return Q[e.floor]}var k=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),V=e=>e.interval??3600,Te=e=>V(e)===3600;function Me([e,t]){return{x:e,y:t}}function A([e,t],o){return{x:o===2||o===3?26-e-1:e,y:o%2?14-t-1:t}}function B(e){return e.seed=Math.imul(e.seed,1664525)+1013904223>>>0,e.seed/4294967296}function w(e,t,o,a=[],n=1){let i={id:++e.eventId,kind:t,text:o,people:a,weight:n,time:e.clock,floor:e.floor};if(e.events.unshift(i),e.events.length=Math.min(e.events.length,96),n>=2)for(let s of e.agents.filter(l=>a.includes(l.id)))s.memories=[i,...s.memories??[]].slice(0,8)}var q=[[4,3],[10,3],[13,8],[6,10],[4,10],[14,3],[21,11],[20,3]],$e=[{kind:"wraith",name:"Rift Wraith",hp:48,attack:12},{kind:"maw",name:"Stone Maw",hp:66,attack:16}];function D(e,t,o){let a=$e[t],n=a.hp+e.floor*11,i={...a,...o,hp:n,maxHp:n,id:`enemy-${++e.enemyId}`,attack:a.attack+e.floor*2};e.monsters.push(i),e.frame?.floor===e.floor&&e.frame.turn===e.turn&&$(e,{type:"spawn",unit:ge(i)})}function xe(e){e.turn=0,e.monsters=[],e.caches=[[2,4],[14,2],[3,11],[15,11],[23,10]].map((t,o)=>({...A(t,e.floor),loot:["tonic","blade","tonic","ward","tonic"][o]}));for(let[t,o]of e.agents.entries())o.hp&&(Object.assign(o,A(q[t],e.floor)),o.hp=Math.min(o.maxHp,o.hp+(e.floor?23:0)),o.escaped=!1,o.goal=null,o.activity="Exploring");D(e,0,A([11,2],e.floor)),D(e,1,A([15,9],e.floor)),D(e,0,A([22,10],e.floor)),w(e,"floor",`${C[e.floor].name} is open. ${e.agents.filter(t=>t.hp).length} crawlers enter.`,[],3)}function Ce(e,t=1,o=(e^e/4294967296)>>>0,a=[],n=12e3){let i={version:1,number:t,clock:e,interval:n,seed:o,floor:0,turn:0,enemyId:0,completed:!1,eventId:0,events:[],recaps:[],history:a,agents:b.map((s,l)=>({id:s.id,index:l,hp:s.hp,maxHp:s.hp,attack:s.attack,level:1,xp:0,tonic:l%2===0?1:0,gear:[],relationships:{},kills:0,sponsoredFloor:-1}))};return xe(i),i}function He(e,{x:t,y:o}){return[[t+1,o],[t-1,o],[t,o+1],[t,o-1]].filter(([a,n])=>e[n]?.[a]).map(Me)}function Xe(e,t,o){let a=t.y*26+t.x,n=o.y*26+o.x;if(a===n)return null;let i=Ve.get(e);if(!i[n]){let f=new Int16Array(364).fill(-1),r=[n];f[n]=0;for(let c=0;c<r.length;c++){let d=r[c];for(let h of we.get(e)[d])f[h]===-1&&(f[h]=f[d]+1,r.push(h))}i[n]=f}let s=i[n],l=we.get(e)[a].find(f=>s[f]>=0&&s[f]<s[a]);return l===void 0?null:{x:l%26,y:Math.floor(l/26)}}var we=new Map(Q.map(e=>[e,e.flatMap((t,o)=>t.map((a,n)=>a?He(e,{x:n,y:o}).map(i=>i.y*26+i.x):[]))])),Ve=new Map(Q.map(e=>[e,Array(364)]));function $(e,t){e.frame?.time===e.clock&&e.frame.actions.push(t)}function ge(e,t){return{id:e.id??t,x:e.x,y:e.y,hp:e.hp,maxHp:e.maxHp??e.hp,index:e.index,kind:e.kind,escaped:e.escaped,direction:e.direction}}function Ye(e){e.enemyId??=0;for(let o of e.monsters)o.id??=`enemy-${++e.enemyId}`,o.maxHp??=($e.find(a=>a.kind===o.kind)?.hp??o.hp)+e.floor*11;let t=U(e);e.frame={floor:e.floor,turn:e.turn,time:e.clock,units:[...e.agents.filter(o=>o.hp),...e.monsters].map(o=>ge(o)),caches:e.caches.map(o=>({...o})),threat:t?{actor:t.monster.id,target:t.crawler.id}:null,actions:[]}}function Ae(e,t,o,a){t.direction=Math.atan2(o.y-t.y,o.x-t.x),Object.assign(t,o),$(e,{type:a,actor:t.id,x:o.x,y:o.y})}function j(e,t,o,a){let n=Xe(F(e),t,o);return n&&Ae(e,t,n,a&&k(a,t)<=1&&k(a,n)>1?"dodge":"walk"),!!n}function X(e,t,o){t.xp+=o,!(t.xp<be(t))&&(t.xp-=be(t),t.level++,t.maxHp+=7,t.hp=Math.min(t.maxHp,t.hp+7),t.attack+=2,w(e,"level",`${b[t.index].name} reached level ${t.level}.`,[t.id],3))}function be(e){return 25+e.level*15}function ee(e,t,o){let a=Math.max(-4,Math.min(4,(e.relationships[t.id]??0)+o));e.relationships[t.id]=a,t.relationships[e.id]=a}function Se(e,t,o=t){t.tonic--;let a=o.hp;o.hp=Math.min(o.maxHp,o.hp+24),$(e,{type:"heal",actor:t.id,target:o.id,hp:o.hp,amount:o.hp-a});let n=b[t.index].name;if(t===o){t.activity="Recovering",w(e,"loot",`${n} drank a tonic and recovered health.`,[t.id]);return}t.activity="Helping an ally",ee(t,o,2),w(e,"bond",`${n} shared a tonic with ${b[o.index].name}.`,[t.id,o.id],3)}function Ze(e,t,o,a){let n=t.attack+Math.floor(B(e)*7);t.direction=Math.atan2(o.y-t.y,o.x-t.x),o.hp=Math.max(0,o.hp-n),$(e,{type:"strike",actor:t.id,target:o.id,x:o.x,y:o.y,damage:n,hp:o.hp}),t.activity="In combat";let i=b[t.index].name;if(o.hp){w(e,"combat",`${i} struck a ${o.name} for ${n} damage.`,[t.id]);return}if(t.kills++,w(e,"combat",`${i} defeated a ${o.name}.`,[t.id],3),o.windup){let l=b.find(f=>f.id===o.windup.crawler);w(e,"outcome",`${i} stopped the ${o.name} before it could strike ${l.name}.`,[...new Set([l.id,t.id])],5)}X(e,t,24);let s=a.find(l=>k(t,l)<=2);if(s){let l=t.relationships[s.id]??0;ee(t,s,1),l===1&&w(e,"bond",`${i} and ${b[s.index].name} formed an alliance.`,[t.id,s.id],3),X(e,s,9)}}function Ke(e,t,o,a){let n;o.loot==="tonic"&&(n="a vitality tonic",t.tonic++),o.loot==="blade"&&(n="a glassblade",t.attack+=2,t.gear.push("Glassblade")),o.loot==="ward"&&(n="a stoneward",t.maxHp+=6,t.hp+=6,t.gear.push("Stoneward"));let i=a.find(l=>l.goal&&k(l.goal,o)===0&&k(l,o)<=2),s=b[t.index].name;i&&b[t.index].style==="Opportunist"?(ee(t,i,-2),w(e,"bond",`${s} snatched ${n} from under ${b[i.index].name}\u2019s nose.`,[t.id,i.id],3)):w(e,"loot",`${s} recovered ${n} from a supply cache.`,[t.id],2),e.caches.splice(e.caches.indexOf(o),1),$(e,{type:"loot",actor:t.id,x:o.x,y:o.y}),X(e,t,13),t.goal=null,t.activity="Scavenging"}function ze(e,t){let o=e.agents.filter(c=>c!==t&&c.hp&&!c.escaped),{name:a,style:n}=b[t.index];if(t.tonic&&t.hp<=t.maxHp*.52)return Se(e,t);let i=o.find(c=>k(t,c)<=2&&c.hp<c.maxHp*.5&&(n==="Loyal"||t.relationships[c.id]>=2));if(t.tonic&&i)return Se(e,t,i);let s=Me(C[e.floor].exit);if(e.turn>=22||e.turn>=15&&t.hp<t.maxHp*.35){let c=e.monsters.find(d=>d.windup?.crawler===t.id);for(let d=0;d<2;d++)j(e,t,s,c);if(t.activity="Heading to exit",k(t,s)===0){if(e.turn<22&&!Te(e)){t.activity="At the locked stairs";return}t.escaped=!0,$(e,{type:"exit",actor:t.id}),t.activity="Reached exit",w(e,"floor",`${a} reached the exit.`,[t.id],2)}return}let f=e.monsters.filter(c=>c.hp).sort((c,d)=>k(t,c)-k(t,d))[0];if(n==="Cautious"&&f&&k(t,f)<=2&&t.hp<t.maxHp*.42){let c=He(F(e),t).find(d=>k(d,f)>k(t,f));if(c){Ae(e,t,c,"dodge"),t.activity="Retreating";return}}if(f&&k(t,f)<=1)return Ze(e,t,f,o);let r=e.caches.slice().sort((c,d)=>k(t,c)-k(t,d))[0];if(r&&k(t,r)===0)return Ke(e,t,r,o);if(f&&k(t,f)<=(n==="Bold"?11:4)&&(n==="Bold"||!r||k(t,r)>=4)){t.activity="Hunting",j(e,t,f);return}r&&(n==="Opportunist"||k(t,r)<11)?t.goal=r:(!t.goal||!F(e)[t.goal.y]?.[t.goal.x]||k(t,t.goal)<=1||e.turn%6===0)&&(t.goal=A(q[Math.floor(B(e)*q.length)],e.floor)),t.activity="Exploring",j(e,t,t.goal)}function U(e){if(e.completed)return null;for(let t of e.monsters){if(!t.hp||!t.windup)continue;let o=e.agents.find(a=>a.id===t.windup.crawler&&a.hp&&!a.escaped);if(o)return{monster:t,crawler:o,damage:t.windup.damage,at:e.clock+(t.windup.turn-e.turn)*V(e)}}return null}function ve(e,t,o,a,n){t.direction=Math.atan2(o.y-t.y,o.x-t.x),o.hp=Math.max(0,o.hp-a),$(e,{type:"strike",actor:t.id,target:o.id,x:o.x,y:o.y,damage:a,hp:o.hp,heavy:!!n});let i=b[o.index].name;if(!o.hp)o.activity="Fallen",w(e,"fallen",n?`The ${t.name}\u2019s charged strike felled ${i}.`:`${i} fell to a ${t.name}.`,[o.id],5);else if(n){let s=n.giftHp?`A sponsor restored ${n.giftHp} HP before the blow. `:"";w(e,"outcome",`${s}${i} took the ${t.name}\u2019s strike and held on with ${o.hp} HP.`,[o.id],5)}else w(e,"combat",`A ${t.name} hit ${i} for ${a} damage.`,[o.id])}function Je(e){let t=e.agents.filter(o=>o.hp&&!o.escaped);for(let o of e.monsters){if(!o.hp)continue;if(o.windup){let s=o.windup,l=t.find(f=>f.id===s.crawler&&f.hp);if(!l){delete o.windup;continue}if(e.turn<s.turn)continue;delete o.windup,k(o,l)<=1?ve(e,o,l,s.damage,s):($(e,{type:"strike",actor:o.id,target:l.id,x:s.x??l.x,y:s.y??l.y,heavy:!0,missed:!0}),w(e,"outcome",`${b[l.index].name} stepped clear. The ${o.name}\u2019s strike missed.`,[l.id],5));continue}t.sort((s,l)=>k(o,s)-k(o,l)||s.hp-l.hp);let a=t.find(s=>s.hp);if(!a)break;let n=k(o,a);if(n>1){n<=10&&j(e,o,a);continue}if(!Te(e)&&e.turn<34&&!e.monsters.some(s=>s.windup)&&e.turn>=(o.chargeAfter??0)&&(o.kind==="maw"||a.hp<=o.attack+8)){let s=o.attack+(o.kind==="maw"?12:8);o.windup={crawler:a.id,x:a.x,y:a.y,turn:e.turn+2,damage:s},o.direction=Math.atan2(a.y-o.y,a.x-o.x),o.chargeAfter=e.turn+7,$(e,{type:"charge",actor:o.id,target:a.id}),w(e,"danger",`The ${o.name} takes aim at ${b[a.index].name}. A ${s}-damage strike is coming.`,[a.id],4);continue}ve(e,o,a,o.attack+Math.floor(B(e)*5))}}function Qe(e){for(let a of e.agents)!a.hp||a.escaped||(a.hp=0,$(e,{type:"fall",actor:a.id}),a.activity="Fallen",w(e,"fallen",`${b[a.index].name} was trapped when the floor sealed.`,[a.id],4));let t=e.agents.filter(a=>a.hp).map(a=>b[a.index].name),o=e.events.filter(a=>a.floor===e.floor&&a.weight>=2&&a.people.length).sort((a,n)=>n.weight-a.weight||n.id-a.id).slice(0,4).sort((a,n)=>a.id-n.id);if(e.recaps.push({floor:e.floor,survivors:t,highlights:o}),!t.length||e.floor===C.length-1){e.completed=!0,w(e,"floor",t.length?`${t.length} crawlers survived the Hollow.`:"The Hollow claimed every crawler. The season is over.",[],5);return}e.floor++,xe(e)}function Y(e){if(e.completed)return;e.clock+=V(e),e.turn++,Ye(e),e.turn===22&&w(e,"floor","The exit is open. Crawlers are making their last run for the stairs.",[],3);let t=e.agents.filter(a=>a.hp&&!a.escaped),o=Math.floor(B(e)*t.length);for(let a of[...t.slice(o),...t.slice(0,o)])ze(e,a);if(Je(e),e.monsters=e.monsters.filter(a=>a.hp),e.turn<21&&e.turn%7===0&&e.monsters.length<4){let a=A(q[Math.floor(B(e)*q.length)],e.floor);D(e,e.turn%2,a),w(e,"combat",`A ${e.monsters.at(-1).name} entered the floor.`)}(e.turn>=36||e.agents.every(a=>!a.hp||a.escaped))&&Qe(e),e.frame.actions.some(a=>a.type==="strike")&&(e.lastFight={...e.frame,actions:e.frame.actions.slice()})}function Ie(e,t){for(;!e.completed&&e.clock+V(e)<=t;)Y(e)}function et(e,t,o,a){return e.completed||!t.hp||t.escaped?"Unavailable on this floor":t.sponsoredFloor===e.floor?"Gift already delivered this floor":o.id==="tonic"&&t.hp===t.maxHp?"Health is already full":a===null?"Sign in to sponsor":a<o.cost?"Insufficient credits":""}function Le(e,t,o,a){if(et(e,t,o,a))return!1;t.sponsoredFloor=e.floor;let n=b[t.index].name;if(o.id==="tonic"){let i=Math.min(30,t.maxHp-t.hp);t.hp+=i;let s=e.monsters.find(l=>l.windup?.crawler===t.id);s&&(s.windup.giftHp=i),w(e,"support",`A sponsor restored ${i} HP to ${n} with a vitality tonic.`,[t.id],4)}else w(e,"support",`A sponsor sent ${n} ${o.id==="relic"?"a runeforged charm":"field training"}.`,[t.id],3);return o.id==="training"&&X(e,t,45),o.id==="relic"&&(t.attack+=3,t.maxHp+=8,t.hp+=8,t.gear.push(o.title)),!0}function v(e,t,o,a="#15101e",n=1){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let[i,s]of t.slice(1))e.lineTo(i,s);e.closePath(),e.fillStyle=o,e.fill(),a&&(e.strokeStyle=a,e.lineWidth=n,e.stroke())}function M(e,t,o,a,n,i){e.beginPath(),e.ellipse(t,o,a,n,0,0,Math.PI*2),e.fillStyle=i,e.fill()}function u(e,t,o,a,n,i,s){e.beginPath(),e.moveTo(t,o),e.lineTo(a,n),e.strokeStyle=i,e.lineWidth=s,e.lineCap="round",e.stroke()}var te=["#a97152","#ca9e79","#c0a276","#b67c58","#caa294","#c59177","#dfb3a1","#81523e"],tt="#bbb8c8";function ot(e,t,o,a,n){let{role:i,color:s}=b[t.index],l=i==="Warrior",f=i==="Mystic",r=l?8:6,c=f?"#33254d":l?"#383340":"#282430",d=Math.sin(n/670+t.index)*1.4-o,h=a?Math.sin(a*Math.PI)*8:0;v(e,[[-r,-23],[2,-21],[r+d,-2],[-3+d,1],[-r-4,-5]],c),v(e,[[-r,-22],[-4,-8],[-r-3,-5],[-r-1,-12]],s+"86",null);for(let R of[-1,1]){let g=R*o;u(e,R*3,-11,R*4+g,-3,"#15101c",5.2),u(e,R*3,-10,R*4+g,-3,l?"#666170":"#55475c",3.1),u(e,R*4+g,-2.4,R*4+g+3,-1.3,"#1c1821",3.8)}let y=e.createLinearGradient(-8,-20,9,-8);y.addColorStop(0,s),y.addColorStop(1,c),v(e,[[-r,-23],[r,-23],[6,-13],[3,-9],[-5,-10]],y),u(e,-5,-11,5,-11,"#2a1a21",2.7),M(e,1,-11,1.45,1.15,"#e7bf78"),l?(v(e,[[-8,-25],[-4,-24],[-4,-20],[-10,-19],[-11,-22]],tt),v(e,[[5,-25],[10,-24],[11,-20],[6,-19]],"#d3c5b7"),u(e,-4,-16,4,-18,"#d8c3a7",1.2)):(u(e,-5,-21,4,-15,s,1.8),M(e,-3,-16.5,1.2,1.2,"#d8bd84"));let p=r+2+h,S=-14-(a?Math.sin(a*Math.PI*1.5)*6:o*.55);if(u(e,-r+1,-20,-r-2-o*.4,-12,"#1a1521",4.6),u(e,r-1,-21,p,S,"#19111f",5.3),u(e,r-1,-21,p,S,s+"ce",3.4),M(e,p,S,2.1,1.8,te[t.index]),l&&(t.index===4||t.index===7)&&(v(e,[[-13,-17],[-7,-18],[-6,-11],[-9,-8],[-13,-11]],"#6c6777","#251e2b",1.5),u(e,-9.5,-16,-9.5,-11,s,1.6)),e.save(),e.translate(p+.5,S),e.rotate(a?-.95+a*2.75:f?.22:-.54),f)u(e,0,9,0,-13,"#613c37",2.1),u(e,0,5,0,-11,"#ad8265",.9),v(e,[[0,-19],[3,-15],[0,-10],[-3,-15]],s,"#e5caff"),M(e,0,-15,a?5:3.6,a?5:3.6,s+"39");else{let R=l?16:10;u(e,0,3,0,-3,"#75523e",2.4),u(e,-3,-3,3,-3,"#d1af7d",1.55),v(e,[[-1.35,-4],[0,-R],[1.55,-R+3],[1.45,-4]],"#f6e5d2","#5a4c5c",.85)}e.restore(),l?(M(e,0,-27,5.8,6.1,"#211a26"),M(e,1,-26,4.2,4.7,te[t.index]),v(e,[[-5,-31],[-1,-34],[5,-31],[5,-28],[1,-28],[-4,-26]],t.index===0?"#4d3033":"#8e879a"),u(e,1,-27.6,4,-27,"#422f38",.95)):(v(e,[[-6,-25],[-6,-30],[-2,-34],[2,-34],[6,-30],[6,-25],[2,-22],[-2,-22]],c),u(e,-4.5,-30,-1,-32.5,s,1.45),M(e,1.8,-27,3.3,3.65,t.index===2?"#a38568":te[t.index]),u(e,1,-28.2,4,-28.2,t.index===2?"#f4c4ff":"#34232b",1),v(e,[[-3,-25],[5,-25],[1,-22],[-3,-23]],s+"b3",null))}function at(e,t,o,a){let n=Math.sin(o/270+t.x),i=e.createLinearGradient(0,-33,0,1);i.addColorStop(0,"#cba7fa"),i.addColorStop(.47,"#794bac"),i.addColorStop(1,"#35205a35"),v(e,[[-8,-26],[-1,-34],[7,-30],[10,-21],[15+a,-15],[8,-12],[12+n,3],[4,-2],[1,-9],[-3,1],[-10+n,-3],[-8,-13],[-15,-11],[-11,-21]],i,"#3a245c"),v(e,[[-4,-27],[3,-29],[7,-24],[4,-19],[-2,-20]],"#261637",null),u(e,-1,-24.5,2,-24.5,"#f2cbff",1.7),u(e,4,-24.3,6,-24.1,"#f2cbff",1.5),u(e,7,-18,17+a,-15+n,"#b985e9",3.7),u(e,14+a,-14+n,19+a,-14+n,"#ecd1ff",1.15),M(e,1,-20,13,13,"#a26cde10")}function nt(e,t,o,a){for(let n of[-1,1]){let i=n*t;v(e,[[-12,-17],[-4,-16],[-7+i,-5],[-14+i,-3],[-15+i,-8]],"#514652","#211723"),v(e,[[5,-17],[10,-16],[16+i+o,-7],[12+i+o,-2],[7+i,-5]],"#78616a","#271822"),u(e,10+i+o,-4,15+i+o,-2,"#d2b8af",1.7)}v(e,[[-15,-17],[-14,-25],[-6,-32],[5,-32],[15,-27],[17,-18],[8,-12],[-9,-11]],"#665365","#251b2c",1.6),v(e,[[-11,-24],[-6,-32],[0,-33],[3,-25],[-4,-21]],"#9b7984","#513c51"),v(e,[[-2,-20],[5,-26],[13,-25],[15,-19],[8,-15],[1,-15]],"#7d6175","#342538"),v(e,[[7,-25],[12,-27],[20,-20],[20,-16],[11,-15],[6,-19]],"#9a7582","#40283b",1.4),v(e,[[11,-19],[20,-18],[18,-14],[11,-15]],"#301921",null),u(e,14,-21.4,18,-20.9,a?"#fff4b6":"#ff9a7c",a?2.6:1.8),u(e,7,-25,4,-20,a?"#ff5874":"#ae6975",1.6)}function oe(e,t,o,a,n,i){let s=t.pose,l=s?.progress??0,f=s?.type==="walk",r=s?.type==="dodge",c=s?.type==="fall",d=s?.type==="hit",h=s?.type==="strike"?l:0,y=Math.cos(t.direction??0)<-.15?-1:1,p=f||r?Math.sin(l*Math.PI*4)*(r?4.5:3.2):0,S=h?Math.sin(h*Math.PI)*(s.heavy?12:8):0,R=d?Math.sin(l*Math.PI)*5:0,g=d?s.direction:t.direction??0,De=t.kind==="wraith"?Math.sin(n/370+t.x)*2.7-4:f?-Math.abs(p)*.7:Math.sin(n/620+t.x)*.8;e.save(),e.globalAlpha*=(t.opacity??(t.escaped?.27:1))*(c?1-l*.69:1),M(e,o,a,t.kind==="maw"?18:12,4,"#090610a0"),e.translate(o+Math.cos(g)*(S+R),a+De+Math.sin(g)*(S+R)),e.scale(y,1),r?(e.rotate(.32*Math.sin(l*Math.PI)),e.scale(1.1,1-Math.sin(l*Math.PI)*.32)):c?e.rotate(l*1.26):i&&t.kind==="maw"&&e.scale(1.03,.92+Math.sin(n/170)*.02),t.kind==="wraith"?at(e,t,n,S*.75):t.kind==="maw"?nt(e,p,S*.72,i):ot(e,t,p,h,n),d&&l<.4&&M(e,0,-18,18*(.6+l),18,"#ff8e9b38"),e.restore()}function ae(e,t,o,a,n,i,s){let l=t.kind?t.kind==="maw"?"Stone Maw":"Rift Wraith":b[t.index].name.split(" ")[0],f=t.kind?"#ff94aa":b[t.index].color,r=t.hp*3<=t.maxHp;if(e.fillStyle="#140e1ce8",e.fillRect(o-11,a+4,22,3.4),e.fillStyle=r?"#ff8499":t.kind?"#ee8bab":"#82deb0",e.fillRect(o-10,a+5,20*Math.min(1,t.hp/t.maxHp),1.65),!i&&!s)return;let c=Math.max(7.5,11/n);e.font=`600 ${c}px system-ui`;let d=e.measureText(l).width+7,h=a-37-c;e.fillStyle="#1b1326ea",e.fillRect(o-d/2,h,d,c+4),e.strokeStyle=s?"#ef82a0":"#725d88",e.lineWidth=.7,e.strokeRect(o-d/2,h,d,c+4),e.textAlign="center",e.fillStyle=f,e.fillText(l,o,h+c)}function ne(e,t,o,a){let n=f=>(f+.5)*o,i=n(t.x),s=n(t.y),l=t.progress;if(e.save(),e.globalAlpha=(1-l)*.98,t.type==="trail")u(e,i+2,s-10,n(t.toX),n(t.toY)-10,"#b5e7f0",2.5),u(e,i-4,s-5,n(t.toX)-2,n(t.toY)-5,"#bea4ff",1.4);else{let f=t.type==="heal"?"#9df6c7":t.type==="miss"?"#c2dbff":"#ffd1a2";if(t.type!=="heal"){e.translate(i,s-10),e.rotate(t.direction),e.beginPath(),e.ellipse(1,0,(t.heavy?20:13)*(.5+l*.7),11,0,-1.1,1.1),e.strokeStyle=f,e.lineWidth=t.heavy?4:2.7,e.stroke(),e.rotate(-t.direction);for(let d=0;d<(t.heavy?8:5);d++){let h=d*2.347+t.direction,y=7+l*(17+d),p=Math.cos(h)*y,S=Math.sin(h)*y;u(e,p*.7,S*.7,p,S,f,1.4)}e.translate(-i,10-s)}else M(e,i,s-17,15+l*7,17,"#86f6bd55");let r=t.type==="miss"?"MISS":t.type==="heal"?`+${t.amount}`:`\u2212${t.amount}`;e.font=`800 ${Math.max(12,16/a)}px system-ui`,e.textAlign="center",e.strokeStyle="#211321",e.lineWidth=2.5;let c=s-36-l*17;e.strokeText(r,i,c),e.fillStyle=f,e.fillText(r,i,c)}e.restore()}var m=40,I=26*m,L=14*m,Oe=["#312c40","#332d43","#373148","#2c273a","#352f43","#3b344c"],Pe=["#3e344d","#443953","#3a3249","#41374f"];function Z(e,t,o=0){return((Math.imul(e+13,76157)^Math.imul(t+19,41843)^Math.imul(o,2351))>>>0)%97}function O(e,t,o,a,n){let i=e.createRadialGradient(t,o,2,t,o,a);i.addColorStop(0,n),i.addColorStop(1,"transparent"),e.fillStyle=i,e.fillRect(t-a,o-a,a*2,a*2)}function Ee(e,t,o,a,n,i){e.beginPath(),e.moveTo(t,o-a),e.lineTo(t+a,o),e.lineTo(t,o+a),e.lineTo(t-a,o),e.closePath(),e.fillStyle=n,e.fill(),e.strokeStyle=i,e.stroke()}function re(e){let t=document.createElement("canvas");t.width=I,t.height=L;let o=t.getContext("2d"),a=F({floor:e}),n=C[e].color,i=(r,c)=>a[c]?.[r];o.fillStyle="#100e18",o.fillRect(0,0,I,L),O(o,I*.55,L*.39,555,n+"15");for(let r=0;r<14;r++)for(let c=0;c<26;c++){let d=c*m,h=r*m,y=Z(c,r,e);if(i(c,r)){o.fillStyle=Oe[y%Oe.length],o.fillRect(d+1,h+1,m-2,m-2),o.fillStyle="#e6d2ff0a",o.fillRect(d+2,h+2,m-4,2);for(let p=0;p<13;p++){let S=Z(c+p,r,31)%36,R=Z(c,r+p,47)%36;o.fillStyle=p%2?"#08050b32":"#e6d2ff10",o.fillRect(d+2+S,h+2+R,1+p%3,1)}y%4===0&&(o.strokeStyle="#110d195f",o.beginPath(),o.moveTo(d+5,h+14),o.lineTo(d+14,h+17),o.lineTo(d+18,h+23),o.lineTo(d+29,h+22),o.stroke()),i(c,r-1)||(o.fillStyle="#0d091678",o.fillRect(d,h,m,11)),i(c+1,r)||(o.fillStyle="#110c1865",o.fillRect(d+m-6,h,6,m));continue}if(![i(c-1,r),i(c+1,r),i(c,r-1),i(c,r+1)].some(Boolean)){y%3===0&&(o.fillStyle="#40334f36",o.fillRect(d+y%18,h+y%22,5+y%11,2));continue}o.fillStyle="#16101f",o.fillRect(d,h+4,m,m-4);for(let p=0;p<2;p++){let S=p===0?5+y%10:20+y%9;o.fillStyle=Pe[(y+p)%Pe.length],o.fillRect(d+1,h+p*13,S,11),o.fillRect(d+S+3,h+p*13,m-S-4,11)}o.fillStyle="#8c72a452",o.fillRect(d+1,h,m-2,2),o.fillStyle="#221928",o.fillRect(d+1,h+25,m-2,5)}for(let[r,c]of[[1,1],[6,1],[9,1],[15,1],[19,1],[24,1],[2,8],[8,8],[11,7],[16,7],[20,8],[24,8]]){let d=((e===2||e===3?26-r-1:r)+.5)*m,h=((e%2?14-c-1:c)+.18)*m,p=Z(r,c)%3===0?n:"#d69661";O(o,d,h+5,77,p+"33"),O(o,d,h+1,28,p+"40"),o.fillStyle="#1a121e",o.fillRect(d-3,h+3,6,11),Ee(o,d,h,5,p,"#f4d4b0"),o.fillStyle="#ffead3",o.fillRect(d-1,h-1,2,3)}let[s,l]=C[e].exit.map(r=>(r+.5)*m);O(o,s,l,48,n+"51"),o.fillStyle="#191125",o.fillRect(s-14,l-15,28,30),o.strokeStyle=n+"a0",o.strokeRect(s-13.5,l-14.5,27,29);for(let r=0;r<5;r++)o.fillStyle=n+["44","55","68","80","a0"][r],o.fillRect(s-10,l-10+r*5,20,3);let f=o.createRadialGradient(I/2,L*.48,L/3,I/2,L*.48,I*.63);return f.addColorStop(0,"transparent"),f.addColorStop(1,"#09070d8c"),o.fillStyle=f,o.fillRect(0,0,I,L),t}function le(e,t,o){if(t.turn>=22&&!t.completed){let[a,n]=C[t.floor].exit.map(i=>(i+.5)*m);O(e,a,n,54,"#d3afff65"),e.strokeStyle="#d3afff",e.strokeRect(a-14,n-15,28,30)}if(t.threat){let a=t.units.get(t.threat.target),n=t.units.get(t.threat.actor),i=(a.x+.5)*m,s=(a.y+.5)*m,l=Math.sin(o/205);O(e,i,s,63,"#df5e7c50"),e.save(),e.strokeStyle="#ff9caa",e.lineWidth=1.6,e.globalAlpha=.7+l*.2,e.setLineDash([5,4]),e.beginPath(),e.moveTo((n.x+.5)*m,(n.y+.5)*m),e.lineTo(i,s),e.stroke(),e.setLineDash([]),e.beginPath(),e.ellipse(i,s+3,18+l*2,10+l,0,0,Math.PI*2),e.stroke(),e.restore()}for(let a of t.caches){let n=(a.x+.5)*m,i=(a.y+.5)*m;O(e,n,i,23,"#f8bd6344"),e.fillStyle="#39262a",e.fillRect(n-9,i-5,18,12),e.strokeStyle="#d3a15c",e.strokeRect(n-9,i-5,18,12),e.fillRect(n-9,i-3,18,4),e.strokeRect(n-9,i-3,18,4),Ee(e,n,i+.5,3,"#ffe1a0","#9b7257")}}var st={walk:590,dodge:440,strike:760,heal:650,charge:430,loot:340,exit:510,spawn:650,fall:680},N=.49;function Fe(e){let t=new Map,o=0,a=0,n=e.actions.map(i=>{let s=[i.actor??i.unit?.id,i.target].filter(Boolean),l=Math.max(o,...s.map(r=>t.get(r)??0)),f=i.heavy?960:st[i.type];for(let r of s)t.set(r,l+f);return o=l+115,a=Math.max(a,l+f),{...i,start:l,span:f}});return{frame:e,actions:n,duration:a}}var ce=e=>Math.min(1,Math.max(0,e)),de=e=>e*e*(3-2*e);function fe(e,t){let{frame:o,actions:a}=e,n=new Map(o.units.map(r=>[r.id,{...r}])),i=o.caches,s=o.threat,l,f=[];for(let r of a){if(t<r.start)break;let c=ce((t-r.start)/r.span),d=n.get(r.actor),h=n.get(r.target);if(r.type==="spawn"){n.set(r.unit.id,{...r.unit,opacity:de(c)});continue}if(d)switch(r.type){case"walk":case"dodge":{let y=d.x,p=d.y,S=Math.atan2(r.y-p,r.x-y),R=r.type==="dodge"?1-(1-c)**3:de(c);d.x+=(r.x-y)*R,d.y+=(r.y-p)*R,d.direction=S,d.pose=c<1?{type:r.type,progress:c}:null,r.type==="dodge"&&c<1&&f.push({type:"trail",x:y,y:p,toX:d.x,toY:d.y,progress:c});break}case"charge":s={actor:r.actor,target:r.target},h&&(d.direction=Math.atan2(h.y-d.y,h.x-d.x));break;case"strike":{let y=Math.atan2(r.y-d.y,r.x-d.x);d.direction=y,d.pose=c<1?{type:"strike",progress:c,heavy:r.heavy,against:{x:r.x,y:r.y}}:null,c<1&&(!l||r.heavy)&&(l={actor:r.actor,target:r.target}),c>=N&&(r.heavy&&(s=null),h&&!r.missed&&(h.hp=r.hp,h.pose={type:r.hp?"hit":"fall",direction:y,progress:ce((c-N)/(1-N))}),c<1&&f.push({type:r.missed?"miss":"impact",x:r.x,y:r.y,amount:r.damage,direction:y,progress:ce((c-N)/(1-N)),heavy:r.heavy}));break}case"heal":h&&c>=.35&&(h.hp=r.hp,c<1&&f.push({type:"heal",x:h.x,y:h.y,amount:r.amount,progress:c}));break;case"loot":c>=.55&&(i=i.filter(y=>y.x!==r.x||y.y!==r.y));break;case"exit":d.opacity=1-de(c)*.82,c===1&&(d.escaped=!0);break;case"fall":d.hp=0,d.pose={type:"fall",direction:0,progress:c};break}}return s&&(!n.get(s.actor)?.hp||!n.get(s.target)?.hp||n.get(s.target)?.escaped)&&(s=null),{floor:o.floor,turn:o.turn,units:n,caches:i,threat:s,effects:f,focus:l}}var rt={survive:"Keep Brakka alive through the strike.",train:"Reach level 2 and survive the strike.",stop:"Defeat the Stone Maw before it can strike."},Tt=Object.keys(rt);function Be({seed:e=1,hp:t=24,attack:o=16}={}){let a=Ce(0,1,e),[n,...i]=a.agents;Object.assign(n,{x:4,y:3,hp:t,tonic:0});for(let s of i)s.hp=0;return a.monsters=[{x:5,y:3,hp:200,maxHp:200,kind:"maw",name:"Stone Maw",attack:o}],Y(a),a}function he(e,t){let o=U(e),a=structuredClone(e),n=a.agents[0],i=n.hp;t&&Le(a,n,t,t.cost);let s=n.hp-i;Y(a);let l=a.frame;Ie(a,o.at),a.frame!==l&&l.actions.push(...a.frame.actions),s&&(l.units.find(r=>r.id===n.id).hp=i,l.actions.unshift({type:"heal",actor:n.id,target:n.id,hp:i+s,amount:s}));let f=a.monsters.find(r=>r.id===o.monster.id);return{playback:Fe(l),hp:n.hp,restoredHp:s,level:n.level,mawHp:f?.hp??0}}var qe=35,_=[{name:"The Toll Gate",enemy:"Rift Wraith",kind:"wraith",hp:55,attack:9,seed:9,story:"The watch bell below goes quiet. Brakka takes the passage alone."},{name:"The Broken Bridge",enemy:"Stone Maw",kind:"maw",hp:38,attack:21,seed:18,story:"The bridge will hold for one crossing. A Stone Maw blocks the way."},{name:"The Last Door",enemy:"Stone Maw",kind:"maw",hp:48,attack:36,seed:31,story:"There is light through the door. One more strike stands between Brakka and the stairs."}];function Ue(e,t){let o=_[e],a=Be({seed:o.seed,hp:t,attack:o.attack}),n=U(a);Object.assign(n.monster,{name:o.enemy,kind:o.kind,hp:o.hp,maxHp:o.hp});let i=he(a);return{room:o,hp:t,incoming:n.damage,baseDamage:o.hp-i.mawHp,playback:i.playback,resolve:s=>s?he(a,s):i}}var T=e=>document.getElementById(e),W=T("run-canvas"),H=W.getContext("2d"),lt=re(0),K=T("run-choices"),me=[...K.querySelectorAll("button")],ct=me.map(e=>e.querySelector("span").textContent),pe=T("run-next"),dt=matchMedia("(prefers-reduced-motion: reduce)"),ye=ke();document.querySelectorAll("[data-carry-source]");function Ne(){document.hidden||ye("view")}document.addEventListener("visibilitychange",Ne);Ne();var E,x,ue,P,G;function _e(e,t){let o=fe(e,t),a=4;H.setTransform(1,0,0,1,0,0),H.clearRect(0,0,W.width,W.height),H.setTransform(a,0,0,a,W.width/2-5*m*a,W.height*.64-3.5*m*a),H.drawImage(lt,0,0),le(H,o,t);for(let n of o.units.values()){if(!n.hp&&n.pose?.type!=="fall")continue;let i=(n.x+.5)*m,s=(n.y+.5)*m+5;oe(H,n,i,s,t,o.threat?.actor===n.id),n.hp&&ae(H,n,i,s,a,!0,o.threat?.actor===n.id)}for(let n of o.effects)ne(H,n,m,a)}function We(e){P=Ue(E,x);let{room:t,incoming:o,baseDamage:a}=P;T("room-number").textContent=`Room ${E+1} of ${_.length}`,T("room-title").textContent=t.name,T("room-story").textContent=t.story,T("run-health").textContent=`${x} HP`,T("run-warning").textContent=`The ${t.enemy} has ${t.hp} HP and is winding up a ${o}-damage hit. Brakka\u2019s two attacks deal ${a} damage without a supply.`,T("run-warning").hidden=!1,T("run-status").textContent="",T("run-actions").hidden=!0,K.hidden=!1;for(let[n,i]of me.entries()){let s=ue.has(i.dataset.gift);i.disabled=s,i.querySelector("span").textContent=s?"Already used":ct[n]}_e(P.playback,0),e&&T("room-title").focus({preventScroll:!0})}function Ge(e=!1){E=0,x=qe,ue=new Set,G=!1,We(e)}function ft(e,t){x=e.hp;let o=x>0&&E===_.length-1;G=x===0||o,T("run-health").textContent=`${x} HP`,T("run-warning").hidden=!0;let a=x===0?`Brakka fell at ${P.room.name}.`:e.mawHp?`Brakka took the hit and made it through with ${x} HP.`:`Brakka stopped the ${P.room.enemy} before the hit. She has ${x} HP left.`;T("run-status").textContent=o?`${a} She reached the stairs.`:a,o&&t&&ye("run-clear"),K.hidden=!0,T("run-watch").hidden=!G,pe.textContent=G?"Play again":`Enter ${_[E+1].name.toLowerCase()}`,T("run-actions").hidden=!1,pe.focus({preventScroll:!0})}K.addEventListener("click",e=>{let t=e.target.closest("button[data-gift]");if(!t||t.disabled)return;let o=e.isTrusted,a=J.find(l=>l.id===t.dataset.gift);a&&ue.add(a.id);for(let l of me)l.disabled=!0;o&&ye("run-start"),T("run-status").textContent=a?`${a.title} sent. The enemy swings soon.`:"Brakka saves her supplies and faces the fight.";let n=P.resolve(a),i=performance.now();function s(l){let{duration:f}=n.playback,r=dt.matches?f:Math.min(f,l-i);_e(n.playback,r),r<f?requestAnimationFrame(s):ft(n,o)}requestAnimationFrame(s)});pe.addEventListener("click",()=>{G?Ge(!0):(E+=1,We(!0))});Ge();})();
const notice = document.getElementById('open-live-notice');
const address = document.getElementById('open-live-address');
const fallback = document.getElementById('open-live-fallback');
for (const anchor of document.querySelectorAll('a[data-open-underwatch]')) {
anchor.addEventListener('click', async event => {
if (window === window.top) return;
event.preventDefault();
fallback.hidden = true;
notice.textContent = '';
try {
const result = await window.napplet?.link?.open(anchor.href, { label: anchor.textContent.trim() });
if (result?.status === 'opened') return;
} catch { /* The host decides which links it opens. */ }
notice.textContent = 'Copy this address to open Underwatch in your browser.';
fallback.hidden = false;
address.value = anchor.href;
address.focus();
address.select();
});
}
</script>
</body>
</html>
