@roudanio/maze 0.2.5 → 0.3.1
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/GEMINI.md +71 -0
- package/README.md +40 -0
- package/dist/maze.css +1 -1
- package/dist/maze.iife.js +2 -2
- package/dist/maze.js +1044 -1143
- package/dist/maze.umd.js +2 -2
- package/package.json +11 -7
- package/tests/canvas-helpers.test.ts +33 -0
- package/tests/maze-generator.test.ts +101 -0
- package/tests/raycasting.test.ts +118 -0
package/dist/maze.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var ge,
|
|
2
|
-
function
|
|
1
|
+
var ge, N, nt, Y, Fe, ot, rt, it, Me, Te, Se, st, re = {}, at = [], Mt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, pe = Array.isArray;
|
|
2
|
+
function V(e, t) {
|
|
3
3
|
for (var n in t) e[n] = t[n];
|
|
4
4
|
return e;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function Le(e) {
|
|
7
7
|
e && e.parentNode && e.parentNode.removeChild(e);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
var o, i, s,
|
|
11
|
-
for (s in t) s == "key" ? o = t[s] : s == "ref" ? i = t[s] :
|
|
12
|
-
if (arguments.length > 2 && (
|
|
13
|
-
return
|
|
9
|
+
function Lt(e, t, n) {
|
|
10
|
+
var o, i, s, a = {};
|
|
11
|
+
for (s in t) s == "key" ? o = t[s] : s == "ref" ? i = t[s] : a[s] = t[s];
|
|
12
|
+
if (arguments.length > 2 && (a.children = arguments.length > 3 ? ge.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (s in e.defaultProps) a[s] === void 0 && (a[s] = e.defaultProps[s]);
|
|
13
|
+
return de(e, a, o, i, null);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var s = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++
|
|
17
|
-
return i == null &&
|
|
15
|
+
function de(e, t, n, o, i) {
|
|
16
|
+
var s = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++nt, __i: -1, __u: 0 };
|
|
17
|
+
return i == null && N.vnode != null && N.vnode(s), s;
|
|
18
18
|
}
|
|
19
19
|
function we(e) {
|
|
20
20
|
return e.children;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function he(e, t) {
|
|
23
23
|
this.props = e, this.context = t;
|
|
24
24
|
}
|
|
25
25
|
function J(e, t) {
|
|
@@ -27,72 +27,65 @@ function J(e, t) {
|
|
|
27
27
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
|
|
28
28
|
return typeof e.type == "function" ? J(e) : null;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function lt(e) {
|
|
31
31
|
var t, n;
|
|
32
32
|
if ((e = e.__) != null && e.__c != null) {
|
|
33
33
|
for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) {
|
|
34
34
|
e.__e = e.__c.base = n.__e;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return lt(e);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!e.__d && (e.__d = !0) &&
|
|
40
|
+
function ke(e) {
|
|
41
|
+
(!e.__d && (e.__d = !0) && Y.push(e) && !ve.__r++ || Fe != N.debounceRendering) && ((Fe = N.debounceRendering) || ot)(ve);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
for (var e, t, n, o, i, s,
|
|
45
|
-
|
|
43
|
+
function ve() {
|
|
44
|
+
for (var e, t, n, o, i, s, a, r = 1; Y.length; ) Y.length > r && Y.sort(rt), e = Y.shift(), r = Y.length, e.__d && (n = void 0, o = void 0, i = (o = (t = e).__v).__e, s = [], a = [], t.__P && ((n = V({}, o)).__v = o.__v + 1, N.vnode && N.vnode(n), Ne(t.__P, n, o, t.__n, t.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? J(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, dt(s, n, a), o.__e = o.__ = null, n.__e != i && lt(n)));
|
|
45
|
+
ve.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
var u, h, f,
|
|
49
|
-
for (
|
|
50
|
-
return n.__e =
|
|
47
|
+
function ct(e, t, n, o, i, s, a, r, c, l, d) {
|
|
48
|
+
var u, h, f, m, g, v, w, y = o && o.__k || at, T = t.length;
|
|
49
|
+
for (c = Nt(n, t, y, c, T), u = 0; u < T; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? re : y[f.__i] || re, f.__i = u, v = Ne(e, f, h, i, s, a, r, c, l, d), m = f.__e, f.ref && h.ref != f.ref && (h.ref && Ae(h.ref, null, f), d.push(f.ref, f.__c || m, f)), g == null && m != null && (g = m), (w = !!(4 & f.__u)) || h.__k === f.__k ? c = ut(f, c, e, w) : typeof f.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), f.__u &= -7);
|
|
50
|
+
return n.__e = g, c;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
var s,
|
|
54
|
-
for (e.__k = new Array(i), s = 0; s < i; s++) (
|
|
55
|
-
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = J(r)),
|
|
52
|
+
function Nt(e, t, n, o, i) {
|
|
53
|
+
var s, a, r, c, l, d = n.length, u = d, h = 0;
|
|
54
|
+
for (e.__k = new Array(i), s = 0; s < i; s++) (a = t[s]) != null && typeof a != "boolean" && typeof a != "function" ? (c = s + h, (a = e.__k[s] = typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? de(null, a, null, null, null) : pe(a) ? de(we, { children: a }, null, null, null) : a.constructor == null && a.__b > 0 ? de(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : a).__ = e, a.__b = e.__b + 1, r = null, (l = a.__i = At(a, n, c, u)) != -1 && (u--, (r = n[l]) && (r.__u |= 2)), r == null || r.__v == null ? (l == -1 && (i > d ? h-- : i < d && h++), typeof a.type != "function" && (a.__u |= 4)) : l != c && (l == c - 1 ? h-- : l == c + 1 ? h++ : (l > c ? h-- : h++, a.__u |= 4))) : e.__k[s] = null;
|
|
55
|
+
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = J(r)), ft(r, r));
|
|
56
56
|
return o;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
var
|
|
58
|
+
function ut(e, t, n, o) {
|
|
59
|
+
var i, s;
|
|
60
60
|
if (typeof e.type == "function") {
|
|
61
|
-
for (
|
|
61
|
+
for (i = e.__k, s = 0; i && s < i.length; s++) i[s] && (i[s].__ = e, t = ut(i[s], t, n, o));
|
|
62
62
|
return t;
|
|
63
63
|
}
|
|
64
|
-
e.__e != t && (t && e.type && !
|
|
64
|
+
e.__e != t && (o && (t && e.type && !t.parentNode && (t = J(e)), n.insertBefore(e.__e, t || null)), t = e.__e);
|
|
65
65
|
do
|
|
66
66
|
t = t && t.nextSibling;
|
|
67
67
|
while (t != null && t.nodeType == 8);
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
var i, s,
|
|
72
|
-
if (
|
|
73
|
-
if (o > (
|
|
74
|
-
if (i >= 0)
|
|
75
|
-
if ((a = t[i]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return i;
|
|
76
|
-
i--;
|
|
77
|
-
}
|
|
78
|
-
if (s < t.length) {
|
|
79
|
-
if ((a = t[s]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return s;
|
|
80
|
-
s++;
|
|
81
|
-
}
|
|
70
|
+
function At(e, t, n, o) {
|
|
71
|
+
var i, s, a, r = e.key, c = e.type, l = t[n], d = l != null && (2 & l.__u) == 0;
|
|
72
|
+
if (l === null && e.key == null || d && r == l.key && c == l.type) return n;
|
|
73
|
+
if (o > (d ? 1 : 0)) {
|
|
74
|
+
for (i = n - 1, s = n + 1; i >= 0 || s < t.length; ) if ((l = t[a = i >= 0 ? i-- : s++]) != null && (2 & l.__u) == 0 && r == l.key && c == l.type) return a;
|
|
82
75
|
}
|
|
83
76
|
return -1;
|
|
84
77
|
}
|
|
85
78
|
function Re(e, t, n) {
|
|
86
|
-
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" ||
|
|
79
|
+
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || Mt.test(t) ? n : n + "px";
|
|
87
80
|
}
|
|
88
|
-
function
|
|
89
|
-
var s;
|
|
81
|
+
function ce(e, t, n, o, i) {
|
|
82
|
+
var s, a;
|
|
90
83
|
e: if (t == "style") if (typeof n == "string") e.style.cssText = n;
|
|
91
84
|
else {
|
|
92
85
|
if (typeof o == "string" && (e.style.cssText = o = ""), o) for (t in o) n && t in n || Re(e.style, t, "");
|
|
93
86
|
if (n) for (t in n) o && n[t] == o[t] || Re(e.style, t, n[t]);
|
|
94
87
|
}
|
|
95
|
-
else if (t[0] == "o" && t[1] == "n") s = t != (t = t.replace(
|
|
88
|
+
else if (t[0] == "o" && t[1] == "n") s = t != (t = t.replace(it, "$1")), a = t.toLowerCase(), t = a in e || t == "onFocusOut" || t == "onFocusIn" ? a.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + s] = n, n ? o ? n.u = o.u : (n.u = Me, e.addEventListener(t, s ? Se : Te, s)) : e.removeEventListener(t, s ? Se : Te, s);
|
|
96
89
|
else {
|
|
97
90
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
98
91
|
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
@@ -103,93 +96,99 @@ function ae(e, t, n, o, i) {
|
|
|
103
96
|
typeof n == "function" || (n == null || n === !1 && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
|
-
function
|
|
99
|
+
function De(e) {
|
|
107
100
|
return function(t) {
|
|
108
101
|
if (this.l) {
|
|
109
102
|
var n = this.l[t.type + e];
|
|
110
|
-
if (t.t == null) t.t =
|
|
103
|
+
if (t.t == null) t.t = Me++;
|
|
111
104
|
else if (t.t < n.u) return;
|
|
112
|
-
return n(
|
|
105
|
+
return n(N.event ? N.event(t) : t);
|
|
113
106
|
}
|
|
114
107
|
};
|
|
115
108
|
}
|
|
116
|
-
function
|
|
117
|
-
var d, u, h, f,
|
|
109
|
+
function Ne(e, t, n, o, i, s, a, r, c, l) {
|
|
110
|
+
var d, u, h, f, m, g, v, w, y, T, p, z, C, S, k, L, E, M = t.type;
|
|
118
111
|
if (t.constructor != null) return null;
|
|
119
|
-
128 & n.__u && (
|
|
120
|
-
e: if (typeof
|
|
121
|
-
if (
|
|
112
|
+
128 & n.__u && (c = !!(32 & n.__u), s = [r = t.__e = n.__e]), (d = N.__b) && d(t);
|
|
113
|
+
e: if (typeof M == "function") try {
|
|
114
|
+
if (w = t.props, y = "prototype" in M && M.prototype.render, T = (d = M.contextType) && o[d.__c], p = d ? T ? T.props.value : d.__ : o, n.__c ? v = (u = t.__c = n.__c).__ = u.__E : (y ? t.__c = u = new M(w, p) : (t.__c = u = new he(w, p), u.constructor = M, u.render = xt), T && T.sub(u), u.props = w, u.state || (u.state = {}), u.context = p, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), y && u.__s == null && (u.__s = u.state), y && M.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = V({}, u.__s)), V(u.__s, M.getDerivedStateFromProps(w, u.__s))), f = u.props, m = u.state, u.__v = t, h) y && M.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), y && u.componentDidMount != null && u.__h.push(u.componentDidMount);
|
|
122
115
|
else {
|
|
123
|
-
if (
|
|
124
|
-
for (t.__v != n.__v && (u.props =
|
|
125
|
-
|
|
126
|
-
}),
|
|
127
|
-
u._sb = [], u.__h.length &&
|
|
116
|
+
if (y && M.getDerivedStateFromProps == null && w !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(w, p), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(w, u.__s, p) === !1 || t.__v == n.__v) {
|
|
117
|
+
for (t.__v != n.__v && (u.props = w, u.state = u.__s, u.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(b) {
|
|
118
|
+
b && (b.__ = t);
|
|
119
|
+
}), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
|
|
120
|
+
u._sb = [], u.__h.length && a.push(u);
|
|
128
121
|
break e;
|
|
129
122
|
}
|
|
130
|
-
u.componentWillUpdate != null && u.componentWillUpdate(
|
|
131
|
-
u.componentDidUpdate(f,
|
|
123
|
+
u.componentWillUpdate != null && u.componentWillUpdate(w, u.__s, p), y && u.componentDidUpdate != null && u.__h.push(function() {
|
|
124
|
+
u.componentDidUpdate(f, m, g);
|
|
132
125
|
});
|
|
133
126
|
}
|
|
134
|
-
if (u.context = p, u.props =
|
|
135
|
-
for (u.state = u.__s, u.__d = !1,
|
|
127
|
+
if (u.context = p, u.props = w, u.__P = e, u.__e = !1, C = N.__r, S = 0, y) {
|
|
128
|
+
for (u.state = u.__s, u.__d = !1, C && C(t), d = u.render(u.props, u.state, u.context), k = 0; k < u._sb.length; k++) u.__h.push(u._sb[k]);
|
|
136
129
|
u._sb = [];
|
|
137
130
|
} else do
|
|
138
|
-
u.__d = !1,
|
|
139
|
-
while (u.__d && ++
|
|
140
|
-
u.state = u.__s, u.getChildContext != null && (o =
|
|
141
|
-
} catch (
|
|
142
|
-
if (t.__v = null,
|
|
143
|
-
for (t.__u |=
|
|
131
|
+
u.__d = !1, C && C(t), d = u.render(u.props, u.state, u.context), u.state = u.__s;
|
|
132
|
+
while (u.__d && ++S < 25);
|
|
133
|
+
u.state = u.__s, u.getChildContext != null && (o = V(V({}, o), u.getChildContext())), y && !h && u.getSnapshotBeforeUpdate != null && (g = u.getSnapshotBeforeUpdate(f, m)), L = d, d != null && d.type === we && d.key == null && (L = ht(d.props.children)), r = ct(e, pe(L) ? L : [L], t, n, o, i, s, a, r, c, l), u.base = t.__e, t.__u &= -161, u.__h.length && a.push(u), v && (u.__E = u.__ = null);
|
|
134
|
+
} catch (b) {
|
|
135
|
+
if (t.__v = null, c || s != null) if (b.then) {
|
|
136
|
+
for (t.__u |= c ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
|
|
144
137
|
s[s.indexOf(r)] = null, t.__e = r;
|
|
145
|
-
} else
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
} else {
|
|
139
|
+
for (E = s.length; E--; ) Le(s[E]);
|
|
140
|
+
Ee(t);
|
|
141
|
+
}
|
|
142
|
+
else t.__e = n.__e, t.__k = n.__k, b.then || Ee(t);
|
|
143
|
+
N.__e(b, t, n);
|
|
148
144
|
}
|
|
149
|
-
else s == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : r = t.__e =
|
|
150
|
-
return (d =
|
|
145
|
+
else s == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : r = t.__e = Pt(n.__e, t, n, o, i, s, a, c, l);
|
|
146
|
+
return (d = N.diffed) && d(t), 128 & t.__u ? void 0 : r;
|
|
147
|
+
}
|
|
148
|
+
function Ee(e) {
|
|
149
|
+
e && e.__c && (e.__c.__e = !0), e && e.__k && e.__k.forEach(Ee);
|
|
151
150
|
}
|
|
152
|
-
function
|
|
151
|
+
function dt(e, t, n) {
|
|
153
152
|
for (var o = 0; o < n.length; o++) Ae(n[o], n[++o], n[++o]);
|
|
154
|
-
|
|
153
|
+
N.__c && N.__c(t, e), e.some(function(i) {
|
|
155
154
|
try {
|
|
156
155
|
e = i.__h, i.__h = [], e.some(function(s) {
|
|
157
156
|
s.call(i);
|
|
158
157
|
});
|
|
159
158
|
} catch (s) {
|
|
160
|
-
|
|
159
|
+
N.__e(s, i.__v);
|
|
161
160
|
}
|
|
162
161
|
});
|
|
163
162
|
}
|
|
164
|
-
function
|
|
165
|
-
return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e : pe(e) ? e.map(
|
|
163
|
+
function ht(e) {
|
|
164
|
+
return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e : pe(e) ? e.map(ht) : V({}, e);
|
|
166
165
|
}
|
|
167
|
-
function
|
|
168
|
-
var
|
|
169
|
-
if (
|
|
170
|
-
for (
|
|
171
|
-
e = f, s[
|
|
166
|
+
function Pt(e, t, n, o, i, s, a, r, c) {
|
|
167
|
+
var l, d, u, h, f, m, g, v = n.props, w = t.props, y = t.type;
|
|
168
|
+
if (y == "svg" ? i = "http://www.w3.org/2000/svg" : y == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
169
|
+
for (l = 0; l < s.length; l++) if ((f = s[l]) && "setAttribute" in f == !!y && (y ? f.localName == y : f.nodeType == 3)) {
|
|
170
|
+
e = f, s[l] = null;
|
|
172
171
|
break;
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
if (e == null) {
|
|
176
|
-
if (
|
|
177
|
-
e = document.createElementNS(i,
|
|
175
|
+
if (y == null) return document.createTextNode(w);
|
|
176
|
+
e = document.createElementNS(i, y, w.is && w), r && (N.__m && N.__m(t, s), r = !1), s = null;
|
|
178
177
|
}
|
|
179
|
-
if (
|
|
178
|
+
if (y == null) v === w || r && e.data == w || (e.data = w);
|
|
180
179
|
else {
|
|
181
|
-
if (s = s && ge.call(e.childNodes), v = n.props ||
|
|
182
|
-
for (
|
|
183
|
-
if (
|
|
184
|
-
else if (!(
|
|
185
|
-
if (
|
|
186
|
-
|
|
180
|
+
if (s = s && ge.call(e.childNodes), v = n.props || re, !r && s != null) for (v = {}, l = 0; l < e.attributes.length; l++) v[(f = e.attributes[l]).name] = f.value;
|
|
181
|
+
for (l in v) if (f = v[l], l != "children") {
|
|
182
|
+
if (l == "dangerouslySetInnerHTML") u = f;
|
|
183
|
+
else if (!(l in w)) {
|
|
184
|
+
if (l == "value" && "defaultValue" in w || l == "checked" && "defaultChecked" in w) continue;
|
|
185
|
+
ce(e, l, null, f, i);
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
|
-
for (
|
|
188
|
+
for (l in w) f = w[l], l == "children" ? h = f : l == "dangerouslySetInnerHTML" ? d = f : l == "value" ? m = f : l == "checked" ? g = f : r && typeof f != "function" || v[l] === f || ce(e, l, f, v[l], i);
|
|
190
189
|
if (d) r || u && (d.__html == u.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = [];
|
|
191
|
-
else if (u && (e.innerHTML = ""),
|
|
192
|
-
r || (
|
|
190
|
+
else if (u && (e.innerHTML = ""), ct(t.type == "template" ? e.content : e, pe(h) ? h : [h], t, n, o, y == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && J(n, 0), r, c), s != null) for (l = s.length; l--; ) Le(s[l]);
|
|
191
|
+
r || (l = "value", y == "progress" && m == null ? e.removeAttribute("value") : m != null && (m !== e[l] || y == "progress" && !m || y == "option" && m != v[l]) && ce(e, l, m, v[l], i), l = "checked", g != null && g != e[l] && ce(e, l, g, v[l], i));
|
|
193
192
|
}
|
|
194
193
|
return e;
|
|
195
194
|
}
|
|
@@ -200,30 +199,30 @@ function Ae(e, t, n) {
|
|
|
200
199
|
o && e.__u(), o && t == null || (e.__u = e(t));
|
|
201
200
|
} else e.current = t;
|
|
202
201
|
} catch (i) {
|
|
203
|
-
|
|
202
|
+
N.__e(i, n);
|
|
204
203
|
}
|
|
205
204
|
}
|
|
206
|
-
function
|
|
205
|
+
function ft(e, t, n) {
|
|
207
206
|
var o, i;
|
|
208
|
-
if (
|
|
207
|
+
if (N.unmount && N.unmount(e), (o = e.ref) && (o.current && o.current != e.__e || Ae(o, null, t)), (o = e.__c) != null) {
|
|
209
208
|
if (o.componentWillUnmount) try {
|
|
210
209
|
o.componentWillUnmount();
|
|
211
210
|
} catch (s) {
|
|
212
|
-
|
|
211
|
+
N.__e(s, t);
|
|
213
212
|
}
|
|
214
213
|
o.base = o.__P = null;
|
|
215
214
|
}
|
|
216
|
-
if (o = e.__k) for (i = 0; i < o.length; i++) o[i] &&
|
|
217
|
-
n ||
|
|
215
|
+
if (o = e.__k) for (i = 0; i < o.length; i++) o[i] && ft(o[i], t, n || typeof e.type != "function");
|
|
216
|
+
n || Le(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
218
217
|
}
|
|
219
|
-
function
|
|
218
|
+
function xt(e, t, n) {
|
|
220
219
|
return this.constructor(e, n);
|
|
221
220
|
}
|
|
222
|
-
function
|
|
223
|
-
var o, i, s,
|
|
224
|
-
t == document && (t = document.documentElement),
|
|
221
|
+
function Oe(e, t, n) {
|
|
222
|
+
var o, i, s, a;
|
|
223
|
+
t == document && (t = document.documentElement), N.__ && N.__(e, t), i = (o = !1) ? null : t.__k, s = [], a = [], Ne(t, e = t.__k = Lt(we, null, [e]), i || re, re, t.namespaceURI, i ? null : t.firstChild ? ge.call(t.childNodes) : null, s, i ? i.__e : t.firstChild, o, a), dt(s, e, a);
|
|
225
224
|
}
|
|
226
|
-
function
|
|
225
|
+
function It(e) {
|
|
227
226
|
function t(n) {
|
|
228
227
|
var o, i;
|
|
229
228
|
return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[t.__c] = this, this.getChildContext = function() {
|
|
@@ -231,180 +230,180 @@ function Nt(e) {
|
|
|
231
230
|
}, this.componentWillUnmount = function() {
|
|
232
231
|
o = null;
|
|
233
232
|
}, this.shouldComponentUpdate = function(s) {
|
|
234
|
-
this.props.value != s.value && o.forEach(function(
|
|
235
|
-
|
|
233
|
+
this.props.value != s.value && o.forEach(function(a) {
|
|
234
|
+
a.__e = !0, ke(a);
|
|
236
235
|
});
|
|
237
236
|
}, this.sub = function(s) {
|
|
238
237
|
o.add(s);
|
|
239
|
-
var
|
|
238
|
+
var a = s.componentWillUnmount;
|
|
240
239
|
s.componentWillUnmount = function() {
|
|
241
|
-
o && o.delete(s),
|
|
240
|
+
o && o.delete(s), a && a.call(s);
|
|
242
241
|
};
|
|
243
242
|
}), n.children;
|
|
244
243
|
}
|
|
245
|
-
return t.__c = "__cC" +
|
|
244
|
+
return t.__c = "__cC" + st++, t.__ = e, t.Provider = t.__l = (t.Consumer = function(n, o) {
|
|
246
245
|
return n.children(o);
|
|
247
246
|
}).contextType = t, t;
|
|
248
247
|
}
|
|
249
|
-
ge =
|
|
250
|
-
for (var i, s,
|
|
251
|
-
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(e)),
|
|
248
|
+
ge = at.slice, N = { __e: function(e, t, n, o) {
|
|
249
|
+
for (var i, s, a; t = t.__; ) if ((i = t.__c) && !i.__) try {
|
|
250
|
+
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(e)), a = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, o || {}), a = i.__d), a) return i.__E = i;
|
|
252
251
|
} catch (r) {
|
|
253
252
|
e = r;
|
|
254
253
|
}
|
|
255
254
|
throw e;
|
|
256
|
-
} },
|
|
255
|
+
} }, nt = 0, he.prototype.setState = function(e, t) {
|
|
257
256
|
var n;
|
|
258
|
-
n = this.__s != null && this.__s != this.state ? this.__s : this.__s =
|
|
259
|
-
},
|
|
260
|
-
this.__v && (this.__e = !0, e && this.__h.push(e),
|
|
261
|
-
},
|
|
257
|
+
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = V({}, this.state), typeof e == "function" && (e = e(V({}, n), this.props)), e && V(n, e), e != null && this.__v && (t && this._sb.push(t), ke(this));
|
|
258
|
+
}, he.prototype.forceUpdate = function(e) {
|
|
259
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), ke(this));
|
|
260
|
+
}, he.prototype.render = we, Y = [], ot = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, rt = function(e, t) {
|
|
262
261
|
return e.__v.__b - t.__v.__b;
|
|
263
|
-
},
|
|
264
|
-
var
|
|
265
|
-
function
|
|
262
|
+
}, ve.__r = 0, it = /(PointerCapture)$|Capture$/i, Me = 0, Te = De(!1), Se = De(!0), st = 0;
|
|
263
|
+
var Ft = 0;
|
|
264
|
+
function _(e, t, n, o, i, s) {
|
|
266
265
|
t || (t = {});
|
|
267
|
-
var
|
|
268
|
-
if ("ref" in
|
|
269
|
-
var
|
|
270
|
-
if (typeof e == "function" && (
|
|
271
|
-
return
|
|
266
|
+
var a, r, c = t;
|
|
267
|
+
if ("ref" in c) for (r in c = {}, t) r == "ref" ? a = t[r] : c[r] = t[r];
|
|
268
|
+
var l = { type: e, props: c, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Ft, __i: -1, __u: 0, __source: i, __self: s };
|
|
269
|
+
if (typeof e == "function" && (a = e.defaultProps)) for (r in a) c[r] === void 0 && (c[r] = a[r]);
|
|
270
|
+
return N.vnode && N.vnode(l), l;
|
|
272
271
|
}
|
|
273
|
-
var
|
|
272
|
+
var Q, x, ye, $e, ie = 0, mt = [], O = N, Ue = O.__b, Ge = O.__r, je = O.diffed, We = O.__c, qe = O.unmount, Be = O.__;
|
|
274
273
|
function Ce(e, t) {
|
|
275
|
-
|
|
276
|
-
var n =
|
|
274
|
+
O.__h && O.__h(x, e, ie || t), ie = 0;
|
|
275
|
+
var n = x.__H || (x.__H = { __: [], __h: [] });
|
|
277
276
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
278
277
|
}
|
|
279
|
-
function
|
|
280
|
-
return
|
|
278
|
+
function G(e) {
|
|
279
|
+
return ie = 1, Rt(vt, e);
|
|
281
280
|
}
|
|
282
|
-
function
|
|
283
|
-
var o = Ce(
|
|
284
|
-
if (o.t = e, !o.__c && (o.__ = [
|
|
285
|
-
var
|
|
286
|
-
|
|
287
|
-
}], o.__c =
|
|
288
|
-
var i = function(r,
|
|
281
|
+
function Rt(e, t, n) {
|
|
282
|
+
var o = Ce(Q++, 2);
|
|
283
|
+
if (o.t = e, !o.__c && (o.__ = [vt(void 0, t), function(r) {
|
|
284
|
+
var c = o.__N ? o.__N[0] : o.__[0], l = o.t(c, r);
|
|
285
|
+
c !== l && (o.__N = [l, o.__[1]], o.__c.setState({}));
|
|
286
|
+
}], o.__c = x, !x.__f)) {
|
|
287
|
+
var i = function(r, c, l) {
|
|
289
288
|
if (!o.__c.__H) return !0;
|
|
290
289
|
var d = o.__c.__H.__.filter(function(h) {
|
|
291
290
|
return !!h.__c;
|
|
292
291
|
});
|
|
293
292
|
if (d.every(function(h) {
|
|
294
293
|
return !h.__N;
|
|
295
|
-
})) return !s || s.call(this, r,
|
|
294
|
+
})) return !s || s.call(this, r, c, l);
|
|
296
295
|
var u = o.__c.props !== r;
|
|
297
296
|
return d.forEach(function(h) {
|
|
298
297
|
if (h.__N) {
|
|
299
298
|
var f = h.__[0];
|
|
300
299
|
h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (u = !0);
|
|
301
300
|
}
|
|
302
|
-
}), s && s.call(this, r,
|
|
301
|
+
}), s && s.call(this, r, c, l) || u;
|
|
303
302
|
};
|
|
304
|
-
|
|
305
|
-
var s =
|
|
306
|
-
|
|
303
|
+
x.__f = !0;
|
|
304
|
+
var s = x.shouldComponentUpdate, a = x.componentWillUpdate;
|
|
305
|
+
x.componentWillUpdate = function(r, c, l) {
|
|
307
306
|
if (this.__e) {
|
|
308
307
|
var d = s;
|
|
309
|
-
s = void 0, i(r,
|
|
308
|
+
s = void 0, i(r, c, l), s = d;
|
|
310
309
|
}
|
|
311
|
-
|
|
312
|
-
},
|
|
310
|
+
a && a.call(this, r, c, l);
|
|
311
|
+
}, x.shouldComponentUpdate = i;
|
|
313
312
|
}
|
|
314
313
|
return o.__N || o.__;
|
|
315
314
|
}
|
|
316
|
-
function
|
|
317
|
-
var n = Ce(
|
|
318
|
-
!
|
|
315
|
+
function F(e, t) {
|
|
316
|
+
var n = Ce(Q++, 3);
|
|
317
|
+
!O.__s && _t(n.__H, t) && (n.__ = e, n.u = t, x.__H.__h.push(n));
|
|
319
318
|
}
|
|
320
|
-
function
|
|
321
|
-
return
|
|
319
|
+
function R(e) {
|
|
320
|
+
return ie = 5, ee(function() {
|
|
322
321
|
return { current: e };
|
|
323
322
|
}, []);
|
|
324
323
|
}
|
|
325
|
-
function
|
|
326
|
-
var n = Ce(
|
|
327
|
-
return
|
|
324
|
+
function ee(e, t) {
|
|
325
|
+
var n = Ce(Q++, 7);
|
|
326
|
+
return _t(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
328
327
|
}
|
|
329
|
-
function
|
|
330
|
-
return
|
|
328
|
+
function Ve(e, t) {
|
|
329
|
+
return ie = 8, ee(function() {
|
|
331
330
|
return e;
|
|
332
331
|
}, t);
|
|
333
332
|
}
|
|
334
|
-
function
|
|
335
|
-
var t =
|
|
336
|
-
return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(
|
|
333
|
+
function Dt(e) {
|
|
334
|
+
var t = x.context[e.__c], n = Ce(Q++, 9);
|
|
335
|
+
return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(x)), t.props.value) : e.__;
|
|
337
336
|
}
|
|
338
|
-
function
|
|
339
|
-
for (var e; e =
|
|
340
|
-
e.__H.__h.forEach(
|
|
337
|
+
function Ot() {
|
|
338
|
+
for (var e; e = mt.shift(); ) if (e.__P && e.__H) try {
|
|
339
|
+
e.__H.__h.forEach(fe), e.__H.__h.forEach(ze), e.__H.__h = [];
|
|
341
340
|
} catch (t) {
|
|
342
|
-
e.__H.__h = [],
|
|
341
|
+
e.__H.__h = [], O.__e(t, e.__v);
|
|
343
342
|
}
|
|
344
343
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
},
|
|
348
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
var t = (
|
|
352
|
-
t && (ye ===
|
|
344
|
+
O.__b = function(e) {
|
|
345
|
+
x = null, Ue && Ue(e);
|
|
346
|
+
}, O.__ = function(e, t) {
|
|
347
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Be && Be(e, t);
|
|
348
|
+
}, O.__r = function(e) {
|
|
349
|
+
Ge && Ge(e), Q = 0;
|
|
350
|
+
var t = (x = e.__c).__H;
|
|
351
|
+
t && (ye === x ? (t.__h = [], x.__h = [], t.__.forEach(function(n) {
|
|
353
352
|
n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
|
|
354
|
-
})) : (t.__h.forEach(
|
|
355
|
-
},
|
|
356
|
-
|
|
353
|
+
})) : (t.__h.forEach(fe), t.__h.forEach(ze), t.__h = [], Q = 0)), ye = x;
|
|
354
|
+
}, O.diffed = function(e) {
|
|
355
|
+
je && je(e);
|
|
357
356
|
var t = e.__c;
|
|
358
|
-
t && t.__H && (t.__H.__h.length && (
|
|
357
|
+
t && t.__H && (t.__H.__h.length && (mt.push(t) !== 1 && $e === O.requestAnimationFrame || (($e = O.requestAnimationFrame) || $t)(Ot)), t.__H.__.forEach(function(n) {
|
|
359
358
|
n.u && (n.__H = n.u), n.u = void 0;
|
|
360
|
-
})), ye =
|
|
361
|
-
},
|
|
359
|
+
})), ye = x = null;
|
|
360
|
+
}, O.__c = function(e, t) {
|
|
362
361
|
t.some(function(n) {
|
|
363
362
|
try {
|
|
364
|
-
n.__h.forEach(
|
|
363
|
+
n.__h.forEach(fe), n.__h = n.__h.filter(function(o) {
|
|
365
364
|
return !o.__ || ze(o);
|
|
366
365
|
});
|
|
367
366
|
} catch (o) {
|
|
368
367
|
t.some(function(i) {
|
|
369
368
|
i.__h && (i.__h = []);
|
|
370
|
-
}), t = [],
|
|
369
|
+
}), t = [], O.__e(o, n.__v);
|
|
371
370
|
}
|
|
372
371
|
}), We && We(e, t);
|
|
373
|
-
},
|
|
374
|
-
|
|
372
|
+
}, O.unmount = function(e) {
|
|
373
|
+
qe && qe(e);
|
|
375
374
|
var t, n = e.__c;
|
|
376
375
|
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
377
376
|
try {
|
|
378
|
-
|
|
377
|
+
fe(o);
|
|
379
378
|
} catch (i) {
|
|
380
379
|
t = i;
|
|
381
380
|
}
|
|
382
|
-
}), n.__H = void 0, t &&
|
|
381
|
+
}), n.__H = void 0, t && O.__e(t, n.__v));
|
|
383
382
|
};
|
|
384
|
-
var
|
|
385
|
-
function
|
|
383
|
+
var He = typeof requestAnimationFrame == "function";
|
|
384
|
+
function $t(e) {
|
|
386
385
|
var t, n = function() {
|
|
387
|
-
clearTimeout(o),
|
|
388
|
-
}, o = setTimeout(n,
|
|
389
|
-
|
|
386
|
+
clearTimeout(o), He && cancelAnimationFrame(t), setTimeout(e);
|
|
387
|
+
}, o = setTimeout(n, 35);
|
|
388
|
+
He && (t = requestAnimationFrame(n));
|
|
390
389
|
}
|
|
391
|
-
function
|
|
392
|
-
var t =
|
|
393
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
390
|
+
function fe(e) {
|
|
391
|
+
var t = x, n = e.__c;
|
|
392
|
+
typeof n == "function" && (e.__c = void 0, n()), x = t;
|
|
394
393
|
}
|
|
395
394
|
function ze(e) {
|
|
396
|
-
var t =
|
|
397
|
-
e.__c = e.__(),
|
|
395
|
+
var t = x;
|
|
396
|
+
e.__c = e.__(), x = t;
|
|
398
397
|
}
|
|
399
|
-
function
|
|
398
|
+
function _t(e, t) {
|
|
400
399
|
return !e || e.length !== t.length || t.some(function(n, o) {
|
|
401
400
|
return n !== e[o];
|
|
402
401
|
});
|
|
403
402
|
}
|
|
404
|
-
function
|
|
403
|
+
function vt(e, t) {
|
|
405
404
|
return typeof t == "function" ? t(e) : t;
|
|
406
405
|
}
|
|
407
|
-
const
|
|
406
|
+
const Ut = (e) => ({
|
|
408
407
|
saveGameData(t) {
|
|
409
408
|
try {
|
|
410
409
|
localStorage.setItem(e, JSON.stringify(t));
|
|
@@ -427,249 +426,207 @@ const Rt = (e) => ({
|
|
|
427
426
|
console.error("Failed to reset maze game data:", t);
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
|
-
}),
|
|
429
|
+
}), gt = It(void 0), Xe = {
|
|
431
430
|
currentLevel: 1,
|
|
432
431
|
highestUnlockedLevel: 1,
|
|
433
432
|
currentTier: 1,
|
|
434
433
|
highestUnlockedTier: 1,
|
|
435
434
|
levelScores: {},
|
|
436
435
|
totalScore: 0
|
|
437
|
-
},
|
|
436
|
+
}, pt = {
|
|
438
437
|
isGameActive: !0,
|
|
439
438
|
levelTransitioning: !1,
|
|
440
439
|
maze: null,
|
|
441
440
|
playerCell: { row: 0, col: 0 },
|
|
442
441
|
exitCell: { row: 0, col: 0 },
|
|
443
442
|
foodCells: [],
|
|
443
|
+
fogEnabled: !0,
|
|
444
444
|
playerAtExit: !1,
|
|
445
445
|
foodCollected: 0,
|
|
446
446
|
totalFoodCount: 0,
|
|
447
447
|
showClue: !1,
|
|
448
448
|
playerPath: [],
|
|
449
449
|
visitCounts: {}
|
|
450
|
-
},
|
|
451
|
-
const n =
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
...
|
|
459
|
-
totalScore:
|
|
450
|
+
}, Gt = ({ children: e, config: t }) => {
|
|
451
|
+
const n = Ut(t.lcPrefix + "progress"), o = n.loadGameData(), i = t.renderConfig?.fogEnabled ?? !0, s = () => ({
|
|
452
|
+
...pt,
|
|
453
|
+
fogEnabled: i
|
|
454
|
+
}), [a, r] = G(() => o || { ...Xe });
|
|
455
|
+
F(() => {
|
|
456
|
+
const f = Object.values(a.levelScores).reduce((m, g) => m + g, 0);
|
|
457
|
+
r((m) => ({
|
|
458
|
+
...m,
|
|
459
|
+
totalScore: f
|
|
460
460
|
}));
|
|
461
|
-
}, [
|
|
462
|
-
n.saveGameData(
|
|
461
|
+
}, [a.levelScores]), F(() => {
|
|
462
|
+
n.saveGameData(a);
|
|
463
463
|
}, [
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
464
|
+
a.currentLevel,
|
|
465
|
+
a.highestUnlockedLevel,
|
|
466
|
+
a.currentTier,
|
|
467
|
+
a.highestUnlockedTier,
|
|
468
|
+
a.levelScores,
|
|
469
|
+
a.totalScore
|
|
470
470
|
]);
|
|
471
|
-
const [
|
|
472
|
-
...
|
|
473
|
-
}),
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}, [
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
], [
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
l
|
|
485
|
-
|
|
486
|
-
]), d = () => {
|
|
487
|
-
n.resetGameData(), s({
|
|
488
|
-
...Ve
|
|
489
|
-
}), r({
|
|
490
|
-
...Ee
|
|
471
|
+
const [c, l] = G({
|
|
472
|
+
...s()
|
|
473
|
+
}), d = R(c);
|
|
474
|
+
F(() => {
|
|
475
|
+
d.current = c;
|
|
476
|
+
}, [c]);
|
|
477
|
+
const u = ee(() => [
|
|
478
|
+
c.playerAtExit ? 1 : 0,
|
|
479
|
+
c.foodCollected === c.totalFoodCount ? 1 : 0,
|
|
480
|
+
c.showClue ? 0 : 1
|
|
481
|
+
], [c.playerAtExit, c.foodCollected, c.totalFoodCount, c.showClue]), h = () => {
|
|
482
|
+
n.resetGameData(), r({
|
|
483
|
+
...Xe
|
|
484
|
+
}), l({
|
|
485
|
+
...s()
|
|
491
486
|
});
|
|
492
487
|
};
|
|
493
|
-
return /* @__PURE__ */
|
|
494
|
-
|
|
488
|
+
return /* @__PURE__ */ _(
|
|
489
|
+
gt.Provider,
|
|
495
490
|
{
|
|
496
491
|
value: {
|
|
497
|
-
gameProgress:
|
|
498
|
-
setGameProgress:
|
|
499
|
-
gamePlayState:
|
|
500
|
-
setGamePlayState:
|
|
501
|
-
gamePlayStateRef:
|
|
502
|
-
currentScore:
|
|
492
|
+
gameProgress: a,
|
|
493
|
+
setGameProgress: r,
|
|
494
|
+
gamePlayState: c,
|
|
495
|
+
setGamePlayState: l,
|
|
496
|
+
gamePlayStateRef: d,
|
|
497
|
+
currentScore: u,
|
|
503
498
|
config: t,
|
|
504
|
-
resetGame:
|
|
499
|
+
resetGame: h
|
|
505
500
|
},
|
|
506
501
|
children: e
|
|
507
502
|
}
|
|
508
503
|
);
|
|
509
|
-
},
|
|
510
|
-
const e =
|
|
504
|
+
}, se = () => {
|
|
505
|
+
const e = Dt(gt);
|
|
511
506
|
if (!e)
|
|
512
507
|
throw new Error("useGameContext must be used within a GameProvider");
|
|
513
508
|
return e;
|
|
514
|
-
},
|
|
515
|
-
const t = e.map((r) => r.length), n = t.reduce((r,
|
|
509
|
+
}, ae = (e) => ee(() => {
|
|
510
|
+
const t = e.map((r) => r.length), n = t.reduce((r, c) => r + c, 0), o = e.length, i = (r) => {
|
|
516
511
|
if (r < 1 || r > n) return 0;
|
|
517
|
-
let
|
|
518
|
-
for (let
|
|
519
|
-
if (
|
|
512
|
+
let c = 0;
|
|
513
|
+
for (let l = 0; l < t.length; l++)
|
|
514
|
+
if (c += t[l], r <= c) return l + 1;
|
|
520
515
|
return 0;
|
|
521
|
-
}, s = (r) => r < 1 || r > o ? 0 : t.slice(0, r - 1).reduce((
|
|
516
|
+
}, s = (r) => r < 1 || r > o ? 0 : t.slice(0, r - 1).reduce((c, l) => c + l, 0) + 1, a = {
|
|
522
517
|
getTotalLevels: () => n,
|
|
523
518
|
getTotalTiers: () => o,
|
|
524
519
|
getTierLevelsRange: (r) => {
|
|
525
520
|
if (r < 1 || r > o) return [0, 0];
|
|
526
|
-
const
|
|
527
|
-
return [
|
|
521
|
+
const c = s(r), l = c + t[r - 1] - 1;
|
|
522
|
+
return [c, l];
|
|
528
523
|
},
|
|
529
524
|
getTierByLevel: i,
|
|
530
525
|
getFirstLevelOfTier: s,
|
|
531
526
|
getLevelConfig: (r) => {
|
|
532
527
|
if (r < 1 || r > n) return null;
|
|
533
|
-
const
|
|
534
|
-
return e[
|
|
528
|
+
const c = i(r), l = s(c), d = r - l;
|
|
529
|
+
return e[c - 1][d];
|
|
535
530
|
},
|
|
536
531
|
getTierConfig: (r) => r < 1 || r > o ? null : e[r - 1],
|
|
537
|
-
isLevelUnlocked: (r,
|
|
538
|
-
isTierUnlocked: (r,
|
|
532
|
+
isLevelUnlocked: (r, c) => r <= c,
|
|
533
|
+
isTierUnlocked: (r, c) => r <= c,
|
|
539
534
|
getNextLevelInfo: (r) => {
|
|
540
535
|
if (r >= n) return null;
|
|
541
|
-
const
|
|
536
|
+
const c = r + 1, l = i(r), d = i(c);
|
|
542
537
|
return {
|
|
543
|
-
nextLevel:
|
|
538
|
+
nextLevel: c,
|
|
544
539
|
nextTier: d,
|
|
545
|
-
isTierChange: d >
|
|
540
|
+
isTierChange: d > l
|
|
546
541
|
};
|
|
547
542
|
},
|
|
548
|
-
getCurrentTierProgress: (r,
|
|
549
|
-
const [
|
|
543
|
+
getCurrentTierProgress: (r, c) => {
|
|
544
|
+
const [l, d] = a.getTierLevelsRange(c), u = r - l + 1, h = d - l + 1;
|
|
550
545
|
return { current: u, total: h };
|
|
551
546
|
},
|
|
552
547
|
isLastLevelInTier: (r) => {
|
|
553
|
-
const
|
|
554
|
-
return r ===
|
|
548
|
+
const c = i(r), [, l] = a.getTierLevelsRange(c);
|
|
549
|
+
return r === l;
|
|
555
550
|
},
|
|
556
551
|
getPreviousLevelInfo: (r) => {
|
|
557
552
|
if (r <= 1) return null;
|
|
558
|
-
const
|
|
553
|
+
const c = r - 1, l = i(r), d = i(c);
|
|
559
554
|
return {
|
|
560
|
-
prevLevel:
|
|
555
|
+
prevLevel: c,
|
|
561
556
|
prevTier: d,
|
|
562
|
-
isTierChange: d <
|
|
557
|
+
isTierChange: d < l
|
|
563
558
|
};
|
|
564
559
|
}
|
|
565
560
|
};
|
|
566
|
-
return
|
|
567
|
-
}, [e]),
|
|
568
|
-
const { gameProgress: n, config: o } =
|
|
569
|
-
return /* @__PURE__ */
|
|
561
|
+
return a;
|
|
562
|
+
}, [e]), jt = ({ onTierChange: e, disabled: t }) => {
|
|
563
|
+
const { gameProgress: n, config: o } = se(), { i18n: i, levelConfig: s } = o, { currentTier: a, highestUnlockedTier: r } = n, l = ae(s).getTotalTiers();
|
|
564
|
+
return /* @__PURE__ */ _("div", { className: "tier-selector", children: /* @__PURE__ */ _(
|
|
570
565
|
"select",
|
|
571
566
|
{
|
|
572
|
-
value:
|
|
567
|
+
value: a,
|
|
573
568
|
onChange: (d) => {
|
|
574
569
|
d.target && d.target.value && e(Number(d.target.value));
|
|
575
570
|
},
|
|
576
571
|
disabled: t,
|
|
577
572
|
className: "tier-dropdown",
|
|
578
|
-
children: Array.from({ length:
|
|
579
|
-
"option",
|
|
580
|
-
{
|
|
581
|
-
value: d,
|
|
582
|
-
disabled: d > r,
|
|
583
|
-
children: i.tier + " " + d
|
|
584
|
-
},
|
|
585
|
-
`tier-${d}`
|
|
586
|
-
))
|
|
573
|
+
children: Array.from({ length: l }, (d, u) => u + 1).map((d) => /* @__PURE__ */ _("option", { value: d, disabled: d > r, children: i.tier + " " + d }, `tier-${d}`))
|
|
587
574
|
}
|
|
588
575
|
) });
|
|
589
|
-
},
|
|
590
|
-
const { gameProgress: n, config: o } =
|
|
591
|
-
const [h, f] = d.getTierLevelsRange(
|
|
592
|
-
return Array.from({ length: f - h + 1 }, (
|
|
593
|
-
const v = h +
|
|
576
|
+
}, Wt = ({ onLevelChange: e, disabled: t }) => {
|
|
577
|
+
const { gameProgress: n, config: o } = se(), { i18n: i, levelConfig: s } = o, { currentTier: a, levelScores: r, currentLevel: c, highestUnlockedLevel: l } = n, d = ae(s), u = ee(() => {
|
|
578
|
+
const [h, f] = d.getTierLevelsRange(a);
|
|
579
|
+
return Array.from({ length: f - h + 1 }, (m, g) => {
|
|
580
|
+
const v = h + g, w = r[v] || 0;
|
|
594
581
|
return {
|
|
595
582
|
level: v,
|
|
596
|
-
score:
|
|
583
|
+
score: w
|
|
597
584
|
};
|
|
598
585
|
});
|
|
599
|
-
}, [
|
|
600
|
-
return /* @__PURE__ */
|
|
586
|
+
}, [a, r]);
|
|
587
|
+
return /* @__PURE__ */ _("div", { className: "level-selector", children: /* @__PURE__ */ _(
|
|
601
588
|
"select",
|
|
602
589
|
{
|
|
603
|
-
value:
|
|
590
|
+
value: c,
|
|
604
591
|
onChange: (h) => {
|
|
605
592
|
h.target && h.target.value && e(Number(h.target.value));
|
|
606
593
|
},
|
|
607
594
|
disabled: t,
|
|
608
595
|
className: "level-dropdown",
|
|
609
|
-
children: u.map(({ level: h, score: f }) => /* @__PURE__ */
|
|
610
|
-
"option",
|
|
611
|
-
{
|
|
612
|
-
value: h,
|
|
613
|
-
disabled: h > c,
|
|
614
|
-
children: `${i.level} ${h} ${"★".repeat(f)}`
|
|
615
|
-
},
|
|
616
|
-
`level-${h}`
|
|
617
|
-
))
|
|
596
|
+
children: u.map(({ level: h, score: f }) => /* @__PURE__ */ _("option", { value: h, disabled: h > l, children: `${i.level} ${h} ${"★".repeat(f)}` }, `level-${h}`))
|
|
618
597
|
}
|
|
619
598
|
) });
|
|
620
|
-
},
|
|
599
|
+
}, oe = ({
|
|
621
600
|
isOpen: e,
|
|
622
601
|
title: t,
|
|
623
602
|
className: n = "",
|
|
624
603
|
message: o,
|
|
625
604
|
children: i,
|
|
626
605
|
noConfirm: s = !1,
|
|
627
|
-
noCancel:
|
|
606
|
+
noCancel: a = !1,
|
|
628
607
|
confirmText: r = "OK",
|
|
629
|
-
cancelText:
|
|
630
|
-
confirmClass:
|
|
608
|
+
cancelText: c = "Cancel",
|
|
609
|
+
confirmClass: l = "",
|
|
631
610
|
cancelClass: d = "",
|
|
632
611
|
onConfirm: u,
|
|
633
612
|
onCancel: h
|
|
634
613
|
}) => {
|
|
635
|
-
const f =
|
|
636
|
-
return
|
|
637
|
-
const
|
|
638
|
-
|
|
614
|
+
const f = R(null);
|
|
615
|
+
return F(() => {
|
|
616
|
+
const m = (g) => {
|
|
617
|
+
g.key === "Escape" && h?.();
|
|
639
618
|
};
|
|
640
|
-
return e && document.addEventListener("keydown",
|
|
641
|
-
document.removeEventListener("keydown",
|
|
619
|
+
return e && document.addEventListener("keydown", m), () => {
|
|
620
|
+
document.removeEventListener("keydown", m);
|
|
642
621
|
};
|
|
643
|
-
}, [e, h]), /* @__PURE__ */
|
|
644
|
-
"div",
|
|
645
|
-
{
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
!l && /* @__PURE__ */ m(
|
|
652
|
-
"button",
|
|
653
|
-
{
|
|
654
|
-
type: "button",
|
|
655
|
-
className: "maze-dialog-cancel " + d,
|
|
656
|
-
onClick: h,
|
|
657
|
-
children: a
|
|
658
|
-
}
|
|
659
|
-
),
|
|
660
|
-
!s && /* @__PURE__ */ m(
|
|
661
|
-
"button",
|
|
662
|
-
{
|
|
663
|
-
type: "button",
|
|
664
|
-
className: "maze-dialog-confirm " + c,
|
|
665
|
-
onClick: u,
|
|
666
|
-
children: r
|
|
667
|
-
}
|
|
668
|
-
)
|
|
669
|
-
] })
|
|
670
|
-
] })
|
|
671
|
-
}
|
|
672
|
-
);
|
|
622
|
+
}, [e, h]), /* @__PURE__ */ _("div", { className: `maze-dialog-overlay ${e ? "maze-dialog-visible" : ""}`, children: /* @__PURE__ */ _("div", { className: "maze-dialog " + n, ref: f, children: [
|
|
623
|
+
/* @__PURE__ */ _("div", { className: "maze-dialog-title", children: t }),
|
|
624
|
+
/* @__PURE__ */ _("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ _("div", { className: "maze-dialog-message", children: o }) }),
|
|
625
|
+
(!a || !s) && /* @__PURE__ */ _("div", { className: "maze-dialog-buttons", children: [
|
|
626
|
+
!a && /* @__PURE__ */ _("button", { type: "button", className: "maze-dialog-cancel " + d, onClick: h, children: c }),
|
|
627
|
+
!s && /* @__PURE__ */ _("button", { type: "button", className: "maze-dialog-confirm " + l, onClick: u, children: r })
|
|
628
|
+
] })
|
|
629
|
+
] }) });
|
|
673
630
|
}, q = {
|
|
674
631
|
container: null,
|
|
675
632
|
// attach Toast container to element, only need to execute once
|
|
@@ -682,9 +639,7 @@ const Rt = (e) => ({
|
|
|
682
639
|
// use it in any component
|
|
683
640
|
show(e, t = 2e3) {
|
|
684
641
|
if (!this.container) {
|
|
685
|
-
console.warn(
|
|
686
|
-
"NativeToast: container not initialized, please call attachTo first"
|
|
687
|
-
);
|
|
642
|
+
console.warn("NativeToast: container not initialized, please call attachTo first");
|
|
688
643
|
return;
|
|
689
644
|
}
|
|
690
645
|
this.currentToast && this.container.contains(this.currentToast) && (this.container.removeChild(this.currentToast), this.currentToast = null), this.currentTimer && (clearTimeout(this.currentTimer), this.currentTimer = null);
|
|
@@ -700,121 +655,93 @@ const Rt = (e) => ({
|
|
|
700
655
|
for (; this.container.firstChild; )
|
|
701
656
|
this.container.removeChild(this.container.firstChild);
|
|
702
657
|
}
|
|
703
|
-
},
|
|
704
|
-
const {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
resetGame: s,
|
|
711
|
-
config: l
|
|
712
|
-
} = re(), { i18n: r, levelConfig: a } = l, c = ie(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = e, g = c.getTotalLevels(), [_, v] = W(!1), [T, b] = W(!1), [C, p] = W(!1), S = (O) => {
|
|
713
|
-
const $ = c.getFirstLevelOfTier(O);
|
|
714
|
-
c.isLevelUnlocked($, h) && (t((U) => ({ ...U, currentTier: O })), w($));
|
|
715
|
-
}, w = (O) => {
|
|
716
|
-
c.isLevelUnlocked(O, h) && (t(($) => ({ ...$, currentLevel: O })), q.show(r.levelGoToast.replace("%LEVEL%", O.toString())));
|
|
717
|
-
}, y = () => {
|
|
658
|
+
}, qt = () => {
|
|
659
|
+
const { gameProgress: e, setGameProgress: t, gamePlayState: n, setGamePlayState: o, gamePlayStateRef: i, resetGame: s, config: a } = se(), { i18n: r, levelConfig: c } = a, l = ae(c), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = e, m = l.getTotalLevels(), [g, v] = G(!1), [w, y] = G(!1), [T, p] = G(!1), z = (D) => {
|
|
660
|
+
const $ = l.getFirstLevelOfTier(D);
|
|
661
|
+
l.isLevelUnlocked($, h) && (t((U) => ({ ...U, currentTier: D })), C($));
|
|
662
|
+
}, C = (D) => {
|
|
663
|
+
l.isLevelUnlocked(D, h) && (t(($) => ({ ...$, currentLevel: D })), q.show(r.levelGoToast.replace("%LEVEL%", D.toString())));
|
|
664
|
+
}, S = () => {
|
|
718
665
|
v(!0);
|
|
719
|
-
},
|
|
666
|
+
}, k = () => {
|
|
720
667
|
v(!1);
|
|
721
|
-
},
|
|
668
|
+
}, L = () => {
|
|
722
669
|
p(!0);
|
|
723
670
|
}, E = () => {
|
|
724
671
|
p(!1);
|
|
725
|
-
},
|
|
672
|
+
}, M = () => {
|
|
726
673
|
q.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
|
|
727
674
|
...i.current,
|
|
728
675
|
// need to sync with ref
|
|
729
676
|
showClue: !i.current.showClue
|
|
730
677
|
})), p(!1);
|
|
731
|
-
},
|
|
732
|
-
|
|
678
|
+
}, b = () => {
|
|
679
|
+
y(!0);
|
|
680
|
+
}, A = () => {
|
|
681
|
+
s(), y(!1), q.show(r.resetDoneToast);
|
|
733
682
|
}, P = () => {
|
|
734
|
-
|
|
735
|
-
}, R = () => {
|
|
736
|
-
b(!1);
|
|
683
|
+
y(!1);
|
|
737
684
|
};
|
|
738
|
-
return /* @__PURE__ */
|
|
739
|
-
/* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
741
|
-
/* @__PURE__ */
|
|
742
|
-
|
|
743
|
-
{
|
|
744
|
-
onTierChange: S,
|
|
745
|
-
disabled: d
|
|
746
|
-
}
|
|
747
|
-
),
|
|
748
|
-
/* @__PURE__ */ m(
|
|
749
|
-
Ot,
|
|
750
|
-
{
|
|
751
|
-
onLevelChange: w,
|
|
752
|
-
disabled: d
|
|
753
|
-
}
|
|
754
|
-
)
|
|
685
|
+
return /* @__PURE__ */ _("div", { class: "game-panel-container", children: [
|
|
686
|
+
/* @__PURE__ */ _("div", { className: "game-controls", children: [
|
|
687
|
+
/* @__PURE__ */ _("div", { className: "selectors-container", children: [
|
|
688
|
+
/* @__PURE__ */ _(jt, { onTierChange: z, disabled: d }),
|
|
689
|
+
/* @__PURE__ */ _(Wt, { onLevelChange: C, disabled: d })
|
|
755
690
|
] }),
|
|
756
|
-
/* @__PURE__ */
|
|
691
|
+
/* @__PURE__ */ _(
|
|
757
692
|
"button",
|
|
758
693
|
{
|
|
759
694
|
className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
|
|
760
695
|
disabled: u,
|
|
761
696
|
title: "Toggle Clue",
|
|
762
|
-
onClick:
|
|
697
|
+
onClick: L,
|
|
763
698
|
children: u ? r.clueOn : r.clueOff
|
|
764
699
|
}
|
|
765
700
|
)
|
|
766
701
|
] }),
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
|
|
702
|
+
/* @__PURE__ */ _("div", { className: "game-settings", children: /* @__PURE__ */ _("span", { className: "game-settings-icon", onClick: S, children: "★ " + f }) }),
|
|
703
|
+
/* @__PURE__ */ _(
|
|
704
|
+
oe,
|
|
770
705
|
{
|
|
771
|
-
isOpen:
|
|
706
|
+
isOpen: g,
|
|
772
707
|
title: r.settings,
|
|
773
708
|
noConfirm: !0,
|
|
774
709
|
cancelText: r.close,
|
|
775
|
-
onCancel:
|
|
710
|
+
onCancel: k,
|
|
776
711
|
children: [
|
|
777
|
-
/* @__PURE__ */
|
|
778
|
-
/* @__PURE__ */
|
|
779
|
-
/* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
712
|
+
/* @__PURE__ */ _("div", { className: "settings-stats", children: [
|
|
713
|
+
/* @__PURE__ */ _("div", { children: r.levelComplete + `: ${h}/${m}` }),
|
|
714
|
+
/* @__PURE__ */ _("div", { children: r.starsCollected + ": " + f }),
|
|
715
|
+
/* @__PURE__ */ _("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
|
|
781
716
|
] }),
|
|
782
|
-
/* @__PURE__ */
|
|
783
|
-
/* @__PURE__ */
|
|
784
|
-
|
|
785
|
-
{
|
|
786
|
-
className: "settings-reset-button",
|
|
787
|
-
title: "Reset Game",
|
|
788
|
-
onClick: L,
|
|
789
|
-
children: r.reset
|
|
790
|
-
}
|
|
791
|
-
),
|
|
792
|
-
/* @__PURE__ */ m("div", { className: "settings-item-tip", children: r.resetTip })
|
|
717
|
+
/* @__PURE__ */ _("div", { className: "settings-item-box", children: [
|
|
718
|
+
/* @__PURE__ */ _("button", { className: "settings-reset-button", title: "Reset Game", onClick: b, children: r.reset }),
|
|
719
|
+
/* @__PURE__ */ _("div", { className: "settings-item-tip", children: r.resetTip })
|
|
793
720
|
] })
|
|
794
721
|
]
|
|
795
722
|
}
|
|
796
723
|
),
|
|
797
|
-
/* @__PURE__ */
|
|
798
|
-
|
|
724
|
+
/* @__PURE__ */ _(
|
|
725
|
+
oe,
|
|
799
726
|
{
|
|
800
|
-
isOpen:
|
|
727
|
+
isOpen: w,
|
|
801
728
|
title: r.confirmReset,
|
|
802
729
|
message: r.confirmResetMessage,
|
|
803
730
|
confirmText: r.reset,
|
|
804
731
|
cancelText: r.cancel,
|
|
805
|
-
onConfirm:
|
|
806
|
-
onCancel:
|
|
732
|
+
onConfirm: A,
|
|
733
|
+
onCancel: P
|
|
807
734
|
}
|
|
808
735
|
),
|
|
809
|
-
/* @__PURE__ */
|
|
810
|
-
|
|
736
|
+
/* @__PURE__ */ _(
|
|
737
|
+
oe,
|
|
811
738
|
{
|
|
812
|
-
isOpen:
|
|
739
|
+
isOpen: T,
|
|
813
740
|
title: r.confirmClue,
|
|
814
741
|
message: r.confirmClueMessage,
|
|
815
742
|
confirmText: r.confirm,
|
|
816
743
|
cancelText: r.cancel,
|
|
817
|
-
onConfirm:
|
|
744
|
+
onConfirm: M,
|
|
818
745
|
onCancel: E
|
|
819
746
|
}
|
|
820
747
|
)
|
|
@@ -824,98 +751,98 @@ function Pe(e, t) {
|
|
|
824
751
|
if (!(e instanceof t))
|
|
825
752
|
throw new TypeError("Cannot call a class as a function");
|
|
826
753
|
}
|
|
827
|
-
function
|
|
754
|
+
function Bt(e, t) {
|
|
828
755
|
for (var n = 0; n < t.length; n++) {
|
|
829
756
|
var o = t[n];
|
|
830
757
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, o.key, o);
|
|
831
758
|
}
|
|
832
759
|
}
|
|
833
|
-
function
|
|
834
|
-
return t &&
|
|
760
|
+
function xe(e, t, n) {
|
|
761
|
+
return t && Bt(e.prototype, t), e;
|
|
835
762
|
}
|
|
836
|
-
function
|
|
763
|
+
function Ye(e) {
|
|
837
764
|
return +e.replace(/px/, "");
|
|
838
765
|
}
|
|
839
|
-
function
|
|
840
|
-
var t = window.devicePixelRatio, n = getComputedStyle(e), o =
|
|
766
|
+
function Vt(e) {
|
|
767
|
+
var t = window.devicePixelRatio, n = getComputedStyle(e), o = Ye(n.getPropertyValue("width")), i = Ye(n.getPropertyValue("height"));
|
|
841
768
|
e.setAttribute("width", (o * t).toString()), e.setAttribute("height", (i * t).toString());
|
|
842
769
|
}
|
|
843
|
-
function
|
|
770
|
+
function W(e, t) {
|
|
844
771
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (t - e) + e;
|
|
845
772
|
return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
|
|
846
773
|
}
|
|
847
|
-
function Ye(e) {
|
|
848
|
-
return e[j(0, e.length)];
|
|
849
|
-
}
|
|
850
|
-
var Wt = 125e-5, jt = 5e-4, qt = 9e-4, Ht = 1e-5, Bt = 6, Vt = 80, Xt = 0.9, Yt = 1.7, Kt = 0.2, Jt = 0.6, Zt = 0.03, Qt = 0.07, en = 15, tn = 82, nn = 100, on = 250, rn = 40, sn = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
|
|
851
774
|
function Ke(e) {
|
|
775
|
+
return e[W(0, e.length)];
|
|
776
|
+
}
|
|
777
|
+
var Ht = 125e-5, Xt = 5e-4, Yt = 9e-4, Kt = 1e-5, Jt = 6, Qt = 80, Zt = 0.9, en = 1.7, tn = 0.2, nn = 0.6, on = 0.03, rn = 0.07, Je = 15, Qe = 82, sn = 100, an = 250, ln = 40, cn = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
|
|
778
|
+
function Ze(e) {
|
|
852
779
|
var t = 1920;
|
|
853
780
|
return Math.log(e) / Math.log(t);
|
|
854
781
|
}
|
|
855
|
-
var
|
|
782
|
+
var et = /* @__PURE__ */ (function() {
|
|
856
783
|
function e(t) {
|
|
857
784
|
Pe(this, e);
|
|
858
|
-
var n = t.initialPosition, o = t.direction, i = t.confettiRadius, s = t.confettiColors,
|
|
785
|
+
var n = t.initialPosition, o = t.direction, i = t.confettiRadius, s = t.confettiColors, a = t.emojis, r = t.emojiSize, c = t.canvasWidth, l = W(Zt, en, 3), d = l * Ze(c);
|
|
859
786
|
this.confettiSpeed = {
|
|
860
787
|
x: d,
|
|
861
788
|
y: d
|
|
862
|
-
}, this.finalConfettiSpeedX =
|
|
789
|
+
}, this.finalConfettiSpeedX = W(tn, nn, 3), this.rotationSpeed = a.length ? 0.01 : W(on, rn, 3) * Ze(c), this.dragForceCoefficient = W(Xt, Yt, 6), this.radius = {
|
|
863
790
|
x: i,
|
|
864
791
|
y: i
|
|
865
|
-
}, this.initialRadius = i, this.rotationAngle = o === "left" ?
|
|
866
|
-
var u = o === "left" ?
|
|
792
|
+
}, this.initialRadius = i, this.rotationAngle = o === "left" ? W(0, 0.2, 3) : W(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = W(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
|
|
793
|
+
var u = o === "left" ? W(Qe, Je) * Math.PI / 180 : W(-Je, -Qe) * Math.PI / 180;
|
|
867
794
|
this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
|
|
868
|
-
var h =
|
|
795
|
+
var h = W(-150, 0), f = {
|
|
869
796
|
x: n.x + (o === "left" ? -h : h) * this.absCos,
|
|
870
797
|
y: n.y - h * this.absSin
|
|
871
798
|
};
|
|
872
|
-
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color =
|
|
799
|
+
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = a.length ? null : Ke(s), this.emoji = a.length ? Ke(a) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
|
|
873
800
|
}
|
|
874
|
-
return
|
|
801
|
+
return xe(e, [{
|
|
875
802
|
key: "draw",
|
|
876
803
|
value: function(n) {
|
|
877
|
-
var o = this.currentPosition, i = this.radius, s = this.color,
|
|
878
|
-
s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) :
|
|
804
|
+
var o = this.currentPosition, i = this.radius, s = this.color, a = this.emoji, r = this.rotationAngle, c = this.emojiRotationAngle, l = this.emojiSize, d = window.devicePixelRatio;
|
|
805
|
+
s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : a && (n.font = "".concat(l, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(c), n.textAlign = "center", n.fillText(a, 0, 0), n.restore());
|
|
879
806
|
}
|
|
880
807
|
}, {
|
|
881
808
|
key: "updatePosition",
|
|
882
809
|
value: function(n, o) {
|
|
883
|
-
var i = this.confettiSpeed, s = this.dragForceCoefficient,
|
|
884
|
-
if (i.x >
|
|
810
|
+
var i = this.confettiSpeed, s = this.dragForceCoefficient, a = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, c = this.rotationSpeed, l = this.createdAt, d = this.direction, u = o - l;
|
|
811
|
+
if (i.x > a && (this.confettiSpeed.x -= s * n), this.currentPosition.x += i.x * (d === "left" ? -this.absCos : this.absCos) * n, this.currentPosition.y = this.initialPosition.y - i.y * this.absSin * u + Ht * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : Kt * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
|
|
885
812
|
this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
|
|
886
813
|
return;
|
|
887
814
|
}
|
|
888
|
-
r === "down" ? (this.radius.y -= n *
|
|
815
|
+
r === "down" ? (this.radius.y -= n * c, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * c, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
|
|
889
816
|
}
|
|
890
817
|
}, {
|
|
891
818
|
key: "getIsVisibleOnCanvas",
|
|
892
819
|
value: function(n) {
|
|
893
|
-
return this.currentPosition.y < n +
|
|
820
|
+
return this.currentPosition.y < n + sn;
|
|
894
821
|
}
|
|
895
822
|
}]), e;
|
|
896
|
-
}();
|
|
897
|
-
function
|
|
823
|
+
})();
|
|
824
|
+
function un() {
|
|
898
825
|
var e = document.createElement("canvas");
|
|
899
826
|
return e.style.position = "fixed", e.style.width = "100%", e.style.height = "100%", e.style.top = "0", e.style.left = "0", e.style.zIndex = "1000", e.style.pointerEvents = "none", document.body.appendChild(e), e;
|
|
900
827
|
}
|
|
901
|
-
function
|
|
902
|
-
var t = e.confettiRadius, n = t === void 0 ?
|
|
828
|
+
function dn(e) {
|
|
829
|
+
var t = e.confettiRadius, n = t === void 0 ? Jt : t, o = e.confettiNumber, i = o === void 0 ? e.confettiesNumber || (e.emojis ? ln : an) : o, s = e.confettiColors, a = s === void 0 ? cn : s, r = e.emojis, c = r === void 0 ? e.emojies || [] : r, l = e.emojiSize, d = l === void 0 ? Qt : l;
|
|
903
830
|
return e.emojies && console.error("emojies argument is deprecated, please use emojis instead"), e.confettiesNumber && console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"), {
|
|
904
831
|
confettiRadius: n,
|
|
905
832
|
confettiNumber: i,
|
|
906
|
-
confettiColors:
|
|
907
|
-
emojis:
|
|
833
|
+
confettiColors: a,
|
|
834
|
+
emojis: c,
|
|
908
835
|
emojiSize: d
|
|
909
836
|
};
|
|
910
837
|
}
|
|
911
|
-
var
|
|
838
|
+
var hn = /* @__PURE__ */ (function() {
|
|
912
839
|
function e(t) {
|
|
913
840
|
var n = this;
|
|
914
841
|
Pe(this, e), this.canvasContext = t, this.shapes = [], this.promise = new Promise(function(o) {
|
|
915
842
|
return n.resolvePromise = o;
|
|
916
843
|
});
|
|
917
844
|
}
|
|
918
|
-
return
|
|
845
|
+
return xe(e, [{
|
|
919
846
|
key: "getBatchCompletePromise",
|
|
920
847
|
value: function() {
|
|
921
848
|
return this.promise;
|
|
@@ -935,27 +862,27 @@ var cn = /* @__PURE__ */ function() {
|
|
|
935
862
|
}, {
|
|
936
863
|
key: "processShapes",
|
|
937
864
|
value: function(n, o, i) {
|
|
938
|
-
var s = this,
|
|
939
|
-
this.shapes = this.shapes.filter(function(
|
|
940
|
-
return
|
|
865
|
+
var s = this, a = n.timeDelta, r = n.currentTime;
|
|
866
|
+
this.shapes = this.shapes.filter(function(c) {
|
|
867
|
+
return c.updatePosition(a, r), c.draw(s.canvasContext), i ? c.getIsVisibleOnCanvas(o) : !0;
|
|
941
868
|
});
|
|
942
869
|
}
|
|
943
870
|
}]), e;
|
|
944
|
-
}(),
|
|
871
|
+
})(), fn = /* @__PURE__ */ (function() {
|
|
945
872
|
function e() {
|
|
946
873
|
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
947
|
-
Pe(this, e), this.activeConfettiBatches = [], this.canvas = t.canvas ||
|
|
874
|
+
Pe(this, e), this.activeConfettiBatches = [], this.canvas = t.canvas || un(), this.canvasContext = this.canvas.getContext("2d"), this.requestAnimationFrameRequested = !1, this.lastUpdated = (/* @__PURE__ */ new Date()).getTime(), this.iterationIndex = 0, this.loop = this.loop.bind(this), requestAnimationFrame(this.loop);
|
|
948
875
|
}
|
|
949
|
-
return
|
|
876
|
+
return xe(e, [{
|
|
950
877
|
key: "loop",
|
|
951
878
|
value: function() {
|
|
952
|
-
this.requestAnimationFrameRequested = !1,
|
|
879
|
+
this.requestAnimationFrameRequested = !1, Vt(this.canvas);
|
|
953
880
|
var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
|
|
954
|
-
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(
|
|
955
|
-
return
|
|
881
|
+
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(a) {
|
|
882
|
+
return a.processShapes({
|
|
956
883
|
timeDelta: o,
|
|
957
884
|
currentTime: n
|
|
958
|
-
}, i, s), s ? !
|
|
885
|
+
}, i, s), s ? !a.complete() : !0;
|
|
959
886
|
}), this.iterationIndex++, this.queueAnimationFrameIfNeeded(n);
|
|
960
887
|
}
|
|
961
888
|
}, {
|
|
@@ -966,35 +893,35 @@ var cn = /* @__PURE__ */ function() {
|
|
|
966
893
|
}, {
|
|
967
894
|
key: "addConfetti",
|
|
968
895
|
value: function() {
|
|
969
|
-
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o =
|
|
896
|
+
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = dn(n), i = o.confettiRadius, s = o.confettiNumber, a = o.confettiColors, r = o.emojis, c = o.emojiSize, l = this.canvas.getBoundingClientRect(), d = l.width, u = l.height, h = u * 5 / 7, f = {
|
|
970
897
|
x: 0,
|
|
971
898
|
y: h
|
|
972
|
-
},
|
|
899
|
+
}, m = {
|
|
973
900
|
x: d,
|
|
974
901
|
y: h
|
|
975
|
-
},
|
|
976
|
-
var
|
|
902
|
+
}, g = new hn(this.canvasContext), v = 0; v < s / 2; v++) {
|
|
903
|
+
var w = new et({
|
|
977
904
|
initialPosition: f,
|
|
978
905
|
direction: "right",
|
|
979
906
|
confettiRadius: i,
|
|
980
|
-
confettiColors:
|
|
907
|
+
confettiColors: a,
|
|
981
908
|
confettiNumber: s,
|
|
982
909
|
emojis: r,
|
|
983
|
-
emojiSize:
|
|
910
|
+
emojiSize: c,
|
|
984
911
|
canvasWidth: d
|
|
985
|
-
}),
|
|
986
|
-
initialPosition:
|
|
912
|
+
}), y = new et({
|
|
913
|
+
initialPosition: m,
|
|
987
914
|
direction: "left",
|
|
988
915
|
confettiRadius: i,
|
|
989
|
-
confettiColors:
|
|
916
|
+
confettiColors: a,
|
|
990
917
|
confettiNumber: s,
|
|
991
918
|
emojis: r,
|
|
992
|
-
emojiSize:
|
|
919
|
+
emojiSize: c,
|
|
993
920
|
canvasWidth: d
|
|
994
921
|
});
|
|
995
|
-
|
|
922
|
+
g.addShapes(w, y);
|
|
996
923
|
}
|
|
997
|
-
return this.activeConfettiBatches.push(
|
|
924
|
+
return this.activeConfettiBatches.push(g), this.queueAnimationFrameIfNeeded(), g.getBatchCompletePromise();
|
|
998
925
|
}
|
|
999
926
|
}, {
|
|
1000
927
|
key: "clearCanvas",
|
|
@@ -1007,143 +934,116 @@ var cn = /* @__PURE__ */ function() {
|
|
|
1007
934
|
this.canvas.remove();
|
|
1008
935
|
}
|
|
1009
936
|
}]), e;
|
|
1010
|
-
}();
|
|
1011
|
-
const
|
|
1012
|
-
const {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
x(() => {
|
|
1021
|
-
g && _ && (dn.addConfetti(), q.show(r.levelCompleteToast), b(!0));
|
|
1022
|
-
}, [g, _]);
|
|
1023
|
-
const C = ie(a), p = C.getTotalLevels(), S = Q(() => v >= p, [v, p]), w = () => {
|
|
1024
|
-
b(!1), q.show(r.levelRestartToast), e?.();
|
|
1025
|
-
}, y = () => {
|
|
1026
|
-
b(!1), i((E) => ({
|
|
937
|
+
})();
|
|
938
|
+
const mn = new fn(), be = 3, _n = ({ onRetry: e }) => {
|
|
939
|
+
const { config: t, currentScore: n, gamePlayState: o, setGamePlayState: i, gameProgress: s, setGameProgress: a } = se(), { i18n: r, levelConfig: c } = t, [l, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: m, levelTransitioning: g } = o, { currentLevel: v } = s, [w, y] = G(!1);
|
|
940
|
+
F(() => {
|
|
941
|
+
m && g && (mn.addConfetti(), q.show(r.levelCompleteToast), y(!0));
|
|
942
|
+
}, [m, g]);
|
|
943
|
+
const T = ae(c), p = T.getTotalLevels(), z = ee(() => v >= p, [v, p]), C = () => {
|
|
944
|
+
y(!1), q.show(r.levelRestartToast), e?.();
|
|
945
|
+
}, S = () => {
|
|
946
|
+
y(!1), i((E) => ({
|
|
1027
947
|
...E,
|
|
1028
948
|
isGameActive: !0,
|
|
1029
949
|
levelTransitioning: !1
|
|
1030
950
|
}));
|
|
1031
|
-
},
|
|
1032
|
-
|
|
1033
|
-
const E =
|
|
951
|
+
}, k = () => {
|
|
952
|
+
y(!1);
|
|
953
|
+
const E = T.getNextLevelInfo(v);
|
|
1034
954
|
if (!E) return;
|
|
1035
|
-
const { nextLevel:
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
highestUnlockedLevel: Math.max(R.highestUnlockedLevel, k),
|
|
1043
|
-
highestUnlockedTier: Math.max(R.highestUnlockedTier, L),
|
|
955
|
+
const { nextLevel: M, nextTier: b, isTierChange: A } = E;
|
|
956
|
+
A && q.show(r.tierUnlockedToast.replace("%TIER%", b.toString())), a((P) => ({
|
|
957
|
+
...P,
|
|
958
|
+
currentLevel: M,
|
|
959
|
+
currentTier: b,
|
|
960
|
+
highestUnlockedLevel: Math.max(P.highestUnlockedLevel, M),
|
|
961
|
+
highestUnlockedTier: Math.max(P.highestUnlockedTier, b),
|
|
1044
962
|
levelScores: {
|
|
1045
|
-
...
|
|
1046
|
-
[
|
|
963
|
+
...P.levelScores,
|
|
964
|
+
[P.currentLevel]: Math.max(
|
|
1047
965
|
Object.values(n).filter(Boolean).length,
|
|
1048
|
-
|
|
966
|
+
P.levelScores[P.currentLevel] || 0
|
|
1049
967
|
)
|
|
1050
968
|
}
|
|
1051
969
|
}));
|
|
1052
|
-
},
|
|
1053
|
-
|
|
1054
|
-
const
|
|
970
|
+
}, L = () => {
|
|
971
|
+
y(!1), a((E) => {
|
|
972
|
+
const M = Math.max(
|
|
1055
973
|
Object.values(n).filter(Boolean).length,
|
|
1056
974
|
E.levelScores[E.currentLevel] || 0
|
|
1057
|
-
),
|
|
975
|
+
), b = {
|
|
1058
976
|
...E.levelScores,
|
|
1059
|
-
[E.currentLevel]:
|
|
977
|
+
[E.currentLevel]: M
|
|
1060
978
|
};
|
|
1061
|
-
let
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
);
|
|
1065
|
-
for (const [$, U] of O)
|
|
979
|
+
let A = 0, P = 0;
|
|
980
|
+
const D = Object.entries(b).sort(($, U) => Number($[0]) - Number(U[0]));
|
|
981
|
+
for (const [$, U] of D)
|
|
1066
982
|
if (U < be) {
|
|
1067
|
-
|
|
983
|
+
A = Number($), P = T.getTierByLevel(A);
|
|
1068
984
|
break;
|
|
1069
985
|
}
|
|
1070
|
-
return (
|
|
986
|
+
return (A > 0 && A !== v || M < be) && q.show(r.notCompleteLevel), (A === 0 || M < be) && e?.(), {
|
|
1071
987
|
...E,
|
|
1072
|
-
currentLevel:
|
|
1073
|
-
currentTier:
|
|
1074
|
-
levelScores:
|
|
988
|
+
currentLevel: A || E.currentLevel,
|
|
989
|
+
currentTier: P || E.currentTier,
|
|
990
|
+
levelScores: b
|
|
1075
991
|
};
|
|
1076
992
|
});
|
|
1077
993
|
};
|
|
1078
|
-
return
|
|
1079
|
-
const E = document.querySelector(".maze-game-container"),
|
|
1080
|
-
|
|
994
|
+
return F(() => {
|
|
995
|
+
const E = document.querySelector(".maze-game-container"), M = (b) => {
|
|
996
|
+
w && ((b.key === " " || b.code === "Space") && E && (E.contains(document.activeElement) || document.activeElement === document.body) && (b.preventDefault(), z ? L() : k()), (b.key === "r" || b.code === "KeyR") && C(), (b.key === "c" || b.code === "KeyC") && S());
|
|
1081
997
|
};
|
|
1082
|
-
return window.addEventListener("keydown",
|
|
1083
|
-
}, [
|
|
1084
|
-
|
|
998
|
+
return window.addEventListener("keydown", M), () => window.removeEventListener("keydown", M);
|
|
999
|
+
}, [w, z]), /* @__PURE__ */ _(
|
|
1000
|
+
oe,
|
|
1085
1001
|
{
|
|
1086
1002
|
className: "level-complete-dialog",
|
|
1087
|
-
isOpen:
|
|
1003
|
+
isOpen: w,
|
|
1088
1004
|
title: r.congratulations,
|
|
1089
1005
|
cancelText: r.retry + " (R)",
|
|
1090
|
-
onCancel:
|
|
1006
|
+
onCancel: C,
|
|
1091
1007
|
noConfirm: !!d,
|
|
1092
1008
|
confirmText: r.continue + " (C)",
|
|
1093
|
-
onConfirm:
|
|
1009
|
+
onConfirm: S,
|
|
1094
1010
|
confirmClass: "maze-continue-btn",
|
|
1095
1011
|
children: [
|
|
1096
|
-
/* @__PURE__ */
|
|
1097
|
-
!!
|
|
1098
|
-
/* @__PURE__ */
|
|
1099
|
-
/* @__PURE__ */
|
|
1012
|
+
/* @__PURE__ */ _("div", { className: "maze-summary-message", children: [
|
|
1013
|
+
!!l && /* @__PURE__ */ _("div", { children: "★ - " + r.findYourExit }),
|
|
1014
|
+
/* @__PURE__ */ _("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
|
|
1015
|
+
/* @__PURE__ */ _("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
|
|
1100
1016
|
] }),
|
|
1101
|
-
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
"
|
|
1104
|
-
{
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
/* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
|
|
1111
|
-
]
|
|
1112
|
-
}
|
|
1113
|
-
) : /* @__PURE__ */ m(
|
|
1114
|
-
"button",
|
|
1115
|
-
{
|
|
1116
|
-
className: "maze-go-next-btn",
|
|
1117
|
-
type: "button",
|
|
1118
|
-
onClick: z,
|
|
1119
|
-
children: [
|
|
1120
|
-
/* @__PURE__ */ m("span", { children: r.nextLevel }),
|
|
1121
|
-
/* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
|
|
1122
|
-
]
|
|
1123
|
-
}
|
|
1124
|
-
) }),
|
|
1125
|
-
!d && /* @__PURE__ */ m("div", { className: "not-all-stars-collected", children: r.continueMessage })
|
|
1017
|
+
z && /* @__PURE__ */ _("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
|
|
1018
|
+
/* @__PURE__ */ _("div", { className: "maze-go-next", children: z ? /* @__PURE__ */ _("button", { className: "maze-go-next-btn", type: "button", onClick: L, children: [
|
|
1019
|
+
/* @__PURE__ */ _("span", { children: r.lastOK }),
|
|
1020
|
+
/* @__PURE__ */ _("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
|
|
1021
|
+
] }) : /* @__PURE__ */ _("button", { className: "maze-go-next-btn", type: "button", onClick: k, children: [
|
|
1022
|
+
/* @__PURE__ */ _("span", { children: r.nextLevel }),
|
|
1023
|
+
/* @__PURE__ */ _("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
|
|
1024
|
+
] }) }),
|
|
1025
|
+
!d && /* @__PURE__ */ _("div", { className: "not-all-stars-collected", children: r.continueMessage })
|
|
1126
1026
|
]
|
|
1127
1027
|
}
|
|
1128
1028
|
);
|
|
1129
|
-
},
|
|
1130
|
-
const n =
|
|
1029
|
+
}, wt = (e, t) => {
|
|
1030
|
+
const n = R({
|
|
1131
1031
|
canvasWidth: 0,
|
|
1132
1032
|
canvasHeight: 0
|
|
1133
1033
|
});
|
|
1134
|
-
return
|
|
1034
|
+
return F(() => {
|
|
1135
1035
|
const o = () => {
|
|
1136
1036
|
const s = e.current;
|
|
1137
1037
|
if (!s) return;
|
|
1138
|
-
const
|
|
1139
|
-
if (!
|
|
1140
|
-
const r =
|
|
1038
|
+
const a = s.parentElement;
|
|
1039
|
+
if (!a) return;
|
|
1040
|
+
const r = a.clientWidth;
|
|
1141
1041
|
if (r === 0)
|
|
1142
1042
|
return;
|
|
1143
|
-
const
|
|
1043
|
+
const c = window.devicePixelRatio || 1;
|
|
1144
1044
|
s.style.width = `${r}px`, s.style.height = `${r}px`;
|
|
1145
|
-
const
|
|
1146
|
-
s.width =
|
|
1045
|
+
const l = r * c, d = r * c;
|
|
1046
|
+
s.width = l, s.height = d, n.current = { canvasWidth: l, canvasHeight: d }, t?.();
|
|
1147
1047
|
};
|
|
1148
1048
|
o();
|
|
1149
1049
|
let i = null;
|
|
@@ -1151,15 +1051,15 @@ const dn = new un(), be = 3, hn = ({ onRetry: e }) => {
|
|
|
1151
1051
|
window.removeEventListener("resize", o), i?.disconnect();
|
|
1152
1052
|
};
|
|
1153
1053
|
}, [e, t]), n;
|
|
1154
|
-
},
|
|
1155
|
-
const o =
|
|
1156
|
-
return
|
|
1054
|
+
}, Ct = (e, t, n) => {
|
|
1055
|
+
const o = R({ cellWidth: 0, cellHeight: 0 });
|
|
1056
|
+
return F(() => {
|
|
1157
1057
|
const i = () => {
|
|
1158
|
-
const
|
|
1159
|
-
if (!
|
|
1160
|
-
const { rows:
|
|
1161
|
-
if (
|
|
1162
|
-
const d = (
|
|
1058
|
+
const a = e.current, r = t.maze;
|
|
1059
|
+
if (!a || !r) return;
|
|
1060
|
+
const { rows: c, cols: l } = r;
|
|
1061
|
+
if (c <= 0 || l <= 0) return;
|
|
1062
|
+
const d = (a.width - n * 2) / l, u = (a.height - n * 2) / c;
|
|
1163
1063
|
o.current = { cellWidth: d, cellHeight: u };
|
|
1164
1064
|
};
|
|
1165
1065
|
i();
|
|
@@ -1168,12 +1068,12 @@ const dn = new un(), be = 3, hn = ({ onRetry: e }) => {
|
|
|
1168
1068
|
e.current && s?.disconnect();
|
|
1169
1069
|
};
|
|
1170
1070
|
}, [e, t.maze, n]), o;
|
|
1171
|
-
},
|
|
1071
|
+
}, ue = {
|
|
1172
1072
|
ArrowUp: [-1, 0],
|
|
1173
1073
|
ArrowDown: [1, 0],
|
|
1174
1074
|
ArrowLeft: [0, -1],
|
|
1175
1075
|
ArrowRight: [0, 1]
|
|
1176
|
-
},
|
|
1076
|
+
}, yt = ({
|
|
1177
1077
|
gamePlayStateRef: e,
|
|
1178
1078
|
setGamePlayState: t,
|
|
1179
1079
|
moveSpeed: n,
|
|
@@ -1183,173 +1083,153 @@ const dn = new un(), be = 3, hn = ({ onRetry: e }) => {
|
|
|
1183
1083
|
playerRadius: i,
|
|
1184
1084
|
// player radius in grid unit, default 0.2
|
|
1185
1085
|
onFoodCollected: s,
|
|
1186
|
-
onExitReached:
|
|
1086
|
+
onExitReached: a,
|
|
1187
1087
|
onFirstMove: r
|
|
1188
1088
|
}) => {
|
|
1189
|
-
const
|
|
1190
|
-
(
|
|
1191
|
-
const
|
|
1192
|
-
if (!
|
|
1089
|
+
const c = () => o?.current ?? n ?? 0.03, l = R(!1), d = R(/* @__PURE__ */ new Set()), u = R(!1), h = Ve(
|
|
1090
|
+
(T, p) => {
|
|
1091
|
+
const z = e.current;
|
|
1092
|
+
if (!z.maze)
|
|
1193
1093
|
return { canMove: !1, newCell: null };
|
|
1194
|
-
const
|
|
1195
|
-
if (
|
|
1094
|
+
const C = c(), [S, k] = ue[T];
|
|
1095
|
+
if (tt(
|
|
1196
1096
|
p,
|
|
1197
|
-
|
|
1198
|
-
|
|
1097
|
+
S,
|
|
1098
|
+
k,
|
|
1199
1099
|
i,
|
|
1200
|
-
|
|
1201
|
-
|
|
1100
|
+
C,
|
|
1101
|
+
z.maze
|
|
1202
1102
|
))
|
|
1203
1103
|
return { canMove: !1, newCell: null };
|
|
1204
|
-
const { row: E, col:
|
|
1205
|
-
if (
|
|
1104
|
+
const { row: E, col: M } = p, b = E + S * C, A = M + k * C, P = -0.5, D = z.maze.rows, $ = z.maze.cols;
|
|
1105
|
+
if (b < P || b >= D || A < P || A >= $)
|
|
1206
1106
|
return { canMove: !1, newCell: null };
|
|
1207
|
-
const U = E < 0 ? 0 : Math.floor(E),
|
|
1208
|
-
return B !== U ||
|
|
1107
|
+
const U = E < 0 ? 0 : Math.floor(E), H = M < 0 ? 0 : Math.floor(M), B = b < 0 ? 0 : Math.floor(b), K = A < 0 ? 0 : Math.floor(A);
|
|
1108
|
+
return B !== U || K !== H ? z.maze.isValid(B, K) ? {
|
|
1209
1109
|
canMove: !0,
|
|
1210
|
-
newCell: { row: B, col:
|
|
1110
|
+
newCell: { row: B, col: K }
|
|
1211
1111
|
} : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
|
|
1212
1112
|
},
|
|
1213
|
-
[i,
|
|
1113
|
+
[i, c]
|
|
1214
1114
|
), f = () => {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
) < w);
|
|
1218
|
-
y !== -1 && s && (s(), e.current = {
|
|
1115
|
+
const T = e.current, { row: p, col: z } = T.playerCell, C = i * 2, S = T.foodCells.findIndex((E) => Math.sqrt(Math.pow(p - E.row, 2) + Math.pow(z - E.col, 2)) < C);
|
|
1116
|
+
S !== -1 && s && (s(), e.current = {
|
|
1219
1117
|
...e.current,
|
|
1220
1118
|
foodCollected: e.current.foodCollected + 1,
|
|
1221
|
-
foodCells: e.current.foodCells.filter(
|
|
1222
|
-
(E, k) => k !== y
|
|
1223
|
-
)
|
|
1119
|
+
foodCells: e.current.foodCells.filter((E, M) => M !== S)
|
|
1224
1120
|
});
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
C.exitCell,
|
|
1228
|
-
C.maze
|
|
1229
|
-
);
|
|
1230
|
-
N && !e.current.playerAtExit ? (e.current = {
|
|
1121
|
+
const L = pn(T.playerCell, T.exitCell, T.maze);
|
|
1122
|
+
L && !e.current.playerAtExit ? (e.current = {
|
|
1231
1123
|
...e.current,
|
|
1232
1124
|
playerAtExit: !0,
|
|
1233
1125
|
isGameActive: !1,
|
|
1234
1126
|
// pause render loop and controls
|
|
1235
1127
|
levelTransitioning: !0
|
|
1236
|
-
},
|
|
1128
|
+
}, a && a(), requestIdleCallback(
|
|
1237
1129
|
() => {
|
|
1238
1130
|
t(() => ({ ...e.current }));
|
|
1239
1131
|
},
|
|
1240
1132
|
{ timeout: 10 }
|
|
1241
|
-
)) : !
|
|
1133
|
+
)) : !L && e.current.playerAtExit && (e.current = {
|
|
1242
1134
|
...e.current,
|
|
1243
1135
|
playerAtExit: !1,
|
|
1244
1136
|
isGameActive: !0,
|
|
1245
1137
|
levelTransitioning: !1
|
|
1246
1138
|
});
|
|
1247
|
-
},
|
|
1248
|
-
const p = e.current,
|
|
1249
|
-
if ((
|
|
1250
|
-
const
|
|
1139
|
+
}, m = (T) => {
|
|
1140
|
+
const p = e.current, z = Math.round(T.row), C = Math.round(T.col), S = p.playerPath[p.playerPath.length - 1], k = S.row === z && S.col === C, L = Math.abs(S.row - z), E = Math.abs(S.col - C);
|
|
1141
|
+
if ((L === 1 && E === 0 || L === 0 && E === 1) && !k) {
|
|
1142
|
+
const b = `${S.row},${S.col}-${z},${C}`;
|
|
1251
1143
|
e.current = {
|
|
1252
1144
|
...e.current,
|
|
1253
|
-
playerPath: [
|
|
1254
|
-
...e.current.playerPath,
|
|
1255
|
-
{ row: S, col: w }
|
|
1256
|
-
],
|
|
1145
|
+
playerPath: [...e.current.playerPath, { row: z, col: C }],
|
|
1257
1146
|
visitCounts: {
|
|
1258
1147
|
...e.current.visitCounts,
|
|
1259
|
-
[
|
|
1148
|
+
[b]: (e.current.visitCounts[b] || 0) + 1
|
|
1260
1149
|
}
|
|
1261
1150
|
};
|
|
1262
1151
|
}
|
|
1263
|
-
},
|
|
1264
|
-
if (
|
|
1265
|
-
const
|
|
1266
|
-
!
|
|
1267
|
-
(
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
C.playerCell
|
|
1271
|
-
);
|
|
1272
|
-
return w;
|
|
1273
|
-
}
|
|
1274
|
-
) || (!u.current && r && (u.current = !0, r()), c.current = !0);
|
|
1152
|
+
}, g = () => {
|
|
1153
|
+
if (l.current || d.current.size === 0) return;
|
|
1154
|
+
const T = e.current;
|
|
1155
|
+
!T.playerCell || !Array.from(d.current).some((z) => {
|
|
1156
|
+
const { canMove: C } = h(z, T.playerCell);
|
|
1157
|
+
return C;
|
|
1158
|
+
}) || (!u.current && r && (u.current = !0, r()), l.current = !0);
|
|
1275
1159
|
};
|
|
1276
|
-
|
|
1277
|
-
const
|
|
1278
|
-
if (
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1281
|
-
|
|
1160
|
+
F(() => {
|
|
1161
|
+
const T = (C) => {
|
|
1162
|
+
if (C.key === "ArrowUp" || C.key === "ArrowDown" || C.key === "ArrowLeft" || C.key === "ArrowRight" || C.key === " ") {
|
|
1163
|
+
const S = document.activeElement;
|
|
1164
|
+
if (S && (S.tagName === "INPUT" || S.tagName === "TEXTAREA" || S.getAttribute("contenteditable") === "true")) return;
|
|
1165
|
+
C.preventDefault();
|
|
1282
1166
|
}
|
|
1283
|
-
}, p = (
|
|
1284
|
-
const
|
|
1285
|
-
if (!(
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
},
|
|
1289
|
-
const
|
|
1290
|
-
if (!(
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1167
|
+
}, p = (C) => {
|
|
1168
|
+
const S = C.key;
|
|
1169
|
+
if (!(S in ue)) return;
|
|
1170
|
+
const k = document.activeElement;
|
|
1171
|
+
k && (k.tagName === "INPUT" || k.tagName === "TEXTAREA" || k.getAttribute("contenteditable") === "true") || (C.preventDefault(), e.current.isGameActive && (d.current.has(S) || (d.current.add(S), l.current || g())));
|
|
1172
|
+
}, z = (C) => {
|
|
1173
|
+
const S = C.key;
|
|
1174
|
+
if (!(S in ue)) return;
|
|
1175
|
+
const k = document.activeElement;
|
|
1176
|
+
k && (k.tagName === "INPUT" || k.tagName === "TEXTAREA" || k.getAttribute("contenteditable") === "true") || (C.preventDefault(), d.current.delete(S), d.current.size === 0 && w());
|
|
1293
1177
|
};
|
|
1294
|
-
return window.addEventListener("keydown",
|
|
1178
|
+
return window.addEventListener("keydown", T, {
|
|
1295
1179
|
capture: !0
|
|
1296
|
-
}), window.addEventListener("keydown", p), window.addEventListener("keyup",
|
|
1297
|
-
window.removeEventListener("keydown",
|
|
1180
|
+
}), window.addEventListener("keydown", p), window.addEventListener("keyup", z), () => {
|
|
1181
|
+
window.removeEventListener("keydown", T, {
|
|
1298
1182
|
capture: !0
|
|
1299
|
-
}), window.removeEventListener("keydown", p), window.removeEventListener("keyup",
|
|
1183
|
+
}), window.removeEventListener("keydown", p), window.removeEventListener("keyup", z);
|
|
1300
1184
|
};
|
|
1301
1185
|
}, []);
|
|
1302
|
-
const v =
|
|
1303
|
-
if (!
|
|
1186
|
+
const v = Ve(() => {
|
|
1187
|
+
if (!l.current || d.current.size === 0)
|
|
1304
1188
|
return e.current.playerCell;
|
|
1305
|
-
const
|
|
1306
|
-
let
|
|
1307
|
-
for (const
|
|
1308
|
-
const { canMove:
|
|
1309
|
-
if (
|
|
1310
|
-
const [
|
|
1311
|
-
|
|
1189
|
+
const T = c(), p = e.current.playerCell;
|
|
1190
|
+
let z = 0, C = 0, S = 0;
|
|
1191
|
+
for (const X of d.current) {
|
|
1192
|
+
const { canMove: I } = h(X, p);
|
|
1193
|
+
if (I) {
|
|
1194
|
+
const [j, te] = ue[X];
|
|
1195
|
+
z += j, C += te, S++;
|
|
1312
1196
|
}
|
|
1313
1197
|
}
|
|
1314
|
-
if (
|
|
1198
|
+
if (S === 0)
|
|
1315
1199
|
return e.current.playerCell;
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
), P = k - p.row, R = L - p.col, O = Math.sqrt(P * P + R * R);
|
|
1321
|
-
if (O > 0) {
|
|
1322
|
-
const A = P / O, G = R / O;
|
|
1323
|
-
if (Ze(
|
|
1200
|
+
const k = Math.sqrt(z * z + C * C), L = k > 0 ? z / k : 0, E = k > 0 ? C / k : 0, M = Number((p.row + L * T).toFixed(2)), b = Number((p.col + E * T).toFixed(2)), A = M - p.row, P = b - p.col, D = Math.sqrt(A * A + P * P);
|
|
1201
|
+
if (D > 0) {
|
|
1202
|
+
const X = A / D, I = P / D;
|
|
1203
|
+
if (tt(
|
|
1324
1204
|
p,
|
|
1325
|
-
|
|
1326
|
-
|
|
1205
|
+
X,
|
|
1206
|
+
I,
|
|
1327
1207
|
i,
|
|
1328
|
-
|
|
1208
|
+
D,
|
|
1329
1209
|
e.current.maze
|
|
1330
1210
|
))
|
|
1331
1211
|
return e.current.playerCell;
|
|
1332
1212
|
}
|
|
1333
1213
|
e.current.playerCell = {
|
|
1334
|
-
row:
|
|
1335
|
-
col:
|
|
1214
|
+
row: M,
|
|
1215
|
+
col: b
|
|
1336
1216
|
}, f();
|
|
1337
|
-
const $ = p.row < 0 ? 0 : Math.round(p.row), U = p.col < 0 ? 0 : Math.round(p.col),
|
|
1338
|
-
return (
|
|
1339
|
-
}, [
|
|
1340
|
-
|
|
1217
|
+
const $ = p.row < 0 ? 0 : Math.round(p.row), U = p.col < 0 ? 0 : Math.round(p.col), H = M < 0 ? 0 : Math.round(M), B = b < 0 ? 0 : Math.round(b);
|
|
1218
|
+
return (H !== $ || B !== U) && m({ row: H, col: B }), e.current.playerCell;
|
|
1219
|
+
}, [c, h]), w = () => {
|
|
1220
|
+
l.current = !1, d.current.clear();
|
|
1341
1221
|
};
|
|
1342
1222
|
return {
|
|
1343
1223
|
updatePlayerPos: v,
|
|
1344
|
-
resetMovingState:
|
|
1224
|
+
resetMovingState: w,
|
|
1345
1225
|
resetFirstMoveState: () => {
|
|
1346
1226
|
u.current = !1;
|
|
1347
1227
|
}
|
|
1348
1228
|
};
|
|
1349
1229
|
};
|
|
1350
|
-
function
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1230
|
+
function tt(e, t, n, o, i, s) {
|
|
1231
|
+
const a = e.row + t * i, r = e.col + n * i, c = { row: a, col: r }, l = [], d = e.row < 0 ? 0 : Math.floor(e.row), u = e.col < 0 ? 0 : Math.floor(e.col);
|
|
1232
|
+
l.push({ row: d, col: u });
|
|
1353
1233
|
const h = [
|
|
1354
1234
|
[-1, 0],
|
|
1355
1235
|
// up
|
|
@@ -1368,19 +1248,19 @@ function Ze(e, t, n, o, i, s) {
|
|
|
1368
1248
|
[1, 1]
|
|
1369
1249
|
// lower right, diagonal
|
|
1370
1250
|
];
|
|
1371
|
-
for (const [f,
|
|
1372
|
-
const
|
|
1373
|
-
s.isValid(
|
|
1251
|
+
for (const [f, m] of h) {
|
|
1252
|
+
const g = d + f, v = u + m;
|
|
1253
|
+
s.isValid(g, v) && l.push({ row: g, col: v });
|
|
1374
1254
|
}
|
|
1375
|
-
for (const f of
|
|
1376
|
-
const
|
|
1377
|
-
for (const
|
|
1378
|
-
if (
|
|
1255
|
+
for (const f of l) {
|
|
1256
|
+
const m = vn(f.row, f.col, s);
|
|
1257
|
+
for (const g of m)
|
|
1258
|
+
if (gn(c, g) < o)
|
|
1379
1259
|
return !0;
|
|
1380
1260
|
}
|
|
1381
1261
|
return !1;
|
|
1382
1262
|
}
|
|
1383
|
-
function
|
|
1263
|
+
function vn(e, t, n) {
|
|
1384
1264
|
const o = [], i = n.grid[e][t];
|
|
1385
1265
|
return i.walls.top && o.push({
|
|
1386
1266
|
start: { row: e - 0.5, col: t - 0.5 },
|
|
@@ -1396,140 +1276,184 @@ function fn(e, t, n) {
|
|
|
1396
1276
|
end: { row: e + 0.5, col: t - 0.5 }
|
|
1397
1277
|
}), o;
|
|
1398
1278
|
}
|
|
1399
|
-
function
|
|
1400
|
-
const { start: n, end: o } = t, i = o.col - n.col, s = o.row - n.row,
|
|
1401
|
-
if (
|
|
1402
|
-
return Math.sqrt(
|
|
1403
|
-
const
|
|
1404
|
-
0,
|
|
1405
|
-
Math.min(
|
|
1406
|
-
1,
|
|
1407
|
-
(l * i + r * s) / a
|
|
1408
|
-
)
|
|
1409
|
-
), d = n.col + c * i, u = n.row + c * s, h = e.col - d, f = e.row - u;
|
|
1279
|
+
function gn(e, t) {
|
|
1280
|
+
const { start: n, end: o } = t, i = o.col - n.col, s = o.row - n.row, a = e.col - n.col, r = e.row - n.row, c = i * i + s * s;
|
|
1281
|
+
if (c === 0)
|
|
1282
|
+
return Math.sqrt(a * a + r * r);
|
|
1283
|
+
const l = Math.max(0, Math.min(1, (a * i + r * s) / c)), d = n.col + l * i, u = n.row + l * s, h = e.col - d, f = e.row - u;
|
|
1410
1284
|
return Math.sqrt(h * h + f * f);
|
|
1411
1285
|
}
|
|
1412
|
-
function
|
|
1286
|
+
function pn(e, t, n) {
|
|
1413
1287
|
if (!n.isValid(t.row, t.col)) return !1;
|
|
1414
1288
|
const o = e.col >= t.col - 0.5 && e.col <= t.col + 0.5, i = e.row >= t.row + 0.5, s = e.row >= t.row - 0.5;
|
|
1415
1289
|
return o && i && s;
|
|
1416
1290
|
}
|
|
1417
|
-
function
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1291
|
+
function Z(e, t, n, o, i) {
|
|
1292
|
+
return {
|
|
1293
|
+
x: i + t * n + n / 2,
|
|
1294
|
+
y: i + e * o + o / 2
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function wn(e, t, n, o, i, s) {
|
|
1298
|
+
e.save(), e.beginPath();
|
|
1299
|
+
for (let a = 0; a < i * 2; a++) {
|
|
1300
|
+
const r = a % 2 === 0 ? o : s, c = Math.PI * a / i;
|
|
1301
|
+
e.lineTo(t + r * Math.sin(c), n + r * Math.cos(c));
|
|
1302
|
+
}
|
|
1303
|
+
e.closePath(), e.fill(), e.restore();
|
|
1304
|
+
}
|
|
1305
|
+
function Cn({
|
|
1306
|
+
ctx: e,
|
|
1307
|
+
canvasWidth: t,
|
|
1308
|
+
canvasHeight: n,
|
|
1309
|
+
cellWidth: o,
|
|
1310
|
+
cellHeight: i,
|
|
1311
|
+
padding: s,
|
|
1312
|
+
playerCell: a,
|
|
1313
|
+
walls: r,
|
|
1314
|
+
fogRadius: c,
|
|
1315
|
+
fogColor: l,
|
|
1316
|
+
fogSoftness: d
|
|
1317
|
+
}) {
|
|
1318
|
+
const u = Math.max(c, 0) * Math.max(o, i) || 0;
|
|
1319
|
+
if (u <= 0) return;
|
|
1320
|
+
const h = Z(a.row, a.col, o, i, s), f = yn(h, r, u);
|
|
1321
|
+
e.save(), e.fillStyle = l, e.fillRect(0, 0, t, n), e.globalCompositeOperation = "destination-out";
|
|
1322
|
+
const m = Math.max(Math.min(o, i) * 0.25, 2);
|
|
1323
|
+
e.filter = `blur(${m}px)`;
|
|
1324
|
+
const g = Math.max(Math.min(d, 1), 0), v = e.createRadialGradient(
|
|
1325
|
+
h.x,
|
|
1326
|
+
h.y,
|
|
1327
|
+
Math.max(u * 0.2, 6),
|
|
1328
|
+
h.x,
|
|
1329
|
+
h.y,
|
|
1330
|
+
u
|
|
1331
|
+
);
|
|
1332
|
+
v.addColorStop(0, "rgba(0, 0, 0, 1)"), v.addColorStop(Math.max(0.25, g - 0.1), "rgba(0, 0, 0, 1)"), v.addColorStop(1, "rgba(0, 0, 0, 0)"), e.fillStyle = v, f.length >= 3 ? (e.beginPath(), f.forEach((w, y) => {
|
|
1333
|
+
y === 0 ? e.moveTo(w.x, w.y) : e.lineTo(w.x, w.y);
|
|
1334
|
+
}), e.closePath(), e.fill()) : (e.beginPath(), e.arc(h.x, h.y, u, 0, Math.PI * 2), e.fill()), e.restore();
|
|
1335
|
+
}
|
|
1336
|
+
function yn(e, t, n) {
|
|
1337
|
+
const i = [];
|
|
1338
|
+
if (t.forEach((a) => {
|
|
1339
|
+
i.push(
|
|
1340
|
+
Math.atan2(a.y1 - e.y, a.x1 - e.x) - 1e-4,
|
|
1341
|
+
Math.atan2(a.y1 - e.y, a.x1 - e.x),
|
|
1342
|
+
Math.atan2(a.y1 - e.y, a.x1 - e.x) + 1e-4,
|
|
1343
|
+
Math.atan2(a.y2 - e.y, a.x2 - e.x) - 1e-4,
|
|
1344
|
+
Math.atan2(a.y2 - e.y, a.x2 - e.x),
|
|
1345
|
+
Math.atan2(a.y2 - e.y, a.x2 - e.x) + 1e-4
|
|
1346
|
+
);
|
|
1347
|
+
}), i.length === 0)
|
|
1348
|
+
for (let a = 0; a < 24; a++)
|
|
1349
|
+
i.push(a / 24 * Math.PI * 2);
|
|
1350
|
+
return Array.from(new Set(i)).sort((a, r) => a - r).map((a) => bn(e, a, t, n));
|
|
1351
|
+
}
|
|
1352
|
+
function bn(e, t, n, o) {
|
|
1353
|
+
const i = { x: Math.cos(t), y: Math.sin(t) };
|
|
1354
|
+
let s = {
|
|
1355
|
+
x: e.x + i.x * o,
|
|
1356
|
+
y: e.y + i.y * o,
|
|
1357
|
+
distance: o
|
|
1358
|
+
};
|
|
1359
|
+
for (const a of n) {
|
|
1360
|
+
const r = Tn(
|
|
1361
|
+
e,
|
|
1362
|
+
i,
|
|
1363
|
+
{ x: a.x1, y: a.y1 },
|
|
1364
|
+
{ x: a.x2, y: a.y2 },
|
|
1365
|
+
o
|
|
1366
|
+
);
|
|
1367
|
+
r && r.distance < s.distance && (s = r);
|
|
1368
|
+
}
|
|
1369
|
+
return {
|
|
1370
|
+
x: s.x,
|
|
1371
|
+
y: s.y
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
function Tn(e, t, n, o, i) {
|
|
1375
|
+
const s = { x: o.x - n.x, y: o.y - n.y }, a = t.x * s.y - t.y * s.x;
|
|
1376
|
+
if (Math.abs(a) < 1e-6)
|
|
1377
|
+
return null;
|
|
1378
|
+
const r = { x: n.x - e.x, y: n.y - e.y }, c = (r.x * s.y - r.y * s.x) / a, l = (r.x * t.y - r.y * t.x) / a;
|
|
1379
|
+
return c < 0 || l < 0 || l > 1 || c > i ? null : {
|
|
1380
|
+
x: e.x + t.x * c,
|
|
1381
|
+
y: e.y + t.y * c,
|
|
1382
|
+
distance: c
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
function bt(e, t, n, o) {
|
|
1386
|
+
const i = [];
|
|
1387
|
+
for (let s = 0; s < e.rows; s++)
|
|
1388
|
+
for (let a = 0; a < e.cols; a++) {
|
|
1389
|
+
const r = e.grid[s][a], c = o + a * t, l = o + s * n;
|
|
1390
|
+
r.walls.top && i.push({
|
|
1391
|
+
x1: c,
|
|
1392
|
+
y1: l,
|
|
1393
|
+
x2: c + t,
|
|
1394
|
+
y2: l
|
|
1395
|
+
}), r.walls.right && i.push({
|
|
1396
|
+
x1: c + t,
|
|
1397
|
+
y1: l,
|
|
1398
|
+
x2: c + t,
|
|
1399
|
+
y2: l + n
|
|
1400
|
+
}), r.walls.bottom && i.push({
|
|
1401
|
+
x1: c,
|
|
1402
|
+
y1: l + n,
|
|
1403
|
+
x2: c + t,
|
|
1404
|
+
y2: l + n
|
|
1405
|
+
}), r.walls.left && i.push({
|
|
1406
|
+
x1: c,
|
|
1407
|
+
y1: l,
|
|
1408
|
+
x2: c,
|
|
1409
|
+
y2: l + n
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
return i;
|
|
1484
1413
|
}
|
|
1485
|
-
function
|
|
1414
|
+
function Sn({
|
|
1486
1415
|
ctx: e,
|
|
1487
1416
|
maze: t,
|
|
1488
1417
|
cellWidth: n,
|
|
1489
1418
|
cellHeight: o,
|
|
1490
1419
|
padding: i,
|
|
1491
1420
|
wallColor: s,
|
|
1492
|
-
wallWidth:
|
|
1421
|
+
wallWidth: a,
|
|
1422
|
+
walls: r
|
|
1493
1423
|
}) {
|
|
1494
|
-
e.save(), e.strokeStyle = s, e.lineWidth =
|
|
1495
|
-
e.moveTo(
|
|
1424
|
+
e.save(), e.strokeStyle = s, e.lineWidth = a, e.lineCap = "round", e.beginPath(), (r ?? bt(t, n, o, i)).forEach((l) => {
|
|
1425
|
+
e.moveTo(l.x1, l.y1), e.lineTo(l.x2, l.y2);
|
|
1496
1426
|
}), e.stroke(), e.restore();
|
|
1497
1427
|
}
|
|
1498
|
-
function
|
|
1428
|
+
function kn({
|
|
1499
1429
|
ctx: e,
|
|
1500
1430
|
playerCell: t,
|
|
1501
1431
|
playerRadius: n,
|
|
1502
1432
|
cellWidth: o,
|
|
1503
1433
|
cellHeight: i,
|
|
1504
1434
|
padding: s,
|
|
1505
|
-
playerColor:
|
|
1435
|
+
playerColor: a
|
|
1506
1436
|
}) {
|
|
1507
|
-
const { x: r, y:
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
i,
|
|
1512
|
-
s
|
|
1513
|
-
), c = Math.min(o, i) * Math.min(n, 0.5);
|
|
1514
|
-
e.save(), e.fillStyle = l, e.beginPath(), e.arc(r, a, c, 0, Math.PI * 2), e.fill(), e.restore();
|
|
1515
|
-
}
|
|
1516
|
-
function pn({
|
|
1437
|
+
const { x: r, y: c } = Z(t.row, t.col, o, i, s), l = Math.min(o, i) * Math.min(n, 0.5);
|
|
1438
|
+
e.save(), e.fillStyle = a, e.beginPath(), e.arc(r, c, l, 0, Math.PI * 2), e.fill(), e.restore();
|
|
1439
|
+
}
|
|
1440
|
+
function En({
|
|
1517
1441
|
ctx: e,
|
|
1518
1442
|
maze: t,
|
|
1519
1443
|
exitCell: n,
|
|
1520
1444
|
cellWidth: o,
|
|
1521
1445
|
cellHeight: i,
|
|
1522
1446
|
padding: s,
|
|
1523
|
-
exitColor:
|
|
1447
|
+
exitColor: a,
|
|
1524
1448
|
exitWallWidth: r,
|
|
1525
|
-
exitDashArray:
|
|
1449
|
+
exitDashArray: c = [8, 12]
|
|
1526
1450
|
}) {
|
|
1527
|
-
const { row:
|
|
1528
|
-
if (!t.isValid(
|
|
1529
|
-
const u = s + d * o, h = s +
|
|
1530
|
-
e.save(), e.globalCompositeOperation = "destination-out", e.lineWidth = r, e.lineCap = "round", e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle =
|
|
1451
|
+
const { row: l, col: d } = n;
|
|
1452
|
+
if (!t.isValid(l, d)) return;
|
|
1453
|
+
const u = s + d * o, h = s + l * i;
|
|
1454
|
+
e.save(), e.globalCompositeOperation = "destination-out", e.lineWidth = r, e.lineCap = "round", e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle = a, e.lineWidth = r, e.setLineDash(c), e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.restore();
|
|
1531
1455
|
}
|
|
1532
|
-
function
|
|
1456
|
+
function zn({
|
|
1533
1457
|
ctx: e,
|
|
1534
1458
|
foodCells: t,
|
|
1535
1459
|
cellWidth: n,
|
|
@@ -1537,106 +1461,135 @@ function wn({
|
|
|
1537
1461
|
padding: i,
|
|
1538
1462
|
foodColor: s
|
|
1539
1463
|
}) {
|
|
1540
|
-
e.fillStyle = s;
|
|
1541
|
-
const
|
|
1464
|
+
e.fillStyle = s, e.shadowColor = "rgba(255, 215, 64, 0.9)", e.shadowBlur = Math.max(Math.min(n, o) * 0.28, 3);
|
|
1465
|
+
const a = Math.min(n, o) * 0.25;
|
|
1542
1466
|
t.forEach((r) => {
|
|
1543
|
-
const { x:
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
i
|
|
1549
|
-
);
|
|
1550
|
-
Cn(e, a, c, l * 1.2, 5, l * 0.6);
|
|
1467
|
+
const { x: c, y: l } = Z(r.row, r.col, n, o, i);
|
|
1468
|
+
wn(e, c, l, a * 1.25, 5, a * 0.62);
|
|
1469
|
+
}), e.shadowBlur = 0, e.strokeStyle = "rgba(255,255,255,0.5)", e.lineWidth = Math.max(a * 0.3, 1), t.forEach((r) => {
|
|
1470
|
+
const { x: c, y: l } = Z(r.row, r.col, n, o, i);
|
|
1471
|
+
e.beginPath(), e.arc(c, l, a * 1.05, 0, Math.PI * 2), e.stroke();
|
|
1551
1472
|
});
|
|
1552
1473
|
}
|
|
1553
|
-
function
|
|
1554
|
-
e.save(), e.beginPath();
|
|
1555
|
-
for (let l = 0; l < i * 2; l++) {
|
|
1556
|
-
const r = l % 2 === 0 ? o : s, a = Math.PI * l / i;
|
|
1557
|
-
e.lineTo(t + r * Math.sin(a), n + r * Math.cos(a));
|
|
1558
|
-
}
|
|
1559
|
-
e.closePath(), e.fill(), e.restore();
|
|
1560
|
-
}
|
|
1561
|
-
function yn({
|
|
1474
|
+
function Mn({
|
|
1562
1475
|
ctx: e,
|
|
1563
1476
|
playerPath: t,
|
|
1564
1477
|
visitCounts: n,
|
|
1565
1478
|
cellWidth: o,
|
|
1566
1479
|
cellHeight: i,
|
|
1567
1480
|
padding: s,
|
|
1568
|
-
clueColor:
|
|
1481
|
+
clueColor: a
|
|
1569
1482
|
}) {
|
|
1570
1483
|
if (!(!t || t.length < 2 || !n)) {
|
|
1571
1484
|
e.save();
|
|
1572
1485
|
for (let r = 1; r < t.length; r++) {
|
|
1573
|
-
const
|
|
1486
|
+
const c = t[r - 1], l = t[r], d = `${c.row},${c.col}-${l.row},${l.col}`, u = `${l.row},${l.col}-${c.row},${c.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), m = Math.max(3, o * 0.1) + h * 0.5;
|
|
1574
1487
|
try {
|
|
1575
|
-
e.strokeStyle =
|
|
1488
|
+
e.strokeStyle = a.replace(")", `, ${f})`).replace("rgb(", "rgba(");
|
|
1576
1489
|
} catch {
|
|
1577
1490
|
e.strokeStyle = `rgba(255, 0, 0, ${f})`;
|
|
1578
1491
|
}
|
|
1579
|
-
e.lineWidth =
|
|
1580
|
-
const { x:
|
|
1581
|
-
|
|
1582
|
-
a.col,
|
|
1583
|
-
o,
|
|
1584
|
-
i,
|
|
1585
|
-
s
|
|
1586
|
-
), { x: T, y: b } = ve(
|
|
1587
|
-
c.row,
|
|
1588
|
-
c.col,
|
|
1589
|
-
o,
|
|
1590
|
-
i,
|
|
1591
|
-
s
|
|
1592
|
-
);
|
|
1593
|
-
e.beginPath(), e.moveTo(_, v), e.lineTo(T, b), e.stroke();
|
|
1492
|
+
e.lineWidth = m, e.lineCap = "round", e.lineJoin = "round";
|
|
1493
|
+
const { x: g, y: v } = Z(c.row, c.col, o, i, s), { x: w, y } = Z(l.row, l.col, o, i, s);
|
|
1494
|
+
e.beginPath(), e.moveTo(g, v), e.lineTo(w, y), e.stroke();
|
|
1594
1495
|
}
|
|
1595
1496
|
e.restore();
|
|
1596
1497
|
}
|
|
1597
1498
|
}
|
|
1598
|
-
function
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1499
|
+
function Tt(e, t, n, o, i) {
|
|
1500
|
+
if (!e || !t.maze) return;
|
|
1501
|
+
const { canvasWidth: s, canvasHeight: a } = n, { cellWidth: r, cellHeight: c } = o, {
|
|
1502
|
+
maze: l,
|
|
1503
|
+
playerCell: d,
|
|
1504
|
+
// row, col, but floating allowed
|
|
1505
|
+
exitCell: u,
|
|
1506
|
+
foodCells: h,
|
|
1507
|
+
showClue: f,
|
|
1508
|
+
playerPath: m,
|
|
1509
|
+
visitCounts: g
|
|
1510
|
+
} = t, {
|
|
1511
|
+
padding: v,
|
|
1512
|
+
wallWidth: w,
|
|
1513
|
+
// need merge with level config when passed here
|
|
1514
|
+
wallColor: y,
|
|
1515
|
+
playerColor: T,
|
|
1516
|
+
playerRadius: p,
|
|
1517
|
+
foodColor: z,
|
|
1518
|
+
backgroundColor: C,
|
|
1519
|
+
clueColor: S,
|
|
1520
|
+
fogEnabled: k,
|
|
1521
|
+
fogRadius: L,
|
|
1522
|
+
fogColor: E,
|
|
1523
|
+
fogSoftness: M,
|
|
1524
|
+
exitColor: b,
|
|
1525
|
+
exitWallWidth: A,
|
|
1526
|
+
exitDashArray: P
|
|
1527
|
+
} = i;
|
|
1528
|
+
e.clearRect(0, 0, s, a), e.save(), e.fillStyle = C, e.fillRect(0, 0, s, a), e.restore(), f && Mn({
|
|
1529
|
+
ctx: e,
|
|
1530
|
+
playerPath: m,
|
|
1531
|
+
visitCounts: g,
|
|
1532
|
+
cellWidth: r,
|
|
1533
|
+
cellHeight: c,
|
|
1534
|
+
padding: v,
|
|
1535
|
+
clueColor: S
|
|
1536
|
+
});
|
|
1537
|
+
const D = bt(l, r, c, v);
|
|
1538
|
+
(t.fogEnabled ?? !0) && k && Cn({
|
|
1539
|
+
ctx: e,
|
|
1540
|
+
canvasWidth: s,
|
|
1541
|
+
canvasHeight: a,
|
|
1542
|
+
cellWidth: r,
|
|
1543
|
+
cellHeight: c,
|
|
1544
|
+
padding: v,
|
|
1545
|
+
playerCell: d,
|
|
1546
|
+
walls: D,
|
|
1547
|
+
fogRadius: L,
|
|
1548
|
+
fogColor: E,
|
|
1549
|
+
fogSoftness: M
|
|
1550
|
+
}), Sn({
|
|
1551
|
+
ctx: e,
|
|
1552
|
+
maze: l,
|
|
1553
|
+
cellWidth: r,
|
|
1554
|
+
cellHeight: c,
|
|
1555
|
+
padding: v,
|
|
1556
|
+
wallColor: y,
|
|
1557
|
+
wallWidth: w,
|
|
1558
|
+
walls: D
|
|
1559
|
+
}), En({
|
|
1560
|
+
ctx: e,
|
|
1561
|
+
maze: l,
|
|
1562
|
+
exitCell: u,
|
|
1563
|
+
cellWidth: r,
|
|
1564
|
+
cellHeight: c,
|
|
1565
|
+
padding: v,
|
|
1566
|
+
exitColor: b,
|
|
1567
|
+
exitWallWidth: A,
|
|
1568
|
+
exitDashArray: P
|
|
1569
|
+
}), kn({
|
|
1570
|
+
ctx: e,
|
|
1571
|
+
playerCell: d,
|
|
1572
|
+
playerRadius: p,
|
|
1573
|
+
cellWidth: r,
|
|
1574
|
+
cellHeight: c,
|
|
1575
|
+
padding: v,
|
|
1576
|
+
playerColor: T
|
|
1577
|
+
}), zn({
|
|
1578
|
+
ctx: e,
|
|
1579
|
+
foodCells: h,
|
|
1580
|
+
cellWidth: r,
|
|
1581
|
+
cellHeight: c,
|
|
1582
|
+
padding: v,
|
|
1583
|
+
foodColor: z
|
|
1584
|
+
});
|
|
1632
1585
|
}
|
|
1633
|
-
function
|
|
1586
|
+
function Ln(e) {
|
|
1634
1587
|
return function() {
|
|
1635
1588
|
let t = e += 1831565813;
|
|
1636
1589
|
return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1637
1590
|
};
|
|
1638
1591
|
}
|
|
1639
|
-
class
|
|
1592
|
+
class Nn {
|
|
1640
1593
|
// initially all walls exit
|
|
1641
1594
|
constructor(t, n) {
|
|
1642
1595
|
this.row = t, this.col = n;
|
|
@@ -1644,7 +1597,7 @@ class kn {
|
|
|
1644
1597
|
visited = !1;
|
|
1645
1598
|
walls = { top: !0, right: !0, bottom: !0, left: !0 };
|
|
1646
1599
|
}
|
|
1647
|
-
class
|
|
1600
|
+
class St {
|
|
1648
1601
|
rows;
|
|
1649
1602
|
cols;
|
|
1650
1603
|
grid;
|
|
@@ -1660,8 +1613,8 @@ class wt {
|
|
|
1660
1613
|
* @param entry Optional entry cell position
|
|
1661
1614
|
* @param exit Optional exit cell position
|
|
1662
1615
|
*/
|
|
1663
|
-
constructor(t, n, o, i, s = { row: 0, col: 0 },
|
|
1664
|
-
this.rows = t, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random =
|
|
1616
|
+
constructor(t, n, o, i, s = { row: 0, col: 0 }, a = { row: t - 1, col: n - 1 }) {
|
|
1617
|
+
this.rows = t, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = Ln(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, a);
|
|
1665
1618
|
}
|
|
1666
1619
|
// Initialize the grid with new MazeCell objects
|
|
1667
1620
|
initializeGrid() {
|
|
@@ -1669,7 +1622,7 @@ class wt {
|
|
|
1669
1622
|
for (let n = 0; n < this.rows; n++) {
|
|
1670
1623
|
t[n] = [];
|
|
1671
1624
|
for (let o = 0; o < this.cols; o++)
|
|
1672
|
-
t[n][o] = new
|
|
1625
|
+
t[n][o] = new Nn(n, o);
|
|
1673
1626
|
}
|
|
1674
1627
|
return t;
|
|
1675
1628
|
}
|
|
@@ -1690,29 +1643,25 @@ class wt {
|
|
|
1690
1643
|
// Left
|
|
1691
1644
|
];
|
|
1692
1645
|
for (const s of i) {
|
|
1693
|
-
const
|
|
1694
|
-
this.isValid(
|
|
1646
|
+
const a = t + s.r, r = n + s.c;
|
|
1647
|
+
this.isValid(a, r) && o.push({ row: a, col: r });
|
|
1695
1648
|
}
|
|
1696
1649
|
return o;
|
|
1697
1650
|
}
|
|
1698
1651
|
// Get only neighbors that haven't been visited yet
|
|
1699
1652
|
getUnvisitedNeighbors(t, n) {
|
|
1700
|
-
return this.getNeighbors(t, n).filter(
|
|
1701
|
-
(o) => !this.grid[o.row][o.col].visited
|
|
1702
|
-
);
|
|
1653
|
+
return this.getNeighbors(t, n).filter((o) => !this.grid[o.row][o.col].visited);
|
|
1703
1654
|
}
|
|
1704
1655
|
/**
|
|
1705
1656
|
* Gets neighbors that have already been visited (part of the maze path).
|
|
1706
1657
|
*/
|
|
1707
1658
|
getVisitedNeighbors(t, n) {
|
|
1708
|
-
return this.getNeighbors(t, n).filter(
|
|
1709
|
-
(o) => this.grid[o.row][o.col].visited
|
|
1710
|
-
);
|
|
1659
|
+
return this.getNeighbors(t, n).filter((o) => this.grid[o.row][o.col].visited);
|
|
1711
1660
|
}
|
|
1712
1661
|
// Remove the wall between two adjacent cells
|
|
1713
1662
|
removeWall(t, n, o, i) {
|
|
1714
|
-
const s = this.grid[t][n],
|
|
1715
|
-
t === o + 1 ? (s.walls.top = !1,
|
|
1663
|
+
const s = this.grid[t][n], a = this.grid[o][i];
|
|
1664
|
+
t === o + 1 ? (s.walls.top = !1, a.walls.bottom = !1) : t === o - 1 ? (s.walls.bottom = !1, a.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, a.walls.right = !1) : n === i - 1 && (s.walls.right = !1, a.walls.left = !1);
|
|
1716
1665
|
}
|
|
1717
1666
|
// --- Generation Methods ---
|
|
1718
1667
|
/**
|
|
@@ -1741,28 +1690,26 @@ class wt {
|
|
|
1741
1690
|
let i = { row: n, col: o };
|
|
1742
1691
|
for (this.grid[n][o].visited = !0, t.push(i); t.length > 0; ) {
|
|
1743
1692
|
i = t[t.length - 1];
|
|
1744
|
-
const { row: s, col:
|
|
1693
|
+
const { row: s, col: a } = i, r = this.getUnvisitedNeighbors(s, a);
|
|
1745
1694
|
if (r.length > 0) {
|
|
1746
|
-
const
|
|
1747
|
-
this.removeWall(s,
|
|
1695
|
+
const c = this.randomPick(r), { row: l, col: d } = c;
|
|
1696
|
+
this.removeWall(s, a, l, d), this.grid[l][d].visited = !0, t.push(c);
|
|
1748
1697
|
} else
|
|
1749
1698
|
t.pop();
|
|
1750
1699
|
}
|
|
1751
1700
|
}
|
|
1752
1701
|
// --- Prim's Algorithm Implementation ---
|
|
1753
1702
|
generateWithPrims() {
|
|
1754
|
-
const t = [], n = (s,
|
|
1755
|
-
const r = this.getNeighbors(s,
|
|
1756
|
-
for (const
|
|
1757
|
-
!this.grid[
|
|
1758
|
-
(c) => c.row === a.row && c.col === a.col
|
|
1759
|
-
) && t.push(a);
|
|
1703
|
+
const t = [], n = (s, a) => {
|
|
1704
|
+
const r = this.getNeighbors(s, a);
|
|
1705
|
+
for (const c of r)
|
|
1706
|
+
!this.grid[c.row][c.col].visited && !t.some((l) => l.row === c.row && l.col === c.col) && t.push(c);
|
|
1760
1707
|
}, o = this.randomNumber(this.rows), i = this.randomNumber(this.cols);
|
|
1761
1708
|
for (this.grid[o][i].visited = !0, n(o, i); t.length > 0; ) {
|
|
1762
|
-
const s = this.randomNumber(t.length),
|
|
1763
|
-
if (
|
|
1764
|
-
const d = this.randomPick(
|
|
1765
|
-
this.removeWall(r,
|
|
1709
|
+
const s = this.randomNumber(t.length), a = t[s], { row: r, col: c } = a, l = this.getVisitedNeighbors(r, c);
|
|
1710
|
+
if (l.length > 0) {
|
|
1711
|
+
const d = this.randomPick(l);
|
|
1712
|
+
this.removeWall(r, c, d.row, d.col), this.grid[r][c].visited = !0, n(r, c);
|
|
1766
1713
|
}
|
|
1767
1714
|
t.splice(s, 1);
|
|
1768
1715
|
}
|
|
@@ -1787,186 +1734,166 @@ class wt {
|
|
|
1787
1734
|
return t[Math.floor(this.random() * t.length)];
|
|
1788
1735
|
}
|
|
1789
1736
|
}
|
|
1790
|
-
const
|
|
1737
|
+
const kt = (e, t, n) => {
|
|
1791
1738
|
if (!e.isValid(t, n)) return !1;
|
|
1792
1739
|
const o = e.grid[t][n];
|
|
1793
1740
|
return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
|
|
1794
|
-
},
|
|
1741
|
+
}, An = (e) => e === 1 ? 2 : e >= 2 && e <= 5 ? 3 : e >= 6 && e <= 11 ? 4 : e >= 12 && e <= 15 ? 5 : 6, Pn = (e, t) => {
|
|
1795
1742
|
if (!t)
|
|
1796
1743
|
return console.error(`Cannot find Level ${e}'s config.`), null;
|
|
1797
|
-
const { size: n, seed: o, method: i, entry: s, exit:
|
|
1744
|
+
const { size: n, seed: o, method: i, entry: s, exit: a } = t, r = n, c = n, l = s || { row: 0, col: 0 }, d = a || {
|
|
1798
1745
|
row: r - 1,
|
|
1799
|
-
col:
|
|
1800
|
-
}, u = new
|
|
1801
|
-
for (let
|
|
1802
|
-
let
|
|
1746
|
+
col: c - 1
|
|
1747
|
+
}, u = new St(r, c, i, o, l, d), h = An(e), f = [];
|
|
1748
|
+
for (let m = 0; m < h; m++) {
|
|
1749
|
+
let g;
|
|
1803
1750
|
do
|
|
1804
|
-
|
|
1751
|
+
g = {
|
|
1805
1752
|
row: Math.floor(u.random() * r),
|
|
1806
|
-
col: Math.floor(u.random() *
|
|
1753
|
+
col: Math.floor(u.random() * c)
|
|
1807
1754
|
};
|
|
1808
|
-
while (
|
|
1809
|
-
f.push(
|
|
1755
|
+
while (g.row === l.row && g.col === l.col || g.row === d.row && g.col === d.col || !kt(u, g.row, g.col) || f.some((v) => v.row === g.row && v.col === g.col));
|
|
1756
|
+
f.push(g);
|
|
1810
1757
|
}
|
|
1811
1758
|
return {
|
|
1812
1759
|
isGameActive: !0,
|
|
1813
1760
|
levelTransitioning: !1,
|
|
1814
1761
|
maze: u,
|
|
1815
|
-
playerCell:
|
|
1762
|
+
playerCell: l,
|
|
1816
1763
|
exitCell: d,
|
|
1817
1764
|
foodCells: f,
|
|
1818
1765
|
playerAtExit: !1,
|
|
1819
1766
|
foodCollected: 0,
|
|
1820
1767
|
totalFoodCount: h,
|
|
1821
1768
|
showClue: !1,
|
|
1822
|
-
playerPath: [
|
|
1823
|
-
visitCounts: { [`${
|
|
1769
|
+
playerPath: [l],
|
|
1770
|
+
visitCounts: { [`${l.row},${l.col}`]: 1 }
|
|
1824
1771
|
};
|
|
1825
|
-
},
|
|
1772
|
+
}, xn = ({
|
|
1826
1773
|
size: e,
|
|
1827
1774
|
seed: t,
|
|
1828
1775
|
method: n,
|
|
1829
1776
|
foodCount: o,
|
|
1830
1777
|
foodRace: i,
|
|
1831
|
-
clue: s
|
|
1778
|
+
clue: s,
|
|
1779
|
+
fogEnabled: a = !0
|
|
1832
1780
|
}) => {
|
|
1833
|
-
const
|
|
1781
|
+
const r = e, c = e, l = { row: 0, col: 0 }, d = { row: r - 1, col: c - 1 }, u = new St(r, c, n, t, l, d), h = [];
|
|
1834
1782
|
if (i)
|
|
1835
|
-
for (let
|
|
1836
|
-
let
|
|
1783
|
+
for (let f = 0; f < o; f++) {
|
|
1784
|
+
let m, g = 0;
|
|
1837
1785
|
do
|
|
1838
|
-
|
|
1839
|
-
row: Math.floor(
|
|
1840
|
-
col: Math.floor(
|
|
1786
|
+
m = {
|
|
1787
|
+
row: Math.floor(u.random() * r),
|
|
1788
|
+
col: Math.floor(u.random() * c)
|
|
1841
1789
|
}, g++;
|
|
1842
|
-
while (g < 50 && (
|
|
1843
|
-
|
|
1844
|
-
)));
|
|
1845
|
-
g < 50 && u.push(f);
|
|
1790
|
+
while (g < 50 && (m.row === l.row && m.col === l.col || m.row === d.row && m.col === d.col || !kt(u, m.row, m.col) || h.some((v) => v.row === m.row && v.col === m.col)));
|
|
1791
|
+
g < 50 && h.push(m);
|
|
1846
1792
|
}
|
|
1847
1793
|
return {
|
|
1848
1794
|
isGameActive: !0,
|
|
1849
1795
|
levelTransitioning: !1,
|
|
1850
|
-
maze:
|
|
1851
|
-
playerCell:
|
|
1852
|
-
exitCell:
|
|
1853
|
-
foodCells:
|
|
1796
|
+
maze: u,
|
|
1797
|
+
playerCell: l,
|
|
1798
|
+
exitCell: d,
|
|
1799
|
+
foodCells: h,
|
|
1854
1800
|
playerAtExit: !1,
|
|
1855
1801
|
foodCollected: 0,
|
|
1856
1802
|
totalFoodCount: i ? o : 0,
|
|
1803
|
+
fogEnabled: a,
|
|
1857
1804
|
showClue: s,
|
|
1858
|
-
playerPath: [
|
|
1859
|
-
visitCounts: { [`${
|
|
1805
|
+
playerPath: [l],
|
|
1806
|
+
visitCounts: { [`${l.row},${l.col}`]: 1 }
|
|
1860
1807
|
};
|
|
1861
1808
|
};
|
|
1862
|
-
function
|
|
1863
|
-
const {
|
|
1864
|
-
|
|
1865
|
-
gamePlayState: t,
|
|
1866
|
-
gamePlayStateRef: n,
|
|
1867
|
-
gameProgress: o,
|
|
1868
|
-
config: i
|
|
1869
|
-
} = re(), s = F(null), l = F(null), { i18n: r, levelConfig: a, renderConfig: c } = i, d = ie(a), u = F(
|
|
1870
|
-
d.getLevelConfig(o.currentLevel)
|
|
1871
|
-
);
|
|
1872
|
-
x(() => {
|
|
1809
|
+
function In() {
|
|
1810
|
+
const { setGamePlayState: e, gamePlayState: t, gamePlayStateRef: n, gameProgress: o, config: i } = se(), s = R(null), a = R(null), { i18n: r, levelConfig: c, renderConfig: l } = i, d = ae(c), u = R(d.getLevelConfig(o.currentLevel));
|
|
1811
|
+
F(() => {
|
|
1873
1812
|
s.current && q.attachTo(s.current);
|
|
1874
1813
|
}, []);
|
|
1875
|
-
const h =
|
|
1814
|
+
const h = R(), f = wt(a, () => {
|
|
1876
1815
|
h.current?.();
|
|
1877
|
-
}),
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
c.padding
|
|
1881
|
-
);
|
|
1882
|
-
x(() => {
|
|
1883
|
-
u.current = d.getLevelConfig(
|
|
1884
|
-
o.currentLevel
|
|
1885
|
-
);
|
|
1816
|
+
}), m = Ct(a, t, l.padding);
|
|
1817
|
+
F(() => {
|
|
1818
|
+
u.current = d.getLevelConfig(o.currentLevel);
|
|
1886
1819
|
}, [o.currentLevel]);
|
|
1887
|
-
const
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1890
|
-
u.current
|
|
1891
|
-
);
|
|
1892
|
-
C && e((p) => ({
|
|
1820
|
+
const g = () => {
|
|
1821
|
+
const T = Pn(o.currentLevel, u.current);
|
|
1822
|
+
T && e((p) => ({
|
|
1893
1823
|
...p,
|
|
1894
|
-
...
|
|
1824
|
+
...T
|
|
1895
1825
|
}));
|
|
1896
1826
|
};
|
|
1897
|
-
|
|
1898
|
-
|
|
1827
|
+
F(() => {
|
|
1828
|
+
g();
|
|
1899
1829
|
}, [o.currentLevel]);
|
|
1900
1830
|
const v = () => {
|
|
1901
|
-
|
|
1902
|
-
}, { updatePlayerPos:
|
|
1831
|
+
g();
|
|
1832
|
+
}, { updatePlayerPos: w, resetMovingState: y } = yt({
|
|
1903
1833
|
gamePlayStateRef: n,
|
|
1904
1834
|
setGamePlayState: e,
|
|
1905
|
-
playerRadius:
|
|
1906
|
-
moveSpeed:
|
|
1835
|
+
playerRadius: l.playerRadius,
|
|
1836
|
+
moveSpeed: l.gridMoveSpeed,
|
|
1907
1837
|
onFoodCollected: () => {
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1910
|
-
r.foodCollectedToast.replace("%NUM%", C.toString()),
|
|
1911
|
-
3e3
|
|
1912
|
-
) : q.show(r.allFoodCollectedToast);
|
|
1838
|
+
const T = n.current.totalFoodCount - n.current.foodCollected - 1;
|
|
1839
|
+
T > 0 ? q.show(r.foodCollectedToast.replace("%NUM%", T.toString()), 3e3) : q.show(r.allFoodCollectedToast);
|
|
1913
1840
|
}
|
|
1914
1841
|
});
|
|
1915
|
-
return
|
|
1916
|
-
|
|
1917
|
-
}, [o.currentLevel,
|
|
1918
|
-
let
|
|
1919
|
-
const
|
|
1920
|
-
const
|
|
1921
|
-
if (!(p &&
|
|
1922
|
-
|
|
1842
|
+
return F(() => {
|
|
1843
|
+
y();
|
|
1844
|
+
}, [o.currentLevel, y]), F(() => {
|
|
1845
|
+
let T, p = !document.hidden;
|
|
1846
|
+
const z = () => {
|
|
1847
|
+
const k = a.current?.getContext("2d"), L = n.current;
|
|
1848
|
+
if (!(p && L?.isGameActive && k && L?.maze)) {
|
|
1849
|
+
T = requestAnimationFrame(z);
|
|
1923
1850
|
return;
|
|
1924
1851
|
}
|
|
1925
|
-
|
|
1926
|
-
},
|
|
1927
|
-
const
|
|
1928
|
-
if (
|
|
1929
|
-
const E = u.current?.wallWidth ||
|
|
1930
|
-
|
|
1931
|
-
...
|
|
1852
|
+
w(), C(), T = requestAnimationFrame(z);
|
|
1853
|
+
}, C = () => {
|
|
1854
|
+
const k = a.current?.getContext("2d"), L = n.current;
|
|
1855
|
+
if (k && L?.maze) {
|
|
1856
|
+
const E = u.current?.wallWidth || l?.wallWidth, M = u.current?.exitColor || l?.exitColor, b = u.current?.exitWallWidth || l?.exitWallWidth, A = u.current?.exitDashArray || l?.exitDashArray;
|
|
1857
|
+
Tt(k, L, f.current, m.current, {
|
|
1858
|
+
...l,
|
|
1932
1859
|
wallWidth: E,
|
|
1933
|
-
exitColor:
|
|
1934
|
-
exitWallWidth:
|
|
1935
|
-
exitDashArray:
|
|
1860
|
+
exitColor: M,
|
|
1861
|
+
exitWallWidth: b,
|
|
1862
|
+
exitDashArray: A
|
|
1936
1863
|
});
|
|
1937
1864
|
}
|
|
1938
1865
|
};
|
|
1939
|
-
h.current =
|
|
1940
|
-
const
|
|
1941
|
-
const
|
|
1942
|
-
p = !document.hidden && document.visibilityState === "visible" && (!
|
|
1866
|
+
h.current = C;
|
|
1867
|
+
const S = (k) => {
|
|
1868
|
+
const L = p;
|
|
1869
|
+
p = !document.hidden && document.visibilityState === "visible" && (!k || k.type !== "blur"), !L && p ? n.current?.levelTransitioning === !1 && e({
|
|
1943
1870
|
...n.current,
|
|
1944
1871
|
isGameActive: !0
|
|
1945
|
-
}) :
|
|
1872
|
+
}) : L && !p && e({
|
|
1946
1873
|
...n.current,
|
|
1947
1874
|
isGameActive: !1
|
|
1948
1875
|
});
|
|
1949
1876
|
};
|
|
1950
|
-
return document.addEventListener("visibilitychange",
|
|
1951
|
-
cancelAnimationFrame(
|
|
1877
|
+
return document.addEventListener("visibilitychange", S), window.addEventListener("blur", S), window.addEventListener("focus", S), T = requestAnimationFrame(z), () => {
|
|
1878
|
+
cancelAnimationFrame(T), document.removeEventListener("visibilitychange", S), window.removeEventListener("blur", S), window.removeEventListener("focus", S);
|
|
1952
1879
|
};
|
|
1953
|
-
}, []),
|
|
1880
|
+
}, []), F(() => {
|
|
1954
1881
|
q.show(r.useArrowKeyTips, 3e3);
|
|
1955
|
-
}, []), /* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
1957
|
-
/* @__PURE__ */
|
|
1958
|
-
/* @__PURE__ */
|
|
1882
|
+
}, []), /* @__PURE__ */ _("div", { className: "maze-game-container", children: [
|
|
1883
|
+
/* @__PURE__ */ _(qt, {}),
|
|
1884
|
+
/* @__PURE__ */ _(_n, { onRetry: v }),
|
|
1885
|
+
/* @__PURE__ */ _("div", { className: "maze-canvas-container", ref: s, children: /* @__PURE__ */ _("canvas", { ref: a, className: "maze-game-canvas" }) })
|
|
1959
1886
|
] });
|
|
1960
1887
|
}
|
|
1961
|
-
const
|
|
1888
|
+
const Fn = (e) => {
|
|
1962
1889
|
const t = Math.floor(e / 60), n = e % 60;
|
|
1963
1890
|
return `${t.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
|
|
1964
|
-
},
|
|
1965
|
-
const [t, n] =
|
|
1966
|
-
return
|
|
1967
|
-
const
|
|
1891
|
+
}, Rn = ({ timer: e }) => {
|
|
1892
|
+
const [t, n] = G(e), o = R(), i = R(!1), s = R(0);
|
|
1893
|
+
return F(() => {
|
|
1894
|
+
const a = () => {
|
|
1968
1895
|
!i.current && !o.current && (i.current = !0, o.current = setInterval(() => {
|
|
1969
|
-
n((
|
|
1896
|
+
n((c) => (s.current = e - c + 1, c <= 1 ? (clearInterval(o.current), window.dispatchEvent(new CustomEvent("maze:timeUp")), 0) : c - 1));
|
|
1970
1897
|
}, 1e3));
|
|
1971
1898
|
}, r = () => {
|
|
1972
1899
|
clearInterval(o.current), o.current = void 0, window.dispatchEvent(
|
|
@@ -1975,162 +1902,128 @@ const Nn = (e) => {
|
|
|
1975
1902
|
})
|
|
1976
1903
|
);
|
|
1977
1904
|
};
|
|
1978
|
-
return window.addEventListener("maze:firstMove",
|
|
1979
|
-
window.removeEventListener("maze:firstMove",
|
|
1905
|
+
return window.addEventListener("maze:firstMove", a), window.addEventListener("maze:gameSuccess", r), () => {
|
|
1906
|
+
window.removeEventListener("maze:firstMove", a), window.removeEventListener("maze:gameSuccess", r), clearInterval(o.current);
|
|
1980
1907
|
};
|
|
1981
|
-
}, [e]),
|
|
1908
|
+
}, [e]), F(() => {
|
|
1982
1909
|
o.current && (clearInterval(o.current), o.current = void 0), n(e), i.current = !1, s.current = 0;
|
|
1983
|
-
}, [e]), /* @__PURE__ */
|
|
1984
|
-
"
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
children: [
|
|
1988
|
-
"⏱️ ",
|
|
1989
|
-
Nn(t)
|
|
1990
|
-
]
|
|
1991
|
-
}
|
|
1992
|
-
) });
|
|
1910
|
+
}, [e]), /* @__PURE__ */ _("div", { className: "single-maze-timer", children: /* @__PURE__ */ _("span", { className: `maze-timer-text ${t <= 10 && i.current ? "maze-timer-warning" : ""}`, children: [
|
|
1911
|
+
"⏱️ ",
|
|
1912
|
+
Fn(t)
|
|
1913
|
+
] }) });
|
|
1993
1914
|
};
|
|
1994
|
-
function
|
|
1995
|
-
const {
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
} = e, [h, f] = W({
|
|
2008
|
-
...Ee
|
|
2009
|
-
}), [g, _] = W(!1), [v, T] = W(!0), [b, C] = W(!1), [p, S] = W(""), w = F(0), y = F(!1), z = F(!1), N = F(null), E = F(null), k = F(h), L = F(), P = _t(N, () => {
|
|
2010
|
-
L.current?.();
|
|
2011
|
-
}), R = vt(N, h, r.padding);
|
|
2012
|
-
x(() => {
|
|
2013
|
-
k.current = h;
|
|
2014
|
-
}, [h]);
|
|
2015
|
-
const { updatePlayerPos: O, resetMovingState: $, resetFirstMoveState: U } = gt({
|
|
2016
|
-
gamePlayStateRef: k,
|
|
2017
|
-
setGamePlayState: f,
|
|
1915
|
+
function Dn({ config: e }) {
|
|
1916
|
+
const { size: t, seed: n, method: o, foodCount: i, foodRace: s, clue: a, renderConfig: r, successCallback: c, failCallback: l, timer: d, i18n: u } = e, h = r.fogEnabled ?? !0, [f, m] = G({
|
|
1917
|
+
...pt,
|
|
1918
|
+
fogEnabled: h
|
|
1919
|
+
}), [g, v] = G(!1), [w, y] = G(!0), [T, p] = G(!1), [z, C] = G(""), S = R(0), k = R(!1), L = R(!1), E = R(null), M = R(null), b = R(f), A = R(), P = wt(E, () => {
|
|
1920
|
+
A.current?.();
|
|
1921
|
+
}), D = Ct(E, f, r.padding);
|
|
1922
|
+
F(() => {
|
|
1923
|
+
b.current = f;
|
|
1924
|
+
}, [f]);
|
|
1925
|
+
const { updatePlayerPos: $, resetMovingState: U, resetFirstMoveState: H } = yt({
|
|
1926
|
+
gamePlayStateRef: b,
|
|
1927
|
+
setGamePlayState: m,
|
|
2018
1928
|
playerRadius: r.playerRadius,
|
|
2019
1929
|
moveSpeed: r.gridMoveSpeed,
|
|
2020
1930
|
onFoodCollected: () => {
|
|
2021
1931
|
console.log("Food collected in single maze");
|
|
2022
1932
|
},
|
|
2023
1933
|
onExitReached: () => {
|
|
2024
|
-
if (!
|
|
2025
|
-
if (s &&
|
|
2026
|
-
|
|
2027
|
-
...
|
|
1934
|
+
if (!k.current) {
|
|
1935
|
+
if (s && b.current.foodCollected < b.current.totalFoodCount) {
|
|
1936
|
+
C(`⭐️ ${u.foodMsg}`), p(!0), m((I) => ({
|
|
1937
|
+
...I,
|
|
2028
1938
|
isGameActive: !1
|
|
2029
1939
|
// Disable controls while popup is shown
|
|
2030
1940
|
}));
|
|
2031
1941
|
return;
|
|
2032
1942
|
}
|
|
2033
|
-
|
|
2034
|
-
...
|
|
1943
|
+
m((I) => ({
|
|
1944
|
+
...I,
|
|
2035
1945
|
isGameActive: !1
|
|
2036
|
-
})),
|
|
1946
|
+
})), K();
|
|
2037
1947
|
}
|
|
2038
1948
|
},
|
|
2039
1949
|
onFirstMove: () => {
|
|
2040
1950
|
window.dispatchEvent(new CustomEvent("maze:firstMove"));
|
|
2041
1951
|
}
|
|
2042
|
-
}),
|
|
2043
|
-
|
|
2044
|
-
...
|
|
1952
|
+
}), B = () => {
|
|
1953
|
+
k.current = !0, C(`⏰ ${u.failMsg}`), p(!0), m({
|
|
1954
|
+
...b.current,
|
|
2045
1955
|
isGameActive: !1
|
|
2046
1956
|
});
|
|
2047
|
-
},
|
|
2048
|
-
|
|
2049
|
-
...
|
|
1957
|
+
}, K = () => {
|
|
1958
|
+
k.current = !0, L.current = !0, C(`🎉 ${u.successMsg}`), p(!0), m((I) => ({
|
|
1959
|
+
...I,
|
|
2050
1960
|
isGameActive: !1
|
|
2051
1961
|
})), window.dispatchEvent(new CustomEvent("maze:gameSuccess"));
|
|
2052
|
-
},
|
|
2053
|
-
if (
|
|
2054
|
-
|
|
2055
|
-
...
|
|
1962
|
+
}, X = () => {
|
|
1963
|
+
if (p(!1), !k.current) {
|
|
1964
|
+
m((I) => ({
|
|
1965
|
+
...I,
|
|
2056
1966
|
isGameActive: !0
|
|
2057
1967
|
}));
|
|
2058
1968
|
return;
|
|
2059
1969
|
}
|
|
2060
|
-
|
|
2061
|
-
...
|
|
1970
|
+
y(!1), m((I) => ({
|
|
1971
|
+
...I,
|
|
2062
1972
|
showClue: !0
|
|
2063
|
-
})),
|
|
1973
|
+
})), L.current ? c?.(S.current) : l?.();
|
|
2064
1974
|
};
|
|
2065
|
-
return
|
|
1975
|
+
return F(() => {
|
|
2066
1976
|
(async () => {
|
|
2067
|
-
|
|
1977
|
+
v(!0);
|
|
2068
1978
|
try {
|
|
2069
|
-
const
|
|
1979
|
+
const j = xn({
|
|
2070
1980
|
size: t,
|
|
2071
1981
|
seed: n,
|
|
2072
1982
|
method: o,
|
|
2073
1983
|
foodCount: i,
|
|
2074
1984
|
foodRace: s,
|
|
2075
|
-
clue:
|
|
1985
|
+
clue: a,
|
|
1986
|
+
fogEnabled: b.current.fogEnabled ?? h
|
|
2076
1987
|
});
|
|
2077
|
-
|
|
2078
|
-
} catch (
|
|
2079
|
-
console.error("Error generating single maze:",
|
|
1988
|
+
b.current = j, m(j);
|
|
1989
|
+
} catch (j) {
|
|
1990
|
+
console.error("Error generating single maze:", j);
|
|
2080
1991
|
} finally {
|
|
2081
|
-
|
|
1992
|
+
v(!1);
|
|
2082
1993
|
}
|
|
2083
1994
|
})();
|
|
2084
|
-
}, [e]),
|
|
2085
|
-
let
|
|
2086
|
-
const
|
|
2087
|
-
const le =
|
|
2088
|
-
if (!(
|
|
2089
|
-
|
|
1995
|
+
}, [e, h]), F(() => {
|
|
1996
|
+
let I;
|
|
1997
|
+
const j = !document.hidden, te = () => {
|
|
1998
|
+
const le = E.current?.getContext("2d"), ne = b.current;
|
|
1999
|
+
if (!(j && ne?.isGameActive && le && ne?.maze)) {
|
|
2000
|
+
I = requestAnimationFrame(te);
|
|
2090
2001
|
return;
|
|
2091
2002
|
}
|
|
2092
|
-
|
|
2093
|
-
},
|
|
2094
|
-
const le =
|
|
2095
|
-
le &&
|
|
2096
|
-
le,
|
|
2097
|
-
ee,
|
|
2098
|
-
P.current,
|
|
2099
|
-
R.current,
|
|
2100
|
-
r
|
|
2101
|
-
);
|
|
2003
|
+
$(), Ie(), I = requestAnimationFrame(te);
|
|
2004
|
+
}, Ie = () => {
|
|
2005
|
+
const le = E.current?.getContext("2d"), ne = b.current;
|
|
2006
|
+
le && ne?.maze && Tt(le, ne, P.current, D.current, r);
|
|
2102
2007
|
};
|
|
2103
|
-
return
|
|
2104
|
-
cancelAnimationFrame(
|
|
2008
|
+
return A.current = Ie, I = requestAnimationFrame(te), () => {
|
|
2009
|
+
cancelAnimationFrame(I);
|
|
2105
2010
|
};
|
|
2106
|
-
}, []),
|
|
2107
|
-
|
|
2108
|
-
}, [e,
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2011
|
+
}, []), F(() => {
|
|
2012
|
+
U(), H();
|
|
2013
|
+
}, [e, U, H]), F(() => {
|
|
2014
|
+
const I = (j) => {
|
|
2015
|
+
S.current = j.detail.timeUsed;
|
|
2111
2016
|
};
|
|
2112
|
-
return window.addEventListener("maze:timeUsed",
|
|
2113
|
-
window.removeEventListener(
|
|
2114
|
-
"maze:timeUsed",
|
|
2115
|
-
A
|
|
2116
|
-
), window.removeEventListener("maze:timeUp", V);
|
|
2017
|
+
return window.addEventListener("maze:timeUsed", I), window.addEventListener("maze:timeUp", B), () => {
|
|
2018
|
+
window.removeEventListener("maze:timeUsed", I), window.removeEventListener("maze:timeUp", B);
|
|
2117
2019
|
};
|
|
2118
|
-
}, []), g ? /* @__PURE__ */
|
|
2119
|
-
|
|
2120
|
-
/* @__PURE__ */
|
|
2121
|
-
/* @__PURE__ */
|
|
2122
|
-
|
|
2123
|
-
{
|
|
2124
|
-
isOpen: b,
|
|
2125
|
-
title: p,
|
|
2126
|
-
noConfirm: !0,
|
|
2127
|
-
cancelText: "OK",
|
|
2128
|
-
onCancel: Y
|
|
2129
|
-
}
|
|
2130
|
-
)
|
|
2131
|
-
] }) : /* @__PURE__ */ m("div", { className: "single-maze-error", children: /* @__PURE__ */ m("div", { children: "Failed to generate maze" }) });
|
|
2020
|
+
}, []), g ? /* @__PURE__ */ _("div", { className: "single-maze-loading", children: /* @__PURE__ */ _("div", { children: "Generating maze..." }) }) : f ? /* @__PURE__ */ _("div", { className: "maze-game-container", children: [
|
|
2021
|
+
/* @__PURE__ */ _("div", { className: "single-maze-toolbar", children: w && /* @__PURE__ */ _(Rn, { timer: d }) }),
|
|
2022
|
+
/* @__PURE__ */ _("div", { className: "single-maze-canvas-container", ref: M, children: /* @__PURE__ */ _("canvas", { ref: E, className: "maze-game-canvas" }) }),
|
|
2023
|
+
/* @__PURE__ */ _(oe, { isOpen: T, title: z, noConfirm: !0, cancelText: "OK", onCancel: X })
|
|
2024
|
+
] }) : /* @__PURE__ */ _("div", { className: "single-maze-error", children: /* @__PURE__ */ _("div", { children: "Failed to generate maze" }) });
|
|
2132
2025
|
}
|
|
2133
|
-
const
|
|
2026
|
+
const Et = [
|
|
2134
2027
|
// Tier 1 (Levels 1-12) - Beginner
|
|
2135
2028
|
[
|
|
2136
2029
|
// debug
|
|
@@ -2288,23 +2181,27 @@ const yt = [
|
|
|
2288
2181
|
{ size: 68, seed: 33341, method: "backtracking" }
|
|
2289
2182
|
// Level 60 - Master
|
|
2290
2183
|
]
|
|
2291
|
-
],
|
|
2292
|
-
gridMoveSpeed:
|
|
2184
|
+
], On = 0.07, zt = {
|
|
2185
|
+
gridMoveSpeed: On,
|
|
2293
2186
|
padding: 10,
|
|
2294
2187
|
wallWidth: 2,
|
|
2295
|
-
wallColor: "#
|
|
2296
|
-
foodColor: "#
|
|
2188
|
+
wallColor: "#222",
|
|
2189
|
+
foodColor: "#FFD54F",
|
|
2297
2190
|
clueColor: "rgb(255,0,0)",
|
|
2298
2191
|
backgroundColor: "#ffffff",
|
|
2299
2192
|
playerColor: "#4CAF50",
|
|
2300
2193
|
playerRadius: 0.2,
|
|
2194
|
+
fogEnabled: !0,
|
|
2195
|
+
fogRadius: 3.6,
|
|
2196
|
+
fogColor: "rgba(8, 10, 18, 0.9)",
|
|
2197
|
+
fogSoftness: 0.55,
|
|
2301
2198
|
// Exit
|
|
2302
2199
|
exitColor: "#F44336",
|
|
2303
2200
|
exitWallWidth: 4,
|
|
2304
2201
|
// default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
|
|
2305
2202
|
exitDashArray: [8, 12]
|
|
2306
2203
|
// default dash: 8px dash, 12px gap
|
|
2307
|
-
},
|
|
2204
|
+
}, me = {
|
|
2308
2205
|
lcPrefix: "maze-",
|
|
2309
2206
|
i18n: {
|
|
2310
2207
|
reset: "Reset",
|
|
@@ -2347,15 +2244,21 @@ const yt = [
|
|
|
2347
2244
|
continue: "Continue",
|
|
2348
2245
|
cluePathEnabled: "Clue Path Enabled",
|
|
2349
2246
|
cluePathDisabled: "Clue Path Disabled",
|
|
2350
|
-
useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
|
|
2247
|
+
useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue.",
|
|
2248
|
+
fogOn: "Fog: ON",
|
|
2249
|
+
fogOff: "Fog: OFF",
|
|
2250
|
+
fogEnabledToast: "Fog enabled",
|
|
2251
|
+
fogDisabledToast: "Fog disabled"
|
|
2351
2252
|
},
|
|
2352
|
-
renderConfig:
|
|
2353
|
-
levelConfig:
|
|
2354
|
-
},
|
|
2253
|
+
renderConfig: zt,
|
|
2254
|
+
levelConfig: Et
|
|
2255
|
+
}, _e = {
|
|
2355
2256
|
i18n: {
|
|
2356
2257
|
successMsg: "Congratulations! You completed the maze!",
|
|
2357
2258
|
failMsg: "Time is up!",
|
|
2358
|
-
foodMsg: "Please collect all stars before leaving!"
|
|
2259
|
+
foodMsg: "Please collect all stars before leaving!",
|
|
2260
|
+
fogOn: "Fog: ON",
|
|
2261
|
+
fogOff: "Fog: OFF"
|
|
2359
2262
|
},
|
|
2360
2263
|
size: 8,
|
|
2361
2264
|
seed: 12345,
|
|
@@ -2364,8 +2267,8 @@ const yt = [
|
|
|
2364
2267
|
foodCount: 0,
|
|
2365
2268
|
foodRace: !1,
|
|
2366
2269
|
// false then omit foodCount, make it to 0, true need to force all food collected
|
|
2367
|
-
renderConfig:
|
|
2368
|
-
timer:
|
|
2270
|
+
renderConfig: zt,
|
|
2271
|
+
timer: 600,
|
|
2369
2272
|
// 10 minutes
|
|
2370
2273
|
successCallback: () => {
|
|
2371
2274
|
console.log("🎉 Single maze completed successfully!");
|
|
@@ -2374,48 +2277,46 @@ const yt = [
|
|
|
2374
2277
|
console.log("⏰ Time is up! Game failed.");
|
|
2375
2278
|
}
|
|
2376
2279
|
};
|
|
2377
|
-
function
|
|
2378
|
-
const t = { ...
|
|
2379
|
-
...
|
|
2280
|
+
function $n({ config: e = {} }) {
|
|
2281
|
+
const t = { ...me.i18n, ...e.i18n || {} }, n = {
|
|
2282
|
+
...me.renderConfig,
|
|
2380
2283
|
...e.renderConfig || {}
|
|
2381
|
-
}, o = e.levelConfig ||
|
|
2382
|
-
...
|
|
2284
|
+
}, o = e.levelConfig || Et, i = {
|
|
2285
|
+
...me,
|
|
2383
2286
|
...e,
|
|
2384
2287
|
i18n: t,
|
|
2385
2288
|
levelConfig: o,
|
|
2386
2289
|
renderConfig: n
|
|
2387
2290
|
};
|
|
2388
|
-
return /* @__PURE__ */
|
|
2291
|
+
return /* @__PURE__ */ _(Gt, { config: i, children: /* @__PURE__ */ _(In, {}) });
|
|
2389
2292
|
}
|
|
2390
|
-
function
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
const t = { ...me.i18n, ...e.i18n || {} }, n = {
|
|
2394
|
-
...me.renderConfig,
|
|
2293
|
+
function Un({ config: e = {} }) {
|
|
2294
|
+
const t = { ..._e.i18n, ...e.i18n || {} }, n = {
|
|
2295
|
+
..._e.renderConfig,
|
|
2395
2296
|
...e.renderConfig || {}
|
|
2396
2297
|
}, o = {
|
|
2397
|
-
...
|
|
2298
|
+
..._e,
|
|
2398
2299
|
...e,
|
|
2399
2300
|
i18n: t,
|
|
2400
2301
|
renderConfig: n
|
|
2401
2302
|
};
|
|
2402
|
-
return /* @__PURE__ */
|
|
2303
|
+
return /* @__PURE__ */ _(Dn, { config: o });
|
|
2403
2304
|
}
|
|
2404
|
-
const
|
|
2405
|
-
root: "https://unpkg.com/@roudanio/maze@0.
|
|
2406
|
-
...fe
|
|
2407
|
-
};
|
|
2408
|
-
`${JSON.stringify(Rn, null, 2)}`;
|
|
2409
|
-
const Fn = {
|
|
2410
|
-
root: "https://unpkg.com/@roudanio/maze@0.2.5/dist/",
|
|
2305
|
+
const Gn = {
|
|
2306
|
+
root: "https://unpkg.com/@roudanio/maze@0.3.1/dist/",
|
|
2411
2307
|
...me
|
|
2412
2308
|
};
|
|
2309
|
+
`${JSON.stringify(Gn, null, 2)}`;
|
|
2310
|
+
const jn = {
|
|
2311
|
+
root: "https://unpkg.com/@roudanio/maze@0.3.1/dist/",
|
|
2312
|
+
..._e
|
|
2313
|
+
};
|
|
2413
2314
|
`${JSON.stringify(
|
|
2414
|
-
|
|
2315
|
+
jn,
|
|
2415
2316
|
(e, t) => typeof t == "function" ? t.toString() : t,
|
|
2416
2317
|
2
|
|
2417
2318
|
)}`;
|
|
2418
|
-
const
|
|
2319
|
+
const qn = {
|
|
2419
2320
|
showNotice() {
|
|
2420
2321
|
console.warn("Cannot find the root element");
|
|
2421
2322
|
const e = document.createElement("div");
|
|
@@ -2456,7 +2357,7 @@ const On = {
|
|
|
2456
2357
|
return;
|
|
2457
2358
|
}
|
|
2458
2359
|
let { root: o = location.origin } = t;
|
|
2459
|
-
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "",
|
|
2360
|
+
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", Oe(/* @__PURE__ */ _($n, { config: t }), n);
|
|
2460
2361
|
},
|
|
2461
2362
|
async initSingle(e, t) {
|
|
2462
2363
|
const n = typeof e == "string" ? document.querySelector(e) : e;
|
|
@@ -2465,9 +2366,9 @@ const On = {
|
|
|
2465
2366
|
return;
|
|
2466
2367
|
}
|
|
2467
2368
|
let { root: o = location.origin } = t;
|
|
2468
|
-
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "",
|
|
2369
|
+
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", Oe(/* @__PURE__ */ _(Un, { config: t }), n);
|
|
2469
2370
|
}
|
|
2470
2371
|
};
|
|
2471
2372
|
export {
|
|
2472
|
-
|
|
2373
|
+
qn as default
|
|
2473
2374
|
};
|