@vimp-games/snakes 0.15.9 → 0.15.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -18
- package/README.md +7 -210
- package/dist/assets/{vimp_snakes_core_bg-p5kW2YDJ.wasm → vimp_snakes_core_bg-Ycx_0IaJ.wasm} +0 -0
- package/dist/{client-BdR-RXPs.js → client-BrlV_OCM.js} +2 -2
- package/dist/core-node/package.json +0 -1
- package/dist/core-node/vimp_snakes_core_bg.wasm +0 -0
- package/dist/{host-D5F6iyyS.js → host-henEezm8.js} +1 -1
- package/dist/manifest.json +4 -4
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) 2026 lgick. All rights reserved.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
VIMP Snakes — its source code, assets and documentation — is proprietary.
|
|
4
|
+
No part of it may be copied, modified, distributed or used without the prior
|
|
5
|
+
written permission of the copyright holder.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
7
|
+
The published npm package `@vimp-games/snakes` may be downloaded and executed
|
|
8
|
+
unmodified as part of the VIMP platform.
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
10
|
+
Third-party materials, if any, remain under their own licenses.
|
package/README.md
CHANGED
|
@@ -1,219 +1,16 @@
|
|
|
1
1
|
# VIMP Snakes
|
|
2
2
|
|
|
3
|
-
A VIMP game plugin (`@vimp-games/snakes`): a snake arena.
|
|
4
|
-
|
|
5
|
-
## The game
|
|
6
|
-
|
|
7
3
|
One circular arena. Snakes are always moving; you steer, you never stop.
|
|
8
4
|
Crystals appear at random in three sizes — eat them to grow, and the bigger the
|
|
9
5
|
crystal the more you grow and the more you score.
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
| --------- | ----------------------------------------------------------------------------- |
|
|
13
|
-
| `A` / `D` | turn left / right |
|
|
14
|
-
| `W` | boost — nearly double speed, paid for in crystals, which drop behind you |
|
|
15
|
-
| `R` | respawn after a crash (the OK button of the result screen presses it for you) |
|
|
16
|
-
|
|
17
|
-
Mouse and touch are the second way to play, and the only one a phone has:
|
|
18
|
-
**press and hold** — the snake turns towards the point under the pointer, no
|
|
19
|
-
faster than the keys would turn it; **double tap and keep holding** — boost,
|
|
20
|
-
for as long as the finger stays down. Releasing hands the snake back to
|
|
21
|
-
whatever heading it had, and taking hold of `A`/`D` cancels the pointer
|
|
22
|
-
target. The channel is muted while the chat or the stat table is open, so
|
|
23
|
-
typing a message never steers the snake.
|
|
24
|
-
|
|
25
|
-
Three ways it ends and only one of them is your fault:
|
|
26
|
-
|
|
27
|
-
- your head touches the boundary of the disc — you crash;
|
|
28
|
-
- your head runs into **another** snake **in front of you** — you crash, and
|
|
29
|
-
everything you were carrying scatters over the map where you died. The
|
|
30
|
-
crash is only ever the one who drove into it: a snake that swings into you
|
|
31
|
-
from the side or from behind takes itself out and leaves you alone (two
|
|
32
|
-
snakes that meet head on are both driving into each other, and both die);
|
|
33
|
-
- your head touches **your own** tail — nothing happens, it passes over.
|
|
34
|
-
|
|
35
|
-
One number follows you and a crash does not reset it: **score** — the crystals
|
|
36
|
-
you have eaten plus a flat **15** per snake that ran into you. The victim keeps
|
|
37
|
-
its own score; what it was carrying scatters on the map for whoever gets there
|
|
38
|
-
first, so killing the leader is still worth it, just not twice. The HUD shows
|
|
39
|
-
the score alone; what you are carrying right now is told by the size of your
|
|
40
|
-
snake. A kill is also worth a point of **rank**, the number `/rank` reports and
|
|
41
|
-
the one that survives the session.
|
|
42
|
-
|
|
43
|
-
The first two seconds of a life are yours: a fresh snake appears whole — body
|
|
44
|
-
and all, not a head that has to grow one — stands still and blinks, kills
|
|
45
|
-
nobody and cannot be killed. Long enough to read the arena, and
|
|
46
|
-
long enough for whoever was flying at that spot to steer around you.
|
|
47
|
-
|
|
48
|
-
The heavier you get the wider you steer: 3.4 rad/s empty, falling with the
|
|
49
|
-
square root of the crystals down to a floor of 1.4. A leader stays steerable
|
|
50
|
-
and stops being nimble — the fastest snake in the arena is a small one.
|
|
51
|
-
|
|
52
|
-
One life is one game: the score of a crashed life is its result, and `Tab`
|
|
53
|
-
shows the game's global daily top ten — the best single game of the day
|
|
54
|
-
across every server — rather than this room. The top ten of the day wears a
|
|
55
|
-
diamond pattern down the body, the top ten of the month a crown. Everyone is a
|
|
56
|
-
player: there are no teams, no spectators and nothing to vote on.
|
|
57
|
-
|
|
58
|
-
## Run it
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
npm install
|
|
62
|
-
npm run core:build # REQUIRED before npm run dev
|
|
63
|
-
npm run dev
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
`npm run core:build` is not optional and not a later step: the dev harness
|
|
67
|
-
(`dev/main.js`) imports the wasm out of `core/pkg-web/`, so until the Rust core
|
|
68
|
-
has been built once Vite fails to resolve the import and `npm run dev` dies on
|
|
69
|
-
startup. The same holds before the master is started against this package,
|
|
70
|
-
even in dev mode — build the core and then `npm run build` at least once.
|
|
71
|
-
|
|
72
|
-
### In the lobby, against another player
|
|
73
|
-
|
|
74
|
-
`npm run dev` is a single tab against bots. To play this game through the
|
|
75
|
-
lobby master (two tabs, a real room), link both halves and start the master
|
|
76
|
-
from the engine checkout:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# once, in this package and in ~/Sites/my/vimp-tanks
|
|
80
|
-
npm link
|
|
81
|
-
|
|
82
|
-
# once, in the engine checkout — BOTH games in ONE command, or the second
|
|
83
|
-
# link overwrites the first
|
|
84
|
-
cd ~/Sites/my/vimp
|
|
85
|
-
npm link @vimp-games/tanks @vimp-games/snakes
|
|
86
|
-
|
|
87
|
-
npm run dev # master on https://localhost:3002
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
The master builds its game catalog from `node_modules/@vimp-games/*` when
|
|
91
|
-
`GAMES_MATRIX` is unset, sorted by id — so `snakes` comes first and is the
|
|
92
|
-
lobby's **active** game, which is what makes the `Create server` button
|
|
93
|
-
clickable (the lobby can only host the active game). To pin a different one,
|
|
94
|
-
start the master with the catalog spelled out:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
GAMES_MATRIX='[{"id":"tanks","package":"@vimp-games/tanks"}]' npm run dev
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
This package must be built (`npm run core:build && npm run build`) before the
|
|
101
|
-
master starts: the catalog reads `dist/manifest.json`, not the sources.
|
|
102
|
-
|
|
103
|
-
## Commands
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npm run core:build # wasm-pack -> core/pkg-web (runtime) + core/pkg-node (tests)
|
|
107
|
-
npm run core:test # cargo test --workspace, including the motion parity suite
|
|
108
|
-
npm run build # dist/: both bundles, maps, sounds, manifest.json
|
|
109
|
-
npm run check:contract # static engine<->game contract check (vimp-contract)
|
|
110
|
-
npm test # vitest
|
|
111
|
-
npm run dev # a match against bots in the tab
|
|
112
|
-
npm run audio:process # ffmpeg: assets/audio-raw/ -> build/sounds/ (optional)
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
The headless runner lives in the engine checkout and is the primary
|
|
116
|
-
verification loop — see `scenarios/` below.
|
|
117
|
-
|
|
118
|
-
## Layout
|
|
119
|
-
|
|
120
|
-
| Path | What |
|
|
121
|
-
| ------------- | ---------------------------------------------------------------- |
|
|
122
|
-
| `core/` | the Rust crate `vimp-snakes-core` — movement, growth, collisions |
|
|
123
|
-
| `src/host/` | HostPlugin: runs in a Web Worker, no DOM and no PixiJS |
|
|
124
|
-
| `src/client/` | ClientPlugin: render parts, bakers and the result screen |
|
|
125
|
-
| `src/config/` | game, client, auth, snapshot and sound configuration |
|
|
126
|
-
| `src/data/` | the map, the snake model, the palette and the arena theme |
|
|
127
|
-
| `scenarios/` | headless scenarios for `npm run sim` |
|
|
128
|
-
| `scripts/` | build steps: bundles -> `dist/` + `manifest.json` |
|
|
129
|
-
| `dev/` | the standalone dev harness — never published |
|
|
130
|
-
|
|
131
|
-
Only `dist/` is published (`files: ["dist"]`).
|
|
132
|
-
|
|
133
|
-
## Three decisions worth knowing before reading the code
|
|
134
|
-
|
|
135
|
-
**The core owns life and death; the engine is never told.** No
|
|
136
|
-
`CoreEvent::Death` is ever emitted. That is what makes the round endless (a
|
|
137
|
-
round only ends through a reported kill) and what makes respawning possible at
|
|
138
|
-
all (the engine has no per-player respawn inside a round — its only spawn
|
|
139
|
-
primitive is private to `_startRound`). The consequence is that the engine also
|
|
140
|
-
never writes `score` or `deaths`, which is why `src/host/StatBridge.js` keeps
|
|
141
|
-
the whole scoring model instead — eaten, kills and score, per game id — off the
|
|
142
|
-
core's `custom` events. See the note atop `src/config/game.js`.
|
|
143
|
-
|
|
144
|
-
**There is no physics.** A snake is a polyline; the arena edge, other bodies
|
|
145
|
-
and crystals are distance tests. The engine's Rapier world is stepped and stays
|
|
146
|
-
empty. That is what makes the client's prediction exact — the predictor runs
|
|
147
|
-
the same `core/src/motion.rs` the host does, with no solver in between to
|
|
148
|
-
disagree about.
|
|
149
|
-
|
|
150
|
-
**The arena is derived, not configured.** The `game` half of the init JSON is a
|
|
151
|
-
fixed field set, and a free-form `gameConfig.parts.*` key reaches the client and
|
|
152
|
-
never the core — so the disc comes out of the map grid by one formula both
|
|
153
|
-
halves apply (`core/src/arena.rs`, `src/client/parts/Arena.js`,
|
|
154
|
-
`src/data/maps/arena.js`).
|
|
155
|
-
|
|
156
|
-
**The arena grows with the crowd.** The area per snake is the difficulty curve,
|
|
157
|
-
so the grid is a function of how many are in the room: `buildArena(count)` in
|
|
158
|
-
`src/data/maps/arena.js` owns the law, `src/host/ArenaScaler.js` owns when it
|
|
159
|
-
applies, and the core's `population` custom event is what triggers it. The
|
|
160
|
-
resize is a `coreAdapter.createMap` plus a MAP_DATA re-send, not an engine map
|
|
161
|
-
change: the round, the panel and the stat table survive it untouched.
|
|
162
|
-
|
|
163
|
-
## Headless verification
|
|
164
|
-
|
|
165
|
-
From the **engine** checkout, with this package linked:
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
npm run sim -- --game <path to vimp-snakes> --scenario <path>/scenarios/movement.json
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
| Scenario | Exercises |
|
|
172
|
-
| ------------------------ | ------------------------------------------------------------------------------------------------- |
|
|
173
|
-
| `movement.json` | cruising and turning, with prediction drift checked against tight thresholds |
|
|
174
|
-
| `crash-and-respawn.json` | driving into the boundary, staying dead, the respawn key |
|
|
175
|
-
| `growth.json` | two players, three bots, crystals, the boost, `/bot` |
|
|
176
|
-
| `pointer.json` | steering to a point with the mouse/finger, the keyboard taking over mid-run, the double-tap boost |
|
|
177
|
-
| `bots.json` | `/bot <count>` as a SET: six bots, then two, then a refused count, then none |
|
|
178
|
-
|
|
179
|
-
All five are expected to pass with `--determinism`.
|
|
180
|
-
The sim runs the **built** plugin (`dist/`), so `npm run build` before it or
|
|
181
|
-
you are testing the previous version. Two invariants skip by
|
|
182
|
-
design: `roundLifecycle` (this game has no round end) and, in two of the four
|
|
183
|
-
scenarios, `predictionDrift` (a crash and a respawn are legitimate one-off
|
|
184
|
-
spikes — `movement.json` and `pointer.json` are the two that watch for drift
|
|
185
|
-
that _grows_).
|
|
186
|
-
|
|
187
|
-
## Sounds without ffmpeg
|
|
188
|
-
|
|
189
|
-
The real pipeline is `assets/audio-raw/*.wav` → `npm run audio:process` →
|
|
190
|
-
`build/sounds/*.{webm,mp3}`. That needs ffmpeg, so the package also ships
|
|
191
|
-
ready-made placeholders in `assets/sounds/`: when `build/sounds/` is absent,
|
|
192
|
-
`scripts/copy-game-sounds.js` falls back to them and the first build stays green
|
|
193
|
-
on a bare machine. The two cues are `pickup` and `death`, both played
|
|
194
|
-
positionally by `src/client/parts/Snake.js`.
|
|
195
|
-
|
|
196
|
-
## Documentation
|
|
197
|
-
|
|
198
|
-
Full documentation lives in [docs/en/](docs/en/README.md):
|
|
199
|
-
|
|
200
|
-
- [Local setup](docs/en/getting-started.md)
|
|
201
|
-
- [Architecture](docs/en/architecture.md)
|
|
202
|
-
- [Gameplay](docs/en/gameplay.md)
|
|
203
|
-
- [Rust core](docs/en/core.md)
|
|
204
|
-
- [Configuration](docs/en/configuration.md)
|
|
205
|
-
- [Extending the game (models, tiers, sounds, parts)](docs/en/extending.md)
|
|
206
|
-
|
|
207
|
-
[Русская версия](docs/ru/README.md)
|
|
208
|
-
|
|
209
|
-
For engine-side concepts (transport, master server, plugin contract), see the
|
|
210
|
-
engine's own docs:
|
|
211
|
-
[vimp-engine/docs/en/](https://github.com/lgick/vimp-engine/blob/main/docs/en/README.md).
|
|
7
|
+
Play it at <https://vimp.lgick.dev/#/snakes>.
|
|
212
8
|
|
|
213
|
-
|
|
9
|
+
- one endless round on a circular arena that grows with the crowd;
|
|
10
|
+
- a Rust simulation core compiled to WASM, PixiJS rendering, positional audio;
|
|
11
|
+
- published as `@vimp-games/snakes`: a game plugin the VIMP engine loads at
|
|
12
|
+
runtime.
|
|
214
13
|
|
|
215
|
-
|
|
216
|
-
`vimp-engine` in `package.json` and `vimp-engine-core` in `Cargo.toml`.
|
|
14
|
+
Build your own game: <https://docs.vimp.lgick.dev>.
|
|
217
15
|
|
|
218
|
-
|
|
219
|
-
under `docs/ai/`.
|
|
16
|
+
Development notes live in `docs/en/README.md` of the game's repository.
|
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{Container as H,Graphics as P,Sprite as _e,Rectangle as le}from"pixi.js";const ge=4,we='#panel-score:before{content:"★ ";color:#ffd76b}#panel-crystals,#panel-dead,#panel-mode,#panel-time{display:none!important}#stat .stat-leaderboard{padding:12px 0;font:400 16px/1.6 system-ui,sans-serif;color:#e6ecf5}#stat .stat-leaderboard .stat-row{grid-template-columns:3.5em 1fr 5.5em;gap:0 12px;padding:4px 16px;border-radius:6px}#stat .stat-leaderboard .stat-row span:first-child,#stat .stat-leaderboard .stat-row span:last-child{font-variant-numeric:tabular-nums;text-align:right}#stat .stat-leaderboard .stat-row span:first-child{opacity:.6}#stat .stat-leaderboard .stat-row span:last-child{font-weight:700;color:#ffd76b}#stat .stat-leaderboard .stat-row span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#stat .stat-leaderboard .is-self{background:#3ab7ff2e;color:#7ef9ff}#snakes-gameover{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#060a149e;font:400 16px/1.5 system-ui,sans-serif;color:#e6ecf5}#snakes-gameover[hidden]{display:none}.snakes-gameover-card{min-width:260px;padding:28px 32px;border:1px solid #39507f;border-radius:12px;background:#141c30;box-shadow:0 18px 48px #00000073;text-align:center}.snakes-gameover-card h2{margin:0 0 4px;font-size:22px;font-weight:600;letter-spacing:.02em}.snakes-gameover-score{margin:0 0 6px;opacity:.75}.snakes-gameover-total{margin:0 0 22px;font-size:15px;letter-spacing:.02em;opacity:.6}.snakes-gameover-total span{font-weight:700;color:#ffd76b}.snakes-gameover-score span{font-size:40px;font-weight:700;color:#7ef9ff;vertical-align:-2px}.snakes-gameover-card button{min-width:120px;padding:10px 20px;border:0;border-radius:8px;background:#3ab7ff;color:#06182a;font:inherit;font-weight:600;cursor:pointer}.snakes-gameover-card button:hover,.snakes-gameover-card button:focus-visible{background:#7ed0ff}',be={background:856608,floor:1317936,edge:3756159,edgeWidth:10,rings:4,ringColor:1911111},m={innerScale:.62,innerDarken:.55,smoothing:4,eye:16251903,pupil:1054760,boostGlow:16771466,accolade:{diamondEvery:1.6,diamondLong:.9,diamondWide:.55,inkDark:1054760,inkLight:16645631,diamondStroke:.18,crownScale:1.9,crownLift:.44,crownTint:16766827,crownOutline:1054760,crownOutlineScale:1.16}},me=.5;class ye extends H{constructor(e){super(),this.zIndex=0,!(Array.isArray(e)||e.type==="dynamic")&&this._draw(e)}_draw({map:e,step:t}){const n=e.length,a=(e[0]?.length??0)*t,i=n*t,c=Math.min(a,i)/2,_=a/2,l=i/2,{background:d,floor:f,edge:h,edgeWidth:u,rings:y,ringColor:v}=be,w=new P;w.rect(-a,-i,a*3,i*3),w.fill(d),w.circle(_,l,c),w.fill(f);for(let A=1;A<y;A+=1)w.circle(_,l,c*A/y),w.stroke({color:v,width:2,alpha:me});w.circle(_,l,c),w.stroke({color:h,width:u,alignment:1}),this.addChild(w)}update(){}destroy(){super.destroy({children:!0})}}const J=[16731469,16752412,16765503,10214972,3065014,3848191,5531903,11623679,16735432,16250871,8250065,16753828],Z=[8321535,10146047,13154047,12386267,16771466,16757702],Q=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],de=16,C=de*2,L={ANGLE:C,RADIUS:C+1,CRYSTALS:C+2,COLOR:C+3,FLAGS:C+4},xe=1,ve=2,Ae=4,ee=.25,ke=.85;function Ee(r){const e=(Math.sin(r/1e3*Ae*Math.PI*2)+1)/2;return ee+(ke-ee)*e}function te(r){return r!=null}function ne(r){const e=t=>{const n=t/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*e(r>>16&255)+.7152*e(r>>8&255)+.0722*e(r&255)}function re(r,e){const t=ne(r),n=ne(e);return(Math.max(t,n)+.05)/(Math.min(t,n)+.05)}function Se(r){const{inkDark:e,inkLight:t}=m.accolade;return re(r,e)>=re(r,t)?[e,t]:[t,e]}function Ce(r,e){const t=Math.round((r>>16&255)*e),n=Math.round((r>>8&255)*e),o=Math.round((r&255)*e);return t<<16|n<<8|o}function Le(r,e){const t=r.length-1;if(t<1)return r;const n=[r[0]];for(let o=0;o<t;o+=1){const a=r[Math.max(o-1,0)],i=r[o],c=r[o+1],_=r[Math.min(o+2,t)];for(let l=1;l<=e;l+=1){const d=l/e,f=d*d,h=f*d;n.push([.5*(2*i[0]+(-a[0]+c[0])*d+(2*a[0]-5*i[0]+4*c[0]-_[0])*f+(-a[0]+3*i[0]-3*c[0]+_[0])*h),.5*(2*i[1]+(-a[1]+c[1])*d+(2*a[1]-5*i[1]+4*c[1]-_[1])*f+(-a[1]+3*i[1]-3*c[1]+_[1])*h)])}}return n}class Oe extends H{constructor(e,t={},n={},o={}){super(),this.zIndex=3,this._sound=n.soundManager,this._localPlayer=n.localPlayer,this._id=o.id??null,this._accolades=n.accolades,this._body=new P,this._head=new P,this.addChild(this._body,this._head),this._crownEdge=t?.crown?this._buildCrown(t.crown,m.accolade.crownOutline):null,this._crown=t?.crown?this._buildCrown(t.crown,m.accolade.crownTint):null,this._headAt=[0,0],this._crystals=null,this.update(e)}update(e){const t=e[L.RADIUS]||1,n=e[L.ANGLE]||0,o=e[L.CRYSTALS]||0,a=e[L.FLAGS]||0,i=(a&xe)!==0,c=(a&ve)!==0,_=J[(e[L.COLOR]||0)%J.length],l=[];for(let h=0;h<de;h+=1)l.push([e[h*2]||0,e[h*2+1]||0]);this.alpha=c?Ee(performance.now()):1;const{daily:d,monthly:f}=this._accolades?.placeOf(this._id)??{};this._drawBody(l,t,_,i,te(d)),this._drawHead(l[0],n,t,_),this._drawCrown(l[0],n,t,te(f)),this._crystals!==null&&o>this._crystals&&this._play("pickup",l[0]),this._crystals=o,this._headAt=l[0]}_drawBody(e,t,n,o,a){const i=Le(e,m.smoothing),c=this._body;c.clear(),c.moveTo(i[0][0],i[0][1]);for(let _=1;_<i.length;_+=1)c.lineTo(i[_][0],i[_][1]);o&&c.stroke({color:m.boostGlow,width:t*2.6,alpha:.22,cap:"round",join:"round"}),c.stroke({color:n,width:t*2,cap:"round",join:"round"}),c.stroke({color:Ce(n,m.innerDarken),width:t*2*m.innerScale,alpha:.45,cap:"round",join:"round"}),a&&this._drawDiamonds(i,t,n)}_drawDiamonds(e,t,n){const{diamondEvery:o,diamondLong:a,diamondWide:i,diamondStroke:c}=m.accolade,_=this._body,l=t*o,d=t*a,f=t*i,[h,u]=Se(n),y=t*c;let v=l*.5;for(let w=1;w<e.length;w+=1){const[A,V]=e[w-1],[pe,ue]=e[w],G=pe-A,Y=ue-V,k=Math.hypot(G,Y);if(k!==0){for(;v<=k;){const X=v/k,I=A+G*X,W=V+Y*X,N=G/k,z=Y/k;_.moveTo(I+N*d,W+z*d),_.lineTo(I-z*f,W+N*f),_.lineTo(I-N*d,W-z*d),_.lineTo(I+z*f,W-N*f),_.closePath(),_.fill(h),_.stroke({width:y,color:u}),v+=l}v-=k}}}_drawHead([e,t],n,o,a){const i=this._head;i.clear(),i.circle(e,t,o),i.fill(a);const c=Math.cos(n),_=Math.sin(n),l=o*.5,d=o*.42,f=o*.32;for(const h of[-1,1]){const u=e+c*d-_*l*h,y=t+_*d+c*l*h;i.circle(u,y,f),i.fill(m.eye),i.circle(u+c*f*.35,y+_*f*.35,f*.5),i.fill(m.pupil)}}_buildCrown(e,t){const n=new _e(e);return n.anchor.set(.5,1),n.tint=t,n.visible=!1,this.addChild(n),n}_drawCrown([e,t],n,o,a){if(!this._crown||(this._crown.visible=a,this._crownEdge&&(this._crownEdge.visible=a),!a))return;const{crownScale:i,crownLift:c,crownOutlineScale:_}=m.accolade,d=o*i/this._crown.texture.width,f=n+Math.PI/2,h=e+Math.cos(n)*o*c,u=t+Math.sin(n)*o*c;this._crown.scale.set(d),this._crown.rotation=f,this._crown.x=h,this._crown.y=u,this._crownEdge&&(this._crownEdge.scale.set(d*_),this._crownEdge.rotation=f,this._crownEdge.x=h,this._crownEdge.y=u)}_isLocal(){return this._localPlayer?this._localPlayer.is(this._id):(this._warned||(this._warned=!0,console.error("[snakes] the `localPlayer` service is missing: engine too old, game cues stay silent")),!1)}_play(e,[t,n]){!this._sound||!this._isLocal()||this._sound.registerSound(e,{position:{x:t,y:n}})}destroy(){this._play("death",this._headAt),super.destroy({children:!0})}}const
|
|
1
|
+
import{Container as H,Graphics as P,Sprite as _e,Rectangle as le}from"pixi.js";const ge=4,we='#panel-score:before{content:"★ ";color:#ffd76b}#panel-crystals,#panel-dead,#panel-mode,#panel-time{display:none!important}#stat .stat-leaderboard{padding:12px 0;font:400 16px/1.6 system-ui,sans-serif;color:#e6ecf5}#stat .stat-leaderboard .stat-row{grid-template-columns:3.5em 1fr 5.5em;gap:0 12px;padding:4px 16px;border-radius:6px}#stat .stat-leaderboard .stat-row span:first-child,#stat .stat-leaderboard .stat-row span:last-child{font-variant-numeric:tabular-nums;text-align:right}#stat .stat-leaderboard .stat-row span:first-child{opacity:.6}#stat .stat-leaderboard .stat-row span:last-child{font-weight:700;color:#ffd76b}#stat .stat-leaderboard .stat-row span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#stat .stat-leaderboard .is-self{background:#3ab7ff2e;color:#7ef9ff}#snakes-gameover{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#060a149e;font:400 16px/1.5 system-ui,sans-serif;color:#e6ecf5}#snakes-gameover[hidden]{display:none}.snakes-gameover-card{min-width:260px;padding:28px 32px;border:1px solid #39507f;border-radius:12px;background:#141c30;box-shadow:0 18px 48px #00000073;text-align:center}.snakes-gameover-card h2{margin:0 0 4px;font-size:22px;font-weight:600;letter-spacing:.02em}.snakes-gameover-score{margin:0 0 6px;opacity:.75}.snakes-gameover-total{margin:0 0 22px;font-size:15px;letter-spacing:.02em;opacity:.6}.snakes-gameover-total span{font-weight:700;color:#ffd76b}.snakes-gameover-score span{font-size:40px;font-weight:700;color:#7ef9ff;vertical-align:-2px}.snakes-gameover-card button{min-width:120px;padding:10px 20px;border:0;border-radius:8px;background:#3ab7ff;color:#06182a;font:inherit;font-weight:600;cursor:pointer}.snakes-gameover-card button:hover,.snakes-gameover-card button:focus-visible{background:#7ed0ff}',be={background:856608,floor:1317936,edge:3756159,edgeWidth:10,rings:4,ringColor:1911111},m={innerScale:.62,innerDarken:.55,smoothing:4,eye:16251903,pupil:1054760,boostGlow:16771466,accolade:{diamondEvery:1.6,diamondLong:.9,diamondWide:.55,inkDark:1054760,inkLight:16645631,diamondStroke:.18,crownScale:1.9,crownLift:.44,crownTint:16766827,crownOutline:1054760,crownOutlineScale:1.16}},me=.5;class ye extends H{constructor(e){super(),this.zIndex=0,!(Array.isArray(e)||e.type==="dynamic")&&this._draw(e)}_draw({map:e,step:t}){const n=e.length,a=(e[0]?.length??0)*t,i=n*t,c=Math.min(a,i)/2,_=a/2,l=i/2,{background:d,floor:f,edge:h,edgeWidth:u,rings:y,ringColor:v}=be,w=new P;w.rect(-a,-i,a*3,i*3),w.fill(d),w.circle(_,l,c),w.fill(f);for(let A=1;A<y;A+=1)w.circle(_,l,c*A/y),w.stroke({color:v,width:2,alpha:me});w.circle(_,l,c),w.stroke({color:h,width:u,alignment:1}),this.addChild(w)}update(){}destroy(){super.destroy({children:!0})}}const J=[16731469,16752412,16765503,10214972,3065014,3848191,5531903,11623679,16735432,16250871,8250065,16753828],Z=[8321535,10146047,13154047,12386267,16771466,16757702],Q=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],de=16,C=de*2,L={ANGLE:C,RADIUS:C+1,CRYSTALS:C+2,COLOR:C+3,FLAGS:C+4},xe=1,ve=2,Ae=4,ee=.25,ke=.85;function Ee(r){const e=(Math.sin(r/1e3*Ae*Math.PI*2)+1)/2;return ee+(ke-ee)*e}function te(r){return r!=null}function ne(r){const e=t=>{const n=t/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*e(r>>16&255)+.7152*e(r>>8&255)+.0722*e(r&255)}function re(r,e){const t=ne(r),n=ne(e);return(Math.max(t,n)+.05)/(Math.min(t,n)+.05)}function Se(r){const{inkDark:e,inkLight:t}=m.accolade;return re(r,e)>=re(r,t)?[e,t]:[t,e]}function Ce(r,e){const t=Math.round((r>>16&255)*e),n=Math.round((r>>8&255)*e),o=Math.round((r&255)*e);return t<<16|n<<8|o}function Le(r,e){const t=r.length-1;if(t<1)return r;const n=[r[0]];for(let o=0;o<t;o+=1){const a=r[Math.max(o-1,0)],i=r[o],c=r[o+1],_=r[Math.min(o+2,t)];for(let l=1;l<=e;l+=1){const d=l/e,f=d*d,h=f*d;n.push([.5*(2*i[0]+(-a[0]+c[0])*d+(2*a[0]-5*i[0]+4*c[0]-_[0])*f+(-a[0]+3*i[0]-3*c[0]+_[0])*h),.5*(2*i[1]+(-a[1]+c[1])*d+(2*a[1]-5*i[1]+4*c[1]-_[1])*f+(-a[1]+3*i[1]-3*c[1]+_[1])*h)])}}return n}class Oe extends H{constructor(e,t={},n={},o={}){super(),this.zIndex=3,this._sound=n.soundManager,this._localPlayer=n.localPlayer,this._id=o.id??null,this._accolades=n.accolades,this._body=new P,this._head=new P,this.addChild(this._body,this._head),this._crownEdge=t?.crown?this._buildCrown(t.crown,m.accolade.crownOutline):null,this._crown=t?.crown?this._buildCrown(t.crown,m.accolade.crownTint):null,this._headAt=[0,0],this._crystals=null,this.update(e)}update(e){const t=e[L.RADIUS]||1,n=e[L.ANGLE]||0,o=e[L.CRYSTALS]||0,a=e[L.FLAGS]||0,i=(a&xe)!==0,c=(a&ve)!==0,_=J[(e[L.COLOR]||0)%J.length],l=[];for(let h=0;h<de;h+=1)l.push([e[h*2]||0,e[h*2+1]||0]);this.alpha=c?Ee(performance.now()):1;const{daily:d,monthly:f}=this._accolades?.placeOf(this._id)??{};this._drawBody(l,t,_,i,te(d)),this._drawHead(l[0],n,t,_),this._drawCrown(l[0],n,t,te(f)),this._crystals!==null&&o>this._crystals&&this._play("pickup",l[0]),this._crystals=o,this._headAt=l[0]}_drawBody(e,t,n,o,a){const i=Le(e,m.smoothing),c=this._body;c.clear(),c.moveTo(i[0][0],i[0][1]);for(let _=1;_<i.length;_+=1)c.lineTo(i[_][0],i[_][1]);o&&c.stroke({color:m.boostGlow,width:t*2.6,alpha:.22,cap:"round",join:"round"}),c.stroke({color:n,width:t*2,cap:"round",join:"round"}),c.stroke({color:Ce(n,m.innerDarken),width:t*2*m.innerScale,alpha:.45,cap:"round",join:"round"}),a&&this._drawDiamonds(i,t,n)}_drawDiamonds(e,t,n){const{diamondEvery:o,diamondLong:a,diamondWide:i,diamondStroke:c}=m.accolade,_=this._body,l=t*o,d=t*a,f=t*i,[h,u]=Se(n),y=t*c;let v=l*.5;for(let w=1;w<e.length;w+=1){const[A,V]=e[w-1],[pe,ue]=e[w],G=pe-A,Y=ue-V,k=Math.hypot(G,Y);if(k!==0){for(;v<=k;){const X=v/k,I=A+G*X,W=V+Y*X,N=G/k,z=Y/k;_.moveTo(I+N*d,W+z*d),_.lineTo(I-z*f,W+N*f),_.lineTo(I-N*d,W-z*d),_.lineTo(I+z*f,W-N*f),_.closePath(),_.fill(h),_.stroke({width:y,color:u}),v+=l}v-=k}}}_drawHead([e,t],n,o,a){const i=this._head;i.clear(),i.circle(e,t,o),i.fill(a);const c=Math.cos(n),_=Math.sin(n),l=o*.5,d=o*.42,f=o*.32;for(const h of[-1,1]){const u=e+c*d-_*l*h,y=t+_*d+c*l*h;i.circle(u,y,f),i.fill(m.eye),i.circle(u+c*f*.35,y+_*f*.35,f*.5),i.fill(m.pupil)}}_buildCrown(e,t){const n=new _e(e);return n.anchor.set(.5,1),n.tint=t,n.visible=!1,this.addChild(n),n}_drawCrown([e,t],n,o,a){if(!this._crown||(this._crown.visible=a,this._crownEdge&&(this._crownEdge.visible=a),!a))return;const{crownScale:i,crownLift:c,crownOutlineScale:_}=m.accolade,d=o*i/this._crown.texture.width,f=n+Math.PI/2,h=e+Math.cos(n)*o*c,u=t+Math.sin(n)*o*c;this._crown.scale.set(d),this._crown.rotation=f,this._crown.x=h,this._crown.y=u,this._crownEdge&&(this._crownEdge.scale.set(d*_),this._crownEdge.rotation=f,this._crownEdge.x=h,this._crownEdge.y=u)}_isLocal(){return this._localPlayer?this._localPlayer.is(this._id):(this._warned||(this._warned=!0,console.error("[snakes] the `localPlayer` service is missing: engine too old, game cues stay silent")),!1)}_play(e,[t,n]){!this._sound||!this._isLocal()||this._sound.registerSound(e,{position:{x:t,y:n}})}destroy(){this._play("death",this._headAt),super.destroy({children:!0})}}const F={X:0,Y:1,TIER:2,COLOR:3},Re=32;class Me extends H{constructor(e,t){super(),this.zIndex=2,this._sprite=new _e(t.crystalGem),this._sprite.anchor.set(.5),this.addChild(this._sprite),this.update(e)}update(e){this.x=e[F.X]||0,this.y=e[F.Y]||0;const t=Q[e[F.TIER]||0]??Q[0];this._sprite.scale.set(t.radius/Re),this._sprite.tint=Z[(e[F.COLOR]||0)%Z.length],this._sprite.rotation=(this.x+this.y)%360*(Math.PI/180)}destroy(){super.destroy({children:!0})}}const Te={Arena:ye,Snake:Oe,Crystal:Me};function Pe(r,e){const{radius:t,facets:n}=r,o=t*2,a=new P,i=(d,f,h=0)=>{const u=(f+h)/n*Math.PI*2-Math.PI/2;return[t+Math.cos(u)*d,t+Math.sin(u)*d]},c=[];for(let d=0;d<n;d+=1)c.push(i(t*.94,d));a.poly(c.flat()),a.fill({color:16777215,alpha:.85});const _=[];for(let d=0;d<n;d+=1)_.push(i(t*.5,d,.5));a.poly(_.flat()),a.fill({color:16777215,alpha:1});const l=e.generateTexture({target:a,frame:new le(0,0,o,o)});return a.destroy(!0),l}function Ie(r,e){const{size:t,points:n}=r,o=new P,a=t*.26,i=t*.08,c=t-a,_=t/n,l=[0,c];for(let f=0;f<n;f+=1){const h=(n-1)/2,u=Math.abs(f-h)/(h||1)*t*.18;l.push(f*_,i+u),l.push((f+.5)*_,c*.55)}l.push(t,i+t*.18,t,c),o.poly(l),o.fill({color:16777215,alpha:.92}),o.rect(0,c,t,a),o.fill({color:16777215,alpha:1});const d=e.generateTexture({target:o,frame:new le(0,0,t,t)});return o.destroy(!0),d}const We={crystalGem:Pe,crown:Ie},E="snakes-gameover",Ne=82,se="d",oe="s";function ze(r,e){const t=new KeyboardEvent(r,{keyCode:e,bubbles:!0});t.keyCode!==e&&(Object.defineProperty(t,"keyCode",{value:e}),Object.defineProperty(t,"which",{value:e})),window.dispatchEvent(t)}function Fe(r){const e={};for(const t of r??[]){const n=String(t).indexOf(":");n>0&&(e[t.slice(0,n)]=Number(t.slice(n+1)))}return e}class je{constructor(){this._root=null,this._crystals=null,this._total=null,this._visible=!1,this._lastScore=0}mount(){if(this._root||typeof document>"u")return;const e=document.createElement("div");e.id=E,e.hidden=!0,e.innerHTML=`
|
|
2
2
|
<div class="${E}-card">
|
|
3
3
|
<h2>You crashed</h2>
|
|
4
4
|
<p class="${E}-score"><span>0</span> crystals</p>
|
|
5
5
|
<p class="${E}-total">Total score: <span>0</span></p>
|
|
6
6
|
<button type="button">OK</button>
|
|
7
7
|
</div>
|
|
8
|
-
`,this._crystals=e.querySelector(`.${E}-score span`),this._total=e.querySelector(`.${E}-total span`),e.querySelector("button").addEventListener("click",()=>this._respawn()),document.body.appendChild(e),this._root=e}onPanel(e){if(!this._root)return;const t=De(e);if(oe in t&&(this._lastScore=t[oe]),!(se in t))return;const n=t[se];n>0?this._show(n-1):this._hide()}reset(){this._hide(),this._lastScore=0}_show(e){this._visible||(this._visible=!0,this._crystals.textContent=String(e),this._total.textContent=String(this._lastScore),this._root.hidden=!1)}_hide(){this._visible&&(this._visible=!1,this._root.hidden=!0)}_respawn(){this._hide();for(const e of["keydown","keyup"])ze(e,Ne)}}const je="modulepreload",Ge=function(r){return"/"+r},ie={},Ye=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");o=_(t.map(l=>{if(l=Ge(l),l in ie)return;ie[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":je,d||(h.as="script"),h.crossOrigin="",h.href=l,c&&h.setAttribute("nonce",c),document.head.appendChild(h),d)return new Promise((u,y)=>{h.addEventListener("load",u),h.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${l}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return o.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return e().catch(a)})},$e=r=>(r??"").endsWith(".js"),Be=r=>import(r),Ue=()=>Ye(()=>Promise.resolve().then(()=>Qe),[]),$=new Fe,tt={id:"snakes",engineApi:ge,requires:["accolades"],async createClientCore(r,{wasmUrl:e}={}){if($e(e)){const a=await Be(e);return{core:new a.ClientCore(r),memory:null}}const{default:t,ClientCore:n}=await Ue(),o=await t({module_or_path:e});return{core:new n(r),memory:o.memory}},parts:Te,bakers:We,styles:we,hooks:{onAuth(r,e){r.set_model(e.model),$.mount(),$.reset()},onPanel(r,e){r.sync_panel(JSON.stringify(e)),$.onPanel(e)},onLocalAction(){return null}}};class U{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ce.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}abi_describe(){let e,t;try{const n=s.clientcore_abi_describe(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}apply_aim(e,t,n,o){s.clientcore_apply_aim(this.__wbg_ptr,e,t,n,o)}apply_input(e,t,n){const o=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=p,i=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=p;s.clientcore_apply_input(this.__wbg_ptr,o,a,i,c,n)}debug_json(){let e,t;try{const n=s.clientcore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,n;try{const o=M(e,s.__wbindgen_malloc),a=p,i=s.clientcore_decode_frame(this.__wbg_ptr,o,a);return t=i[0],n=i[1],b(i[0],i[1])}finally{s.__wbindgen_free(t,n,1)}}dispatch(e,t){const n=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=p,a=M(t,s.__wbindgen_malloc),i=p,c=s.clientcore_dispatch(this.__wbg_ptr,n,o,a,i);var _=F(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.clientcore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],ce.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const n=M(e,s.__wbindgen_malloc),o=p;return s.clientcore_push_frame(this.__wbg_ptr,n,o,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.clientcore_set_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}set_model(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p;s.clientcore_set_model(this.__wbg_ptr,t,n)}sync_panel(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p;s.clientcore_sync_panel(this.__wbg_ptr,t,n)}take_divergence(){let e,t;try{const n=s.clientcore_take_divergence(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const n=s.clientcore_take_frames(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);class q{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ae.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}abi_describe(){let e,t;try{const n=s.gamecore_abi_describe(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,n,o,a){s.gamecore_apply_aim(this.__wbg_ptr,e,t,n,o,a)}apply_input(e,t,n,o){const a=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),i=p,c=g(o,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p;s.gamecore_apply_input(this.__wbg_ptr,e,t,a,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const n=s.gamecore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=M(e,s.__wbindgen_malloc),n=p,o=s.gamecore_deserialize_state(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}dispatch(e,t){const n=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=p,a=M(t,s.__wbindgen_malloc),i=p,c=s.gamecore_dispatch(this.__wbg_ptr,n,o,a,i);var _=F(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=F(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.gamecore_load_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}map_info(){let e,t;try{const n=s.gamecore_map_info(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.gamecore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],ae.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw x(e[0])}pack_frame(e,t,n,o,a,i,c,_){var l=Ke(c)?0:g(c,s.__wbindgen_malloc,s.__wbindgen_realloc),d=p;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,n,o,a,i,l,d,_)>>>0}players_data(){let e,t;try{const n=s.gamecore_players_data(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var n=K(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),n}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const n=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,n,o,a){s.gamecore_reset_actor(this.__wbg_ptr,e,t,n,o,a)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw x(e[2]);var t=F(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}set_actor_level(e,t){s.gamecore_set_actor_level(this.__wbg_ptr,e,t)}spawn_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}spawn_scripted_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const n=s.gamecore_take_events(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);function fe(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(b(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(b(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const ce=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_clientcore_free(r,1)),ae=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_gamecore_free(r,1));function K(r,e){return r=r>>>0,qe().subarray(r/4,r/4+e)}function F(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}let O=null;function qe(){return(O===null||O.byteLength===0)&&(O=new Float32Array(s.memory.buffer)),O}function b(r,e){return Ve(r>>>0,e)}let R=null;function S(){return(R===null||R.byteLength===0)&&(R=new Uint8Array(s.memory.buffer)),R}function Ke(r){return r==null}function M(r,e){const t=e(r.length*1,1)>>>0;return S().set(r,t/1),p=r.length,t}function g(r,e,t){if(t===void 0){const c=T.encode(r),_=e(c.length,1)>>>0;return S().subarray(_,_+c.length).set(c),p=c.length,_}let n=r.length,o=e(n,1)>>>0;const a=S();let i=0;for(;i<n;i++){const c=r.charCodeAt(i);if(c>127)break;a[o+i]=c}if(i!==n){i!==0&&(r=r.slice(i)),o=t(o,n,n=i+r.length*3,1)>>>0;const c=S().subarray(o+i,o+n),_=T.encodeInto(r,c);i+=_.written,o=t(o,n,i,1)>>>0}return p=i,o}function x(r){const e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}let j=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});j.decode();const He=2146435072;let B=0;function Ve(r,e){return B+=e,B>=He&&(j=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),j.decode(),B=e),j.decode(S().subarray(r,r+e))}const T=new TextEncoder;"encodeInto"in T||(T.encodeInto=function(r,e){const t=T.encode(r);return e.set(t),{read:r.length,written:t.length}});let p=0,s;function he(r,e){return s=r.exports,O=null,R=null,s.__wbindgen_start(),s}async function Xe(r,e){if(typeof Response=="function"&&r instanceof Response){if(!r.ok)throw new Error(`failed to fetch Wasm: ${r.status} ${r.statusText} fetching '${r.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(t(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}function Je(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=fe();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return he(t)}async function Ze(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0&&(r=new URL("/assets/vimp_snakes_core_bg-p5kW2YDJ.wasm",import.meta.url));const e=fe();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:t,module:n}=await Xe(await r,e);return he(t)}const Qe=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:U,GameCore:q,default:Ze,initSync:Je},Symbol.toStringTag,{value:"Module"}));export{tt as default};
|
|
8
|
+
`,this._crystals=e.querySelector(`.${E}-score span`),this._total=e.querySelector(`.${E}-total span`),e.querySelector("button").addEventListener("click",()=>this._respawn()),document.body.appendChild(e),this._root=e}onPanel(e){if(!this._root)return;const t=Fe(e);if(oe in t&&(this._lastScore=t[oe]),!(se in t))return;const n=t[se];n>0?this._show(n-1):this._hide()}reset(){this._hide(),this._lastScore=0}_show(e){this._visible||(this._visible=!0,this._crystals.textContent=String(e),this._total.textContent=String(this._lastScore),this._root.hidden=!1)}_hide(){this._visible&&(this._visible=!1,this._root.hidden=!0)}_respawn(){this._hide();for(const e of["keydown","keyup"])ze(e,Ne)}}const De="modulepreload",Ge=function(r){return"/"+r},ie={},Ye=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");o=_(t.map(l=>{if(l=Ge(l),l in ie)return;ie[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":De,d||(h.as="script"),h.crossOrigin="",h.href=l,c&&h.setAttribute("nonce",c),document.head.appendChild(h),d)return new Promise((u,y)=>{h.addEventListener("load",u),h.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${l}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return o.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return e().catch(a)})},$e=r=>(r??"").endsWith(".js"),Be=r=>import(r),Ue=()=>Ye(()=>Promise.resolve().then(()=>Qe),[]),$=new je,tt={id:"snakes",engineApi:ge,requires:["accolades"],async createClientCore(r,{wasmUrl:e}={}){if($e(e)){const a=await Be(e);return{core:new a.ClientCore(r),memory:null}}const{default:t,ClientCore:n}=await Ue(),o=await t({module_or_path:e});return{core:new n(r),memory:o.memory}},parts:Te,bakers:We,styles:we,hooks:{onAuth(r,e){r.set_model(e.model),$.mount(),$.reset()},onPanel(r,e){r.sync_panel(JSON.stringify(e)),$.onPanel(e)},onLocalAction(){return null}}};class U{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ce.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}abi_describe(){let e,t;try{const n=s.clientcore_abi_describe(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}apply_aim(e,t,n,o){s.clientcore_apply_aim(this.__wbg_ptr,e,t,n,o)}apply_input(e,t,n){const o=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=p,i=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=p;s.clientcore_apply_input(this.__wbg_ptr,o,a,i,c,n)}debug_json(){let e,t;try{const n=s.clientcore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,n;try{const o=M(e,s.__wbindgen_malloc),a=p,i=s.clientcore_decode_frame(this.__wbg_ptr,o,a);return t=i[0],n=i[1],b(i[0],i[1])}finally{s.__wbindgen_free(t,n,1)}}dispatch(e,t){const n=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=p,a=M(t,s.__wbindgen_malloc),i=p,c=s.clientcore_dispatch(this.__wbg_ptr,n,o,a,i);var _=j(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.clientcore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],ce.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const n=M(e,s.__wbindgen_malloc),o=p;return s.clientcore_push_frame(this.__wbg_ptr,n,o,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.clientcore_set_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}set_model(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p;s.clientcore_set_model(this.__wbg_ptr,t,n)}sync_panel(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p;s.clientcore_sync_panel(this.__wbg_ptr,t,n)}take_divergence(){let e,t;try{const n=s.clientcore_take_divergence(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const n=s.clientcore_take_frames(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);class q{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ae.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}abi_describe(){let e,t;try{const n=s.gamecore_abi_describe(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,n,o,a){s.gamecore_apply_aim(this.__wbg_ptr,e,t,n,o,a)}apply_input(e,t,n,o){const a=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),i=p,c=g(o,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p;s.gamecore_apply_input(this.__wbg_ptr,e,t,a,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const n=s.gamecore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=M(e,s.__wbindgen_malloc),n=p,o=s.gamecore_deserialize_state(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}dispatch(e,t){const n=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=p,a=M(t,s.__wbindgen_malloc),i=p,c=s.gamecore_dispatch(this.__wbg_ptr,n,o,a,i);var _=j(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=j(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.gamecore_load_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}map_info(){let e,t;try{const n=s.gamecore_map_info(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=p,o=s.gamecore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],ae.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw x(e[0])}pack_frame(e,t,n,o,a,i,c,_){var l=Ke(c)?0:g(c,s.__wbindgen_malloc,s.__wbindgen_realloc),d=p;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,n,o,a,i,l,d,_)>>>0}players_data(){let e,t;try{const n=s.gamecore_players_data(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var n=K(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),n}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const n=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,n,o,a){s.gamecore_reset_actor(this.__wbg_ptr,e,t,n,o,a)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw x(e[2]);var t=j(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}set_actor_level(e,t){s.gamecore_set_actor_level(this.__wbg_ptr,e,t)}spawn_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}spawn_scripted_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=p,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const n=s.gamecore_take_events(this.__wbg_ptr);return e=n[0],t=n[1],b(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);function fe(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(b(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(b(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const ce=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_clientcore_free(r,1)),ae=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_gamecore_free(r,1));function K(r,e){return r=r>>>0,qe().subarray(r/4,r/4+e)}function j(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}let O=null;function qe(){return(O===null||O.byteLength===0)&&(O=new Float32Array(s.memory.buffer)),O}function b(r,e){return Ve(r>>>0,e)}let R=null;function S(){return(R===null||R.byteLength===0)&&(R=new Uint8Array(s.memory.buffer)),R}function Ke(r){return r==null}function M(r,e){const t=e(r.length*1,1)>>>0;return S().set(r,t/1),p=r.length,t}function g(r,e,t){if(t===void 0){const c=T.encode(r),_=e(c.length,1)>>>0;return S().subarray(_,_+c.length).set(c),p=c.length,_}let n=r.length,o=e(n,1)>>>0;const a=S();let i=0;for(;i<n;i++){const c=r.charCodeAt(i);if(c>127)break;a[o+i]=c}if(i!==n){i!==0&&(r=r.slice(i)),o=t(o,n,n=i+r.length*3,1)>>>0;const c=S().subarray(o+i,o+n),_=T.encodeInto(r,c);i+=_.written,o=t(o,n,i,1)>>>0}return p=i,o}function x(r){const e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}let D=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});D.decode();const He=2146435072;let B=0;function Ve(r,e){return B+=e,B>=He&&(D=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),D.decode(),B=e),D.decode(S().subarray(r,r+e))}const T=new TextEncoder;"encodeInto"in T||(T.encodeInto=function(r,e){const t=T.encode(r);return e.set(t),{read:r.length,written:t.length}});let p=0,s;function he(r,e){return s=r.exports,O=null,R=null,s.__wbindgen_start(),s}async function Xe(r,e){if(typeof Response=="function"&&r instanceof Response){if(!r.ok)throw new Error(`failed to fetch Wasm: ${r.status} ${r.statusText} fetching '${r.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(t(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}function Je(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=fe();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return he(t)}async function Ze(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0&&(r=new URL("/assets/vimp_snakes_core_bg-Ycx_0IaJ.wasm",import.meta.url));const e=fe();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:t,module:n}=await Xe(await r,e);return he(t)}const Qe=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:U,GameCore:q,default:Ze,initSync:Je},Symbol.toStringTag,{value:"Module"}));export{tt as default};
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const X=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),Z={s1:{id:1,kind:"indexed8",class:"hot",fields:[...X,{name:"angle",ty:"f32",interp:"lerpAngle"},{name:"radius",ty:"f32",interp:"lerp"},{name:"crystals",ty:"u16"},{name:"color",ty:"u8"},{name:"boost",ty:"u8"}]},cr:{id:2,kind:"indexed32",class:"event",fields:[{name:"x",ty:"f32"},{name:"y",ty:"f32"},{name:"tier",ty:"u8"},{name:"color",ty:"u8"}]},c1:{id:3,kind:"indexedNoNull8",class:"hot",fields:[{name:"x",ty:"f32",interp:"lerp"},{name:"y",ty:"f32",interp:"lerp"},{name:"angle",ty:"f32",interp:"lerpAngle"}]}},I=[16731469,16752412,16765503,10214972,3065014,3848191,5531903,11623679,16735432,16250871,8250065,16753828],J=n=>`#${I[n%I.length].toString(16).padStart(6,"0")}`,Q=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],E={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.4,turnSpeedFalloff:.18,turnSpeedMin:1.4,baseRadius:14,radiusGain:1.6,baseLength:150,lengthPerCrystal:9,pointSpacing:6,boostDrainPerSecond:6,boostMinCrystals:2,world:{maxCrystals:60,spawnInterval:.35,tierWeights:[70,25,5],tiers:Q,dropRatio:.8,edgeMargin:60,startCrystals:0,spawnGraceSeconds:2}}},ee={},W=128,D=1,te=20,O=8,N=4,A=64,re=Math.PI*(3-Math.sqrt(5)),ne=.72,se=25;function P(n){const e=Math.ceil(Math.max(n,0)/N)*N,t=Math.max(e,O);return Math.round(te*Math.sqrt(t/O))}const L=Math.log2(A);if(!Number.isInteger(L))throw new Error(`RESPAWN_COUNT must be a power of two (the order is bit-reversed), got ${A}`);function ae(n){let e=0;for(let t=0;t<L;t+=1)e=e<<1|n>>t&1;return e}function oe(n){const e=n*W/2,t=e;return Array.from({length:A},(r,a)=>{const o=ae(a),i=e*ne*Math.sqrt((o+.5)/A),c=o*re,_=t+Math.cos(c)*i,l=t+Math.sin(c)*i,h=(a*.6180339887%1*2-1)*se,m=c*180/Math.PI+180+h;return[Math.round(_),Math.round(l),Math.round((m%360+360)%360)]})}function U(n=0){const e=P(n);return{setId:"c1",scale:1,step:W,physicsStatic:[],physicsDynamic:[],layers:{1:[D]},map:Array.from({length:e},()=>Array.from({length:e},()=>D)),respawns:{players:oe(e)}}}const ie=U(0),ce={arena:ie},_e={title:"Snakes",parts:{models:E,weapons:ee,friendlyFire:!1},snapshot:Z,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},maps:ce,currentMap:"arena",mapScale:1,mapSetId:"c1",mapsInVote:1,timers:{timeStep:1e3/120,networkSendRate:4,roundTime:36e5,mapTime:36e5,roomTimeMin:1e4,roomTimeMax:36e5,voteTime:1e4,timeBlockedVote:3e4,teamChangeGracePeriod:1e4,roundRestartDelay:5e3,mapChangeDelay:2e3,rttPingInterval:3e3,idleCheckInterval:3e4},playerState:{defaultState:{best:0,eaten:0}},noSpectators:!0,endlessRound:!0,statMode:"leaderboard",teams:{players:1},scripted:{namePrefix:"Snake",defaultModel:"s1"},playerKeys:{left:{key:1},right:{key:2},boost:{key:4},respawn:{key:8,type:1}},panel:{fields:{crystals:{key:"c",value:0},score:{key:"s",value:0},dead:{key:"d",value:0}},activeKey:"wa"},stat:{name:{key:0,bodyMethod:"=",headSync:!0,headMethod:"#"},status:{key:1,bodyMethod:"=",bodyValue:"",headValue:""},score:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:3,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},le={elems:{authId:"auth",fieldsId:"auth-fields",errorId:"auth-error",enterId:"auth-enter",titleId:"auth-title",informsId:"auth-informs"},texts:{title:"Snakes",sections:[{heading:"How to play",lines:[{keys:"a, d",text:"turn"},{keys:"w",text:"boost (burns crystals)"},{keys:"r",text:"respawn after a crash"},{separator:!0},{keys:"",text:"eat crystals to grow"},{keys:"",text:"the edge and other snakes kill you"},{keys:"",text:"your own tail does not"},{separator:!0},{keys:"c",text:"chat"},{keys:"<Tab>",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(E),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in E}},de={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},pe={codecList:["webm","mp3"],spatial:{mode:"topDown",innerRadius:14},sounds:de},ue={parts:{gameSets:{s1:["Snake"],cr:["Crystal"],c1:["Arena"]},entitiesOnCanvas:{Arena:"vimp",Snake:"vimp",Crystal:"vimp"},bakedAssets:{vimp:[{name:"crystalGem",component:"Crystal",params:{radius:32,facets:6}},{name:"crown",component:"Snake",params:{size:64,points:3}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"],accolades:["Snake"]},sounds:pe},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{modes:{77:""},keySetList:[{78:"nextPlayer",80:"prevPlayer"},{65:"left",68:"right",87:"boost",82:"respawn"}],pointer:{keySets:[1],doubleTapMs:300,doubleTapPx:40,sendIntervalMs:50}},chat:{params:{messages:{s:["The arena is full. You will join as soon as a place frees up","You are already in the arena","You are in the arena","You are watching the arena","{0} crashed into {1}","{0} joined the game","{0} left the game","Host changed","You are no longer the host (connection lost)","Host changed: the previous host was lagging","Host changed: the previous host went inactive","Host changed: the previous host had a poor connection"],v:["A vote has been created","Voting has started","Your vote has been accepted","Voting is temporarily unavailable","Vote passed","Vote failed","Usage: /changehost","You are the host — use “Hand over host” in the room menu","No connection to the master server","A host vote was held recently","No other player can host","A host vote is already in progress","A host vote is not possible right now","Vote to change host passed ({0}/{1})","Vote to change host failed ({0}/{1})","Host vote cancelled"],m:["Current map: {0}","Next map: {0}"],c:["Command not found","Your place today: {0} of {1} ({2} points)"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"score",elem:"panel-score",type:"value"},{name:"crystals",elem:"panel-crystals",type:"value"},{name:"dead",elem:"panel-dead",type:"value"},{name:"mode",elem:"panel-mode",type:"weapon"},{name:"time",elem:"panel-time",type:"time"}]},stat:{params:{mode:"leaderboard",period:"day",limit:10,columns:["#","snake","score"]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class he{constructor({participants:e,coreAdapter:t,socketManager:r},a){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=a,this._vimp=null,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e,t={}){t.vimp&&(this._vimp=t.vimp),!(!e||e.type!=="population")&&this._apply(Number(e.count)||0)}_apply(e){const t=this._sizeFor(e);if(t!==this._size){this._size=t,this._population=e;const r=U(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._vimp?.overrideMapData?.(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return P(e);const t=P(e);return t>this._size||e<=this._population-N?t:this._size}_broadcast(){if(!this._mapData)return;const e=this._participants.getHumans(),t=new Set;for(const r of e)t.add(r.socketId),!(!r.isReady||this._delivered.get(r.socketId)===this._size)&&(this._delivered.set(r.socketId,this._size),this._socketManager.sendMap(r.socketId,this._mapData));for(const r of this._delivered.keys())t.has(r)||this._delivered.delete(r)}reapply(){this._mapData&&(this._vimp?.overrideMapData?.(this._mapData),this._coreAdapter.createMap(this._mapData),this._scriptedManager?.createMap(this._mapData),this._broadcast())}get mapData(){return this._mapData??null}}class fe{constructor({participants:e}){this._participants=e}onCoreEvent(e){if(!e||e.type!=="spawn")return;const t=Number(e.color);!Number.isFinite(t)||t<0||this._participants?.setChatColor?.(String(e.id),J(t))}}class me{constructor({participants:e,coreAdapter:t,panel:r,stat:a,scripted:o}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=a,this._model=o.defaultModel,this._respawns=null}createMap(e){this._respawns=e.respawns}getCountsPerTeam(){const e={};for(const t of this._participants.getScripted())e[t.team]=(e[t.team]??0)+1;return e}createScripted(e,t=null){if(!this._respawns)return 0;const r=this._participants.getPlayableTeams();let a=0;for(let o=0;o<e&&!this._participants.isFull;o+=1){const i=t??this._pickTeam(r);if(!i||!this._hasRoom(i))break;const c=this._participants.createScripted({team:i,model:this._model}),_=this._participants.get(c);this._stat.addUser(c,_.teamId,{name:_.name,status:"",latency:"BOT"}),this._panel.addUser(c),a+=1}return a}_hasRoom(e){const t=this._respawns[e];return!!(t&&this._participants.getTeamSize(e)<t.length)}_pickTeam(e){return[...e].sort((t,r)=>this._participants.getTeamSize(t)-this._participants.getTeamSize(r)).find(t=>this._hasRoom(t))??null}removeScripted(e=null){const t=this._participants.getScripted();(e?t.filter(a=>a.team===e):t).forEach(a=>this._remove(a.gameId))}removeOneForHuman(e){for(const t of this._participants.getScripted())if(t.team===e)return this._remove(t.gameId),!0;return!1}_remove(e){const t=this._participants.get(e);!t||!t.isScripted||(this._stat.removeUser(e,t.teamId),this._panel.removeUser(e),this._coreAdapter.removePlayer(e),this._participants.remove(e))}}const ge=15;class be{constructor({participants:e,stat:t}){this._participants=e,this._stat=t,this._totals=new Map}onCoreEvent(e,t={}){if(!e||typeof e!="object")return;const{vimp:r,panel:a}=t,o=String(e.id);switch(e.type){case"crystals":this._onCrystals(o,Number(e.gained)||0,r,a);break;case"burn":this._onBurn(o,Number(e.burned)||0,r,a);break;case"death":this._onDeath(o,e,r,a);break;case"respawn":this._onRespawn(o,r,a);break;case"population":this._publishNewcomers(r,a),r?.flushPlayerData?.();break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r,a){const o=this._record(e);!o||t<=0||(o.eaten+=t,o.score+=t,this._publish(e,o,r,a))}_onBurn(e,t,r,a){const o=this._record(e);!o||t<=0||(o.score=Math.max(0,o.score-t),this._publish(e,o,r,a))}_onDeath(e,t,r,a){const o=this._record(e);if(!o)return;const i=t.killer===null||t.killer===void 0?null:String(t.killer);if(i!==null&&i!==e){const l=this._record(i);l&&(l.kills+=1,l.score+=ge,this._publish(i,l,r,a))}this._publish(e,o,r,a);const _=r?.isPlayerRatingLoaded?.(e,"day")===!0?r.getPlayerRating?.(e,"day")?.value??0:1/0;r?.addPlayerPoints?.(e,o.score),r?.finishPlayerGame?.(e),this._recordBest(e,o,r),r?.flushPlayerData?.({urgent:o.score>_})}_onRespawn(e,t,r){const a=this._record(e);a&&(a.eaten=0,a.kills=0,a.score=0,a.flushedEaten=0,this._publish(e,a,t,r))}_record(e){const t=this._participants.get(e);if(!t)return null;const r=this._totals.get(e);if(r&&r.participant===t)return r;const a={participant:t,eaten:0,kills:0,score:0,flushedEaten:0,published:!1};return this._totals.set(e,a),a}_publishNewcomers(e,t){for(const r of this._participants.getAll()){const a=r.gameId,o=this._totals.get(a),i=o?.participant===r?o:this._record(a);i&&!i.published&&this._publish(a,i,e,t)}}_publish(e,t,r,a){const{score:o}=t;t.published=!0,this._stat.updateUser(e,t.participant.teamId,{score:o}),a&&a.updateUser(e,"score",o,"set")}_recordBest(e,t,r){if(!r?.getPlayerState)return;const a=r.getPlayerState(e);if(!a)return;const o=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const i=Math.max(Number(a.best)||0,t.score),c=(Number(a.eaten)||0)+o;r.setPlayerState(e,{...a,best:i,eaten:c})}}let V=null,j=null,G=null;function ye(n){const e=new me(n);return V=new be(n),j=new he(n,e),G=new fe(n),{scripted:e}}function we(){return V}function Y(){return j}function ve(){return G}const Se={name:"/bot",handler(n,e,t){const r=Number(t[0]);if(t[0]===void 0||!Number.isFinite(r)||r<0){n.chat.pushSystemByUser(e,"BOT_COUNT_INVALID");return}const{maxPlayers:a}=n.participants,o=Math.trunc(r),i=a>0?Math.min(o,a):o;n.scripted.removeScripted();const c=i>0?n.scripted.createScripted(i):0;n.chat.pushSystem("BOTS_SET",[c]),c>0&&(n.roundManager.initiateNewRound(),Y()?.reapply())}},ke={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},Me={name:"/rank",async handler(n,e){let t=null;try{t=await n.playerDataSync?.refreshPlacement?.(e,"day")}catch{t=n.playerDataSync?.getRating?.(e,"day")??null}const{value:r=0,placement:a=null,total:o=0}=t??{};n.chat.pushSystemByUser(e,"RANK",[a??"—",o,r])}},Ae={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},Ce="modulepreload",Ee=function(n){return"/"+n},F={},Ne=function(e,t,r){let a=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");a=_(t.map(l=>{if(l=Ee(l),l in F)return;F[l]=!0;const h=l.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Ce,h||(g.as="script"),g.crossOrigin="",g.href=l,c&&g.setAttribute("nonce",c),document.head.appendChild(g),h)return new Promise((H,K)=>{g.addEventListener("load",H),g.addEventListener("error",()=>K(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return e().catch(o)})},Pe=n=>(n??"").endsWith(".js"),Re=n=>import(n),Te=()=>Ne(()=>Promise.resolve().then(()=>We),[]),Le={id:"snakes",engineApi:4,requires:["accolades"],async createCore(n,{wasmUrl:e}={}){if(Pe(e)){const a=await Re(e);return new a.GameCore(n)}const{default:t,GameCore:r}=await Te();return await t({module_or_path:e}),new r(n)},gameConfig:_e,authSchema:le,chatCommands:[Se,ke,Me],systemMessages:Ae,createModules:ye,buildClientGameConfig:()=>ue,onCoreEvent(n,e={}){we()?.onCoreEvent(n,e),Y()?.onCoreEvent(n,e),ve()?.onCoreEvent(n)}};class R{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}abi_describe(){let e,t;try{const r=s.clientcore_abi_describe(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}apply_aim(e,t,r,a){s.clientcore_apply_aim(this.__wbg_ptr,e,t,r,a)}apply_input(e,t,r){const a=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=d,i=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=d;s.clientcore_apply_input(this.__wbg_ptr,a,o,i,c,r)}debug_json(){let e,t;try{const r=s.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const a=v(e,s.__wbindgen_malloc),o=d,i=s.clientcore_decode_frame(this.__wbg_ptr,a,o);return t=i[0],r=i[1],u(i[0],i[1])}finally{s.__wbindgen_free(t,r,1)}}dispatch(e,t){const r=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d,o=v(t,s.__wbindgen_malloc),i=d,c=s.clientcore_dispatch(this.__wbg_ptr,r,a,o,i);var _=k(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=x(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.clientcore_new(t,r);if(a[2])throw f(a[1]);return this.__wbg_ptr=a[0],z.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=v(e,s.__wbindgen_malloc),a=d;return s.clientcore_push_frame(this.__wbg_ptr,r,a,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.clientcore_set_map(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}set_model(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d;s.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d;s.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=s.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=s.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,B.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}abi_describe(){let e,t;try{const r=s.gamecore_abi_describe(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=x(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,a,o){s.gamecore_apply_aim(this.__wbg_ptr,e,t,r,a,o)}apply_input(e,t,r,a){const o=p(r,s.__wbindgen_malloc,s.__wbindgen_realloc),i=d,c=p(a,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d;s.gamecore_apply_input(this.__wbg_ptr,e,t,o,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const r=s.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=v(e,s.__wbindgen_malloc),r=d,a=s.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}dispatch(e,t){const r=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d,o=v(t,s.__wbindgen_malloc),i=d,c=s.gamecore_dispatch(this.__wbg_ptr,r,a,o,i);var _=k(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=k(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.gamecore_load_map(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}map_info(){let e,t;try{const r=s.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.gamecore_new(t,r);if(a[2])throw f(a[1]);return this.__wbg_ptr=a[0],B.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw f(e[0])}pack_frame(e,t,r,a,o,i,c,_){var l=Ie(c)?0:p(c,s.__wbindgen_malloc,s.__wbindgen_realloc),h=d;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,r,a,o,i,l,h,_)>>>0}players_data(){let e,t;try{const r=s.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var r=x(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,r,a,o){s.gamecore_reset_actor(this.__wbg_ptr,e,t,r,a,o)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=k(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}set_actor_level(e,t){s.gamecore_set_actor_level(this.__wbg_ptr,e,t)}spawn_actor(e,t,r,a,o,i){const c=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,r,a,o,i);if(l[1])throw f(l[0])}spawn_scripted_actor(e,t,r,a,o,i){const c=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,r,a,o,i);if(l[1])throw f(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=s.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);function q(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(u(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(u(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_clientcore_free(n,1)),B=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_gamecore_free(n,1));function x(n,e){return n=n>>>0,xe().subarray(n/4,n/4+e)}function k(n,e){return n=n>>>0,b().subarray(n/1,n/1+e)}let y=null;function xe(){return(y===null||y.byteLength===0)&&(y=new Float32Array(s.memory.buffer)),y}function u(n,e){return Oe(n>>>0,e)}let w=null;function b(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(s.memory.buffer)),w}function Ie(n){return n==null}function v(n,e){const t=e(n.length*1,1)>>>0;return b().set(n,t/1),d=n.length,t}function p(n,e,t){if(t===void 0){const c=S.encode(n),_=e(c.length,1)>>>0;return b().subarray(_,_+c.length).set(c),d=c.length,_}let r=n.length,a=e(r,1)>>>0;const o=b();let i=0;for(;i<r;i++){const c=n.charCodeAt(i);if(c>127)break;o[a+i]=c}if(i!==r){i!==0&&(n=n.slice(i)),a=t(a,r,r=i+n.length*3,1)>>>0;const c=b().subarray(a+i,a+r),_=S.encodeInto(n,c);i+=_.written,a=t(a,r,i,1)>>>0}return d=i,a}function f(n){const e=s.__wbindgen_externrefs.get(n);return s.__externref_table_dealloc(n),e}let M=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});M.decode();const De=2146435072;let C=0;function Oe(n,e){return C+=e,C>=De&&(M=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),M.decode(),C=e),M.decode(b().subarray(n,n+e))}const S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(n,e){const t=S.encode(n);return e.set(t),{read:n.length,written:t.length}});let d=0,s;function $(n,e){return s=n.exports,y=null,w=null,s.__wbindgen_start(),s}async function Fe(n,e){if(typeof Response=="function"&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(a){if(t(n.type)&&n.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",a);else throw a}const r=await n.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(n,e);return r instanceof WebAssembly.Instance?{instance:r,module:n}:r}function t(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function ze(n){if(s!==void 0)return s;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=q();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return $(t)}async function Be(n){if(s!==void 0)return s;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),n===void 0&&(n=new URL("/assets/vimp_snakes_core_bg-p5kW2YDJ.wasm",import.meta.url));const e=q();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Fe(await n,e);return $(t)}const We=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:R,GameCore:T,default:Be,initSync:ze},Symbol.toStringTag,{value:"Module"}));export{Le as default};
|
|
1
|
+
const X=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),Z={s1:{id:1,kind:"indexed8",class:"hot",fields:[...X,{name:"angle",ty:"f32",interp:"lerpAngle"},{name:"radius",ty:"f32",interp:"lerp"},{name:"crystals",ty:"u16"},{name:"color",ty:"u8"},{name:"boost",ty:"u8"}]},cr:{id:2,kind:"indexed32",class:"event",fields:[{name:"x",ty:"f32"},{name:"y",ty:"f32"},{name:"tier",ty:"u8"},{name:"color",ty:"u8"}]},c1:{id:3,kind:"indexedNoNull8",class:"hot",fields:[{name:"x",ty:"f32",interp:"lerp"},{name:"y",ty:"f32",interp:"lerp"},{name:"angle",ty:"f32",interp:"lerpAngle"}]}},I=[16731469,16752412,16765503,10214972,3065014,3848191,5531903,11623679,16735432,16250871,8250065,16753828],J=n=>`#${I[n%I.length].toString(16).padStart(6,"0")}`,Q=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],E={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.4,turnSpeedFalloff:.18,turnSpeedMin:1.4,baseRadius:14,radiusGain:1.6,baseLength:150,lengthPerCrystal:9,pointSpacing:6,boostDrainPerSecond:6,boostMinCrystals:2,world:{maxCrystals:60,spawnInterval:.35,tierWeights:[70,25,5],tiers:Q,dropRatio:.8,edgeMargin:60,startCrystals:0,spawnGraceSeconds:2}}},ee={},L=128,D=1,te=20,O=8,N=4,A=64,re=Math.PI*(3-Math.sqrt(5)),ne=.72,se=25;function P(n){const e=Math.ceil(Math.max(n,0)/N)*N,t=Math.max(e,O);return Math.round(te*Math.sqrt(t/O))}const W=Math.log2(A);if(!Number.isInteger(W))throw new Error(`RESPAWN_COUNT must be a power of two (the order is bit-reversed), got ${A}`);function ae(n){let e=0;for(let t=0;t<W;t+=1)e=e<<1|n>>t&1;return e}function oe(n){const e=n*L/2,t=e;return Array.from({length:A},(r,a)=>{const o=ae(a),i=e*ne*Math.sqrt((o+.5)/A),c=o*re,_=t+Math.cos(c)*i,l=t+Math.sin(c)*i,h=(a*.6180339887%1*2-1)*se,m=c*180/Math.PI+180+h;return[Math.round(_),Math.round(l),Math.round((m%360+360)%360)]})}function U(n=0){const e=P(n);return{setId:"c1",scale:1,step:L,physicsStatic:[],physicsDynamic:[],layers:{1:[D]},map:Array.from({length:e},()=>Array.from({length:e},()=>D)),respawns:{players:oe(e)}}}const ie=U(0),ce={arena:ie},_e={title:"Snakes",parts:{models:E,weapons:ee,friendlyFire:!1},snapshot:Z,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},maps:ce,currentMap:"arena",mapScale:1,mapSetId:"c1",mapsInVote:1,timers:{timeStep:1e3/120,networkSendRate:4,roundTime:36e5,mapTime:36e5,roomTimeMin:1e4,roomTimeMax:36e5,voteTime:1e4,timeBlockedVote:3e4,teamChangeGracePeriod:1e4,roundRestartDelay:5e3,mapChangeDelay:2e3,rttPingInterval:3e3,idleCheckInterval:3e4},playerState:{defaultState:{best:0,eaten:0}},noSpectators:!0,endlessRound:!0,statMode:"leaderboard",teams:{players:1},scripted:{namePrefix:"Snake",defaultModel:"s1"},playerKeys:{left:{key:1},right:{key:2},boost:{key:4},respawn:{key:8,type:1}},panel:{fields:{crystals:{key:"c",value:0},score:{key:"s",value:0},dead:{key:"d",value:0}},activeKey:"wa"},stat:{name:{key:0,bodyMethod:"=",headSync:!0,headMethod:"#"},status:{key:1,bodyMethod:"=",bodyValue:"",headValue:""},score:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:3,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},le={elems:{authId:"auth",fieldsId:"auth-fields",errorId:"auth-error",enterId:"auth-enter",titleId:"auth-title",informsId:"auth-informs"},texts:{title:"Snakes",sections:[{heading:"How to play",lines:[{keys:"a, d",text:"turn"},{keys:"w",text:"boost (burns crystals)"},{keys:"r",text:"respawn after a crash"},{separator:!0},{keys:"",text:"eat crystals to grow"},{keys:"",text:"the edge and other snakes kill you"},{keys:"",text:"your own tail does not"},{separator:!0},{keys:"c",text:"chat"},{keys:"<Tab>",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(E),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in E}},de={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},pe={codecList:["webm","mp3"],spatial:{mode:"topDown",innerRadius:14},sounds:de},ue={parts:{gameSets:{s1:["Snake"],cr:["Crystal"],c1:["Arena"]},entitiesOnCanvas:{Arena:"vimp",Snake:"vimp",Crystal:"vimp"},bakedAssets:{vimp:[{name:"crystalGem",component:"Crystal",params:{radius:32,facets:6}},{name:"crown",component:"Snake",params:{size:64,points:3}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"],accolades:["Snake"]},sounds:pe},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{modes:{77:""},keySetList:[{78:"nextPlayer",80:"prevPlayer"},{65:"left",68:"right",87:"boost",82:"respawn"}],pointer:{keySets:[1],doubleTapMs:300,doubleTapPx:40,sendIntervalMs:50}},chat:{params:{messages:{s:["The arena is full. You will join as soon as a place frees up","You are already in the arena","You are in the arena","You are watching the arena","{0} crashed into {1}","{0} joined the game","{0} left the game","Host changed","You are no longer the host (connection lost)","Host changed: the previous host was lagging","Host changed: the previous host went inactive","Host changed: the previous host had a poor connection"],v:["A vote has been created","Voting has started","Your vote has been accepted","Voting is temporarily unavailable","Vote passed","Vote failed","Usage: /changehost","You are the host — use “Hand over host” in the room menu","No connection to the master server","A host vote was held recently","No other player can host","A host vote is already in progress","A host vote is not possible right now","Vote to change host passed ({0}/{1})","Vote to change host failed ({0}/{1})","Host vote cancelled"],m:["Current map: {0}","Next map: {0}"],c:["Command not found","Your place today: {0} of {1} ({2} points)"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"score",elem:"panel-score",type:"value"},{name:"crystals",elem:"panel-crystals",type:"value"},{name:"dead",elem:"panel-dead",type:"value"},{name:"mode",elem:"panel-mode",type:"weapon"},{name:"time",elem:"panel-time",type:"time"}]},stat:{params:{mode:"leaderboard",period:"day",limit:10,columns:["#","snake","score"]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class he{constructor({participants:e,coreAdapter:t,socketManager:r},a){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=a,this._vimp=null,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e,t={}){t.vimp&&(this._vimp=t.vimp),!(!e||e.type!=="population")&&this._apply(Number(e.count)||0)}_apply(e){const t=this._sizeFor(e);if(t!==this._size){this._size=t,this._population=e;const r=U(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._vimp?.overrideMapData?.(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return P(e);const t=P(e);return t>this._size||e<=this._population-N?t:this._size}_broadcast(){if(!this._mapData)return;const e=this._participants.getHumans(),t=new Set;for(const r of e)t.add(r.socketId),!(!r.isReady||this._delivered.get(r.socketId)===this._size)&&(this._delivered.set(r.socketId,this._size),this._socketManager.sendMap(r.socketId,this._mapData));for(const r of this._delivered.keys())t.has(r)||this._delivered.delete(r)}reapply(){this._mapData&&(this._vimp?.overrideMapData?.(this._mapData),this._coreAdapter.createMap(this._mapData),this._scriptedManager?.createMap(this._mapData),this._broadcast())}get mapData(){return this._mapData??null}}class fe{constructor({participants:e}){this._participants=e}onCoreEvent(e){if(!e||e.type!=="spawn")return;const t=Number(e.color);!Number.isFinite(t)||t<0||this._participants?.setChatColor?.(String(e.id),J(t))}}class me{constructor({participants:e,coreAdapter:t,panel:r,stat:a,scripted:o}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=a,this._model=o.defaultModel,this._respawns=null}createMap(e){this._respawns=e.respawns}getCountsPerTeam(){const e={};for(const t of this._participants.getScripted())e[t.team]=(e[t.team]??0)+1;return e}createScripted(e,t=null){if(!this._respawns)return 0;const r=this._participants.getPlayableTeams();let a=0;for(let o=0;o<e&&!this._participants.isFull;o+=1){const i=t??this._pickTeam(r);if(!i||!this._hasRoom(i))break;const c=this._participants.createScripted({team:i,model:this._model}),_=this._participants.get(c);this._stat.addUser(c,_.teamId,{name:_.name,status:"",latency:"BOT"}),this._panel.addUser(c),a+=1}return a}_hasRoom(e){const t=this._respawns[e];return!!(t&&this._participants.getTeamSize(e)<t.length)}_pickTeam(e){return[...e].sort((t,r)=>this._participants.getTeamSize(t)-this._participants.getTeamSize(r)).find(t=>this._hasRoom(t))??null}removeScripted(e=null){const t=this._participants.getScripted();(e?t.filter(a=>a.team===e):t).forEach(a=>this._remove(a.gameId))}removeOneForHuman(e){for(const t of this._participants.getScripted())if(t.team===e)return this._remove(t.gameId),!0;return!1}_remove(e){const t=this._participants.get(e);!t||!t.isScripted||(this._stat.removeUser(e,t.teamId),this._panel.removeUser(e),this._coreAdapter.removePlayer(e),this._participants.remove(e))}}const ge=15;class be{constructor({participants:e,stat:t}){this._participants=e,this._stat=t,this._totals=new Map}onCoreEvent(e,t={}){if(!e||typeof e!="object")return;const{vimp:r,panel:a}=t,o=String(e.id);switch(e.type){case"crystals":this._onCrystals(o,Number(e.gained)||0,r,a);break;case"burn":this._onBurn(o,Number(e.burned)||0,r,a);break;case"death":this._onDeath(o,e,r,a);break;case"respawn":this._onRespawn(o,r,a);break;case"population":this._publishNewcomers(r,a),r?.flushPlayerData?.();break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r,a){const o=this._record(e);!o||t<=0||(o.eaten+=t,o.score+=t,this._publish(e,o,r,a))}_onBurn(e,t,r,a){const o=this._record(e);!o||t<=0||(o.score=Math.max(0,o.score-t),this._publish(e,o,r,a))}_onDeath(e,t,r,a){const o=this._record(e);if(!o)return;const i=t.killer===null||t.killer===void 0?null:String(t.killer);if(i!==null&&i!==e){const l=this._record(i);l&&(l.kills+=1,l.score+=ge,this._publish(i,l,r,a))}this._publish(e,o,r,a);const _=r?.isPlayerRatingLoaded?.(e,"day")===!0?r.getPlayerRating?.(e,"day")?.value??0:1/0;r?.addPlayerPoints?.(e,o.score),r?.finishPlayerGame?.(e),this._recordBest(e,o,r),r?.flushPlayerData?.({urgent:o.score>_})}_onRespawn(e,t,r){const a=this._record(e);a&&(a.eaten=0,a.kills=0,a.score=0,a.flushedEaten=0,this._publish(e,a,t,r))}_record(e){const t=this._participants.get(e);if(!t)return null;const r=this._totals.get(e);if(r&&r.participant===t)return r;const a={participant:t,eaten:0,kills:0,score:0,flushedEaten:0,published:!1};return this._totals.set(e,a),a}_publishNewcomers(e,t){for(const r of this._participants.getAll()){const a=r.gameId,o=this._totals.get(a),i=o?.participant===r?o:this._record(a);i&&!i.published&&this._publish(a,i,e,t)}}_publish(e,t,r,a){const{score:o}=t;t.published=!0,this._stat.updateUser(e,t.participant.teamId,{score:o}),a&&a.updateUser(e,"score",o,"set")}_recordBest(e,t,r){if(!r?.getPlayerState)return;const a=r.getPlayerState(e);if(!a)return;const o=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const i=Math.max(Number(a.best)||0,t.score),c=(Number(a.eaten)||0)+o;r.setPlayerState(e,{...a,best:i,eaten:c})}}let V=null,j=null,G=null;function ye(n){const e=new me(n);return V=new be(n),j=new he(n,e),G=new fe(n),{scripted:e}}function we(){return V}function Y(){return j}function ve(){return G}const Se={name:"/bot",handler(n,e,t){const r=Number(t[0]);if(t[0]===void 0||!Number.isFinite(r)||r<0){n.chat.pushSystemByUser(e,"BOT_COUNT_INVALID");return}const{maxPlayers:a}=n.participants,o=Math.trunc(r),i=a>0?Math.min(o,a):o;n.scripted.removeScripted();const c=i>0?n.scripted.createScripted(i):0;n.chat.pushSystem("BOTS_SET",[c]),c>0&&(n.roundManager.initiateNewRound(),Y()?.reapply())}},ke={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},Me={name:"/rank",async handler(n,e){let t=null;try{t=await n.playerDataSync?.refreshPlacement?.(e,"day")}catch{t=n.playerDataSync?.getRating?.(e,"day")??null}const{value:r=0,placement:a=null,total:o=0}=t??{};n.chat.pushSystemByUser(e,"RANK",[a??"—",o,r])}},Ae={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},Ce="modulepreload",Ee=function(n){return"/"+n},F={},Ne=function(e,t,r){let a=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");a=_(t.map(l=>{if(l=Ee(l),l in F)return;F[l]=!0;const h=l.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Ce,h||(g.as="script"),g.crossOrigin="",g.href=l,c&&g.setAttribute("nonce",c),document.head.appendChild(g),h)return new Promise((H,K)=>{g.addEventListener("load",H),g.addEventListener("error",()=>K(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return e().catch(o)})},Pe=n=>(n??"").endsWith(".js"),Re=n=>import(n),Te=()=>Ne(()=>Promise.resolve().then(()=>Le),[]),We={id:"snakes",engineApi:4,requires:["accolades"],async createCore(n,{wasmUrl:e}={}){if(Pe(e)){const a=await Re(e);return new a.GameCore(n)}const{default:t,GameCore:r}=await Te();return await t({module_or_path:e}),new r(n)},gameConfig:_e,authSchema:le,chatCommands:[Se,ke,Me],systemMessages:Ae,createModules:ye,buildClientGameConfig:()=>ue,onCoreEvent(n,e={}){we()?.onCoreEvent(n,e),Y()?.onCoreEvent(n,e),ve()?.onCoreEvent(n)}};class R{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}abi_describe(){let e,t;try{const r=s.clientcore_abi_describe(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}apply_aim(e,t,r,a){s.clientcore_apply_aim(this.__wbg_ptr,e,t,r,a)}apply_input(e,t,r){const a=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=d,i=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=d;s.clientcore_apply_input(this.__wbg_ptr,a,o,i,c,r)}debug_json(){let e,t;try{const r=s.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const a=v(e,s.__wbindgen_malloc),o=d,i=s.clientcore_decode_frame(this.__wbg_ptr,a,o);return t=i[0],r=i[1],u(i[0],i[1])}finally{s.__wbindgen_free(t,r,1)}}dispatch(e,t){const r=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d,o=v(t,s.__wbindgen_malloc),i=d,c=s.clientcore_dispatch(this.__wbg_ptr,r,a,o,i);var _=k(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=x(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.clientcore_new(t,r);if(a[2])throw f(a[1]);return this.__wbg_ptr=a[0],z.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=v(e,s.__wbindgen_malloc),a=d;return s.clientcore_push_frame(this.__wbg_ptr,r,a,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.clientcore_set_map(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}set_model(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d;s.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d;s.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=s.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=s.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,B.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}abi_describe(){let e,t;try{const r=s.gamecore_abi_describe(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=x(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,a,o){s.gamecore_apply_aim(this.__wbg_ptr,e,t,r,a,o)}apply_input(e,t,r,a){const o=p(r,s.__wbindgen_malloc,s.__wbindgen_realloc),i=d,c=p(a,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d;s.gamecore_apply_input(this.__wbg_ptr,e,t,o,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const r=s.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=v(e,s.__wbindgen_malloc),r=d,a=s.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}dispatch(e,t){const r=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d,o=v(t,s.__wbindgen_malloc),i=d,c=s.gamecore_dispatch(this.__wbg_ptr,r,a,o,i);var _=k(c[0],c[1]).slice();return s.__wbindgen_free(c[0],c[1]*1,1),_}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=k(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.gamecore_load_map(this.__wbg_ptr,t,r);if(a[1])throw f(a[0])}map_info(){let e,t;try{const r=s.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=p(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.gamecore_new(t,r);if(a[2])throw f(a[1]);return this.__wbg_ptr=a[0],B.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw f(e[0])}pack_frame(e,t,r,a,o,i,c,_){var l=Ie(c)?0:p(c,s.__wbindgen_malloc,s.__wbindgen_realloc),h=d;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,r,a,o,i,l,h,_)>>>0}players_data(){let e,t;try{const r=s.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var r=x(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,r,a,o){s.gamecore_reset_actor(this.__wbg_ptr,e,t,r,a,o)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=k(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}set_actor_level(e,t){s.gamecore_set_actor_level(this.__wbg_ptr,e,t)}spawn_actor(e,t,r,a,o,i){const c=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,r,a,o,i);if(l[1])throw f(l[0])}spawn_scripted_actor(e,t,r,a,o,i){const c=p(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=d,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,r,a,o,i);if(l[1])throw f(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=s.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);function q(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(u(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(u(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_clientcore_free(n,1)),B=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_gamecore_free(n,1));function x(n,e){return n=n>>>0,xe().subarray(n/4,n/4+e)}function k(n,e){return n=n>>>0,b().subarray(n/1,n/1+e)}let y=null;function xe(){return(y===null||y.byteLength===0)&&(y=new Float32Array(s.memory.buffer)),y}function u(n,e){return Oe(n>>>0,e)}let w=null;function b(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(s.memory.buffer)),w}function Ie(n){return n==null}function v(n,e){const t=e(n.length*1,1)>>>0;return b().set(n,t/1),d=n.length,t}function p(n,e,t){if(t===void 0){const c=S.encode(n),_=e(c.length,1)>>>0;return b().subarray(_,_+c.length).set(c),d=c.length,_}let r=n.length,a=e(r,1)>>>0;const o=b();let i=0;for(;i<r;i++){const c=n.charCodeAt(i);if(c>127)break;o[a+i]=c}if(i!==r){i!==0&&(n=n.slice(i)),a=t(a,r,r=i+n.length*3,1)>>>0;const c=b().subarray(a+i,a+r),_=S.encodeInto(n,c);i+=_.written,a=t(a,r,i,1)>>>0}return d=i,a}function f(n){const e=s.__wbindgen_externrefs.get(n);return s.__externref_table_dealloc(n),e}let M=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});M.decode();const De=2146435072;let C=0;function Oe(n,e){return C+=e,C>=De&&(M=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),M.decode(),C=e),M.decode(b().subarray(n,n+e))}const S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(n,e){const t=S.encode(n);return e.set(t),{read:n.length,written:t.length}});let d=0,s;function $(n,e){return s=n.exports,y=null,w=null,s.__wbindgen_start(),s}async function Fe(n,e){if(typeof Response=="function"&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(a){if(t(n.type)&&n.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",a);else throw a}const r=await n.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(n,e);return r instanceof WebAssembly.Instance?{instance:r,module:n}:r}function t(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function ze(n){if(s!==void 0)return s;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=q();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return $(t)}async function Be(n){if(s!==void 0)return s;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),n===void 0&&(n=new URL("/assets/vimp_snakes_core_bg-Ycx_0IaJ.wasm",import.meta.url));const e=q();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Fe(await n,e);return $(t)}const Le=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:R,GameCore:T,default:Be,initSync:ze},Symbol.toStringTag,{value:"Module"}));export{We as default};
|
package/dist/manifest.json
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"requires": [
|
|
5
5
|
"accolades"
|
|
6
6
|
],
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "5d85ad0f351553db",
|
|
8
8
|
"title": "Snakes",
|
|
9
9
|
"entries": {
|
|
10
|
-
"client": "/games/snakes/client-
|
|
11
|
-
"host": "/games/snakes/host-
|
|
12
|
-
"wasm": "/games/snakes/assets/vimp_snakes_core_bg-
|
|
10
|
+
"client": "/games/snakes/client-BrlV_OCM.js",
|
|
11
|
+
"host": "/games/snakes/host-henEezm8.js",
|
|
12
|
+
"wasm": "/games/snakes/assets/vimp_snakes_core_bg-Ycx_0IaJ.wasm",
|
|
13
13
|
"wasmNode": "./core-node/vimp_snakes_core.js"
|
|
14
14
|
},
|
|
15
15
|
"assetsBase": "/games/snakes/",
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vimp-games/snakes",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.10",
|
|
4
4
|
"description": "VIMP Snakes — a VIMP game plugin",
|
|
5
5
|
"author": "lgick",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+ssh://git@github.com/lgick/vimp-snakes.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.vimp.lgick.dev",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.11.0"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"globals": "^16.2.0",
|
|
47
47
|
"happy-dom": "^20.10.6",
|
|
48
48
|
"pixi.js": "^8.14.0",
|
|
49
|
-
"vimp-engine": "^0.38.
|
|
49
|
+
"vimp-engine": "^0.38.2",
|
|
50
50
|
"vite": "^7.1.11",
|
|
51
51
|
"vitest": "^4.1.9"
|
|
52
52
|
}
|