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