@roudanio/maze 0.0.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maze.iife.js +3 -3
- package/dist/maze.js +647 -592
- package/dist/maze.umd.js +3 -3
- package/package.json +1 -1
package/dist/maze.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var se,
|
|
1
|
+
var se, S, Ue, W, be, We, je, Ge, me, de, he, He, V = {}, qe = [], it = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, le = Array.isArray;
|
|
2
2
|
function $(t, e) {
|
|
3
3
|
for (var n in e) t[n] = e[n];
|
|
4
4
|
return t;
|
|
@@ -7,14 +7,14 @@ function ve(t) {
|
|
|
7
7
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
8
8
|
}
|
|
9
9
|
function st(t, e, n) {
|
|
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 Q(t,
|
|
10
|
+
var o, i, s, l = {};
|
|
11
|
+
for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : l[s] = e[s];
|
|
12
|
+
if (arguments.length > 2 && (l.children = arguments.length > 3 ? se.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) l[s] == null && (l[s] = t.defaultProps[s]);
|
|
13
|
+
return Q(t, l, o, i, null);
|
|
14
14
|
}
|
|
15
15
|
function Q(t, e, n, o, i) {
|
|
16
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 ?? ++Ue, __i: -1, __u: 0 };
|
|
17
|
-
return i == null &&
|
|
17
|
+
return i == null && S.vnode != null && S.vnode(s), s;
|
|
18
18
|
}
|
|
19
19
|
function ae(t) {
|
|
20
20
|
return t.children;
|
|
@@ -22,10 +22,10 @@ function ae(t) {
|
|
|
22
22
|
function ee(t, e) {
|
|
23
23
|
this.props = t, this.context = e;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (e == null) return t.__ ?
|
|
25
|
+
function G(t, e) {
|
|
26
|
+
if (e == null) return t.__ ? G(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" ? G(t) : null;
|
|
29
29
|
}
|
|
30
30
|
function Be(t) {
|
|
31
31
|
var e, n;
|
|
@@ -37,22 +37,22 @@ function Be(t) {
|
|
|
37
37
|
return Be(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!t.__d && (t.__d = !0) &&
|
|
40
|
+
function fe(t) {
|
|
41
|
+
(!t.__d && (t.__d = !0) && W.push(t) && !re.__r++ || be != S.debounceRendering) && ((be = S.debounceRendering) || We)(re);
|
|
42
42
|
}
|
|
43
43
|
function re() {
|
|
44
|
-
for (var t, e, n, o, i, s,
|
|
44
|
+
for (var t, e, n, o, i, s, l, r = 1; W.length; ) W.length > r && W.sort(je), t = W.shift(), r = W.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], l = [], e.__P && ((n = $({}, o)).__v = o.__v + 1, S.vnode && S.vnode(n), ge(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? G(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, Xe(s, n, l), n.__e != i && Be(n)));
|
|
45
45
|
re.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function Ve(t, e, n, o, i, s,
|
|
48
|
-
var u, h,
|
|
49
|
-
for (
|
|
50
|
-
return n.__e =
|
|
47
|
+
function Ve(t, e, n, o, i, s, l, r, a, c, d) {
|
|
48
|
+
var u, h, f, m, g, _, p = o && o.__k || qe, v = e.length;
|
|
49
|
+
for (a = lt(n, e, p, a, v), u = 0; u < v; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? V : p[f.__i] || V, f.__i = u, _ = ge(t, f, h, i, s, l, r, a, c, d), m = f.__e, f.ref && h.ref != f.ref && (h.ref && pe(h.ref, null, f), d.push(f.ref, f.__c || m, f)), g == null && m != null && (g = m), 4 & f.__u || h.__k === f.__k ? a = Ye(f, a, t) : typeof f.type == "function" && _ !== void 0 ? a = _ : m && (a = m.nextSibling), f.__u &= -7);
|
|
50
|
+
return n.__e = g, a;
|
|
51
51
|
}
|
|
52
52
|
function lt(t, e, n, o, i) {
|
|
53
|
-
var s,
|
|
54
|
-
for (t.__k = new Array(i), s = 0; s < i; s++) (
|
|
55
|
-
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o =
|
|
53
|
+
var s, l, r, a, c, d = n.length, u = d, h = 0;
|
|
54
|
+
for (t.__k = new Array(i), s = 0; s < i; s++) (l = e[s]) != null && typeof l != "boolean" && typeof l != "function" ? (a = s + h, (l = t.__k[s] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? Q(null, l, null, null, null) : le(l) ? Q(ae, { children: l }, null, null, null) : l.constructor == null && l.__b > 0 ? Q(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : l).__ = t, l.__b = t.__b + 1, r = null, (c = l.__i = at(l, n, a, u)) != -1 && (u--, (r = n[c]) && (r.__u |= 2)), r == null || r.__v == null ? (c == -1 && (i > d ? h-- : i < d && h++), typeof l.type != "function" && (l.__u |= 4)) : c != a && (c == a - 1 ? h-- : c == a + 1 ? h++ : (c > a ? h-- : h++, l.__u |= 4))) : t.__k[s] = null;
|
|
55
|
+
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = G(r)), Je(r, r));
|
|
56
56
|
return o;
|
|
57
57
|
}
|
|
58
58
|
function Ye(t, e, n) {
|
|
@@ -61,22 +61,22 @@ function Ye(t, e, n) {
|
|
|
61
61
|
for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = Ye(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 = G(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
70
|
function at(t, e, n, o) {
|
|
71
|
-
var i, s,
|
|
72
|
-
if (
|
|
73
|
-
if (o > (
|
|
71
|
+
var i, s, l = t.key, r = t.type, a = e[n];
|
|
72
|
+
if (a === null && t.key == null || a && l == a.key && r == a.type && (2 & a.__u) == 0) return n;
|
|
73
|
+
if (o > (a != null && (2 & a.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
|
|
74
74
|
if (i >= 0) {
|
|
75
|
-
if ((
|
|
75
|
+
if ((a = e[i]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return i;
|
|
76
76
|
i--;
|
|
77
77
|
}
|
|
78
78
|
if (s < e.length) {
|
|
79
|
-
if ((
|
|
79
|
+
if ((a = e[s]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return s;
|
|
80
80
|
s++;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -92,7 +92,7 @@ function J(t, e, n, o, i) {
|
|
|
92
92
|
if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || ke(t.style, e, "");
|
|
93
93
|
if (n) for (e in n) o && n[e] == o[e] || ke(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(Ge, "$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 = me, t.addEventListener(e, s ? he : de, s)) : t.removeEventListener(e, s ? he : de, 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 {
|
|
@@ -109,107 +109,107 @@ function Te(t) {
|
|
|
109
109
|
var n = this.l[e.type + t];
|
|
110
110
|
if (e.t == null) e.t = me++;
|
|
111
111
|
else if (e.t < n.u) return;
|
|
112
|
-
return n(
|
|
112
|
+
return n(S.event ? S.event(e) : e);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
var d, u, h,
|
|
116
|
+
function ge(t, e, n, o, i, s, l, r, a, c) {
|
|
117
|
+
var d, u, h, f, m, g, _, p, v, y, w, b, k, T, z, L, E, N = e.type;
|
|
118
118
|
if (e.constructor != null) return null;
|
|
119
|
-
128 & n.__u && (
|
|
120
|
-
e: if (typeof
|
|
121
|
-
if (
|
|
119
|
+
128 & n.__u && (a = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = S.__b) && d(e);
|
|
120
|
+
e: if (typeof N == "function") try {
|
|
121
|
+
if (p = e.props, v = "prototype" in N && N.prototype.render, y = (d = N.contextType) && o[d.__c], w = d ? y ? y.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (v ? e.__c = u = new N(p, w) : (e.__c = u = new ee(p, w), u.constructor = N, u.render = ut), y && y.sub(u), u.props = p, u.state || (u.state = {}), u.context = w, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), v && u.__s == null && (u.__s = u.state), v && N.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = $({}, u.__s)), $(u.__s, N.getDerivedStateFromProps(p, u.__s))), f = u.props, m = u.state, u.__v = e, h) v && N.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), v && u.componentDidMount != null && u.__h.push(u.componentDidMount);
|
|
122
122
|
else {
|
|
123
|
-
if (
|
|
124
|
-
for (e.__v != n.__v && (u.props =
|
|
123
|
+
if (v && N.getDerivedStateFromProps == null && p !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(p, w), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(p, u.__s, w) === !1 || e.__v == n.__v) {
|
|
124
|
+
for (e.__v != n.__v && (u.props = p, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(P) {
|
|
125
125
|
P && (P.__ = e);
|
|
126
126
|
}), b = 0; b < u._sb.length; b++) u.__h.push(u._sb[b]);
|
|
127
|
-
u._sb = [], u.__h.length &&
|
|
127
|
+
u._sb = [], u.__h.length && l.push(u);
|
|
128
128
|
break e;
|
|
129
129
|
}
|
|
130
|
-
u.componentWillUpdate != null && u.componentWillUpdate(
|
|
131
|
-
u.componentDidUpdate(
|
|
130
|
+
u.componentWillUpdate != null && u.componentWillUpdate(p, u.__s, w), v && u.componentDidUpdate != null && u.__h.push(function() {
|
|
131
|
+
u.componentDidUpdate(f, m, g);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
if (u.context =
|
|
135
|
-
for (u.state = u.__s, u.__d = !1, k && k(e), d = u.render(u.props, u.state, u.context),
|
|
134
|
+
if (u.context = w, u.props = p, u.__P = t, u.__e = !1, k = S.__r, T = 0, v) {
|
|
135
|
+
for (u.state = u.__s, u.__d = !1, k && k(e), d = u.render(u.props, u.state, u.context), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
|
|
136
136
|
u._sb = [];
|
|
137
137
|
} else do
|
|
138
138
|
u.__d = !1, k && k(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
|
|
139
139
|
while (u.__d && ++T < 25);
|
|
140
|
-
u.state = u.__s, u.getChildContext != null && (o = $($({}, o), u.getChildContext())),
|
|
140
|
+
u.state = u.__s, u.getChildContext != null && (o = $($({}, o), u.getChildContext())), v && !h && u.getSnapshotBeforeUpdate != null && (g = u.getSnapshotBeforeUpdate(f, m)), L = d, d != null && d.type === ae && d.key == null && (L = Ke(d.props.children)), r = Ve(t, le(L) ? L : [L], e, n, o, i, s, l, r, a, c), u.base = e.__e, e.__u &= -161, u.__h.length && l.push(u), _ && (u.__E = u.__ = null);
|
|
141
141
|
} catch (P) {
|
|
142
|
-
if (e.__v = null,
|
|
143
|
-
for (e.__u |=
|
|
142
|
+
if (e.__v = null, a || s != null) if (P.then) {
|
|
143
|
+
for (e.__u |= a ? 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 (E = s.length; E--; ) ve(s[E]);
|
|
146
146
|
else e.__e = n.__e, e.__k = n.__k;
|
|
147
|
-
|
|
147
|
+
S.__e(P, e, n);
|
|
148
148
|
}
|
|
149
|
-
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = ct(n.__e, e, n, o, i, s,
|
|
150
|
-
return (d =
|
|
149
|
+
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = ct(n.__e, e, n, o, i, s, l, a, c);
|
|
150
|
+
return (d = S.diffed) && d(e), 128 & e.__u ? void 0 : r;
|
|
151
151
|
}
|
|
152
152
|
function Xe(t, e, n) {
|
|
153
|
-
for (var o = 0; o < n.length; o++)
|
|
154
|
-
|
|
153
|
+
for (var o = 0; o < n.length; o++) pe(n[o], n[++o], n[++o]);
|
|
154
|
+
S.__c && S.__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
|
+
S.__e(s, i.__v);
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
function Ke(t) {
|
|
165
165
|
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : le(t) ? t.map(Ke) : $({}, t);
|
|
166
166
|
}
|
|
167
|
-
function ct(t, e, n, o, i, s,
|
|
168
|
-
var c, d, u, h,
|
|
169
|
-
if (
|
|
170
|
-
for (c = 0; c < s.length; c++) if ((
|
|
171
|
-
t =
|
|
167
|
+
function ct(t, e, n, o, i, s, l, r, a) {
|
|
168
|
+
var c, d, u, h, f, m, g, _ = n.props, p = e.props, v = e.type;
|
|
169
|
+
if (v == "svg" ? i = "http://www.w3.org/2000/svg" : v == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
170
|
+
for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!v && (v ? f.localName == v : f.nodeType == 3)) {
|
|
171
|
+
t = f, s[c] = null;
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (t == null) {
|
|
176
|
-
if (
|
|
177
|
-
t = document.createElementNS(i,
|
|
176
|
+
if (v == null) return document.createTextNode(p);
|
|
177
|
+
t = document.createElementNS(i, v, p.is && p), r && (S.__m && S.__m(e, s), r = !1), s = null;
|
|
178
178
|
}
|
|
179
|
-
if (
|
|
179
|
+
if (v == null) _ === p || r && t.data == p || (t.data = p);
|
|
180
180
|
else {
|
|
181
|
-
if (s = s && se.call(t.childNodes),
|
|
182
|
-
for (c in
|
|
183
|
-
if (c == "dangerouslySetInnerHTML") u =
|
|
184
|
-
else if (!(c in
|
|
185
|
-
if (c == "value" && "defaultValue" in
|
|
186
|
-
J(t, c, null,
|
|
181
|
+
if (s = s && se.call(t.childNodes), _ = n.props || V, !r && s != null) for (_ = {}, c = 0; c < t.attributes.length; c++) _[(f = t.attributes[c]).name] = f.value;
|
|
182
|
+
for (c in _) if (f = _[c], c != "children") {
|
|
183
|
+
if (c == "dangerouslySetInnerHTML") u = f;
|
|
184
|
+
else if (!(c in p)) {
|
|
185
|
+
if (c == "value" && "defaultValue" in p || c == "checked" && "defaultChecked" in p) continue;
|
|
186
|
+
J(t, c, null, f, i);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
for (c in
|
|
189
|
+
for (c in p) f = p[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? m = f : c == "checked" ? g = f : r && typeof f != "function" || _[c] === f || J(t, c, f, _[c], i);
|
|
190
190
|
if (d) r || u && (d.__html == u.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
|
|
191
|
-
else if (u && (t.innerHTML = ""), Ve(e.type == "template" ? t.content : t, le(h) ? h : [h], e, n, o,
|
|
192
|
-
r || (c = "value",
|
|
191
|
+
else if (u && (t.innerHTML = ""), Ve(e.type == "template" ? t.content : t, le(h) ? h : [h], e, n, o, v == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, l, s ? s[0] : n.__k && G(n, 0), r, a), s != null) for (c = s.length; c--; ) ve(s[c]);
|
|
192
|
+
r || (c = "value", v == "progress" && m == null ? t.removeAttribute("value") : m != null && (m !== t[c] || v == "progress" && !m || v == "option" && m != _[c]) && J(t, c, m, _[c], i), c = "checked", g != null && g != t[c] && J(t, c, g, _[c], i));
|
|
193
193
|
}
|
|
194
194
|
return t;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function pe(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
|
+
S.__e(i, n);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
function Je(t, e, n) {
|
|
207
207
|
var o, i;
|
|
208
|
-
if (
|
|
208
|
+
if (S.unmount && S.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || pe(o, null, e)), (o = t.__c) != null) {
|
|
209
209
|
if (o.componentWillUnmount) try {
|
|
210
210
|
o.componentWillUnmount();
|
|
211
211
|
} catch (s) {
|
|
212
|
-
|
|
212
|
+
S.__e(s, e);
|
|
213
213
|
}
|
|
214
214
|
o.base = o.__P = null;
|
|
215
215
|
}
|
|
@@ -220,8 +220,8 @@ function ut(t, e, n) {
|
|
|
220
220
|
return this.constructor(t, n);
|
|
221
221
|
}
|
|
222
222
|
function dt(t, e, n) {
|
|
223
|
-
var o, i, s,
|
|
224
|
-
e == document && (e = document.documentElement),
|
|
223
|
+
var o, i, s, l;
|
|
224
|
+
e == document && (e = document.documentElement), S.__ && S.__(t, e), i = (o = !1) ? null : e.__k, s = [], l = [], ge(e, t = e.__k = st(ae, null, [t]), i || V, V, e.namespaceURI, i ? null : e.firstChild ? se.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, l), Xe(s, t, l);
|
|
225
225
|
}
|
|
226
226
|
function ht(t) {
|
|
227
227
|
function e(n) {
|
|
@@ -231,14 +231,14 @@ function ht(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(l) {
|
|
235
|
+
l.__e = !0, fe(l);
|
|
236
236
|
});
|
|
237
237
|
}, this.sub = function(s) {
|
|
238
238
|
o.add(s);
|
|
239
|
-
var
|
|
239
|
+
var l = s.componentWillUnmount;
|
|
240
240
|
s.componentWillUnmount = function() {
|
|
241
|
-
o && o.delete(s),
|
|
241
|
+
o && o.delete(s), l && l.call(s);
|
|
242
242
|
};
|
|
243
243
|
}), n.children;
|
|
244
244
|
}
|
|
@@ -246,132 +246,132 @@ function ht(t) {
|
|
|
246
246
|
return n.children(o);
|
|
247
247
|
}).contextType = e, e;
|
|
248
248
|
}
|
|
249
|
-
se = qe.slice,
|
|
250
|
-
for (var i, s,
|
|
251
|
-
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)),
|
|
249
|
+
se = qe.slice, S = { __e: function(t, e, n, o) {
|
|
250
|
+
for (var i, s, l; e = e.__; ) if ((i = e.__c) && !i.__) try {
|
|
251
|
+
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), l = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), l = i.__d), l) return i.__E = i;
|
|
252
252
|
} catch (r) {
|
|
253
253
|
t = r;
|
|
254
254
|
}
|
|
255
255
|
throw t;
|
|
256
256
|
} }, Ue = 0, ee.prototype.setState = function(t, e) {
|
|
257
257
|
var n;
|
|
258
|
-
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = $({}, this.state), typeof t == "function" && (t = t($({}, n), this.props)), t && $(n, t), t != null && this.__v && (e && this._sb.push(e),
|
|
258
|
+
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = $({}, this.state), typeof t == "function" && (t = t($({}, n), this.props)), t && $(n, t), t != null && this.__v && (e && this._sb.push(e), fe(this));
|
|
259
259
|
}, ee.prototype.forceUpdate = function(t) {
|
|
260
|
-
this.__v && (this.__e = !0, t && this.__h.push(t),
|
|
261
|
-
}, ee.prototype.render = ae,
|
|
260
|
+
this.__v && (this.__e = !0, t && this.__h.push(t), fe(this));
|
|
261
|
+
}, ee.prototype.render = ae, W = [], We = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, je = function(t, e) {
|
|
262
262
|
return t.__v.__b - e.__v.__b;
|
|
263
|
-
}, re.__r = 0,
|
|
264
|
-
var
|
|
263
|
+
}, re.__r = 0, Ge = /(PointerCapture)$|Capture$/i, me = 0, de = Te(!1), he = Te(!0), He = 0;
|
|
264
|
+
var ft = 0;
|
|
265
265
|
function C(t, e, n, o, i, s) {
|
|
266
266
|
e || (e = {});
|
|
267
|
-
var
|
|
268
|
-
if ("ref" in
|
|
269
|
-
var c = { type: t, props:
|
|
270
|
-
if (typeof t == "function" && (
|
|
271
|
-
return
|
|
267
|
+
var l, r, a = e;
|
|
268
|
+
if ("ref" in a) for (r in a = {}, e) r == "ref" ? l = e[r] : a[r] = e[r];
|
|
269
|
+
var c = { type: t, props: a, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --ft, __i: -1, __u: 0, __source: i, __self: s };
|
|
270
|
+
if (typeof t == "function" && (l = t.defaultProps)) for (r in l) a[r] === void 0 && (a[r] = l[r]);
|
|
271
|
+
return S.vnode && S.vnode(c), c;
|
|
272
272
|
}
|
|
273
|
-
var
|
|
273
|
+
var H, A, ue, Le, Y = 0, Ze = [], M = S, Se = M.__b, ze = M.__r, Ne = M.diffed, Ae = M.__c, Ee = M.unmount, Me = M.__;
|
|
274
274
|
function ce(t, e) {
|
|
275
|
-
|
|
276
|
-
var n =
|
|
275
|
+
M.__h && M.__h(A, t, Y || e), Y = 0;
|
|
276
|
+
var n = A.__H || (A.__H = { __: [], __h: [] });
|
|
277
277
|
return t >= n.__.length && n.__.push({}), n.__[t];
|
|
278
278
|
}
|
|
279
|
-
function
|
|
280
|
-
return Y = 1,
|
|
279
|
+
function j(t) {
|
|
280
|
+
return Y = 1, _t(et, t);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
var o = ce(
|
|
282
|
+
function _t(t, e, n) {
|
|
283
|
+
var o = ce(H++, 2);
|
|
284
284
|
if (o.t = t, !o.__c && (o.__ = [et(void 0, e), function(r) {
|
|
285
|
-
var
|
|
286
|
-
|
|
287
|
-
}], o.__c =
|
|
288
|
-
var i = function(r,
|
|
285
|
+
var a = o.__N ? o.__N[0] : o.__[0], c = o.t(a, r);
|
|
286
|
+
a !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
|
|
287
|
+
}], o.__c = A, !A.__f)) {
|
|
288
|
+
var i = function(r, a, c) {
|
|
289
289
|
if (!o.__c.__H) return !0;
|
|
290
290
|
var d = o.__c.__H.__.filter(function(h) {
|
|
291
291
|
return !!h.__c;
|
|
292
292
|
});
|
|
293
293
|
if (d.every(function(h) {
|
|
294
294
|
return !h.__N;
|
|
295
|
-
})) return !s || s.call(this, r,
|
|
295
|
+
})) return !s || s.call(this, r, a, c);
|
|
296
296
|
var u = o.__c.props !== r;
|
|
297
297
|
return d.forEach(function(h) {
|
|
298
298
|
if (h.__N) {
|
|
299
|
-
var
|
|
300
|
-
h.__ = h.__N, h.__N = void 0,
|
|
299
|
+
var f = h.__[0];
|
|
300
|
+
h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (u = !0);
|
|
301
301
|
}
|
|
302
|
-
}), s && s.call(this, r,
|
|
302
|
+
}), s && s.call(this, r, a, c) || u;
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
var s =
|
|
306
|
-
|
|
304
|
+
A.__f = !0;
|
|
305
|
+
var s = A.shouldComponentUpdate, l = A.componentWillUpdate;
|
|
306
|
+
A.componentWillUpdate = function(r, a, c) {
|
|
307
307
|
if (this.__e) {
|
|
308
308
|
var d = s;
|
|
309
|
-
s = void 0, i(r,
|
|
309
|
+
s = void 0, i(r, a, c), s = d;
|
|
310
310
|
}
|
|
311
|
-
|
|
312
|
-
},
|
|
311
|
+
l && l.call(this, r, a, c);
|
|
312
|
+
}, A.shouldComponentUpdate = i;
|
|
313
313
|
}
|
|
314
314
|
return o.__N || o.__;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
var n = ce(
|
|
318
|
-
!
|
|
316
|
+
function x(t, e) {
|
|
317
|
+
var n = ce(H++, 3);
|
|
318
|
+
!M.__s && Qe(n.__H, e) && (n.__ = t, n.u = e, A.__H.__h.push(n));
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
return Y = 5,
|
|
320
|
+
function O(t) {
|
|
321
|
+
return Y = 5, q(function() {
|
|
322
322
|
return { current: t };
|
|
323
323
|
}, []);
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
var n = ce(
|
|
325
|
+
function q(t, e) {
|
|
326
|
+
var n = ce(H++, 7);
|
|
327
327
|
return Qe(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
|
|
328
328
|
}
|
|
329
329
|
function mt(t, e) {
|
|
330
|
-
return Y = 8,
|
|
330
|
+
return Y = 8, q(function() {
|
|
331
331
|
return t;
|
|
332
332
|
}, e);
|
|
333
333
|
}
|
|
334
334
|
function vt(t) {
|
|
335
|
-
var e =
|
|
336
|
-
return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(
|
|
335
|
+
var e = A.context[t.__c], n = ce(H++, 9);
|
|
336
|
+
return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(A)), e.props.value) : t.__;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function gt() {
|
|
339
339
|
for (var t; t = Ze.shift(); ) if (t.__P && t.__H) try {
|
|
340
|
-
t.__H.__h.forEach(te), t.__H.__h.forEach(
|
|
340
|
+
t.__H.__h.forEach(te), t.__H.__h.forEach(_e), t.__H.__h = [];
|
|
341
341
|
} catch (e) {
|
|
342
|
-
t.__H.__h = [],
|
|
342
|
+
t.__H.__h = [], M.__e(e, t.__v);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
},
|
|
345
|
+
M.__b = function(t) {
|
|
346
|
+
A = null, Se && Se(t);
|
|
347
|
+
}, M.__ = function(t, e) {
|
|
348
348
|
t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Me && Me(t, e);
|
|
349
|
-
},
|
|
350
|
-
ze && ze(t),
|
|
351
|
-
var e = (
|
|
352
|
-
e && (ue ===
|
|
349
|
+
}, M.__r = function(t) {
|
|
350
|
+
ze && ze(t), H = 0;
|
|
351
|
+
var e = (A = t.__c).__H;
|
|
352
|
+
e && (ue === A ? (e.__h = [], A.__h = [], e.__.forEach(function(n) {
|
|
353
353
|
n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
|
|
354
|
-
})) : (e.__h.forEach(te), e.__h.forEach(
|
|
355
|
-
},
|
|
354
|
+
})) : (e.__h.forEach(te), e.__h.forEach(_e), e.__h = [], H = 0)), ue = A;
|
|
355
|
+
}, M.diffed = function(t) {
|
|
356
356
|
Ne && Ne(t);
|
|
357
357
|
var e = t.__c;
|
|
358
|
-
e && e.__H && (e.__H.__h.length && (Ze.push(e) !== 1 && Le ===
|
|
358
|
+
e && e.__H && (e.__H.__h.length && (Ze.push(e) !== 1 && Le === M.requestAnimationFrame || ((Le = M.requestAnimationFrame) || pt)(gt)), e.__H.__.forEach(function(n) {
|
|
359
359
|
n.u && (n.__H = n.u), n.u = void 0;
|
|
360
|
-
})), ue =
|
|
361
|
-
},
|
|
360
|
+
})), ue = A = null;
|
|
361
|
+
}, M.__c = function(t, e) {
|
|
362
362
|
e.some(function(n) {
|
|
363
363
|
try {
|
|
364
364
|
n.__h.forEach(te), n.__h = n.__h.filter(function(o) {
|
|
365
|
-
return !o.__ ||
|
|
365
|
+
return !o.__ || _e(o);
|
|
366
366
|
});
|
|
367
367
|
} catch (o) {
|
|
368
368
|
e.some(function(i) {
|
|
369
369
|
i.__h && (i.__h = []);
|
|
370
|
-
}), e = [],
|
|
370
|
+
}), e = [], M.__e(o, n.__v);
|
|
371
371
|
}
|
|
372
|
-
}),
|
|
373
|
-
},
|
|
374
|
-
|
|
372
|
+
}), Ae && Ae(t, e);
|
|
373
|
+
}, M.unmount = function(t) {
|
|
374
|
+
Ee && Ee(t);
|
|
375
375
|
var e, n = t.__c;
|
|
376
376
|
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
377
377
|
try {
|
|
@@ -379,22 +379,22 @@ E.__b = function(t) {
|
|
|
379
379
|
} catch (i) {
|
|
380
380
|
e = i;
|
|
381
381
|
}
|
|
382
|
-
}), n.__H = void 0, e &&
|
|
382
|
+
}), n.__H = void 0, e && M.__e(e, n.__v));
|
|
383
383
|
};
|
|
384
384
|
var Pe = typeof requestAnimationFrame == "function";
|
|
385
|
-
function
|
|
385
|
+
function pt(t) {
|
|
386
386
|
var e, n = function() {
|
|
387
387
|
clearTimeout(o), Pe && cancelAnimationFrame(e), setTimeout(t);
|
|
388
388
|
}, o = setTimeout(n, 100);
|
|
389
389
|
Pe && (e = requestAnimationFrame(n));
|
|
390
390
|
}
|
|
391
391
|
function te(t) {
|
|
392
|
-
var e =
|
|
393
|
-
typeof n == "function" && (t.__c = void 0, n()),
|
|
392
|
+
var e = A, n = t.__c;
|
|
393
|
+
typeof n == "function" && (t.__c = void 0, n()), A = e;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
396
|
-
var e =
|
|
397
|
-
t.__c = t.__(),
|
|
395
|
+
function _e(t) {
|
|
396
|
+
var e = A;
|
|
397
|
+
t.__c = t.__(), A = e;
|
|
398
398
|
}
|
|
399
399
|
function Qe(t, e) {
|
|
400
400
|
return !t || t.length !== e.length || e.some(function(n, o) {
|
|
@@ -432,8 +432,9 @@ const Ct = (t) => ({
|
|
|
432
432
|
highestUnlockedLevel: 1,
|
|
433
433
|
currentTier: 1,
|
|
434
434
|
highestUnlockedTier: 1,
|
|
435
|
-
levelScores: {}
|
|
436
|
-
|
|
435
|
+
levelScores: {},
|
|
436
|
+
totalScore: 0
|
|
437
|
+
}, xe = {
|
|
437
438
|
isGameActive: !0,
|
|
438
439
|
levelTransitioning: !1,
|
|
439
440
|
maze: null,
|
|
@@ -447,36 +448,46 @@ const Ct = (t) => ({
|
|
|
447
448
|
playerPath: [],
|
|
448
449
|
visitCounts: {}
|
|
449
450
|
}, wt = ({ children: t, config: e }) => {
|
|
450
|
-
const n = Ct(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] =
|
|
451
|
-
|
|
451
|
+
const n = Ct(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = j(() => o || { ...Ie });
|
|
452
|
+
x(() => {
|
|
453
|
+
const u = Object.values(i.levelScores).reduce(
|
|
454
|
+
(h, f) => h + f,
|
|
455
|
+
0
|
|
456
|
+
);
|
|
457
|
+
s((h) => ({
|
|
458
|
+
...h,
|
|
459
|
+
totalScore: u
|
|
460
|
+
}));
|
|
461
|
+
}, [i.levelScores]), x(() => {
|
|
452
462
|
n.saveGameData(i);
|
|
453
463
|
}, [
|
|
454
464
|
i.currentLevel,
|
|
455
465
|
i.highestUnlockedLevel,
|
|
456
466
|
i.currentTier,
|
|
457
467
|
i.highestUnlockedTier,
|
|
458
|
-
i.levelScores
|
|
468
|
+
i.levelScores,
|
|
469
|
+
i.totalScore
|
|
459
470
|
]);
|
|
460
|
-
const
|
|
461
|
-
...
|
|
462
|
-
}),
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}, [
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
471
|
+
const [l, r] = j({
|
|
472
|
+
...xe
|
|
473
|
+
}), a = O(l);
|
|
474
|
+
x(() => {
|
|
475
|
+
a.current = l;
|
|
476
|
+
}, [l]);
|
|
477
|
+
const c = q(() => [
|
|
478
|
+
l.playerAtExit ? 1 : 0,
|
|
479
|
+
l.foodCollected === l.totalFoodCount ? 1 : 0,
|
|
480
|
+
l.showClue ? 0 : 1
|
|
470
481
|
], [
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
]),
|
|
482
|
+
l.playerAtExit,
|
|
483
|
+
l.foodCollected,
|
|
484
|
+
l.totalFoodCount,
|
|
485
|
+
l.showClue
|
|
486
|
+
]), d = () => {
|
|
476
487
|
n.resetGameData(), s({
|
|
477
488
|
...Ie
|
|
478
|
-
}),
|
|
479
|
-
...
|
|
489
|
+
}), r({
|
|
490
|
+
...xe
|
|
480
491
|
});
|
|
481
492
|
};
|
|
482
493
|
return /* @__PURE__ */ C(
|
|
@@ -485,13 +496,12 @@ const Ct = (t) => ({
|
|
|
485
496
|
value: {
|
|
486
497
|
gameProgress: i,
|
|
487
498
|
setGameProgress: s,
|
|
488
|
-
gamePlayState:
|
|
489
|
-
setGamePlayState:
|
|
490
|
-
gamePlayStateRef:
|
|
491
|
-
currentScore:
|
|
492
|
-
totalScore: a,
|
|
499
|
+
gamePlayState: l,
|
|
500
|
+
setGamePlayState: r,
|
|
501
|
+
gamePlayStateRef: a,
|
|
502
|
+
currentScore: c,
|
|
493
503
|
config: e,
|
|
494
|
-
resetGame:
|
|
504
|
+
resetGame: d
|
|
495
505
|
},
|
|
496
506
|
children: t
|
|
497
507
|
}
|
|
@@ -501,65 +511,65 @@ const Ct = (t) => ({
|
|
|
501
511
|
if (!t)
|
|
502
512
|
throw new Error("useGameContext must be used within a GameProvider");
|
|
503
513
|
return t;
|
|
504
|
-
}, X = (t) =>
|
|
505
|
-
const e = t.map((r) => r.length), n = e.reduce((r,
|
|
514
|
+
}, X = (t) => q(() => {
|
|
515
|
+
const e = t.map((r) => r.length), n = e.reduce((r, a) => r + a, 0), o = t.length, i = (r) => {
|
|
506
516
|
if (r < 1 || r > n) return 0;
|
|
507
|
-
let
|
|
517
|
+
let a = 0;
|
|
508
518
|
for (let c = 0; c < e.length; c++)
|
|
509
|
-
if (
|
|
519
|
+
if (a += e[c], r <= a) return c + 1;
|
|
510
520
|
return 0;
|
|
511
|
-
}, 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((a, c) => a + c, 0) + 1, l = {
|
|
512
522
|
getTotalLevels: () => n,
|
|
513
523
|
getTotalTiers: () => o,
|
|
514
524
|
getTierLevelsRange: (r) => {
|
|
515
525
|
if (r < 1 || r > o) return [0, 0];
|
|
516
|
-
const
|
|
517
|
-
return [
|
|
526
|
+
const a = s(r), c = a + e[r - 1] - 1;
|
|
527
|
+
return [a, c];
|
|
518
528
|
},
|
|
519
529
|
getTierByLevel: i,
|
|
520
530
|
getFirstLevelOfTier: s,
|
|
521
531
|
getLevelConfig: (r) => {
|
|
522
532
|
if (r < 1 || r > n) return null;
|
|
523
|
-
const
|
|
524
|
-
return t[
|
|
533
|
+
const a = i(r), c = s(a), d = r - c;
|
|
534
|
+
return t[a - 1][d];
|
|
525
535
|
},
|
|
526
536
|
getTierConfig: (r) => r < 1 || r > o ? null : t[r - 1],
|
|
527
|
-
isLevelUnlocked: (r,
|
|
528
|
-
isTierUnlocked: (r,
|
|
537
|
+
isLevelUnlocked: (r, a) => r <= a,
|
|
538
|
+
isTierUnlocked: (r, a) => r <= a,
|
|
529
539
|
getNextLevelInfo: (r) => {
|
|
530
540
|
if (r >= n) return null;
|
|
531
|
-
const
|
|
541
|
+
const a = r + 1, c = i(r), d = i(a);
|
|
532
542
|
return {
|
|
533
|
-
nextLevel:
|
|
543
|
+
nextLevel: a,
|
|
534
544
|
nextTier: d,
|
|
535
545
|
isTierChange: d > c
|
|
536
546
|
};
|
|
537
547
|
},
|
|
538
|
-
getCurrentTierProgress: (r,
|
|
539
|
-
const [c, d] =
|
|
548
|
+
getCurrentTierProgress: (r, a) => {
|
|
549
|
+
const [c, d] = l.getTierLevelsRange(a), u = r - c + 1, h = d - c + 1;
|
|
540
550
|
return { current: u, total: h };
|
|
541
551
|
},
|
|
542
552
|
isLastLevelInTier: (r) => {
|
|
543
|
-
const
|
|
553
|
+
const a = i(r), [, c] = l.getTierLevelsRange(a);
|
|
544
554
|
return r === c;
|
|
545
555
|
},
|
|
546
556
|
getPreviousLevelInfo: (r) => {
|
|
547
557
|
if (r <= 1) return null;
|
|
548
|
-
const
|
|
558
|
+
const a = r - 1, c = i(r), d = i(a);
|
|
549
559
|
return {
|
|
550
|
-
prevLevel:
|
|
560
|
+
prevLevel: a,
|
|
551
561
|
prevTier: d,
|
|
552
562
|
isTierChange: d < c
|
|
553
563
|
};
|
|
554
564
|
}
|
|
555
565
|
};
|
|
556
|
-
return
|
|
566
|
+
return l;
|
|
557
567
|
}, [t]), yt = ({ onTierChange: t, disabled: e }) => {
|
|
558
|
-
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier:
|
|
568
|
+
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: l, highestUnlockedTier: r } = n, c = X(s).getTotalTiers();
|
|
559
569
|
return /* @__PURE__ */ C("div", { className: "tier-selector", children: /* @__PURE__ */ C(
|
|
560
570
|
"select",
|
|
561
571
|
{
|
|
562
|
-
value:
|
|
572
|
+
value: l,
|
|
563
573
|
onChange: (d) => {
|
|
564
574
|
d.target && d.target.value && t(Number(d.target.value));
|
|
565
575
|
},
|
|
@@ -577,31 +587,31 @@ const Ct = (t) => ({
|
|
|
577
587
|
}
|
|
578
588
|
) });
|
|
579
589
|
}, bt = ({ onLevelChange: t, disabled: e }) => {
|
|
580
|
-
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier:
|
|
581
|
-
const [h,
|
|
582
|
-
return Array.from({ length:
|
|
583
|
-
const
|
|
590
|
+
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: l, levelScores: r, currentLevel: a, highestUnlockedLevel: c } = n, d = X(s), u = q(() => {
|
|
591
|
+
const [h, f] = d.getTierLevelsRange(l);
|
|
592
|
+
return Array.from({ length: f - h + 1 }, (m, g) => {
|
|
593
|
+
const _ = h + g, p = r[_] || 0;
|
|
584
594
|
return {
|
|
585
|
-
level:
|
|
586
|
-
score:
|
|
595
|
+
level: _,
|
|
596
|
+
score: p
|
|
587
597
|
};
|
|
588
598
|
});
|
|
589
|
-
}, [
|
|
599
|
+
}, [l, r]);
|
|
590
600
|
return /* @__PURE__ */ C("div", { className: "level-selector", children: /* @__PURE__ */ C(
|
|
591
601
|
"select",
|
|
592
602
|
{
|
|
593
|
-
value:
|
|
603
|
+
value: a,
|
|
594
604
|
onChange: (h) => {
|
|
595
605
|
h.target && h.target.value && t(Number(h.target.value));
|
|
596
606
|
},
|
|
597
607
|
disabled: e,
|
|
598
608
|
className: "level-dropdown",
|
|
599
|
-
children: u.map(({ level: h, score:
|
|
609
|
+
children: u.map(({ level: h, score: f }) => /* @__PURE__ */ C(
|
|
600
610
|
"option",
|
|
601
611
|
{
|
|
602
612
|
value: h,
|
|
603
613
|
disabled: h > c,
|
|
604
|
-
children: `${i.level} ${h} ${"★".repeat(
|
|
614
|
+
children: `${i.level} ${h} ${"★".repeat(f)}`
|
|
605
615
|
},
|
|
606
616
|
`level-${h}`
|
|
607
617
|
))
|
|
@@ -614,16 +624,16 @@ const Ct = (t) => ({
|
|
|
614
624
|
message: o,
|
|
615
625
|
children: i,
|
|
616
626
|
noConfirm: s = !1,
|
|
617
|
-
noCancel:
|
|
627
|
+
noCancel: l = !1,
|
|
618
628
|
confirmText: r = "OK",
|
|
619
|
-
cancelText:
|
|
629
|
+
cancelText: a = "Cancel",
|
|
620
630
|
onConfirm: c,
|
|
621
631
|
onCancel: d
|
|
622
632
|
}) => {
|
|
623
|
-
const u =
|
|
624
|
-
return
|
|
625
|
-
const h = (
|
|
626
|
-
|
|
633
|
+
const u = O(null);
|
|
634
|
+
return x(() => {
|
|
635
|
+
const h = (f) => {
|
|
636
|
+
f.key === "Escape" && d?.();
|
|
627
637
|
};
|
|
628
638
|
return t && document.addEventListener("keydown", h), () => {
|
|
629
639
|
document.removeEventListener("keydown", h);
|
|
@@ -635,14 +645,14 @@ const Ct = (t) => ({
|
|
|
635
645
|
children: /* @__PURE__ */ C("div", { className: "maze-dialog " + n, ref: u, children: [
|
|
636
646
|
/* @__PURE__ */ C("div", { className: "maze-dialog-title", children: e }),
|
|
637
647
|
/* @__PURE__ */ C("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ C("div", { className: "maze-dialog-message", children: o }) }),
|
|
638
|
-
(!
|
|
639
|
-
!
|
|
648
|
+
(!l || !s) && /* @__PURE__ */ C("div", { className: "maze-dialog-buttons", children: [
|
|
649
|
+
!l && /* @__PURE__ */ C(
|
|
640
650
|
"button",
|
|
641
651
|
{
|
|
642
652
|
type: "button",
|
|
643
653
|
className: "maze-dialog-cancel",
|
|
644
654
|
onClick: d,
|
|
645
|
-
children:
|
|
655
|
+
children: a
|
|
646
656
|
}
|
|
647
657
|
),
|
|
648
658
|
!s && /* @__PURE__ */ C(
|
|
@@ -695,37 +705,36 @@ const Ct = (t) => ({
|
|
|
695
705
|
gamePlayState: n,
|
|
696
706
|
setGamePlayState: o,
|
|
697
707
|
gamePlayStateRef: i,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
d.isLevelUnlocked(U, _) && (e((K) => ({ ...K, currentTier: D })), k(U));
|
|
708
|
+
resetGame: s,
|
|
709
|
+
config: l
|
|
710
|
+
} = B(), { i18n: r, levelConfig: a } = l, c = X(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, m = c.getTotalLevels(), [g, _] = j(!1), [p, v] = j(!1), [y, w] = j(!1), b = (D) => {
|
|
711
|
+
const U = c.getFirstLevelOfTier(D);
|
|
712
|
+
c.isLevelUnlocked(U, h) && (e((K) => ({ ...K, currentTier: D })), k(U));
|
|
704
713
|
}, k = (D) => {
|
|
705
|
-
|
|
706
|
-
|
|
714
|
+
c.isLevelUnlocked(D, h) && (e((U) => ({ ...U, currentLevel: D })), R.show(
|
|
715
|
+
r.levelGoToast.replace("%LEVEL%", D.toString()),
|
|
707
716
|
"success"
|
|
708
717
|
));
|
|
709
718
|
}, T = () => {
|
|
710
|
-
|
|
711
|
-
}, A = () => {
|
|
712
|
-
m(!1);
|
|
713
|
-
}, N = () => {
|
|
714
|
-
y(!0);
|
|
715
|
-
}, M = () => {
|
|
716
|
-
y(!1);
|
|
719
|
+
_(!0);
|
|
717
720
|
}, z = () => {
|
|
718
|
-
|
|
721
|
+
_(!1);
|
|
722
|
+
}, L = () => {
|
|
723
|
+
w(!0);
|
|
724
|
+
}, E = () => {
|
|
725
|
+
w(!1);
|
|
726
|
+
}, N = () => {
|
|
727
|
+
R.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
|
|
719
728
|
...i.current,
|
|
720
729
|
// need to sync with ref
|
|
721
730
|
showClue: !i.current.showClue
|
|
722
|
-
})),
|
|
731
|
+
})), w(!1);
|
|
723
732
|
}, P = () => {
|
|
724
|
-
|
|
725
|
-
},
|
|
726
|
-
|
|
733
|
+
v(!0);
|
|
734
|
+
}, I = () => {
|
|
735
|
+
s(), v(!1), R.show(r.resetDoneToast);
|
|
727
736
|
}, ye = () => {
|
|
728
|
-
|
|
737
|
+
v(!1);
|
|
729
738
|
};
|
|
730
739
|
return /* @__PURE__ */ C("div", { class: "game-panel-container", children: [
|
|
731
740
|
/* @__PURE__ */ C("div", { className: "game-controls", children: [
|
|
@@ -734,42 +743,42 @@ const Ct = (t) => ({
|
|
|
734
743
|
yt,
|
|
735
744
|
{
|
|
736
745
|
onTierChange: b,
|
|
737
|
-
disabled:
|
|
746
|
+
disabled: d
|
|
738
747
|
}
|
|
739
748
|
),
|
|
740
749
|
/* @__PURE__ */ C(
|
|
741
750
|
bt,
|
|
742
751
|
{
|
|
743
752
|
onLevelChange: k,
|
|
744
|
-
disabled:
|
|
753
|
+
disabled: d
|
|
745
754
|
}
|
|
746
755
|
)
|
|
747
756
|
] }),
|
|
748
757
|
/* @__PURE__ */ C(
|
|
749
758
|
"button",
|
|
750
759
|
{
|
|
751
|
-
className: `settings-clue-button ${
|
|
752
|
-
disabled:
|
|
760
|
+
className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
|
|
761
|
+
disabled: u,
|
|
753
762
|
title: "Toggle Clue",
|
|
754
|
-
onClick:
|
|
755
|
-
children:
|
|
763
|
+
onClick: L,
|
|
764
|
+
children: u ? r.clueOn : r.clueOff
|
|
756
765
|
}
|
|
757
766
|
)
|
|
758
767
|
] }),
|
|
759
|
-
/* @__PURE__ */ C("div", { className: "game-settings", children: /* @__PURE__ */ C("span", { className: "game-settings-icon", onClick: T, children: "★ " +
|
|
768
|
+
/* @__PURE__ */ C("div", { className: "game-settings", children: /* @__PURE__ */ C("span", { className: "game-settings-icon", onClick: T, children: "★ " + f }) }),
|
|
760
769
|
/* @__PURE__ */ C(
|
|
761
770
|
ne,
|
|
762
771
|
{
|
|
763
|
-
isOpen:
|
|
764
|
-
title:
|
|
772
|
+
isOpen: g,
|
|
773
|
+
title: r.settings,
|
|
765
774
|
noConfirm: !0,
|
|
766
|
-
cancelText:
|
|
767
|
-
onCancel:
|
|
775
|
+
cancelText: r.close,
|
|
776
|
+
onCancel: z,
|
|
768
777
|
children: [
|
|
769
778
|
/* @__PURE__ */ C("div", { className: "settings-stats", children: [
|
|
770
|
-
/* @__PURE__ */ C("div", { children:
|
|
771
|
-
/* @__PURE__ */ C("div", { children:
|
|
772
|
-
/* @__PURE__ */ C("div", { children:
|
|
779
|
+
/* @__PURE__ */ C("div", { children: r.levelComplete + `: ${h}/${m}` }),
|
|
780
|
+
/* @__PURE__ */ C("div", { children: r.starsCollected + ": " + f }),
|
|
781
|
+
/* @__PURE__ */ C("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
|
|
773
782
|
] }),
|
|
774
783
|
/* @__PURE__ */ C("div", { className: "settings-item-box", children: [
|
|
775
784
|
/* @__PURE__ */ C(
|
|
@@ -778,10 +787,10 @@ const Ct = (t) => ({
|
|
|
778
787
|
className: "settings-reset-button",
|
|
779
788
|
title: "Reset Game",
|
|
780
789
|
onClick: P,
|
|
781
|
-
children:
|
|
790
|
+
children: r.reset
|
|
782
791
|
}
|
|
783
792
|
),
|
|
784
|
-
/* @__PURE__ */ C("div", { className: "settings-item-tip", children:
|
|
793
|
+
/* @__PURE__ */ C("div", { className: "settings-item-tip", children: r.resetTip })
|
|
785
794
|
] })
|
|
786
795
|
]
|
|
787
796
|
}
|
|
@@ -789,25 +798,25 @@ const Ct = (t) => ({
|
|
|
789
798
|
/* @__PURE__ */ C(
|
|
790
799
|
ne,
|
|
791
800
|
{
|
|
792
|
-
isOpen:
|
|
793
|
-
title:
|
|
794
|
-
message:
|
|
795
|
-
confirmText:
|
|
796
|
-
cancelText:
|
|
797
|
-
onConfirm:
|
|
801
|
+
isOpen: p,
|
|
802
|
+
title: r.confirmReset,
|
|
803
|
+
message: r.confirmResetMessage,
|
|
804
|
+
confirmText: r.reset,
|
|
805
|
+
cancelText: r.cancel,
|
|
806
|
+
onConfirm: I,
|
|
798
807
|
onCancel: ye
|
|
799
808
|
}
|
|
800
809
|
),
|
|
801
810
|
/* @__PURE__ */ C(
|
|
802
811
|
ne,
|
|
803
812
|
{
|
|
804
|
-
isOpen:
|
|
805
|
-
title:
|
|
806
|
-
message:
|
|
807
|
-
confirmText:
|
|
808
|
-
cancelText:
|
|
809
|
-
onConfirm:
|
|
810
|
-
onCancel:
|
|
813
|
+
isOpen: y,
|
|
814
|
+
title: r.confirmClue,
|
|
815
|
+
message: r.confirmClueMessage,
|
|
816
|
+
confirmText: r.confirm,
|
|
817
|
+
cancelText: r.cancel,
|
|
818
|
+
onConfirm: N,
|
|
819
|
+
onCancel: E
|
|
811
820
|
}
|
|
812
821
|
)
|
|
813
822
|
] });
|
|
@@ -832,52 +841,52 @@ function Lt(t) {
|
|
|
832
841
|
var e = window.devicePixelRatio, n = getComputedStyle(t), o = De(n.getPropertyValue("width")), i = De(n.getPropertyValue("height"));
|
|
833
842
|
t.setAttribute("width", (o * e).toString()), t.setAttribute("height", (i * e).toString());
|
|
834
843
|
}
|
|
835
|
-
function
|
|
844
|
+
function F(t, e) {
|
|
836
845
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (e - t) + t;
|
|
837
846
|
return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
|
|
838
847
|
}
|
|
839
|
-
function
|
|
840
|
-
return t[
|
|
848
|
+
function Fe(t) {
|
|
849
|
+
return t[F(0, t.length)];
|
|
841
850
|
}
|
|
842
|
-
var St = 125e-5, zt = 5e-4, Nt = 9e-4,
|
|
843
|
-
function
|
|
851
|
+
var St = 125e-5, zt = 5e-4, Nt = 9e-4, At = 1e-5, Et = 6, Mt = 80, Pt = 0.9, It = 1.7, xt = 0.2, Dt = 0.6, Ft = 0.03, Ot = 0.07, Rt = 15, $t = 82, Ut = 100, Wt = 250, jt = 40, Gt = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
|
|
852
|
+
function Oe(t) {
|
|
844
853
|
var e = 1920;
|
|
845
854
|
return Math.log(t) / Math.log(e);
|
|
846
855
|
}
|
|
847
856
|
var Re = /* @__PURE__ */ function() {
|
|
848
857
|
function t(e) {
|
|
849
858
|
Ce(this, t);
|
|
850
|
-
var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors,
|
|
859
|
+
var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, l = e.emojis, r = e.emojiSize, a = e.canvasWidth, c = F(Pt, It, 3), d = c * Oe(a);
|
|
851
860
|
this.confettiSpeed = {
|
|
852
861
|
x: d,
|
|
853
862
|
y: d
|
|
854
|
-
}, this.finalConfettiSpeedX =
|
|
863
|
+
}, this.finalConfettiSpeedX = F(xt, Dt, 3), this.rotationSpeed = l.length ? 0.01 : F(Ft, Ot, 3) * Oe(a), this.dragForceCoefficient = F(zt, Nt, 6), this.radius = {
|
|
855
864
|
x: i,
|
|
856
865
|
y: i
|
|
857
|
-
}, this.initialRadius = i, this.rotationAngle = o === "left" ?
|
|
858
|
-
var u = o === "left" ?
|
|
866
|
+
}, this.initialRadius = i, this.rotationAngle = o === "left" ? F(0, 0.2, 3) : F(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = F(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
|
|
867
|
+
var u = o === "left" ? F($t, Rt) * Math.PI / 180 : F(-15, -82) * Math.PI / 180;
|
|
859
868
|
this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
|
|
860
|
-
var h =
|
|
869
|
+
var h = F(-150, 0), f = {
|
|
861
870
|
x: n.x + (o === "left" ? -h : h) * this.absCos,
|
|
862
871
|
y: n.y - h * this.absSin
|
|
863
872
|
};
|
|
864
|
-
this.currentPosition = Object.assign({},
|
|
873
|
+
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = l.length ? null : Fe(s), this.emoji = l.length ? Fe(l) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
|
|
865
874
|
}
|
|
866
875
|
return we(t, [{
|
|
867
876
|
key: "draw",
|
|
868
877
|
value: function(n) {
|
|
869
|
-
var o = this.currentPosition, i = this.radius, s = this.color,
|
|
870
|
-
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()) :
|
|
878
|
+
var o = this.currentPosition, i = this.radius, s = this.color, l = this.emoji, r = this.rotationAngle, a = this.emojiRotationAngle, c = this.emojiSize, d = window.devicePixelRatio;
|
|
879
|
+
s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : l && (n.font = "".concat(c, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(a), n.textAlign = "center", n.fillText(l, 0, 0), n.restore());
|
|
871
880
|
}
|
|
872
881
|
}, {
|
|
873
882
|
key: "updatePosition",
|
|
874
883
|
value: function(n, o) {
|
|
875
|
-
var i = this.confettiSpeed, s = this.dragForceCoefficient,
|
|
876
|
-
if (i.x >
|
|
884
|
+
var i = this.confettiSpeed, s = this.dragForceCoefficient, l = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, a = this.rotationSpeed, c = this.createdAt, d = this.direction, u = o - c;
|
|
885
|
+
if (i.x > l && (this.confettiSpeed.x -= s * n), this.currentPosition.x += i.x * (d === "left" ? -this.absCos : this.absCos) * n, this.currentPosition.y = this.initialPosition.y - i.y * this.absSin * u + St * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : At * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
|
|
877
886
|
this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
|
|
878
887
|
return;
|
|
879
888
|
}
|
|
880
|
-
r === "down" ? (this.radius.y -= n *
|
|
889
|
+
r === "down" ? (this.radius.y -= n * a, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * a, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
|
|
881
890
|
}
|
|
882
891
|
}, {
|
|
883
892
|
key: "getIsVisibleOnCanvas",
|
|
@@ -891,12 +900,12 @@ function Ht() {
|
|
|
891
900
|
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;
|
|
892
901
|
}
|
|
893
902
|
function qt(t) {
|
|
894
|
-
var e = t.confettiRadius, n = e === void 0 ?
|
|
903
|
+
var e = t.confettiRadius, n = e === void 0 ? Et : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? jt : Wt) : o, s = t.confettiColors, l = s === void 0 ? Gt : s, r = t.emojis, a = r === void 0 ? t.emojies || [] : r, c = t.emojiSize, d = c === void 0 ? Mt : c;
|
|
895
904
|
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"), {
|
|
896
905
|
confettiRadius: n,
|
|
897
906
|
confettiNumber: i,
|
|
898
|
-
confettiColors:
|
|
899
|
-
emojis:
|
|
907
|
+
confettiColors: l,
|
|
908
|
+
emojis: a,
|
|
900
909
|
emojiSize: d
|
|
901
910
|
};
|
|
902
911
|
}
|
|
@@ -927,9 +936,9 @@ var Bt = /* @__PURE__ */ function() {
|
|
|
927
936
|
}, {
|
|
928
937
|
key: "processShapes",
|
|
929
938
|
value: function(n, o, i) {
|
|
930
|
-
var s = this,
|
|
931
|
-
this.shapes = this.shapes.filter(function(
|
|
932
|
-
return
|
|
939
|
+
var s = this, l = n.timeDelta, r = n.currentTime;
|
|
940
|
+
this.shapes = this.shapes.filter(function(a) {
|
|
941
|
+
return a.updatePosition(l, r), a.draw(s.canvasContext), i ? a.getIsVisibleOnCanvas(o) : !0;
|
|
933
942
|
});
|
|
934
943
|
}
|
|
935
944
|
}]), t;
|
|
@@ -943,11 +952,11 @@ var Bt = /* @__PURE__ */ function() {
|
|
|
943
952
|
value: function() {
|
|
944
953
|
this.requestAnimationFrameRequested = !1, Lt(this.canvas);
|
|
945
954
|
var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
|
|
946
|
-
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(
|
|
947
|
-
return
|
|
955
|
+
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(l) {
|
|
956
|
+
return l.processShapes({
|
|
948
957
|
timeDelta: o,
|
|
949
958
|
currentTime: n
|
|
950
|
-
}, i, s), s ? !
|
|
959
|
+
}, i, s), s ? !l.complete() : !0;
|
|
951
960
|
}), this.iterationIndex++, this.queueAnimationFrameIfNeeded(n);
|
|
952
961
|
}
|
|
953
962
|
}, {
|
|
@@ -958,35 +967,35 @@ var Bt = /* @__PURE__ */ function() {
|
|
|
958
967
|
}, {
|
|
959
968
|
key: "addConfetti",
|
|
960
969
|
value: function() {
|
|
961
|
-
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = qt(n), i = o.confettiRadius, s = o.confettiNumber,
|
|
970
|
+
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = qt(n), i = o.confettiRadius, s = o.confettiNumber, l = o.confettiColors, r = o.emojis, a = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
|
|
962
971
|
x: 0,
|
|
963
972
|
y: h
|
|
964
|
-
},
|
|
973
|
+
}, m = {
|
|
965
974
|
x: d,
|
|
966
975
|
y: h
|
|
967
|
-
},
|
|
968
|
-
var
|
|
969
|
-
initialPosition:
|
|
976
|
+
}, g = new Bt(this.canvasContext), _ = 0; _ < s / 2; _++) {
|
|
977
|
+
var p = new Re({
|
|
978
|
+
initialPosition: f,
|
|
970
979
|
direction: "right",
|
|
971
980
|
confettiRadius: i,
|
|
972
|
-
confettiColors:
|
|
981
|
+
confettiColors: l,
|
|
973
982
|
confettiNumber: s,
|
|
974
983
|
emojis: r,
|
|
975
|
-
emojiSize:
|
|
984
|
+
emojiSize: a,
|
|
976
985
|
canvasWidth: d
|
|
977
|
-
}),
|
|
978
|
-
initialPosition:
|
|
986
|
+
}), v = new Re({
|
|
987
|
+
initialPosition: m,
|
|
979
988
|
direction: "left",
|
|
980
989
|
confettiRadius: i,
|
|
981
|
-
confettiColors:
|
|
990
|
+
confettiColors: l,
|
|
982
991
|
confettiNumber: s,
|
|
983
992
|
emojis: r,
|
|
984
|
-
emojiSize:
|
|
993
|
+
emojiSize: a,
|
|
985
994
|
canvasWidth: d
|
|
986
995
|
});
|
|
987
|
-
|
|
996
|
+
g.addShapes(p, v);
|
|
988
997
|
}
|
|
989
|
-
return this.activeConfettiBatches.push(
|
|
998
|
+
return this.activeConfettiBatches.push(g), this.queueAnimationFrameIfNeeded(), g.getBatchCompletePromise();
|
|
990
999
|
}
|
|
991
1000
|
}, {
|
|
992
1001
|
key: "clearCanvas",
|
|
@@ -1007,38 +1016,38 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1007
1016
|
gamePlayState: o,
|
|
1008
1017
|
setGamePlayState: i,
|
|
1009
1018
|
gameProgress: s,
|
|
1010
|
-
setGameProgress:
|
|
1011
|
-
} = B(), { i18n: r, levelConfig:
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}, [
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1019
|
+
setGameProgress: l
|
|
1020
|
+
} = B(), { i18n: r, levelConfig: a } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: m, levelTransitioning: g } = o, { currentLevel: _ } = s, [p, v] = j(!1);
|
|
1021
|
+
x(() => {
|
|
1022
|
+
m && g && (Yt.addConfetti(), R.show(r.levelCompleteToast, "success"), v(!0));
|
|
1023
|
+
}, [m, g]);
|
|
1024
|
+
const y = X(a), w = y.getTotalLevels(), b = q(() => _ >= w, [_, w]), k = () => {
|
|
1025
|
+
v(!1), R.show(r.levelRestartToast, "info"), t?.();
|
|
1017
1026
|
}, T = () => {
|
|
1018
|
-
|
|
1019
|
-
...
|
|
1027
|
+
v(!1), i((L) => ({
|
|
1028
|
+
...L,
|
|
1020
1029
|
isGameActive: !0,
|
|
1021
1030
|
levelTransitioning: !1
|
|
1022
1031
|
}));
|
|
1023
|
-
},
|
|
1024
|
-
|
|
1025
|
-
const
|
|
1026
|
-
if (!
|
|
1027
|
-
const { nextLevel:
|
|
1032
|
+
}, z = () => {
|
|
1033
|
+
v(!1);
|
|
1034
|
+
const L = y.getNextLevelInfo(_);
|
|
1035
|
+
if (!L) return;
|
|
1036
|
+
const { nextLevel: E, nextTier: N, isTierChange: P } = L;
|
|
1028
1037
|
P && R.show(
|
|
1029
|
-
r.tierUnlockedToast.replace("%TIER%",
|
|
1038
|
+
r.tierUnlockedToast.replace("%TIER%", N.toString()),
|
|
1030
1039
|
"success"
|
|
1031
|
-
),
|
|
1032
|
-
...
|
|
1033
|
-
currentLevel:
|
|
1034
|
-
currentTier:
|
|
1035
|
-
highestUnlockedLevel: Math.max(
|
|
1036
|
-
highestUnlockedTier: Math.max(
|
|
1040
|
+
), l((I) => ({
|
|
1041
|
+
...I,
|
|
1042
|
+
currentLevel: E,
|
|
1043
|
+
currentTier: N,
|
|
1044
|
+
highestUnlockedLevel: Math.max(I.highestUnlockedLevel, E),
|
|
1045
|
+
highestUnlockedTier: Math.max(I.highestUnlockedTier, N),
|
|
1037
1046
|
levelScores: {
|
|
1038
|
-
...
|
|
1039
|
-
[
|
|
1047
|
+
...I.levelScores,
|
|
1048
|
+
[I.currentLevel]: Math.max(
|
|
1040
1049
|
Object.values(n).filter(Boolean).length,
|
|
1041
|
-
|
|
1050
|
+
I.levelScores[I.currentLevel] || 0
|
|
1042
1051
|
)
|
|
1043
1052
|
}
|
|
1044
1053
|
}));
|
|
@@ -1047,7 +1056,7 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1047
1056
|
ne,
|
|
1048
1057
|
{
|
|
1049
1058
|
className: "level-complete-dialog",
|
|
1050
|
-
isOpen:
|
|
1059
|
+
isOpen: p,
|
|
1051
1060
|
title: r.congratulations,
|
|
1052
1061
|
cancelText: r.retry,
|
|
1053
1062
|
onCancel: k,
|
|
@@ -1058,29 +1067,29 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1058
1067
|
/* @__PURE__ */ C("div", { className: "maze-summary-message", children: [
|
|
1059
1068
|
!!c && /* @__PURE__ */ C("div", { children: "★ - " + r.findYourExit }),
|
|
1060
1069
|
/* @__PURE__ */ C("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
|
|
1061
|
-
/* @__PURE__ */ C("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${
|
|
1070
|
+
/* @__PURE__ */ C("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
|
|
1062
1071
|
] }),
|
|
1063
1072
|
b && /* @__PURE__ */ C("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
|
|
1064
|
-
/* @__PURE__ */ C("div", { className: "go-next-level", children: b ? "OK" : /* @__PURE__ */ C("button", { type: "button", onClick:
|
|
1073
|
+
/* @__PURE__ */ C("div", { className: "go-next-level", children: b ? "OK" : /* @__PURE__ */ C("button", { type: "button", onClick: z, children: r.nextLevel }) }),
|
|
1065
1074
|
!d && /* @__PURE__ */ C("div", { className: "not-all-stars-collected", children: r.continueMessage })
|
|
1066
1075
|
]
|
|
1067
1076
|
}
|
|
1068
1077
|
);
|
|
1069
1078
|
}, Kt = (t, e) => {
|
|
1070
|
-
const n =
|
|
1079
|
+
const n = O({
|
|
1071
1080
|
canvasWidth: 0,
|
|
1072
1081
|
canvasHeight: 0
|
|
1073
1082
|
});
|
|
1074
|
-
return
|
|
1083
|
+
return x(() => {
|
|
1075
1084
|
const o = () => {
|
|
1076
1085
|
const s = t.current;
|
|
1077
1086
|
if (!s) return;
|
|
1078
|
-
const
|
|
1079
|
-
if (!
|
|
1080
|
-
const r =
|
|
1087
|
+
const l = s.parentElement;
|
|
1088
|
+
if (!l) return;
|
|
1089
|
+
const r = l.clientWidth, a = window.devicePixelRatio || 1;
|
|
1081
1090
|
s.style.width = `${r}px`, s.style.height = `${r}px`;
|
|
1082
|
-
const c = r *
|
|
1083
|
-
s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d };
|
|
1091
|
+
const c = r * a, d = r * a;
|
|
1092
|
+
s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, e?.();
|
|
1084
1093
|
};
|
|
1085
1094
|
o();
|
|
1086
1095
|
let i = null;
|
|
@@ -1092,20 +1101,20 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1092
1101
|
const {
|
|
1093
1102
|
config: e,
|
|
1094
1103
|
gamePlayState: { maze: n }
|
|
1095
|
-
} = B(), o =
|
|
1096
|
-
return
|
|
1104
|
+
} = B(), o = O({ cellWidth: 0, cellHeight: 0 });
|
|
1105
|
+
return x(() => {
|
|
1097
1106
|
const i = e.renderConfig.padding, s = () => {
|
|
1098
1107
|
const r = t.current;
|
|
1099
1108
|
if (!r || !n) return;
|
|
1100
|
-
const { rows:
|
|
1101
|
-
if (
|
|
1102
|
-
const d = (r.width - i * 2) / c, u = (r.height - i * 2) /
|
|
1109
|
+
const { rows: a, cols: c } = n;
|
|
1110
|
+
if (a <= 0 || c <= 0) return;
|
|
1111
|
+
const d = (r.width - i * 2) / c, u = (r.height - i * 2) / a;
|
|
1103
1112
|
o.current = { cellWidth: d, cellHeight: u };
|
|
1104
1113
|
};
|
|
1105
1114
|
s();
|
|
1106
|
-
let
|
|
1107
|
-
return t.current && window.ResizeObserver && (
|
|
1108
|
-
t.current &&
|
|
1115
|
+
let l = null;
|
|
1116
|
+
return t.current && window.ResizeObserver && (l = new ResizeObserver(s), l.observe(t.current)), () => {
|
|
1117
|
+
t.current && l?.disconnect();
|
|
1109
1118
|
};
|
|
1110
1119
|
}, [t, n]), o;
|
|
1111
1120
|
}, Z = {
|
|
@@ -1123,43 +1132,43 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1123
1132
|
// player radius in grid unit, default 0.2
|
|
1124
1133
|
onFoodCollected: s
|
|
1125
1134
|
}) => {
|
|
1126
|
-
const
|
|
1127
|
-
const
|
|
1128
|
-
if (!
|
|
1135
|
+
const l = O(!1), r = O(/* @__PURE__ */ new Set()), a = (m, g) => {
|
|
1136
|
+
const _ = e.current;
|
|
1137
|
+
if (!_.maze)
|
|
1129
1138
|
return { canMove: !1, newCell: null };
|
|
1130
|
-
const [
|
|
1139
|
+
const [p, v] = Z[m];
|
|
1131
1140
|
if ($e(
|
|
1132
|
-
p,
|
|
1133
1141
|
g,
|
|
1134
|
-
|
|
1142
|
+
p,
|
|
1143
|
+
v,
|
|
1135
1144
|
i,
|
|
1136
1145
|
o,
|
|
1137
|
-
|
|
1146
|
+
_.maze
|
|
1138
1147
|
))
|
|
1139
1148
|
return { canMove: !1, newCell: null };
|
|
1140
|
-
const { row:
|
|
1141
|
-
return
|
|
1149
|
+
const { row: w, col: b } = g, k = w + p * o, T = b + v * o, z = Math.floor(w), L = Math.floor(b), E = Math.floor(k), N = Math.floor(T);
|
|
1150
|
+
return E !== z || N !== L ? _.maze.isValid(E, N) ? {
|
|
1142
1151
|
canMove: !0,
|
|
1143
|
-
newCell: { row:
|
|
1152
|
+
newCell: { row: E, col: N }
|
|
1144
1153
|
} : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
|
|
1145
1154
|
}, c = () => {
|
|
1146
|
-
const
|
|
1147
|
-
Math.pow(
|
|
1148
|
-
) <
|
|
1149
|
-
|
|
1155
|
+
const m = e.current, { row: g, col: _ } = m.playerCell, p = i * 2, v = m.foodCells.findIndex((b) => Math.sqrt(
|
|
1156
|
+
Math.pow(g - b.row, 2) + Math.pow(_ - b.col, 2)
|
|
1157
|
+
) < p);
|
|
1158
|
+
v !== -1 && s && (s(), e.current = {
|
|
1150
1159
|
...e.current,
|
|
1151
1160
|
foodCollected: e.current.foodCollected + 1,
|
|
1152
1161
|
foodCells: e.current.foodCells.filter(
|
|
1153
|
-
(b, k) => k !==
|
|
1162
|
+
(b, k) => k !== v
|
|
1154
1163
|
)
|
|
1155
1164
|
});
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1165
|
+
const w = en(
|
|
1166
|
+
m.playerCell,
|
|
1167
|
+
m.exitCell,
|
|
1168
|
+
m.maze,
|
|
1160
1169
|
i
|
|
1161
1170
|
);
|
|
1162
|
-
|
|
1171
|
+
w && !e.current.playerAtExit ? (e.current = {
|
|
1163
1172
|
...e.current,
|
|
1164
1173
|
playerAtExit: !0,
|
|
1165
1174
|
isGameActive: !1,
|
|
@@ -1170,21 +1179,21 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1170
1179
|
n(() => ({ ...e.current }));
|
|
1171
1180
|
},
|
|
1172
1181
|
{ timeout: 10 }
|
|
1173
|
-
)) : !
|
|
1182
|
+
)) : !w && e.current.playerAtExit && (e.current = {
|
|
1174
1183
|
...e.current,
|
|
1175
1184
|
playerAtExit: !1,
|
|
1176
1185
|
isGameActive: !0,
|
|
1177
1186
|
levelTransitioning: !1
|
|
1178
1187
|
});
|
|
1179
|
-
}, d = (
|
|
1180
|
-
const
|
|
1181
|
-
if ((
|
|
1182
|
-
const T = `${
|
|
1188
|
+
}, d = (m) => {
|
|
1189
|
+
const g = e.current, _ = Math.round(m.row), p = Math.round(m.col), v = g.playerPath[g.playerPath.length - 1], y = v.row === _ && v.col === p, w = Math.abs(v.row - _), b = Math.abs(v.col - p);
|
|
1190
|
+
if ((w === 1 && b === 0 || w === 0 && b === 1) && !y) {
|
|
1191
|
+
const T = `${v.row},${v.col}-${_},${p}`;
|
|
1183
1192
|
e.current = {
|
|
1184
1193
|
...e.current,
|
|
1185
1194
|
playerPath: [
|
|
1186
1195
|
...e.current.playerPath,
|
|
1187
|
-
{ row:
|
|
1196
|
+
{ row: _, col: p }
|
|
1188
1197
|
],
|
|
1189
1198
|
visitCounts: {
|
|
1190
1199
|
...e.current.visitCounts,
|
|
@@ -1193,75 +1202,75 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1193
1202
|
};
|
|
1194
1203
|
}
|
|
1195
1204
|
}, u = () => {
|
|
1196
|
-
if (
|
|
1197
|
-
const
|
|
1198
|
-
!
|
|
1199
|
-
(
|
|
1200
|
-
const { canMove:
|
|
1201
|
-
|
|
1202
|
-
|
|
1205
|
+
if (l.current || r.current.size === 0) return;
|
|
1206
|
+
const m = e.current;
|
|
1207
|
+
!m.playerCell || !Array.from(r.current).some(
|
|
1208
|
+
(_) => {
|
|
1209
|
+
const { canMove: p } = a(
|
|
1210
|
+
_,
|
|
1211
|
+
m.playerCell
|
|
1203
1212
|
);
|
|
1204
|
-
return
|
|
1213
|
+
return p;
|
|
1205
1214
|
}
|
|
1206
|
-
) || (
|
|
1215
|
+
) || (l.current = !0);
|
|
1207
1216
|
};
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1210
|
-
(
|
|
1211
|
-
},
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
-
},
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
},
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1220
|
-
if (!
|
|
1217
|
+
x(() => {
|
|
1218
|
+
const m = (y) => {
|
|
1219
|
+
(y.key === "ArrowUp" || y.key === "ArrowDown" || y.key === "ArrowLeft" || y.key === "ArrowRight" || y.key === " ") && y.preventDefault();
|
|
1220
|
+
}, g = (y) => {
|
|
1221
|
+
const w = y.key;
|
|
1222
|
+
w in Z && (y.preventDefault(), e.current.isGameActive && (r.current.has(w) || (r.current.add(w), l.current || u())));
|
|
1223
|
+
}, _ = (y) => {
|
|
1224
|
+
const w = y.key;
|
|
1225
|
+
w in Z && (y.preventDefault(), r.current.delete(w), r.current.size === 0 && f());
|
|
1226
|
+
}, p = (y) => {
|
|
1227
|
+
y.preventDefault();
|
|
1228
|
+
const w = e.current;
|
|
1229
|
+
if (!w.isGameActive || !w.maze || l.current)
|
|
1221
1230
|
return;
|
|
1222
|
-
const b =
|
|
1231
|
+
const b = y.touches[0], k = document.elementFromPoint(b.clientX, b.clientY);
|
|
1223
1232
|
let T = null;
|
|
1224
1233
|
k && (k.classList.contains("maze-up") ? T = "ArrowUp" : k.classList.contains("maze-down") ? T = "ArrowDown" : k.classList.contains("maze-left") ? T = "ArrowLeft" : k.classList.contains("maze-right") && (T = "ArrowRight")), T && (r.current.clear(), r.current.add(T), u());
|
|
1225
|
-
},
|
|
1226
|
-
|
|
1234
|
+
}, v = () => {
|
|
1235
|
+
f();
|
|
1227
1236
|
};
|
|
1228
|
-
return window.addEventListener("keydown",
|
|
1237
|
+
return window.addEventListener("keydown", m, {
|
|
1229
1238
|
capture: !0
|
|
1230
|
-
}), window.addEventListener("keydown",
|
|
1239
|
+
}), window.addEventListener("keydown", g), window.addEventListener("keyup", _), t.current?.addEventListener("touchstart", p, {
|
|
1231
1240
|
passive: !1
|
|
1232
|
-
}), t.current?.addEventListener("touchend",
|
|
1233
|
-
window.removeEventListener("keydown",
|
|
1241
|
+
}), t.current?.addEventListener("touchend", v), () => {
|
|
1242
|
+
window.removeEventListener("keydown", m, {
|
|
1234
1243
|
capture: !0
|
|
1235
|
-
}), window.removeEventListener("keydown",
|
|
1244
|
+
}), window.removeEventListener("keydown", g), window.removeEventListener("keyup", _), t.current?.removeEventListener("touchstart", p), t.current?.removeEventListener("touchend", v);
|
|
1236
1245
|
};
|
|
1237
1246
|
}, []);
|
|
1238
1247
|
const h = mt(() => {
|
|
1239
|
-
if (!
|
|
1248
|
+
if (!l.current || r.current.size === 0)
|
|
1240
1249
|
return e.current.playerCell;
|
|
1241
|
-
const
|
|
1242
|
-
let
|
|
1250
|
+
const m = e.current.playerCell;
|
|
1251
|
+
let g = 0, _ = 0, p = 0;
|
|
1243
1252
|
for (const D of r.current) {
|
|
1244
|
-
const { canMove: U } =
|
|
1253
|
+
const { canMove: U } = a(D, m);
|
|
1245
1254
|
if (U) {
|
|
1246
1255
|
const [K, rt] = Z[D];
|
|
1247
|
-
|
|
1256
|
+
g += K, _ += rt, p++;
|
|
1248
1257
|
}
|
|
1249
1258
|
}
|
|
1250
|
-
if (
|
|
1259
|
+
if (p === 0)
|
|
1251
1260
|
return e.current.playerCell;
|
|
1252
|
-
const
|
|
1253
|
-
(
|
|
1261
|
+
const v = Math.sqrt(g * g + _ * _), y = v > 0 ? g / v : 0, w = v > 0 ? _ / v : 0, b = Number(
|
|
1262
|
+
(m.row + y * o).toFixed(2)
|
|
1254
1263
|
), k = Number(
|
|
1255
|
-
(
|
|
1256
|
-
), T = b -
|
|
1257
|
-
if (
|
|
1258
|
-
const D = T /
|
|
1264
|
+
(m.col + w * o).toFixed(2)
|
|
1265
|
+
), T = b - m.row, z = k - m.col, L = Math.sqrt(T * T + z * z);
|
|
1266
|
+
if (L > 0) {
|
|
1267
|
+
const D = T / L, U = z / L;
|
|
1259
1268
|
if ($e(
|
|
1260
|
-
|
|
1269
|
+
m,
|
|
1261
1270
|
D,
|
|
1262
1271
|
U,
|
|
1263
1272
|
i,
|
|
1264
|
-
|
|
1273
|
+
L,
|
|
1265
1274
|
e.current.maze
|
|
1266
1275
|
))
|
|
1267
1276
|
return e.current.playerCell;
|
|
@@ -1270,18 +1279,18 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
|
|
|
1270
1279
|
row: b,
|
|
1271
1280
|
col: k
|
|
1272
1281
|
}, c();
|
|
1273
|
-
const
|
|
1274
|
-
return (P !==
|
|
1275
|
-
}, [o]),
|
|
1276
|
-
|
|
1282
|
+
const E = Math.round(m.row), N = Math.round(m.col), P = Math.round(b), I = Math.round(k);
|
|
1283
|
+
return (P !== E || I !== N) && d({ row: P, col: I }), e.current.playerCell;
|
|
1284
|
+
}, [o]), f = () => {
|
|
1285
|
+
l.current = !1, r.current.clear();
|
|
1277
1286
|
};
|
|
1278
1287
|
return {
|
|
1279
1288
|
updatePlayerPos: h,
|
|
1280
|
-
resetMovingState:
|
|
1289
|
+
resetMovingState: f
|
|
1281
1290
|
};
|
|
1282
1291
|
};
|
|
1283
1292
|
function $e(t, e, n, o, i, s) {
|
|
1284
|
-
const
|
|
1293
|
+
const l = t.row + e * i, r = t.col + n * i, a = { row: l, col: r }, c = [], d = Math.floor(t.row), u = Math.floor(t.col);
|
|
1285
1294
|
c.push({ row: d, col: u });
|
|
1286
1295
|
const h = [
|
|
1287
1296
|
[-1, 0],
|
|
@@ -1301,14 +1310,14 @@ function $e(t, e, n, o, i, s) {
|
|
|
1301
1310
|
[1, 1]
|
|
1302
1311
|
// lower right, diagonal
|
|
1303
1312
|
];
|
|
1304
|
-
for (const [
|
|
1305
|
-
const
|
|
1306
|
-
s.isValid(
|
|
1313
|
+
for (const [f, m] of h) {
|
|
1314
|
+
const g = d + f, _ = u + m;
|
|
1315
|
+
s.isValid(g, _) && c.push({ row: g, col: _ });
|
|
1307
1316
|
}
|
|
1308
|
-
for (const
|
|
1309
|
-
const
|
|
1310
|
-
for (const
|
|
1311
|
-
if (nt(
|
|
1317
|
+
for (const f of c) {
|
|
1318
|
+
const m = Qt(f.row, f.col, s);
|
|
1319
|
+
for (const g of m)
|
|
1320
|
+
if (nt(a, g) < o)
|
|
1312
1321
|
return !0;
|
|
1313
1322
|
}
|
|
1314
1323
|
return !1;
|
|
@@ -1330,98 +1339,104 @@ function Qt(t, e, n) {
|
|
|
1330
1339
|
}), o;
|
|
1331
1340
|
}
|
|
1332
1341
|
function nt(t, e) {
|
|
1333
|
-
const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row,
|
|
1334
|
-
if (
|
|
1335
|
-
return Math.sqrt(
|
|
1342
|
+
const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row, l = t.col - n.col, r = t.row - n.row, a = i * i + s * s;
|
|
1343
|
+
if (a === 0)
|
|
1344
|
+
return Math.sqrt(l * l + r * r);
|
|
1336
1345
|
const c = Math.max(
|
|
1337
1346
|
0,
|
|
1338
1347
|
Math.min(
|
|
1339
1348
|
1,
|
|
1340
|
-
(
|
|
1349
|
+
(l * i + r * s) / a
|
|
1341
1350
|
)
|
|
1342
|
-
), d = n.col + c * i, u = n.row + c * s, h = t.col - d,
|
|
1343
|
-
return Math.sqrt(h * h +
|
|
1351
|
+
), d = n.col + c * i, u = n.row + c * s, h = t.col - d, f = t.row - u;
|
|
1352
|
+
return Math.sqrt(h * h + f * f);
|
|
1344
1353
|
}
|
|
1345
1354
|
function en(t, e, n, o) {
|
|
1346
1355
|
if (Math.sqrt(
|
|
1347
1356
|
Math.pow(t.row - e.row, 2) + Math.pow(t.col - e.col, 2)
|
|
1348
1357
|
) > 1.5 || !n.isValid(e.row, e.col)) return !1;
|
|
1349
1358
|
if (n.grid[e.row][e.col].walls.bottom) {
|
|
1350
|
-
const
|
|
1359
|
+
const l = {
|
|
1351
1360
|
start: { row: e.row + 0.5, col: e.col - 0.5 },
|
|
1352
1361
|
end: { row: e.row + 0.5, col: e.col + 0.5 }
|
|
1353
|
-
}
|
|
1354
|
-
if (nt(
|
|
1362
|
+
}, r = nt(
|
|
1355
1363
|
t,
|
|
1356
|
-
|
|
1357
|
-
)
|
|
1358
|
-
|
|
1364
|
+
l
|
|
1365
|
+
), a = 0.05;
|
|
1366
|
+
if (console.log("Distance between player point to exit wall: ", r), console.log(
|
|
1367
|
+
"collision condition: playerRadius + COLLISION_TOLERANCE: ",
|
|
1368
|
+
o + a
|
|
1369
|
+
), r <= o + a)
|
|
1370
|
+
return console.log("collision true: ", o + a), !0;
|
|
1359
1371
|
}
|
|
1360
1372
|
return !1;
|
|
1361
1373
|
}
|
|
1362
1374
|
function tn(t, e, n, o, i) {
|
|
1363
1375
|
if (!t || !e.maze) return;
|
|
1364
|
-
const { canvasWidth: s, canvasHeight:
|
|
1376
|
+
const { canvasWidth: s, canvasHeight: l } = n, { cellWidth: r, cellHeight: a } = o, {
|
|
1365
1377
|
maze: c,
|
|
1366
1378
|
playerCell: d,
|
|
1367
1379
|
// row, col, but floating allowed
|
|
1368
1380
|
exitCell: u,
|
|
1369
1381
|
foodCells: h,
|
|
1370
|
-
showClue:
|
|
1371
|
-
playerPath:
|
|
1372
|
-
visitCounts:
|
|
1382
|
+
showClue: f,
|
|
1383
|
+
playerPath: m,
|
|
1384
|
+
visitCounts: g
|
|
1373
1385
|
} = e, {
|
|
1374
|
-
padding:
|
|
1375
|
-
wallWidth:
|
|
1386
|
+
padding: _,
|
|
1387
|
+
wallWidth: p,
|
|
1376
1388
|
// need merge with level config when passed here
|
|
1377
|
-
wallColor:
|
|
1378
|
-
playerColor:
|
|
1379
|
-
playerRadius:
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1389
|
+
wallColor: v,
|
|
1390
|
+
playerColor: y,
|
|
1391
|
+
playerRadius: w,
|
|
1392
|
+
foodColor: b,
|
|
1393
|
+
backgroundColor: k,
|
|
1394
|
+
clueColor: T,
|
|
1395
|
+
exitColor: z,
|
|
1396
|
+
exitWallWidth: L,
|
|
1397
|
+
exitDashArray: E
|
|
1384
1398
|
} = i;
|
|
1385
|
-
t.clearRect(0, 0, s,
|
|
1399
|
+
t.clearRect(0, 0, s, l), t.save(), t.fillStyle = k, t.fillRect(0, 0, s, l), t.restore(), f && an({
|
|
1386
1400
|
ctx: t,
|
|
1387
|
-
playerPath:
|
|
1388
|
-
visitCounts:
|
|
1401
|
+
playerPath: m,
|
|
1402
|
+
visitCounts: g,
|
|
1389
1403
|
cellWidth: r,
|
|
1390
|
-
cellHeight:
|
|
1391
|
-
padding:
|
|
1392
|
-
clueColor:
|
|
1404
|
+
cellHeight: a,
|
|
1405
|
+
padding: _,
|
|
1406
|
+
clueColor: T
|
|
1393
1407
|
}), nn({
|
|
1394
1408
|
ctx: t,
|
|
1395
1409
|
maze: c,
|
|
1396
1410
|
cellWidth: r,
|
|
1397
|
-
cellHeight:
|
|
1398
|
-
padding:
|
|
1399
|
-
wallColor:
|
|
1400
|
-
wallWidth:
|
|
1411
|
+
cellHeight: a,
|
|
1412
|
+
padding: _,
|
|
1413
|
+
wallColor: v,
|
|
1414
|
+
wallWidth: p
|
|
1401
1415
|
}), rn({
|
|
1402
1416
|
ctx: t,
|
|
1403
1417
|
maze: c,
|
|
1404
1418
|
exitCell: u,
|
|
1405
1419
|
cellWidth: r,
|
|
1406
|
-
cellHeight:
|
|
1407
|
-
padding:
|
|
1408
|
-
exitColor:
|
|
1409
|
-
|
|
1420
|
+
cellHeight: a,
|
|
1421
|
+
padding: _,
|
|
1422
|
+
exitColor: z,
|
|
1423
|
+
exitWallWidth: L,
|
|
1424
|
+
exitDashArray: E
|
|
1410
1425
|
}), sn({
|
|
1411
1426
|
ctx: t,
|
|
1412
1427
|
foodCells: h,
|
|
1413
1428
|
cellWidth: r,
|
|
1414
|
-
cellHeight:
|
|
1415
|
-
padding:
|
|
1416
|
-
foodColor:
|
|
1429
|
+
cellHeight: a,
|
|
1430
|
+
padding: _,
|
|
1431
|
+
foodColor: b
|
|
1417
1432
|
}), on({
|
|
1418
1433
|
ctx: t,
|
|
1419
1434
|
playerCell: d,
|
|
1420
|
-
playerRadius:
|
|
1435
|
+
playerRadius: w,
|
|
1421
1436
|
cellWidth: r,
|
|
1422
|
-
cellHeight:
|
|
1423
|
-
padding:
|
|
1424
|
-
playerColor:
|
|
1437
|
+
cellHeight: a,
|
|
1438
|
+
padding: _,
|
|
1439
|
+
playerColor: y
|
|
1425
1440
|
});
|
|
1426
1441
|
}
|
|
1427
1442
|
function nn({
|
|
@@ -1431,10 +1446,10 @@ function nn({
|
|
|
1431
1446
|
cellHeight: o,
|
|
1432
1447
|
padding: i,
|
|
1433
1448
|
wallColor: s,
|
|
1434
|
-
wallWidth:
|
|
1449
|
+
wallWidth: l
|
|
1435
1450
|
}) {
|
|
1436
|
-
t.save(), t.strokeStyle = s, t.lineWidth =
|
|
1437
|
-
t.moveTo(
|
|
1451
|
+
t.save(), t.strokeStyle = s, t.lineWidth = l, t.lineCap = "round", t.beginPath(), cn(e, n, o, i).forEach((a) => {
|
|
1452
|
+
t.moveTo(a.x1, a.y1), t.lineTo(a.x2, a.y2);
|
|
1438
1453
|
}), t.stroke(), t.restore();
|
|
1439
1454
|
}
|
|
1440
1455
|
function on({
|
|
@@ -1444,16 +1459,16 @@ function on({
|
|
|
1444
1459
|
cellWidth: o,
|
|
1445
1460
|
cellHeight: i,
|
|
1446
1461
|
padding: s,
|
|
1447
|
-
playerColor:
|
|
1462
|
+
playerColor: l
|
|
1448
1463
|
}) {
|
|
1449
|
-
const { x: r, y:
|
|
1464
|
+
const { x: r, y: a } = ie(
|
|
1450
1465
|
e.row,
|
|
1451
1466
|
e.col,
|
|
1452
1467
|
o,
|
|
1453
1468
|
i,
|
|
1454
1469
|
s
|
|
1455
1470
|
), c = Math.min(o, i) * Math.min(n, 0.5);
|
|
1456
|
-
t.save(), t.fillStyle =
|
|
1471
|
+
t.save(), t.fillStyle = l, t.beginPath(), t.arc(r, a, c, 0, Math.PI * 2), t.fill(), t.restore();
|
|
1457
1472
|
}
|
|
1458
1473
|
function rn({
|
|
1459
1474
|
ctx: t,
|
|
@@ -1462,13 +1477,14 @@ function rn({
|
|
|
1462
1477
|
cellWidth: o,
|
|
1463
1478
|
cellHeight: i,
|
|
1464
1479
|
padding: s,
|
|
1465
|
-
exitColor:
|
|
1466
|
-
|
|
1480
|
+
exitColor: l,
|
|
1481
|
+
exitWallWidth: r,
|
|
1482
|
+
exitDashArray: a = [8, 12]
|
|
1467
1483
|
}) {
|
|
1468
|
-
const { row:
|
|
1469
|
-
if (!e.isValid(
|
|
1470
|
-
const
|
|
1471
|
-
t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r
|
|
1484
|
+
const { row: c, col: d } = n;
|
|
1485
|
+
if (!e.isValid(c, d)) return;
|
|
1486
|
+
const u = e.grid[c][d], h = s + d * o, f = s + c * i;
|
|
1487
|
+
t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.globalCompositeOperation = "source-over", t.strokeStyle = l, t.lineWidth = r, t.setLineDash(a), t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.restore();
|
|
1472
1488
|
}
|
|
1473
1489
|
function sn({
|
|
1474
1490
|
ctx: t,
|
|
@@ -1479,23 +1495,23 @@ function sn({
|
|
|
1479
1495
|
foodColor: s
|
|
1480
1496
|
}) {
|
|
1481
1497
|
t.fillStyle = s;
|
|
1482
|
-
const
|
|
1498
|
+
const l = Math.min(n, o) * 0.25;
|
|
1483
1499
|
e.forEach((r) => {
|
|
1484
|
-
const { x:
|
|
1500
|
+
const { x: a, y: c } = ie(
|
|
1485
1501
|
r.row,
|
|
1486
1502
|
r.col,
|
|
1487
1503
|
n,
|
|
1488
1504
|
o,
|
|
1489
1505
|
i
|
|
1490
1506
|
);
|
|
1491
|
-
ln(t,
|
|
1507
|
+
ln(t, a, c, l * 1.2, 5, l * 0.6);
|
|
1492
1508
|
});
|
|
1493
1509
|
}
|
|
1494
1510
|
function ln(t, e, n, o, i, s) {
|
|
1495
1511
|
t.save(), t.beginPath();
|
|
1496
|
-
for (let
|
|
1497
|
-
const r =
|
|
1498
|
-
t.lineTo(e + r * Math.sin(
|
|
1512
|
+
for (let l = 0; l < i * 2; l++) {
|
|
1513
|
+
const r = l % 2 === 0 ? o : s, a = Math.PI * l / i;
|
|
1514
|
+
t.lineTo(e + r * Math.sin(a), n + r * Math.cos(a));
|
|
1499
1515
|
}
|
|
1500
1516
|
t.closePath(), t.fill(), t.restore();
|
|
1501
1517
|
}
|
|
@@ -1506,32 +1522,32 @@ function an({
|
|
|
1506
1522
|
cellWidth: o,
|
|
1507
1523
|
cellHeight: i,
|
|
1508
1524
|
padding: s,
|
|
1509
|
-
clueColor:
|
|
1525
|
+
clueColor: l
|
|
1510
1526
|
}) {
|
|
1511
1527
|
if (!(!e || e.length < 2 || !n)) {
|
|
1512
1528
|
t.save();
|
|
1513
1529
|
for (let r = 1; r < e.length; r++) {
|
|
1514
|
-
const
|
|
1530
|
+
const a = e[r - 1], c = e[r], d = `${a.row},${a.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${a.row},${a.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), m = Math.max(3, o * 0.1) + h * 0.5;
|
|
1515
1531
|
try {
|
|
1516
|
-
t.strokeStyle =
|
|
1532
|
+
t.strokeStyle = l.replace(")", `, ${f})`).replace("rgb(", "rgba(");
|
|
1517
1533
|
} catch {
|
|
1518
|
-
t.strokeStyle = `rgba(255, 0, 0, ${
|
|
1534
|
+
t.strokeStyle = `rgba(255, 0, 0, ${f})`;
|
|
1519
1535
|
}
|
|
1520
|
-
t.lineWidth =
|
|
1521
|
-
const { x:
|
|
1522
|
-
|
|
1523
|
-
|
|
1536
|
+
t.lineWidth = m, t.lineCap = "round", t.lineJoin = "round";
|
|
1537
|
+
const { x: g, y: _ } = ie(
|
|
1538
|
+
a.row,
|
|
1539
|
+
a.col,
|
|
1524
1540
|
o,
|
|
1525
1541
|
i,
|
|
1526
1542
|
s
|
|
1527
|
-
), { x:
|
|
1543
|
+
), { x: p, y: v } = ie(
|
|
1528
1544
|
c.row,
|
|
1529
1545
|
c.col,
|
|
1530
1546
|
o,
|
|
1531
1547
|
i,
|
|
1532
1548
|
s
|
|
1533
1549
|
);
|
|
1534
|
-
t.beginPath(), t.moveTo(
|
|
1550
|
+
t.beginPath(), t.moveTo(g, _), t.lineTo(p, v), t.stroke();
|
|
1535
1551
|
}
|
|
1536
1552
|
t.restore();
|
|
1537
1553
|
}
|
|
@@ -1539,27 +1555,27 @@ function an({
|
|
|
1539
1555
|
function cn(t, e, n, o) {
|
|
1540
1556
|
const i = [];
|
|
1541
1557
|
for (let s = 0; s < t.rows; s++)
|
|
1542
|
-
for (let
|
|
1543
|
-
const r = t.grid[s][
|
|
1558
|
+
for (let l = 0; l < t.cols; l++) {
|
|
1559
|
+
const r = t.grid[s][l], a = o + l * e, c = o + s * n;
|
|
1544
1560
|
r.walls.top && i.push({
|
|
1545
|
-
x1:
|
|
1561
|
+
x1: a,
|
|
1546
1562
|
y1: c,
|
|
1547
|
-
x2:
|
|
1563
|
+
x2: a + e,
|
|
1548
1564
|
y2: c
|
|
1549
1565
|
}), r.walls.right && i.push({
|
|
1550
|
-
x1:
|
|
1566
|
+
x1: a + e,
|
|
1551
1567
|
y1: c,
|
|
1552
|
-
x2:
|
|
1568
|
+
x2: a + e,
|
|
1553
1569
|
y2: c + n
|
|
1554
1570
|
}), r.walls.bottom && i.push({
|
|
1555
|
-
x1:
|
|
1571
|
+
x1: a,
|
|
1556
1572
|
y1: c + n,
|
|
1557
|
-
x2:
|
|
1573
|
+
x2: a + e,
|
|
1558
1574
|
y2: c + n
|
|
1559
1575
|
}), r.walls.left && i.push({
|
|
1560
|
-
x1:
|
|
1576
|
+
x1: a,
|
|
1561
1577
|
y1: c,
|
|
1562
|
-
x2:
|
|
1578
|
+
x2: a,
|
|
1563
1579
|
y2: c + n
|
|
1564
1580
|
});
|
|
1565
1581
|
}
|
|
@@ -1631,8 +1647,8 @@ class hn {
|
|
|
1631
1647
|
// Left
|
|
1632
1648
|
];
|
|
1633
1649
|
for (const s of i) {
|
|
1634
|
-
const
|
|
1635
|
-
this.isValid(
|
|
1650
|
+
const l = e + s.r, r = n + s.c;
|
|
1651
|
+
this.isValid(l, r) && o.push({ row: l, col: r });
|
|
1636
1652
|
}
|
|
1637
1653
|
return o;
|
|
1638
1654
|
}
|
|
@@ -1652,8 +1668,8 @@ class hn {
|
|
|
1652
1668
|
}
|
|
1653
1669
|
// Remove the wall between two adjacent cells
|
|
1654
1670
|
removeWall(e, n, o, i) {
|
|
1655
|
-
const s = this.grid[e][n],
|
|
1656
|
-
e === o + 1 ? (s.walls.top = !1,
|
|
1671
|
+
const s = this.grid[e][n], l = this.grid[o][i];
|
|
1672
|
+
e === o + 1 ? (s.walls.top = !1, l.walls.bottom = !1) : e === o - 1 ? (s.walls.bottom = !1, l.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, l.walls.right = !1) : n === i - 1 && (s.walls.right = !1, l.walls.left = !1);
|
|
1657
1673
|
}
|
|
1658
1674
|
// --- Generation Methods ---
|
|
1659
1675
|
/**
|
|
@@ -1682,28 +1698,28 @@ class hn {
|
|
|
1682
1698
|
let i = { row: n, col: o };
|
|
1683
1699
|
for (this.grid[n][o].visited = !0, e.push(i); e.length > 0; ) {
|
|
1684
1700
|
i = e[e.length - 1];
|
|
1685
|
-
const { row: s, col:
|
|
1701
|
+
const { row: s, col: l } = i, r = this.getUnvisitedNeighbors(s, l);
|
|
1686
1702
|
if (r.length > 0) {
|
|
1687
|
-
const
|
|
1688
|
-
this.removeWall(s,
|
|
1703
|
+
const a = this.randomPick(r), { row: c, col: d } = a;
|
|
1704
|
+
this.removeWall(s, l, c, d), this.grid[c][d].visited = !0, e.push(a);
|
|
1689
1705
|
} else
|
|
1690
1706
|
e.pop();
|
|
1691
1707
|
}
|
|
1692
1708
|
}
|
|
1693
1709
|
// --- Prim's Algorithm Implementation ---
|
|
1694
1710
|
generateWithPrims() {
|
|
1695
|
-
const e = [], n = (s,
|
|
1696
|
-
const r = this.getNeighbors(s,
|
|
1697
|
-
for (const
|
|
1698
|
-
!this.grid[
|
|
1699
|
-
(c) => c.row ===
|
|
1700
|
-
) && e.push(
|
|
1711
|
+
const e = [], n = (s, l) => {
|
|
1712
|
+
const r = this.getNeighbors(s, l);
|
|
1713
|
+
for (const a of r)
|
|
1714
|
+
!this.grid[a.row][a.col].visited && !e.some(
|
|
1715
|
+
(c) => c.row === a.row && c.col === a.col
|
|
1716
|
+
) && e.push(a);
|
|
1701
1717
|
}, o = this.randomNumber(this.rows), i = this.randomNumber(this.cols);
|
|
1702
1718
|
for (this.grid[o][i].visited = !0, n(o, i); e.length > 0; ) {
|
|
1703
|
-
const s = this.randomNumber(e.length),
|
|
1719
|
+
const s = this.randomNumber(e.length), l = e[s], { row: r, col: a } = l, c = this.getVisitedNeighbors(r, a);
|
|
1704
1720
|
if (c.length > 0) {
|
|
1705
1721
|
const d = this.randomPick(c);
|
|
1706
|
-
this.removeWall(r,
|
|
1722
|
+
this.removeWall(r, a, d.row, d.col), this.grid[r][a].visited = !0, n(r, a);
|
|
1707
1723
|
}
|
|
1708
1724
|
e.splice(s, 1);
|
|
1709
1725
|
}
|
|
@@ -1728,26 +1744,26 @@ class hn {
|
|
|
1728
1744
|
return e[Math.floor(this.random() * e.length)];
|
|
1729
1745
|
}
|
|
1730
1746
|
}
|
|
1731
|
-
const
|
|
1747
|
+
const fn = (t, e, n) => {
|
|
1732
1748
|
if (!t.isValid(e, n)) return !1;
|
|
1733
1749
|
const o = t.grid[e][n];
|
|
1734
1750
|
return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
|
|
1735
|
-
},
|
|
1751
|
+
}, _n = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, mn = (t, e) => {
|
|
1736
1752
|
if (!e)
|
|
1737
1753
|
return console.error(`Cannot find Level ${t}'s config.`), null;
|
|
1738
|
-
const { size: n, seed: o, method: i, entry: s, exit:
|
|
1754
|
+
const { size: n, seed: o, method: i, entry: s, exit: l } = e, r = n, a = n, c = s || { row: 0, col: 0 }, d = l || {
|
|
1739
1755
|
row: r - 1,
|
|
1740
|
-
col:
|
|
1741
|
-
}, u = new hn(r,
|
|
1742
|
-
for (let
|
|
1743
|
-
let
|
|
1756
|
+
col: a - 1
|
|
1757
|
+
}, u = new hn(r, a, i, o, s), h = _n(t), f = [];
|
|
1758
|
+
for (let m = 0; m < h; m++) {
|
|
1759
|
+
let g;
|
|
1744
1760
|
do
|
|
1745
|
-
|
|
1761
|
+
g = {
|
|
1746
1762
|
row: Math.floor(u.random() * r),
|
|
1747
|
-
col: Math.floor(u.random() *
|
|
1763
|
+
col: Math.floor(u.random() * a)
|
|
1748
1764
|
};
|
|
1749
|
-
while (
|
|
1750
|
-
|
|
1765
|
+
while (g.row === c.row && g.col === c.col || g.row === d.row && g.col === d.col || !fn(u, g.row, g.col) || f.some((_) => _.row === g.row && _.col === g.col));
|
|
1766
|
+
f.push(g);
|
|
1751
1767
|
}
|
|
1752
1768
|
return {
|
|
1753
1769
|
isGameActive: !0,
|
|
@@ -1755,7 +1771,7 @@ const _n = (t, e, n) => {
|
|
|
1755
1771
|
maze: u,
|
|
1756
1772
|
playerCell: c,
|
|
1757
1773
|
exitCell: d,
|
|
1758
|
-
foodCells:
|
|
1774
|
+
foodCells: f,
|
|
1759
1775
|
playerAtExit: !1,
|
|
1760
1776
|
foodCollected: 0,
|
|
1761
1777
|
totalFoodCount: h,
|
|
@@ -1765,83 +1781,95 @@ const _n = (t, e, n) => {
|
|
|
1765
1781
|
};
|
|
1766
1782
|
};
|
|
1767
1783
|
function vn() {
|
|
1768
|
-
const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = B(), i =
|
|
1784
|
+
const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = B(), i = O(null), s = O(null), l = O(null), { i18n: r, levelConfig: a, renderConfig: c } = o, d = X(a), u = O(
|
|
1769
1785
|
d.getLevelConfig(n.currentLevel)
|
|
1770
1786
|
);
|
|
1771
|
-
|
|
1787
|
+
x(() => {
|
|
1772
1788
|
i.current && R.attachTo(i.current);
|
|
1773
1789
|
}, []);
|
|
1774
|
-
const h =
|
|
1775
|
-
|
|
1790
|
+
const h = O(), f = Kt(l, () => {
|
|
1791
|
+
h.current?.();
|
|
1792
|
+
}), m = Jt(l);
|
|
1793
|
+
x(() => {
|
|
1776
1794
|
u.current = d.getLevelConfig(
|
|
1777
1795
|
n.currentLevel
|
|
1778
1796
|
);
|
|
1779
1797
|
}, [n.currentLevel]);
|
|
1780
|
-
const
|
|
1781
|
-
const
|
|
1798
|
+
const g = () => {
|
|
1799
|
+
const y = mn(
|
|
1782
1800
|
n.currentLevel,
|
|
1783
1801
|
u.current
|
|
1784
1802
|
);
|
|
1785
|
-
|
|
1803
|
+
y && t((w) => ({
|
|
1786
1804
|
...w,
|
|
1787
|
-
...
|
|
1805
|
+
...y
|
|
1788
1806
|
}));
|
|
1789
1807
|
};
|
|
1790
|
-
|
|
1791
|
-
|
|
1808
|
+
x(() => {
|
|
1809
|
+
g();
|
|
1792
1810
|
}, [n.currentLevel]);
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1795
|
-
}, { updatePlayerPos:
|
|
1811
|
+
const _ = () => {
|
|
1812
|
+
g();
|
|
1813
|
+
}, { updatePlayerPos: p, resetMovingState: v } = Zt({
|
|
1796
1814
|
containerRef: s,
|
|
1797
1815
|
gamePlayStateRef: e,
|
|
1798
1816
|
setGamePlayState: t,
|
|
1799
1817
|
playerRadius: c.playerRadius,
|
|
1800
1818
|
moveSpeed: c.gridMoveSpeed,
|
|
1801
1819
|
onFoodCollected: () => {
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1804
|
-
r.foodCollectedToast.replace("%NUM%",
|
|
1820
|
+
const y = e.current.totalFoodCount - e.current.foodCollected - 1;
|
|
1821
|
+
y > 0 ? R.show(
|
|
1822
|
+
r.foodCollectedToast.replace("%NUM%", y.toString()),
|
|
1805
1823
|
"success",
|
|
1806
1824
|
3e3
|
|
1807
1825
|
) : R.show(r.allFoodCollectedToast, "success");
|
|
1808
1826
|
}
|
|
1809
1827
|
});
|
|
1810
|
-
return
|
|
1811
|
-
|
|
1812
|
-
}, [n.currentLevel,
|
|
1813
|
-
let
|
|
1814
|
-
const
|
|
1815
|
-
const
|
|
1816
|
-
if (!(w &&
|
|
1817
|
-
|
|
1828
|
+
return x(() => {
|
|
1829
|
+
v();
|
|
1830
|
+
}, [n.currentLevel, v]), x(() => {
|
|
1831
|
+
let y, w = !document.hidden;
|
|
1832
|
+
const b = () => {
|
|
1833
|
+
const z = l.current?.getContext("2d"), L = e.current;
|
|
1834
|
+
if (!(w && L?.isGameActive && z && L?.maze)) {
|
|
1835
|
+
y = requestAnimationFrame(b);
|
|
1818
1836
|
return;
|
|
1819
1837
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1838
|
+
p(), k(), y = requestAnimationFrame(b);
|
|
1839
|
+
}, k = () => {
|
|
1840
|
+
const z = l.current?.getContext("2d"), L = e.current;
|
|
1841
|
+
if (z && L?.maze) {
|
|
1842
|
+
const E = u.current?.wallWidth || c?.wallWidth, N = u.current?.exitColor || c?.exitColor, P = u.current?.exitWallWidth || c?.exitWallWidth, I = u.current?.exitDashArray || c?.exitDashArray;
|
|
1843
|
+
tn(z, L, f.current, m.current, {
|
|
1844
|
+
...c,
|
|
1845
|
+
wallWidth: E,
|
|
1846
|
+
exitColor: N,
|
|
1847
|
+
exitWallWidth: P,
|
|
1848
|
+
exitDashArray: I
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
h.current = k;
|
|
1853
|
+
const T = (z) => {
|
|
1854
|
+
const L = w;
|
|
1855
|
+
w = !document.hidden && document.visibilityState === "visible" && (!z || z.type !== "blur"), !L && w ? e.current?.levelTransitioning === !1 && t({
|
|
1828
1856
|
...e.current,
|
|
1829
1857
|
isGameActive: !0
|
|
1830
|
-
}) :
|
|
1858
|
+
}) : L && !w && t({
|
|
1831
1859
|
...e.current,
|
|
1832
1860
|
isGameActive: !1
|
|
1833
1861
|
});
|
|
1834
1862
|
};
|
|
1835
|
-
return document.addEventListener("visibilitychange",
|
|
1836
|
-
cancelAnimationFrame(
|
|
1863
|
+
return document.addEventListener("visibilitychange", T), window.addEventListener("blur", T), window.addEventListener("focus", T), y = requestAnimationFrame(b), () => {
|
|
1864
|
+
cancelAnimationFrame(y), document.removeEventListener("visibilitychange", T), window.removeEventListener("blur", T), window.removeEventListener("focus", T);
|
|
1837
1865
|
};
|
|
1838
|
-
}, []),
|
|
1866
|
+
}, []), x(() => {
|
|
1839
1867
|
R.show(r.useArrowKeyTips, "info", 3e3);
|
|
1840
1868
|
}, []), /* @__PURE__ */ C("div", { className: "maze-game-container", ref: i, children: [
|
|
1841
1869
|
/* @__PURE__ */ C(kt, {}),
|
|
1842
|
-
/* @__PURE__ */ C(Xt, { onRetry:
|
|
1870
|
+
/* @__PURE__ */ C(Xt, { onRetry: _ }),
|
|
1843
1871
|
/* @__PURE__ */ C("div", { className: "maze-canvas-container", ref: s, children: [
|
|
1844
|
-
/* @__PURE__ */ C("canvas", { ref:
|
|
1872
|
+
/* @__PURE__ */ C("canvas", { ref: l, className: "maze-game-canvas" }),
|
|
1845
1873
|
/* @__PURE__ */ C("div", { className: "maze-touch-area maze-up" }),
|
|
1846
1874
|
/* @__PURE__ */ C("div", { className: "maze-touch-area maze-down" }),
|
|
1847
1875
|
/* @__PURE__ */ C("div", { className: "maze-touch-area maze-left" }),
|
|
@@ -1852,9 +1880,31 @@ function vn() {
|
|
|
1852
1880
|
const ot = [
|
|
1853
1881
|
// Tier 1 (Levels 1-12) - Beginner
|
|
1854
1882
|
[
|
|
1855
|
-
|
|
1883
|
+
// debug
|
|
1884
|
+
// {
|
|
1885
|
+
// size: 38,
|
|
1886
|
+
// seed: 1248,
|
|
1887
|
+
// method: 'backtracking',
|
|
1888
|
+
// wallWidth: 1,
|
|
1889
|
+
// exitWallWidth: 3,
|
|
1890
|
+
// },
|
|
1891
|
+
{
|
|
1892
|
+
size: 8,
|
|
1893
|
+
seed: 12345,
|
|
1894
|
+
method: "backtracking",
|
|
1895
|
+
wallWidth: 4,
|
|
1896
|
+
exitWallWidth: 6,
|
|
1897
|
+
exitDashArray: [8, 12]
|
|
1898
|
+
},
|
|
1856
1899
|
// Level 1 - Very easy, small maze
|
|
1857
|
-
{
|
|
1900
|
+
{
|
|
1901
|
+
size: 8,
|
|
1902
|
+
seed: 23456,
|
|
1903
|
+
method: "backtracking",
|
|
1904
|
+
exitColor: "#33f",
|
|
1905
|
+
exitWallWidth: 4,
|
|
1906
|
+
exitDashArray: [8, 16]
|
|
1907
|
+
},
|
|
1858
1908
|
// Level 2 - Very easy
|
|
1859
1909
|
{ size: 8, seed: 34567, method: "prims" },
|
|
1860
1910
|
// Level 3 - Very easy
|
|
@@ -2032,16 +2082,21 @@ const ot = [
|
|
|
2032
2082
|
padding: 10,
|
|
2033
2083
|
wallWidth: 2,
|
|
2034
2084
|
wallColor: "#000000",
|
|
2035
|
-
exitColor: "#F44336",
|
|
2036
2085
|
foodColor: "#4CAF50",
|
|
2037
2086
|
clueColor: "rgb(255,0,0)",
|
|
2038
2087
|
backgroundColor: "#ffffff",
|
|
2039
2088
|
playerColor: "#4CAF50",
|
|
2040
|
-
playerRadius: 0.2
|
|
2089
|
+
playerRadius: 0.2,
|
|
2090
|
+
// Exit
|
|
2091
|
+
exitColor: "#F44336",
|
|
2092
|
+
exitWallWidth: 4,
|
|
2093
|
+
// default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
|
|
2094
|
+
exitDashArray: [8, 12]
|
|
2095
|
+
// default dash: 8px dash, 12px gap
|
|
2041
2096
|
},
|
|
2042
2097
|
levelConfig: ot
|
|
2043
2098
|
};
|
|
2044
|
-
function
|
|
2099
|
+
function gn({ config: t = {} }) {
|
|
2045
2100
|
const e = { ...oe.i18n, ...t.i18n || {} }, n = {
|
|
2046
2101
|
...oe.renderConfig,
|
|
2047
2102
|
...t.renderConfig || {}
|
|
@@ -2054,18 +2109,18 @@ function pn({ config: t = {} }) {
|
|
|
2054
2109
|
};
|
|
2055
2110
|
return /* @__PURE__ */ C(wt, { config: i, children: /* @__PURE__ */ C(vn, {}) });
|
|
2056
2111
|
}
|
|
2057
|
-
const
|
|
2058
|
-
root: "https://unpkg.com/@roudanio/maze@0.0
|
|
2112
|
+
const pn = {
|
|
2113
|
+
root: "https://unpkg.com/@roudanio/maze@0.1.0/dist/",
|
|
2059
2114
|
...oe
|
|
2060
2115
|
};
|
|
2061
|
-
`${JSON.stringify(
|
|
2116
|
+
`${JSON.stringify(pn, null, 2)}`;
|
|
2062
2117
|
const Cn = {
|
|
2063
2118
|
async init(t, e) {
|
|
2064
2119
|
const n = typeof t == "string" ? document.querySelector(t) : t;
|
|
2065
2120
|
if (!n) {
|
|
2066
2121
|
console.warn("Cannot find the root element");
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2122
|
+
const a = document.createElement("div");
|
|
2123
|
+
a.style.textAlign = "center", a.style.padding = "20px", a.innerHTML = "Cannot find the root element", document.body.append(a);
|
|
2069
2124
|
return;
|
|
2070
2125
|
}
|
|
2071
2126
|
let { root: o = location.origin } = e;
|
|
@@ -2084,15 +2139,15 @@ const Cn = {
|
|
|
2084
2139
|
transition: width 1.5s ease-in-out;
|
|
2085
2140
|
transition: width 1.5s ease-in-out;
|
|
2086
2141
|
`, i.append(s), n.append(i);
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2142
|
+
const l = document.createElement("style");
|
|
2143
|
+
l.innerHTML = `
|
|
2089
2144
|
@keyframes loading {
|
|
2090
2145
|
0% { width: 0%; }
|
|
2091
2146
|
100% { width: 99%; }
|
|
2092
|
-
}`, document.head.appendChild(
|
|
2147
|
+
}`, document.head.appendChild(l), await (async (a) => new Promise((c, d) => {
|
|
2093
2148
|
const u = document.createElement("link");
|
|
2094
|
-
u.rel = "stylesheet", u.type = "text/css", u.href =
|
|
2095
|
-
}))(o + "maze.css"), dt(/* @__PURE__ */ C(
|
|
2149
|
+
u.rel = "stylesheet", u.type = "text/css", u.href = a, u.onload = c, u.onerror = d, document.head.appendChild(u);
|
|
2150
|
+
}))(o + "maze.css"), dt(/* @__PURE__ */ C(gn, { config: e }), n);
|
|
2096
2151
|
}
|
|
2097
2152
|
};
|
|
2098
2153
|
export {
|