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