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