@fluritheme/grinch 0.0.0-stage → 0.1.0
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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +188 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +508 -0
- package/dist/index.js.map +1 -0
- package/dist/layers.d.ts +12 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +58 -0
- package/dist/layers.js.map +1 -0
- package/dist/model.d.ts +67 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +404 -0
- package/dist/model.js.map +1 -0
- package/dist/options.d.ts +26 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +89 -0
- package/dist/options.js.map +1 -0
- package/dist/paint.d.ts +9 -0
- package/dist/paint.d.ts.map +1 -0
- package/dist/paint.js +355 -0
- package/dist/paint.js.map +1 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -4
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Options } from './options.js';
|
|
2
|
+
import type { Box, GiftState, GrinchEvent, GrinchEventData, GrinchPhase, Point } from './types.js';
|
|
3
|
+
export declare const clamp: (n: number, a: number, b: number) => number;
|
|
4
|
+
export declare const distance: (a: Point, b: Point) => number;
|
|
5
|
+
export interface Gift {
|
|
6
|
+
id: string;
|
|
7
|
+
position: Point;
|
|
8
|
+
state: GiftState;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
color: string;
|
|
11
|
+
returning: {
|
|
12
|
+
from: Point;
|
|
13
|
+
age: number;
|
|
14
|
+
} | null;
|
|
15
|
+
element?: HTMLElement;
|
|
16
|
+
}
|
|
17
|
+
export interface Shelter {
|
|
18
|
+
id: string;
|
|
19
|
+
box: Box;
|
|
20
|
+
}
|
|
21
|
+
export interface Actor extends Point {
|
|
22
|
+
phase: GrinchPhase;
|
|
23
|
+
age: number;
|
|
24
|
+
gait: number;
|
|
25
|
+
facing: number;
|
|
26
|
+
behind: boolean;
|
|
27
|
+
visible: boolean;
|
|
28
|
+
destination: Point;
|
|
29
|
+
rope: Point | null;
|
|
30
|
+
}
|
|
31
|
+
type Emit = (event: GrinchEvent, data: GrinchEventData) => void;
|
|
32
|
+
export declare class Mischief {
|
|
33
|
+
private readonly options;
|
|
34
|
+
private readonly emit;
|
|
35
|
+
readonly actor: Actor;
|
|
36
|
+
gifts: Gift[];
|
|
37
|
+
totalStolen: number;
|
|
38
|
+
caught: number;
|
|
39
|
+
time: number;
|
|
40
|
+
private nextHeist;
|
|
41
|
+
private lastCatch;
|
|
42
|
+
private target;
|
|
43
|
+
private shelter;
|
|
44
|
+
private initialized;
|
|
45
|
+
private afterClimb;
|
|
46
|
+
constructor(options: Options, emit?: Emit);
|
|
47
|
+
get held(): Gift | undefined;
|
|
48
|
+
get stolen(): number;
|
|
49
|
+
change(phase: GrinchPhase): void;
|
|
50
|
+
spawn(view: Box, quiet?: boolean): void;
|
|
51
|
+
settleEntrance(): void;
|
|
52
|
+
steal(gift?: Gift): boolean;
|
|
53
|
+
private hand;
|
|
54
|
+
private sack;
|
|
55
|
+
giftPoint(gift: Gift): Point;
|
|
56
|
+
private returnGift;
|
|
57
|
+
returnGifts(immediate?: boolean): void;
|
|
58
|
+
redeem(immediate?: boolean): void;
|
|
59
|
+
shoo(immediate?: boolean): void;
|
|
60
|
+
wave(): void;
|
|
61
|
+
private move;
|
|
62
|
+
private hide;
|
|
63
|
+
dispose(): void;
|
|
64
|
+
step(dt: number, view: Box, shelters: readonly Shelter[], pointer: Point | null, quiet?: boolean): void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.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0,0 +1,404 @@
|
|
|
1
|
+
export const clamp = (n, a, b) => Math.max(a, Math.min(b, n));
|
|
2
|
+
export const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
3
|
+
export class Mischief {
|
|
4
|
+
options;
|
|
5
|
+
emit;
|
|
6
|
+
actor = {
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0,
|
|
9
|
+
phase: 'idle',
|
|
10
|
+
age: 0,
|
|
11
|
+
gait: 0,
|
|
12
|
+
facing: 1,
|
|
13
|
+
behind: false,
|
|
14
|
+
visible: true,
|
|
15
|
+
destination: { x: 0, y: 0 },
|
|
16
|
+
rope: null,
|
|
17
|
+
};
|
|
18
|
+
gifts = [];
|
|
19
|
+
totalStolen = 0;
|
|
20
|
+
caught = 0;
|
|
21
|
+
time = 0;
|
|
22
|
+
nextHeist = 1.4;
|
|
23
|
+
lastCatch = -10;
|
|
24
|
+
target = null;
|
|
25
|
+
shelter = null;
|
|
26
|
+
initialized = false;
|
|
27
|
+
afterClimb = 'reaching';
|
|
28
|
+
constructor(options, emit = () => { }) {
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.emit = emit;
|
|
31
|
+
}
|
|
32
|
+
get held() {
|
|
33
|
+
return this.gifts.find((g) => g.state === 'held');
|
|
34
|
+
}
|
|
35
|
+
get stolen() {
|
|
36
|
+
return this.gifts.filter((g) => g.state === 'stolen').length;
|
|
37
|
+
}
|
|
38
|
+
change(phase) {
|
|
39
|
+
this.actor.phase = phase;
|
|
40
|
+
this.actor.age = 0;
|
|
41
|
+
this.emit('phase', { phase });
|
|
42
|
+
}
|
|
43
|
+
spawn(view, quiet = false) {
|
|
44
|
+
if (this.initialized || view.width < 1 || view.height < 1)
|
|
45
|
+
return;
|
|
46
|
+
this.initialized = true;
|
|
47
|
+
const first = this.gifts.find((g) => g.visible);
|
|
48
|
+
const landing = {
|
|
49
|
+
x: clamp((first?.position.x ?? view.x + view.width * 0.65) - 65 * this.options.size, view.x + 35, view.x + Math.max(36, view.width - 35)),
|
|
50
|
+
y: first?.position.y ?? view.y + view.height * 0.72,
|
|
51
|
+
};
|
|
52
|
+
this.actor.destination = landing;
|
|
53
|
+
if (quiet || this.options.entrance === 'appear') {
|
|
54
|
+
Object.assign(this.actor, landing);
|
|
55
|
+
this.change('idle');
|
|
56
|
+
}
|
|
57
|
+
else if (this.options.entrance === 'rope') {
|
|
58
|
+
this.actor.x = landing.x;
|
|
59
|
+
this.actor.y = view.y - 130;
|
|
60
|
+
this.actor.rope = { x: landing.x, y: view.y - 20 };
|
|
61
|
+
this.change('arriving');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.actor.x = view.x - 55;
|
|
65
|
+
this.actor.y = landing.y;
|
|
66
|
+
this.change('arriving');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
settleEntrance() {
|
|
70
|
+
if (this.actor.phase === 'arriving') {
|
|
71
|
+
Object.assign(this.actor, this.actor.destination);
|
|
72
|
+
this.actor.rope = null;
|
|
73
|
+
this.change('idle');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
steal(gift) {
|
|
77
|
+
if (this.options.mood !== 'mischievous' ||
|
|
78
|
+
!['idle', 'waving', 'peeking'].includes(this.actor.phase))
|
|
79
|
+
return false;
|
|
80
|
+
const chosen = gift ??
|
|
81
|
+
this.gifts
|
|
82
|
+
.filter((g) => g.visible && g.state === 'available' && distance(g.position, this.actor) < 1200)
|
|
83
|
+
.sort((a, b) => distance(a.position, this.actor) - distance(b.position, this.actor))[0];
|
|
84
|
+
if (!chosen || chosen.state !== 'available' || !chosen.visible)
|
|
85
|
+
return false;
|
|
86
|
+
this.target = chosen;
|
|
87
|
+
this.actor.behind = false;
|
|
88
|
+
this.actor.rope = null;
|
|
89
|
+
this.change('sneaking');
|
|
90
|
+
this.emit('theft:start', { giftId: chosen.id });
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
hand() {
|
|
94
|
+
return {
|
|
95
|
+
x: this.actor.x + this.actor.facing * 23 * this.options.size,
|
|
96
|
+
y: this.actor.y - 51 * this.options.size,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
sack() {
|
|
100
|
+
return {
|
|
101
|
+
x: this.actor.x - this.actor.facing * 22 * this.options.size,
|
|
102
|
+
y: this.actor.y - 39 * this.options.size,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
giftPoint(gift) {
|
|
106
|
+
const r = gift.returning;
|
|
107
|
+
if (r) {
|
|
108
|
+
const t = clamp(r.age / 0.85, 0, 1), ease = t * t * (3 - 2 * t);
|
|
109
|
+
return {
|
|
110
|
+
x: r.from.x + (gift.position.x - r.from.x) * ease,
|
|
111
|
+
y: r.from.y +
|
|
112
|
+
(gift.position.y - r.from.y) * ease -
|
|
113
|
+
Math.sin(t * Math.PI) * 65 * this.options.size,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (gift.state === 'held') {
|
|
117
|
+
const hand = this.hand();
|
|
118
|
+
if (this.actor.phase === 'stealing') {
|
|
119
|
+
const t = clamp(this.actor.age / 0.65, 0, 1);
|
|
120
|
+
return {
|
|
121
|
+
x: gift.position.x + (hand.x - gift.position.x) * t,
|
|
122
|
+
y: gift.position.y + (hand.y - gift.position.y) * t - Math.sin(t * Math.PI) * 12,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (this.actor.phase === 'stashing') {
|
|
126
|
+
const t = clamp(this.actor.age / 0.7, 0, 1), sack = this.sack();
|
|
127
|
+
return {
|
|
128
|
+
x: hand.x + (sack.x - hand.x) * t,
|
|
129
|
+
y: hand.y + (sack.y - hand.y) * t - Math.sin(t * Math.PI) * 18,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return hand;
|
|
133
|
+
}
|
|
134
|
+
return { ...gift.position };
|
|
135
|
+
}
|
|
136
|
+
returnGift(gift, immediate = false) {
|
|
137
|
+
if (gift.state === 'available' || gift.state === 'returning')
|
|
138
|
+
return;
|
|
139
|
+
const from = gift.state === 'held' ? this.giftPoint(gift) : this.sack();
|
|
140
|
+
gift.state = immediate ? 'available' : 'returning';
|
|
141
|
+
gift.returning = immediate ? null : { from, age: 0 };
|
|
142
|
+
if (immediate)
|
|
143
|
+
this.emit('gift:returned', { giftId: gift.id });
|
|
144
|
+
}
|
|
145
|
+
returnGifts(immediate = false) {
|
|
146
|
+
for (const gift of this.gifts)
|
|
147
|
+
this.returnGift(gift, immediate);
|
|
148
|
+
this.target = null;
|
|
149
|
+
this.actor.rope = null;
|
|
150
|
+
this.nextHeist = this.time + this.options.cooldown;
|
|
151
|
+
if (this.actor.phase !== 'warming')
|
|
152
|
+
this.change('waving');
|
|
153
|
+
}
|
|
154
|
+
redeem(immediate = false) {
|
|
155
|
+
this.options.mood = 'friendly';
|
|
156
|
+
this.returnGifts(immediate);
|
|
157
|
+
this.change('warming');
|
|
158
|
+
this.emit('redeemed', {});
|
|
159
|
+
if (immediate)
|
|
160
|
+
this.change('idle');
|
|
161
|
+
}
|
|
162
|
+
shoo(immediate = false) {
|
|
163
|
+
if (this.time - this.lastCatch < 1)
|
|
164
|
+
return;
|
|
165
|
+
const gift = this.held ?? [...this.gifts].reverse().find((g) => g.state === 'stolen');
|
|
166
|
+
if (gift)
|
|
167
|
+
this.returnGift(gift, immediate);
|
|
168
|
+
this.lastCatch = this.time;
|
|
169
|
+
this.caught++;
|
|
170
|
+
this.target = null;
|
|
171
|
+
this.actor.rope = null;
|
|
172
|
+
this.change('caught');
|
|
173
|
+
this.emit('caught', {});
|
|
174
|
+
}
|
|
175
|
+
wave() {
|
|
176
|
+
if (this.held)
|
|
177
|
+
this.returnGifts();
|
|
178
|
+
this.target = null;
|
|
179
|
+
this.actor.rope = null;
|
|
180
|
+
this.change('waving');
|
|
181
|
+
this.nextHeist = this.time + 3;
|
|
182
|
+
}
|
|
183
|
+
move(to, dt, rate) {
|
|
184
|
+
const a = this.actor, dx = to.x - a.x, dy = to.y - a.y, len = Math.hypot(dx, dy), travel = Math.min(len, dt * rate * this.options.speed);
|
|
185
|
+
if (Math.abs(dx) > 1)
|
|
186
|
+
a.facing = dx > 0 ? 1 : -1;
|
|
187
|
+
if (len > 0.01) {
|
|
188
|
+
a.x += (dx / len) * travel;
|
|
189
|
+
a.y += (dy / len) * travel;
|
|
190
|
+
a.gait += travel * 0.11;
|
|
191
|
+
}
|
|
192
|
+
return len < 2;
|
|
193
|
+
}
|
|
194
|
+
hide(shelters) {
|
|
195
|
+
const size = this.options.size;
|
|
196
|
+
this.shelter =
|
|
197
|
+
shelters
|
|
198
|
+
.filter((s) => s.box.height > 155 * size &&
|
|
199
|
+
s.box.width > 80 * size &&
|
|
200
|
+
distance({ x: s.box.x + s.box.width / 2, y: s.box.y + s.box.height / 2 }, this.actor) <
|
|
201
|
+
650)
|
|
202
|
+
.sort((a, b) => distance(a.box, this.actor) - distance(b.box, this.actor))[0] ?? null;
|
|
203
|
+
if (this.shelter) {
|
|
204
|
+
const b = this.shelter.box;
|
|
205
|
+
this.actor.destination = { x: b.x + b.width * 0.5, y: b.y + b.height - 8 };
|
|
206
|
+
this.actor.behind = true;
|
|
207
|
+
this.change('escaping');
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
this.actor.behind = false;
|
|
211
|
+
this.change('waving');
|
|
212
|
+
this.nextHeist = this.time + this.options.cooldown;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
dispose() {
|
|
216
|
+
this.gifts = [];
|
|
217
|
+
this.target = null;
|
|
218
|
+
this.shelter = null;
|
|
219
|
+
this.actor.rope = null;
|
|
220
|
+
}
|
|
221
|
+
step(dt, view, shelters, pointer, quiet = false) {
|
|
222
|
+
if (!this.initialized)
|
|
223
|
+
this.spawn(view, quiet);
|
|
224
|
+
if (!this.initialized)
|
|
225
|
+
return;
|
|
226
|
+
const a = this.actor, size = this.options.size;
|
|
227
|
+
a.visible =
|
|
228
|
+
a.x > view.x - 70 &&
|
|
229
|
+
a.x < view.x + view.width + 70 &&
|
|
230
|
+
a.y > view.y - 30 &&
|
|
231
|
+
a.y - 145 * size < view.y + view.height;
|
|
232
|
+
if (quiet) {
|
|
233
|
+
this.settleEntrance();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (!(dt > 0))
|
|
237
|
+
return;
|
|
238
|
+
dt = clamp(dt, 0, 0.05);
|
|
239
|
+
this.time += dt;
|
|
240
|
+
this.actor.age += dt;
|
|
241
|
+
for (const gift of this.gifts)
|
|
242
|
+
if (gift.returning) {
|
|
243
|
+
gift.returning.age += dt;
|
|
244
|
+
if (gift.returning.age >= 0.85) {
|
|
245
|
+
gift.returning = null;
|
|
246
|
+
gift.state = 'available';
|
|
247
|
+
this.emit('gift:returned', { giftId: gift.id });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (this.shelter) {
|
|
251
|
+
const live = shelters.find((s) => s.id === this.shelter.id);
|
|
252
|
+
if (live)
|
|
253
|
+
this.shelter = live;
|
|
254
|
+
else {
|
|
255
|
+
this.shelter = null;
|
|
256
|
+
a.behind = false;
|
|
257
|
+
if (['hiding', 'peeking', 'escaping'].includes(a.phase))
|
|
258
|
+
this.change('idle');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (pointer &&
|
|
262
|
+
this.options.fearRadius > 0 &&
|
|
263
|
+
a.visible &&
|
|
264
|
+
!a.behind &&
|
|
265
|
+
!['caught', 'warming', 'arriving'].includes(a.phase) &&
|
|
266
|
+
this.time - this.lastCatch > 3 &&
|
|
267
|
+
distance({ x: a.x, y: a.y - 60 * size }, pointer) < this.options.fearRadius)
|
|
268
|
+
this.shoo();
|
|
269
|
+
if (this.target && !this.gifts.includes(this.target)) {
|
|
270
|
+
this.target = null;
|
|
271
|
+
a.rope = null;
|
|
272
|
+
this.change('idle');
|
|
273
|
+
this.nextHeist = this.time + 2;
|
|
274
|
+
}
|
|
275
|
+
const gift = this.target;
|
|
276
|
+
switch (a.phase) {
|
|
277
|
+
case 'arriving':
|
|
278
|
+
if (this.move(a.destination, dt, this.options.entrance === 'rope' ? 180 : 95)) {
|
|
279
|
+
a.rope = null;
|
|
280
|
+
this.change('waving');
|
|
281
|
+
this.nextHeist = this.time + 1.5;
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case 'idle':
|
|
285
|
+
if (this.options.mood === 'mischievous' &&
|
|
286
|
+
this.options.autoSteal &&
|
|
287
|
+
this.time > this.nextHeist &&
|
|
288
|
+
a.visible)
|
|
289
|
+
this.steal();
|
|
290
|
+
else if (this.options.mood === 'friendly' && a.age > 5)
|
|
291
|
+
this.wave();
|
|
292
|
+
break;
|
|
293
|
+
case 'sneaking':
|
|
294
|
+
case 'climbing': {
|
|
295
|
+
if (!gift && this.afterClimb === 'idle' && a.phase === 'climbing') {
|
|
296
|
+
if (this.move(a.destination, dt, 95)) {
|
|
297
|
+
a.rope = null;
|
|
298
|
+
a.behind = false;
|
|
299
|
+
this.change('idle');
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
if (!gift || !gift.visible || gift.state !== 'available') {
|
|
304
|
+
this.target = null;
|
|
305
|
+
a.rope = null;
|
|
306
|
+
this.change('idle');
|
|
307
|
+
this.nextHeist = this.time + 2;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
const side = gift.position.x >= a.x ? 1 : -1;
|
|
311
|
+
const to = { x: gift.position.x - side * 28 * size, y: gift.position.y };
|
|
312
|
+
if (a.phase === 'sneaking' && Math.abs(to.y - a.y) > 32) {
|
|
313
|
+
if (Math.abs(to.x - a.x) > 65 * size)
|
|
314
|
+
this.move({ x: to.x, y: a.y }, dt, 80);
|
|
315
|
+
else {
|
|
316
|
+
this.afterClimb = 'reaching';
|
|
317
|
+
a.rope = { x: to.x, y: to.y - 8 };
|
|
318
|
+
this.change('climbing');
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else if (this.move(to, dt, a.phase === 'climbing' ? 105 : 80)) {
|
|
322
|
+
a.facing = gift.position.x >= a.x ? 1 : -1;
|
|
323
|
+
a.rope = null;
|
|
324
|
+
this.change('reaching');
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case 'reaching':
|
|
329
|
+
if (!gift || !gift.visible || gift.state !== 'available') {
|
|
330
|
+
this.target = null;
|
|
331
|
+
this.change('idle');
|
|
332
|
+
}
|
|
333
|
+
else if (distance(a, { x: gift.position.x - a.facing * 28 * size, y: gift.position.y }) >
|
|
334
|
+
20 * size)
|
|
335
|
+
this.change('sneaking');
|
|
336
|
+
else if (a.age > 0.55) {
|
|
337
|
+
gift.state = 'held';
|
|
338
|
+
this.change('stealing');
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
case 'stealing':
|
|
342
|
+
if (a.age > 0.65)
|
|
343
|
+
this.change('stashing');
|
|
344
|
+
break;
|
|
345
|
+
case 'stashing':
|
|
346
|
+
if (a.age > 0.7 && gift?.state === 'held') {
|
|
347
|
+
gift.state = 'stolen';
|
|
348
|
+
this.totalStolen++;
|
|
349
|
+
this.nextHeist = this.time + this.options.cooldown;
|
|
350
|
+
this.emit('gift:stolen', { giftId: gift.id, totalStolen: this.totalStolen });
|
|
351
|
+
this.target = null;
|
|
352
|
+
this.change('gloating');
|
|
353
|
+
}
|
|
354
|
+
break;
|
|
355
|
+
case 'gloating':
|
|
356
|
+
if (a.age > 1.0)
|
|
357
|
+
this.hide(shelters);
|
|
358
|
+
break;
|
|
359
|
+
case 'caught':
|
|
360
|
+
if (a.age > 1.1)
|
|
361
|
+
this.hide(shelters);
|
|
362
|
+
break;
|
|
363
|
+
case 'escaping':
|
|
364
|
+
if (this.shelter) {
|
|
365
|
+
const b = this.shelter.box;
|
|
366
|
+
a.destination = { x: b.x + b.width * 0.5, y: b.y + b.height - 8 };
|
|
367
|
+
if (this.move(a.destination, dt, 155))
|
|
368
|
+
this.change('hiding');
|
|
369
|
+
}
|
|
370
|
+
else
|
|
371
|
+
this.change('idle');
|
|
372
|
+
break;
|
|
373
|
+
case 'hiding':
|
|
374
|
+
if (a.age > 1.0)
|
|
375
|
+
this.change('peeking');
|
|
376
|
+
break;
|
|
377
|
+
case 'peeking':
|
|
378
|
+
if (this.shelter) {
|
|
379
|
+
const b = this.shelter.box, to = { x: b.x - 14 * size, y: b.y + b.height - 8 };
|
|
380
|
+
if (this.move(to, dt, 95) && a.age > 2.5) {
|
|
381
|
+
a.destination = { x: to.x, y: b.y };
|
|
382
|
+
a.rope = { x: to.x, y: b.y };
|
|
383
|
+
this.afterClimb = 'idle';
|
|
384
|
+
this.target = null;
|
|
385
|
+
this.change('climbing');
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else
|
|
389
|
+
this.change('idle');
|
|
390
|
+
break;
|
|
391
|
+
case 'warming':
|
|
392
|
+
if (a.age > 2.0) {
|
|
393
|
+
a.behind = false;
|
|
394
|
+
this.change('waving');
|
|
395
|
+
}
|
|
396
|
+
break;
|
|
397
|
+
case 'waving':
|
|
398
|
+
if (a.age > 1.35)
|
|
399
|
+
this.change('idle');
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAQ,EAAE,CAAQ,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAy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AM,CAAC,QAAQ,CAAC,CAAC;gBACxB,CAAC;gBACD,MAAM;YACR,KAAK,QAAQ;gBACX,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI;oBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACtC,MAAM;QACV,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { GrinchOptions, GrinchTuning } from './types.js';
|
|
2
|
+
export declare const defaults: {
|
|
3
|
+
readonly territory: "page";
|
|
4
|
+
readonly objects: "[data-grinch-object], [data-grinch-gift], [data-weather-surface], article, .card, button, img, pre";
|
|
5
|
+
readonly maxGifts: 5;
|
|
6
|
+
readonly size: 1;
|
|
7
|
+
readonly mobileScale: 0.85;
|
|
8
|
+
readonly speed: 1;
|
|
9
|
+
readonly cooldown: 10;
|
|
10
|
+
readonly fearRadius: 90;
|
|
11
|
+
readonly mood: "mischievous";
|
|
12
|
+
readonly autoSteal: true;
|
|
13
|
+
readonly entrance: "sneak";
|
|
14
|
+
readonly motion: "system";
|
|
15
|
+
readonly observe: true;
|
|
16
|
+
readonly zIndex: 140;
|
|
17
|
+
readonly furColor: "#79ad30";
|
|
18
|
+
readonly coatColor: "#c92c42";
|
|
19
|
+
readonly controls: false;
|
|
20
|
+
};
|
|
21
|
+
export type Options = Omit<Required<GrinchOptions>, 'root' | 'targets'>;
|
|
22
|
+
export declare const tuningKeys: Set<string>;
|
|
23
|
+
export declare function selector(value: unknown): asserts value is string;
|
|
24
|
+
export declare function resolveOptions(input?: GrinchOptions): Options;
|
|
25
|
+
export declare function validateTuning(patch: GrinchTuning): void;
|
|
26
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAmBX,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAExE,eAAO,MAAM,UAAU,aAUrB,CAAC;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAGhE;AACD,wBAAgB,cAAc,CAAC,KAAK,GAAE,aAAkB,GAAG,OAAO,CA4CjE;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAQxD"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const defaults = {
|
|
2
|
+
territory: 'page',
|
|
3
|
+
objects: '[data-grinch-object], [data-grinch-gift], [data-weather-surface], article, .card, button, img, pre',
|
|
4
|
+
maxGifts: 5,
|
|
5
|
+
size: 1,
|
|
6
|
+
mobileScale: 0.85,
|
|
7
|
+
speed: 1,
|
|
8
|
+
cooldown: 10,
|
|
9
|
+
fearRadius: 90,
|
|
10
|
+
mood: 'mischievous',
|
|
11
|
+
autoSteal: true,
|
|
12
|
+
entrance: 'sneak',
|
|
13
|
+
motion: 'system',
|
|
14
|
+
observe: true,
|
|
15
|
+
zIndex: 140,
|
|
16
|
+
furColor: '#79ad30',
|
|
17
|
+
coatColor: '#c92c42',
|
|
18
|
+
controls: false,
|
|
19
|
+
};
|
|
20
|
+
const keys = new Set([...Object.keys(defaults), 'root', 'targets']);
|
|
21
|
+
export const tuningKeys = new Set([
|
|
22
|
+
'size',
|
|
23
|
+
'mobileScale',
|
|
24
|
+
'speed',
|
|
25
|
+
'cooldown',
|
|
26
|
+
'fearRadius',
|
|
27
|
+
'mood',
|
|
28
|
+
'autoSteal',
|
|
29
|
+
'furColor',
|
|
30
|
+
'coatColor',
|
|
31
|
+
]);
|
|
32
|
+
export function selector(value) {
|
|
33
|
+
if (typeof value !== 'string' || !value.trim() || value.length > 512)
|
|
34
|
+
throw new TypeError('Grinch: selectors must contain 1–512 characters.');
|
|
35
|
+
}
|
|
36
|
+
export function resolveOptions(input = {}) {
|
|
37
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
38
|
+
throw new TypeError('Grinch: options must be an object.');
|
|
39
|
+
if (Object.keys(input).some((k) => !keys.has(k)))
|
|
40
|
+
throw new TypeError('Grinch: unknown option.');
|
|
41
|
+
const result = { ...defaults, ...input };
|
|
42
|
+
const bounds = {
|
|
43
|
+
maxGifts: [1, 12],
|
|
44
|
+
size: [0.6, 1.8],
|
|
45
|
+
mobileScale: [0.6, 1],
|
|
46
|
+
speed: [0.25, 2],
|
|
47
|
+
cooldown: [3, 120],
|
|
48
|
+
fearRadius: [0, 240],
|
|
49
|
+
zIndex: [-2147483648, 2147483647],
|
|
50
|
+
};
|
|
51
|
+
for (const key of Object.keys(bounds)) {
|
|
52
|
+
const value = result[key], [min, max] = bounds[key];
|
|
53
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max)
|
|
54
|
+
throw new RangeError(`Grinch: ${key} must be between ${min} and ${max}.`);
|
|
55
|
+
}
|
|
56
|
+
for (const key of ['maxGifts', 'zIndex'])
|
|
57
|
+
if (!Number.isInteger(result[key]))
|
|
58
|
+
throw new TypeError(`Grinch: ${key} must be an integer.`);
|
|
59
|
+
for (const key of ['observe', 'autoSteal', 'controls'])
|
|
60
|
+
if (typeof result[key] !== 'boolean')
|
|
61
|
+
throw new TypeError(`Grinch: ${key} must be boolean.`);
|
|
62
|
+
if (!['mischievous', 'friendly'].includes(result.mood))
|
|
63
|
+
throw new TypeError('Grinch: invalid mood.');
|
|
64
|
+
if (!['system', 'full', 'none'].includes(result.motion))
|
|
65
|
+
throw new TypeError('Grinch: invalid motion.');
|
|
66
|
+
if (!['sneak', 'rope', 'appear'].includes(result.entrance))
|
|
67
|
+
throw new TypeError('Grinch: invalid entrance.');
|
|
68
|
+
if (!['page', 'root'].includes(result.territory))
|
|
69
|
+
throw new TypeError('Grinch: invalid territory.');
|
|
70
|
+
for (const key of ['furColor', 'coatColor'])
|
|
71
|
+
if (typeof result[key] !== 'string' || !/^#[a-f\d]{6}$/i.test(result[key]))
|
|
72
|
+
throw new TypeError(`Grinch: ${key} must be a six-digit hex color.`);
|
|
73
|
+
selector(result.objects);
|
|
74
|
+
if (input.targets !== undefined &&
|
|
75
|
+
typeof input.targets !== 'string' &&
|
|
76
|
+
!Array.isArray(input.targets))
|
|
77
|
+
throw new TypeError('Grinch: targets must be a selector or array of elements.');
|
|
78
|
+
if (typeof input.targets === 'string')
|
|
79
|
+
selector(input.targets);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
export function validateTuning(patch) {
|
|
83
|
+
if (!patch ||
|
|
84
|
+
typeof patch !== 'object' ||
|
|
85
|
+
Array.isArray(patch) ||
|
|
86
|
+
Object.keys(patch).some((k) => !tuningKeys.has(k)))
|
|
87
|
+
throw new TypeError('Grinch: update accepts tuning options only.');
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,MAAM;IACjB,OAAO,EACL,oGAAoG;IACtG,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,aAAa;IACnB,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,KAAK;CACP,CAAC;AAE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CAAC,6CAA6C,CAAC,CAAC;AACvE,CAAC"}
|
package/dist/paint.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Options } from './options.js';
|
|
2
|
+
import { type Mischief } from './model.js';
|
|
3
|
+
import type { Point } from './types.js';
|
|
4
|
+
export declare function paintGift(ctx: CanvasRenderingContext2D, point: Point, color: string, size?: number, scale?: number): void;
|
|
5
|
+
/** Original procedural character artwork, with expressive poses instead of downloaded sprites. */
|
|
6
|
+
export declare function paintGrinch(ctx: CanvasRenderingContext2D, model: Mischief, options: Options, quiet: boolean): void;
|
|
7
|
+
export declare function paintPresents(ctx: CanvasRenderingContext2D, model: Mischief, size: number, held: boolean): void;
|
|
8
|
+
export declare function giftColor(index: number): string;
|
|
9
|
+
//# sourceMappingURL=paint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.d.ts","sourceRoot":"","sources":["../src/paint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAS,KAAK,QAAQ,EAAa,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,SAAS,CACvB,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,SAAI,EACR,KAAK,SAAI,GACR,IAAI,CA+BN;AAmBD,kGAAkG;AAClG,wBAAgB,WAAW,CACzB,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,GACb,IAAI,CAuUN;AACD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GACZ,IAAI,CAWN;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|