diff --git a/assets/index-JRuigLSK.js b/assets/index-NI7xsO7L.js similarity index 57% rename from assets/index-JRuigLSK.js rename to assets/index-NI7xsO7L.js index 2966d64..f319e65 100644 --- a/assets/index-JRuigLSK.js +++ b/assets/index-NI7xsO7L.js @@ -1,4 +1,4 @@ -(function(){const _=document.createElement("link").relList;if(_&&_.supports&&_.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function t(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerPolicy&&(r.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?r.credentials="include":o.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(o){if(o.ep)return;o.ep=!0;const r=t(o);fetch(o.href,r)}})();var K,a,we,H,ue,Ee,Z,D={},Ae=[],Ue=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function P(e,_){for(var t in _)e[t]=_[t];return e}function $e(e){var _=e.parentNode;_&&_.removeChild(e)}function Oe(e,_,t){var n,o,r,s={};for(r in _)r=="key"?n=_[r]:r=="ref"?o=_[r]:s[r]=_[r];if(arguments.length>2&&(s.children=arguments.length>3?K.call(arguments,2):t),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)s[r]===void 0&&(s[r]=e.defaultProps[r]);return V(e,s,n,o,null)}function V(e,_,t,n,o){var r={type:e,props:_,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o??++we,__i:-1,__u:0};return o==null&&a.vnode!=null&&a.vnode(r),r}function U(e){return e.children}function W(e,_){this.props=e,this.context=_}function L(e,_){if(_==null)return e.__?L(e.__,e.__i+1):null;for(var t;__&&H.sort(Z));B.__r=0}function He(e,_,t,n,o,r,s,l,u,c,p){var i,d,f,v,k,m=n&&n.__k||Ae,h=_.length;for(t.__d=u,Ie(t,_,m),u=t.__d,i=0;i0?V(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)!=null?(o.__=e,o.__b=e.__b+1,l=Re(o,t,s=n+i,p),o.__i=l,r=null,l!==-1&&(p--,(r=t[l])&&(r.__u|=131072)),r==null||r.__v===null?(l==-1&&i--,typeof o.type!="function"&&(o.__u|=65536)):l!==s&&(l===s+1?i++:l>s?p>u-s?i+=l-s:i--:i=l(u!=null&&!(131072&u.__u)?1:0))for(;s>=0||l<_.length;){if(s>=0){if((u=_[s])&&!(131072&u.__u)&&o==u.key&&r===u.type)return s;s--}if(l<_.length){if((u=_[l])&&!(131072&u.__u)&&o==u.key&&r===u.type)return l;l++}}return-1}function ae(e,_,t){_[0]==="-"?e.setProperty(_,t??""):e[_]=t==null?"":typeof t!="number"||Ue.test(_)?t:t+"px"}function F(e,_,t,n,o){var r;e:if(_==="style")if(typeof t=="string")e.style.cssText=t;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(_ in n)t&&_ in t||ae(e.style,_,"");if(t)for(_ in t)n&&t[_]===n[_]||ae(e.style,_,t[_])}else if(_[0]==="o"&&_[1]==="n")r=_!==(_=_.replace(/(PointerCapture)$|Capture$/,"$1")),_=_.toLowerCase()in e?_.toLowerCase().slice(2):_.slice(2),e.l||(e.l={}),e.l[_+r]=t,t?n?t.u=n.u:(t.u=Date.now(),e.addEventListener(_,r?de:pe,r)):e.removeEventListener(_,r?de:pe,r);else{if(o)_=_.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(_!=="width"&&_!=="height"&&_!=="href"&&_!=="list"&&_!=="form"&&_!=="tabIndex"&&_!=="download"&&_!=="rowSpan"&&_!=="colSpan"&&_!=="role"&&_ in e)try{e[_]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&_[4]!=="-"?e.removeAttribute(_):e.setAttribute(_,t))}}function pe(e){var _=this.l[e.type+!1];if(e.t){if(e.t<=_.u)return}else e.t=Date.now();return _(a.event?a.event(e):e)}function de(e){return this.l[e.type+!0](a.event?a.event(e):e)}function le(e,_,t,n,o,r,s,l,u,c){var p,i,d,f,v,k,m,h,g,$,O,S,ce,I,z,b=_.type;if(_.constructor!==void 0)return null;128&t.__u&&(u=!!(32&t.__u),r=[l=_.__e=t.__e]),(p=a.__b)&&p(_);e:if(typeof b=="function")try{if(h=_.props,g=(p=b.contextType)&&n[p.__c],$=p?g?g.props.value:p.__:n,t.__c?m=(i=_.__c=t.__c).__=i.__E:("prototype"in b&&b.prototype.render?_.__c=i=new b(h,$):(_.__c=i=new W(h,$),i.constructor=b,i.render=Ve),g&&g.sub(i),i.props=h,i.state||(i.state={}),i.context=$,i.__n=n,d=i.__d=!0,i.__h=[],i._sb=[]),i.__s==null&&(i.__s=i.state),b.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=P({},i.__s)),P(i.__s,b.getDerivedStateFromProps(h,i.__s))),f=i.props,v=i.state,i.__v=_,d)b.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(b.getDerivedStateFromProps==null&&h!==f&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(h,$),!i.__e&&(i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(h,i.__s,$)===!1||_.__v===t.__v)){for(_.__v!==t.__v&&(i.props=h,i.state=i.__s,i.__d=!1),_.__e=t.__e,_.__k=t.__k,_.__k.forEach(function(R){R&&(R.__=_)}),O=0;O=t.__.length&&t.__.push({__V:Y}),t.__[e]}function Ye(e){return _e=1,qe(Ce,e)}function qe(e,_,t){var n=Te(G++,2);if(n.t=e,!n.__c&&(n.__=[t?t(_):Ce(void 0,_),function(l){var u=n.__N?n.__N[0]:n.__[0],c=n.t(u,l);u!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=y,!y.u)){var o=function(l,u,c){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(d){return d.__c});if(p.every(function(d){return!d.__N}))return!r||r.call(this,l,u,c);var i=!1;return p.forEach(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(i=!0)}}),!(!i&&n.__c.props===l)&&(!r||r.call(this,l,u,c))};y.u=!0;var r=y.shouldComponentUpdate,s=y.componentWillUpdate;y.componentWillUpdate=function(l,u,c){if(this.__e){var p=r;r=void 0,o(l,u,c),r=p}s&&s.call(this,l,u,c)},y.shouldComponentUpdate=o}return n.__N||n.__}function Be(e,_){var t=Te(G++,3);!a.__s&&Xe(t.__H,_)&&(t.__=e,t.i=_,y.__H.__h.push(t))}function Ge(){for(var e;e=Ne.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(q),e.__H.__h.forEach(te),e.__H.__h=[]}catch(_){e.__H.__h=[],a.__e(_,e.__v)}}a.__b=function(e){y=null,ye&&ye(e)},a.__r=function(e){ve&&ve(e),G=0;var _=(y=e.__c).__H;_&&(J===y?(_.__h=[],y.__h=[],_.__.forEach(function(t){t.__N&&(t.__=t.__N),t.__V=Y,t.__N=t.i=void 0})):(_.__h.forEach(q),_.__h.forEach(te),_.__h=[],G=0)),J=y},a.diffed=function(e){me&&me(e);var _=e.__c;_&&_.__H&&(_.__H.__h.length&&(Ne.push(_)!==1&&he===a.requestAnimationFrame||((he=a.requestAnimationFrame)||Ke)(Ge)),_.__H.__.forEach(function(t){t.i&&(t.__H=t.i),t.__V!==Y&&(t.__=t.__V),t.i=void 0,t.__V=Y})),J=y=null},a.__c=function(e,_){_.some(function(t){try{t.__h.forEach(q),t.__h=t.__h.filter(function(n){return!n.__||te(n)})}catch(n){_.some(function(o){o.__h&&(o.__h=[])}),_=[],a.__e(n,t.__v)}}),ge&&ge(e,_)},a.unmount=function(e){be&&be(e);var _,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(n){try{q(n)}catch(o){_=o}}),t.__H=void 0,_&&a.__e(_,t.__v))};var xe=typeof requestAnimationFrame=="function";function Ke(e){var _,t=function(){clearTimeout(n),xe&&cancelAnimationFrame(_),setTimeout(e)},n=setTimeout(t,100);xe&&(_=requestAnimationFrame(t))}function q(e){var _=y,t=e.__c;typeof t=="function"&&(e.__c=void 0,t()),y=_}function te(e){var _=y;e.__c=e.__(),y=_}function Xe(e,_){return!e||e.length!==_.length||_.some(function(t,n){return t!==e[n]})}function Ce(e,_){return typeof _=="function"?_(e):_}const T=15,C=15;var ne=(e=>(e[e.PLAYING=0]="PLAYING",e[e.VICTORY=1]="VICTORY",e[e.GAME_OVER=2]="GAME_OVER",e))(ne||{});const Q=10,X=[],N=[];let x;const w=[];let oe;const M={};let j=0;function je(){ze();for(let e=0;e.8?_.push("#"):_.push(".");X.push(_)}}function Se(){for(let e=0;e0&&(N[w[e].y][w[e].x]="e")}function Qe(e,_){return e.x+_.x>=0&&e.x+_.x<=C-1&&e.y+_.y>=0&&e.y+_.y<=T-1&&X[e.y+_.y][e.x+_.x]==="."}function A(e,_){if(!Qe(e,_))return!1;const t=e.y+_.y+"_"+(e.x+_.x),n=M[t];return n?(n.hp--,n.hp===0&&(M[t]=null,w.splice(w.indexOf(n),1),n!=x&&(oe--,oe===0&&(j=1)))):(M[e.y+"_"+e.x]=null,e.y+=_.y,e.x+=_.x,M[e.y+"_"+e.x]=e),!0}function ke(e){Se();let _=!1;switch(e.key){case"ArrowLeft":_=A(x,{x:-1,y:0});break;case"ArrowRight":_=A(x,{x:1,y:0});break;case"ArrowUp":_=A(x,{x:0,y:-1});break;case"ArrowDown":_=A(x,{x:0,y:1});break}if(_)for(const t in w){const n=w[t];n!=null&&Ze(n)}return De(),{map:[...N],state:j}}function Ze(e){const _=[{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}],t=x.x-e.x,n=x.y-e.y;if(Math.abs(t)+Math.abs(n)>6){let o=!1;do o=A(e,_[re(_.length)]);while(!o)}Math.abs(t)>Math.abs(n)?t<0?A(e,_[0]):A(e,_[1]):n<0?A(e,_[2]):A(e,_[3]),x.hp<1&&(j=2)}const e_=(e,_)=>{const t=e;let n=0,o=0,r=0,s=0;t.addEventListener("touchstart",function(l){n=l.changedTouches[0].pageX,o=l.changedTouches[0].pageY}),t.addEventListener("touchmove",function(l){l.preventDefault()}),t.addEventListener("touchend",function(l){r=l.changedTouches[0].pageX-n,s=l.changedTouches[0].pageY-o,Math.abs(r)>Math.abs(s)?r>0?_({key:"ArrowRight"}):_({key:"ArrowLeft"}):s>0?_({key:"ArrowDown"}):_({key:"ArrowUp"})})};var __=0;function E(e,_,t,n,o,r){var s,l,u={};for(l in _)l=="ref"?s=_[l]:u[l]=_[l];var c={type:e,props:u,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--__,__i:-1,__u:0,__source:o,__self:r};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)u[l]===void 0&&(u[l]=s[l]);return a.vnode&&a.vnode(c),c}const t_=je();function n_(){const[e,_]=Ye(t_);Be(()=>{e_(document.body,n=>_(ke(n)))},[]);const t=n=>{n.preventDefault();const o=ke(n);_(o)};return e.state!==ne.PLAYING&&document.getElementById("dialog").showModal(),E(U,{children:[E("style",{children:`:root { +(function(){const _=document.createElement("link").relList;if(_&&_.supports&&_.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function t(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerPolicy&&(r.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?r.credentials="include":o.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(o){if(o.ep)return;o.ep=!0;const r=t(o);fetch(o.href,r)}})();var K,a,we,P,ce,Ee,Z,D={},Ae=[],Ue=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function $(e,_){for(var t in _)e[t]=_[t];return e}function $e(e){var _=e.parentNode;_&&_.removeChild(e)}function Oe(e,_,t){var n,o,r,s={};for(r in _)r=="key"?n=_[r]:r=="ref"?o=_[r]:s[r]=_[r];if(arguments.length>2&&(s.children=arguments.length>3?K.call(arguments,2):t),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)s[r]===void 0&&(s[r]=e.defaultProps[r]);return V(e,s,n,o,null)}function V(e,_,t,n,o){var r={type:e,props:_,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o??++we,__i:-1,__u:0};return o==null&&a.vnode!=null&&a.vnode(r),r}function U(e){return e.children}function W(e,_){this.props=e,this.context=_}function M(e,_){if(_==null)return e.__?M(e.__,e.__i+1):null;for(var t;__&&P.sort(Z));B.__r=0}function He(e,_,t,n,o,r,s,l,c,u,p){var i,d,f,v,k,m=n&&n.__k||Ae,h=_.length;for(t.__d=c,Ie(t,_,m),c=t.__d,i=0;i0?V(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)!=null?(o.__=e,o.__b=e.__b+1,l=Re(o,t,s=n+i,p),o.__i=l,r=null,l!==-1&&(p--,(r=t[l])&&(r.__u|=131072)),r==null||r.__v===null?(l==-1&&i--,typeof o.type!="function"&&(o.__u|=65536)):l!==s&&(l===s+1?i++:l>s?p>c-s?i+=l-s:i--:i=l(c!=null&&!(131072&c.__u)?1:0))for(;s>=0||l<_.length;){if(s>=0){if((c=_[s])&&!(131072&c.__u)&&o==c.key&&r===c.type)return s;s--}if(l<_.length){if((c=_[l])&&!(131072&c.__u)&&o==c.key&&r===c.type)return l;l++}}return-1}function ae(e,_,t){_[0]==="-"?e.setProperty(_,t??""):e[_]=t==null?"":typeof t!="number"||Ue.test(_)?t:t+"px"}function F(e,_,t,n,o){var r;e:if(_==="style")if(typeof t=="string")e.style.cssText=t;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(_ in n)t&&_ in t||ae(e.style,_,"");if(t)for(_ in t)n&&t[_]===n[_]||ae(e.style,_,t[_])}else if(_[0]==="o"&&_[1]==="n")r=_!==(_=_.replace(/(PointerCapture)$|Capture$/,"$1")),_=_.toLowerCase()in e?_.toLowerCase().slice(2):_.slice(2),e.l||(e.l={}),e.l[_+r]=t,t?n?t.u=n.u:(t.u=Date.now(),e.addEventListener(_,r?de:pe,r)):e.removeEventListener(_,r?de:pe,r);else{if(o)_=_.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(_!=="width"&&_!=="height"&&_!=="href"&&_!=="list"&&_!=="form"&&_!=="tabIndex"&&_!=="download"&&_!=="rowSpan"&&_!=="colSpan"&&_!=="role"&&_ in e)try{e[_]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&_[4]!=="-"?e.removeAttribute(_):e.setAttribute(_,t))}}function pe(e){var _=this.l[e.type+!1];if(e.t){if(e.t<=_.u)return}else e.t=Date.now();return _(a.event?a.event(e):e)}function de(e){return this.l[e.type+!0](a.event?a.event(e):e)}function le(e,_,t,n,o,r,s,l,c,u){var p,i,d,f,v,k,m,h,g,A,O,S,ue,I,z,b=_.type;if(_.constructor!==void 0)return null;128&t.__u&&(c=!!(32&t.__u),r=[l=_.__e=t.__e]),(p=a.__b)&&p(_);e:if(typeof b=="function")try{if(h=_.props,g=(p=b.contextType)&&n[p.__c],A=p?g?g.props.value:p.__:n,t.__c?m=(i=_.__c=t.__c).__=i.__E:("prototype"in b&&b.prototype.render?_.__c=i=new b(h,A):(_.__c=i=new W(h,A),i.constructor=b,i.render=Ve),g&&g.sub(i),i.props=h,i.state||(i.state={}),i.context=A,i.__n=n,d=i.__d=!0,i.__h=[],i._sb=[]),i.__s==null&&(i.__s=i.state),b.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=$({},i.__s)),$(i.__s,b.getDerivedStateFromProps(h,i.__s))),f=i.props,v=i.state,i.__v=_,d)b.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(b.getDerivedStateFromProps==null&&h!==f&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(h,A),!i.__e&&(i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(h,i.__s,A)===!1||_.__v===t.__v)){for(_.__v!==t.__v&&(i.props=h,i.state=i.__s,i.__d=!1),_.__e=t.__e,_.__k=t.__k,_.__k.forEach(function(R){R&&(R.__=_)}),O=0;O=t.__.length&&t.__.push({__V:Y}),t.__[e]}function Ye(e){return _e=1,qe(Ce,e)}function qe(e,_,t){var n=Te(G++,2);if(n.t=e,!n.__c&&(n.__=[t?t(_):Ce(void 0,_),function(l){var c=n.__N?n.__N[0]:n.__[0],u=n.t(c,l);c!==u&&(n.__N=[u,n.__[1]],n.__c.setState({}))}],n.__c=y,!y.u)){var o=function(l,c,u){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(d){return d.__c});if(p.every(function(d){return!d.__N}))return!r||r.call(this,l,c,u);var i=!1;return p.forEach(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(i=!0)}}),!(!i&&n.__c.props===l)&&(!r||r.call(this,l,c,u))};y.u=!0;var r=y.shouldComponentUpdate,s=y.componentWillUpdate;y.componentWillUpdate=function(l,c,u){if(this.__e){var p=r;r=void 0,o(l,c,u),r=p}s&&s.call(this,l,c,u)},y.shouldComponentUpdate=o}return n.__N||n.__}function Be(e,_){var t=Te(G++,3);!a.__s&&Xe(t.__H,_)&&(t.__=e,t.i=_,y.__H.__h.push(t))}function Ge(){for(var e;e=Ne.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(q),e.__H.__h.forEach(te),e.__H.__h=[]}catch(_){e.__H.__h=[],a.__e(_,e.__v)}}a.__b=function(e){y=null,ye&&ye(e)},a.__r=function(e){ve&&ve(e),G=0;var _=(y=e.__c).__H;_&&(J===y?(_.__h=[],y.__h=[],_.__.forEach(function(t){t.__N&&(t.__=t.__N),t.__V=Y,t.__N=t.i=void 0})):(_.__h.forEach(q),_.__h.forEach(te),_.__h=[],G=0)),J=y},a.diffed=function(e){me&&me(e);var _=e.__c;_&&_.__H&&(_.__H.__h.length&&(Ne.push(_)!==1&&he===a.requestAnimationFrame||((he=a.requestAnimationFrame)||Ke)(Ge)),_.__H.__.forEach(function(t){t.i&&(t.__H=t.i),t.__V!==Y&&(t.__=t.__V),t.i=void 0,t.__V=Y})),J=y=null},a.__c=function(e,_){_.some(function(t){try{t.__h.forEach(q),t.__h=t.__h.filter(function(n){return!n.__||te(n)})}catch(n){_.some(function(o){o.__h&&(o.__h=[])}),_=[],a.__e(n,t.__v)}}),ge&&ge(e,_)},a.unmount=function(e){be&&be(e);var _,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(n){try{q(n)}catch(o){_=o}}),t.__H=void 0,_&&a.__e(_,t.__v))};var xe=typeof requestAnimationFrame=="function";function Ke(e){var _,t=function(){clearTimeout(n),xe&&cancelAnimationFrame(_),setTimeout(e)},n=setTimeout(t,100);xe&&(_=requestAnimationFrame(t))}function q(e){var _=y,t=e.__c;typeof t=="function"&&(e.__c=void 0,t()),y=_}function te(e){var _=y;e.__c=e.__(),y=_}function Xe(e,_){return!e||e.length!==_.length||_.some(function(t,n){return t!==e[n]})}function Ce(e,_){return typeof _=="function"?_(e):_}const T=15,C=15;var ne=(e=>(e[e.PLAYING=0]="PLAYING",e[e.VICTORY=1]="VICTORY",e[e.GAME_OVER=2]="GAME_OVER",e))(ne||{});const Q=10,X=[],L=[];let x;const N=[];let oe;const H={};let j=0;function je(){ze();for(let e=0;e.8?_.push("#"):_.push(".");X.push(_)}}function Se(){for(let e=0;e0&&(L[e.y][e.x]="e")}function Qe(e,_){return e.x+_.x>=0&&e.x+_.x<=C-1&&e.y+_.y>=0&&e.y+_.y<=T-1&&X[e.y+_.y][e.x+_.x]==="."}function E(e,_){if(!Qe(e,_))return!1;const t=e.y+_.y+"_"+(e.x+_.x),n=H[t];return n?(n.hp--,n.hp===0&&(H[t]=null,N.splice(N.indexOf(n),1),n!=x&&(oe--,oe===0&&(j=1)))):(H[e.y+"_"+e.x]=null,e.y+=_.y,e.x+=_.x,H[e.y+"_"+e.x]=e),!0}function ke(e){Se();let _=!1;switch(e.key){case"ArrowLeft":_=E(x,{x:-1,y:0});break;case"ArrowRight":_=E(x,{x:1,y:0});break;case"ArrowUp":_=E(x,{x:0,y:-1});break;case"ArrowDown":_=E(x,{x:0,y:1});break}if(_)for(const t of N)t!=null&&Ze(t);return De(),{map:[...L],state:j}}function Ze(e){const _=[{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}],t=x.x-e.x,n=x.y-e.y;if(Math.abs(t)+Math.abs(n)>6){let o=!1;do o=E(e,_[re(_.length)]);while(!o)}Math.abs(t)>Math.abs(n)?t<0?E(e,_[0]):E(e,_[1]):n<0?E(e,_[2]):E(e,_[3]),x.hp<1&&(j=2)}const e_=(e,_)=>{const t=e;let n=0,o=0,r=0,s=0;t.addEventListener("touchstart",function(l){n=l.changedTouches[0].pageX,o=l.changedTouches[0].pageY}),t.addEventListener("touchmove",function(l){l.preventDefault()}),t.addEventListener("touchend",function(l){r=l.changedTouches[0].pageX-n,s=l.changedTouches[0].pageY-o,Math.abs(r)>Math.abs(s)?r>0?_({key:"ArrowRight"}):_({key:"ArrowLeft"}):s>0?_({key:"ArrowDown"}):_({key:"ArrowUp"})})};var __=0;function w(e,_,t,n,o,r){var s,l,c={};for(l in _)l=="ref"?s=_[l]:c[l]=_[l];var u={type:e,props:c,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--__,__i:-1,__u:0,__source:o,__self:r};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return a.vnode&&a.vnode(u),u}const t_=je();function n_(){const[e,_]=Ye(t_);Be(()=>{e_(document.body,n=>_(ke(n)))},[]);const t=n=>{n.preventDefault();const o=ke(n);_(o)};return e.state!==ne.PLAYING&&document.getElementById("dialog").showModal(),w(U,{children:[w("style",{children:`:root { --map-rows: ${T}; --map-cols: ${C}; - }`}),E("h1",{children:"First ASCII Roguelike"}),E("div",{class:"grid",onKeyUp:t,tabIndex:0,children:e.map.map(n=>n.map(o=>E("div",{"data-cell":o,children:o})))}),E("dialog",{id:"dialog",children:[E("h1",{children:e.state===ne.VICTORY?"Victory":"Game Over"}),E("p",{children:"Refresh the page to restart"})]})]})}We(E(n_,{}),document.getElementById("app")); + }`}),w("h1",{children:"First ASCII Roguelike"}),w("div",{class:"grid",onKeyUp:t,tabIndex:0,children:e.map.map(n=>n.map(o=>w("div",{"data-cell":o,children:o})))}),w("dialog",{id:"dialog",children:[w("h1",{children:e.state===ne.VICTORY?"Victory":"Game Over"}),w("p",{children:"Refresh the page to restart"})]})]})}We(w(n_,{}),document.getElementById("app")); diff --git a/index.html b/index.html index 3723d70..574f5a2 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ First ASCII Roguelike - +