puzzle/build/public/assets/index.2f18bf13.js

2 lines
45 KiB
JavaScript
Raw Normal View History

import{d as e,c as t,a as n,w as o,b as l,r as i,o as s,e as a,t as r,F as d,f as c,g as u,v as p,h,i as g,j as y,k as m,l as f,m as w,n as v}from"./vendor.00b608ff.js";var x=e({name:"app",computed:{showNav(){return!["game","replay"].includes(String(this.$route.name))}}});const b={id:"app"},A={key:0,class:"nav"},z=a("Index"),T=a("New game");x.render=function(e,a,r,d,c,u){const p=i("router-link"),h=i("router-view");return s(),t("div",b,[e.showNav?(s(),t("ul",A,[n("li",null,[n(p,{class:"btn",to:{name:"index"}},{default:o((()=>[z])),_:1})]),n("li",null,[n(p,{class:"btn",to:{name:"new-game"}},{default:o((()=>[T])),_:1})])])):l("",!0),n(h)])};const S=864e5,C=e=>{const t=Math.floor(e/S);e%=S;const n=Math.floor(e/36e5);e%=36e5;const o=Math.floor(e/6e4);e%=6e4;return`${t}d ${n}h ${o}m ${Math.floor(e/1e3)}s`};var k=1e3,I=()=>{const e=new Date;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())},P=(e,t)=>C(t-e),_=C,D=e({name:"game-teaser",props:{game:{type:Object,required:!0}},computed:{style(){return{"background-image":`url("${this.game.imageUrl.replace("uploads/","uploads/r/")+"-375x210.webp"}")`}}},methods:{time(e,t){const n=t?"🏁":"⏳",o=e,l=t||I();return`${n} ${P(o,l)}`}}});const B={class:"game-info-text"},O=n("br",null,null,-1),E=n("br",null,null,-1),M=n("br",null,null,-1);D.render=function(e,d,c,u,p,h){const g=i("router-link");return s(),t("div",{class:"game-teaser",style:e.style},[n(g,{class:"game-info",to:{name:"game",params:{id:e.game.id}}},{default:o((()=>[n("span",B,[a(" 🧩 "+r(e.game.tilesFinished)+"/"+r(e.game.tilesTotal),1),O,a(" 👥 "+r(e.game.players),1),E,a(" "+r(e.time(e.game.started,e.game.finished)),1),M])])),_:1},8,["to"]),l("",!0)],4)};var N=e({components:{GameTeaser:D},data:()=>({gamesRunning:[],gamesFinished:[]}),async created(){const e=await fetch("/api/index-data"),t=await e.json();this.gamesRunning=t.gamesRunning,this.gamesFinished=t.gamesFinished}});const U=n("h1",null,"Running games",-1),R=n("h1",null,"Finished games",-1);function $(e,t){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function G(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}N.render=function(e,o,l,a,r,u){const p=i("game-teaser");return s(),t("div",null,[U,(s(!0),t(d,null,c(e.gamesRunning,((e,o)=>(s(),t("div",{class:"game-teaser-wrap",key:o},[n(p,{game:e},null,8,["game"])])))),128)),R,(s(!0),t(d,null,c(e.gamesFinished,((e,o)=>(s(),t("div",{class:"game-teaser-wrap",key:o},[n(p,{game:e},null,8,["game"])])))),128))])};var V={pointSub:function(e,t){return{x:e.x-t.x,y:e.y-t.y}},pointAdd:function(e,t){return{x:e.x+t.x,y:e.y+t.y}},pointDistance:$,pointInBounds:function(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h},rectCenter:G,rectMoved:function(e,t,n){return{x:e.x+t,y:e.y+n,w:e.w,h:e.h}},rectCenterDistance:function(e,t){return $(G(e),G(t))},rectsOverlap:function(e,t){return!(t.x>e.x+e.w||e.x>t.x+t.w||t.y>e.y+e.h||e.y>t.y+t.h)}};var j=1,W=4,F=5,H=2,L=3,Q=6,Y=2,q=4,Z=3,K=9,J=1,X=2,ee=3,te=4,ne=5,oe=6,le=7,ie=8,se=10,ae=1,re=2,de=3;class ce{constructor(e){this.rand_high=e||3735929054,this.rand_low=1231121986^e}random(e,t){return this.rand_high=(this.rand_high<<16)+(this.rand_high>>16)+this.rand_low&4294967295,this.rand_low=this.rand_low+this.rand_high&4294967295,e+(this.rand_high>>>0)/4294967295*(t-e+1)|0}choice(e){return e[this.random(0,e.length-1)]}shuffle(e){const t=e.slice();for(let n=0;n<=t.length-2;n++){const e=this.random(n,t.length-1),o=t[n];t[n]=t[e],t[e]=o}return t}static serialize(e){return{rand_high:e.rand_high,rand_low:e.rand_low}}static unserialize(e){const t=new ce(0);return t.rand_high=e.rand_high,t.rand_low=e.rand_low,t}}const ue=(e,t)=>{const n=`${e}`;return n.length>=t.length?n:t.substr(0,t.length-n.length)+n},pe=(...e)=>{const t=t=>(...n)=>{const o=new Date,l=ue(o.getHours(),"00"),i=ue(o.getMinutes(),"00"),s=ue(o.getSeconds(),"00");console[t](`${l}:${i}:${s}`,...e,...n)};return{log:t("log"),error:t("error"),info:t("info")}};var he={hash:e=>{let t=0;for(let n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},uniqI