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