-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathmin.js
1 lines (1 loc) · 26.3 KB
/
min.js
1
var e,o,t,r,a,s,n,i,l,d,m,g,c,h,v,p,u,f,y,w,b,S,x,L,M,k,T,j,B,C,D,X,$,z,I,H=this,K=document,W="World of Emojis",Y={mons:[]},P=1,F=1,G=100,R=1,A=0,N=0,E=0,O=9,_=1,Z=[],U=[],q=[],J=1,Q=Math.PI,V=1,ee=1,oe=1,te=1,re=1,ae=0,se=[],ne=[{emoji:"🐡",offsetY:1,name:"Pufferfish",t:["poison","water"],pow:"7☠",hp:50},{emoji:"🦣",name:"Mammoth",t:["beast","ice"],pow:"11❄",hp:80,reload:1.4,repel:.8},{emoji:"🐓",name:"Rooster",t:["bird","ground"],pow:6,hp:40,reload:.5,repel:1.2},{emoji:"🐇",name:"Rabbit",pow:4,hp:30,reload:.5},{emoji:"🐿",name:"Squirrel",pow:5,hp:20},{emoji:"🦗",name:"Cricket",pow:2,hp:15},{emoji:"🐀",name:"Rat",pow:"2☠",hp:4},{emoji:"🐌",name:"Snail",pow:2,hp:70,reload:1.5},{emoji:"🦨",name:"Skunk",pow:"4☠",hp:50,repel:.6},{emoji:"🦆",name:"Duck",pow:5,hp:20},{emoji:"🦖",name:"T-Rex",pow:30,hp:200,repel:.5},{emoji:"🐉",name:"Dragon",pow:25,hp:230},this.gMonKindCure={emoji:"❤",name:"Heart",pow:1,hp:10,flip:1},{emoji:"🩹",name:"Bandage",pow:2,hp:7},e={emoji:"📦",name:"Package",pow:1,hp:10}],ie=e=>{e.div.remove(),e.shadowDiv?.remove(),e.hpObj&&ie(e.hpObj)},le=e=>{var o=30-e.reloadMax/5;no(e.hS||=so([o,o,e.monKind.pow/100,2,2]))},de=e=>e.monKind.pow*(mo(.6)+.7)|0,me=(e,o)=>{o<0&&(o=0),o&&!e.hp&&Se(e.div,"dead"),!o&&e.hp&&(Se(e.div,"dead",1),no(z)),e.hp=o;var t=e.hp/e.hpMax;e.hpDiv?(e.hpDiv.innerHTML=0|o,e.hpBarDiv.style.width=100*t+"%",e.hpBarDiv.style.background=`rgb(${255*(1-t)|0},${255*t|0},0)`):e.div.lastChild.lastChild.lastChild.lastChild.style.width=100*(1-t)+"%"},ge=e=>{gButR.style.display=gButL.style.display="block",Ie(x.cameraY),ze(x.cameraZ),K.body.classList.remove("zoom"),K.body.classList.remove("zoom2"),a=0,De(1),ke(-.001),fo(x.song,2),Je(),Ce(o+1)},ce=e=>{for(var o of Y.mons)if(o.hp){n=o;break}De(11),n||(K.body.style.filter="grayscale(1)",gDead.style.display="flex",De(16))},he=e=>{var o=ve(e,0,0,55,4-(e==gMonKindCure),0,0,4);return Y.mons.push(o),setTimeout(Me,44),no(B),x&&Je(),o},ve=(e,o,t,r,a,s,n,i,l,d)=>{var m;n||(n=.07),e.name&&(m=e,e=e.emoji);var g={emoji:e,x:o,y:t,z:r,sizeY:a,offsetY:n,kind:i,monKind:m,speech:l,scene:x,sceneGo:d,shadowNo:s};(l||d)&&se.push(g),l&&(g.onPress=e=>{ye(g)},g.onLeave=fe),d&&(g.onPress=e=>{Ie(d.cameraY),ze(d.cameraZ),re=S,De(2),Y.div.style.transition="translate .4s ease",x==gSceneWorld||d==gSceneBedroom?Y.div.style.translate="0 0 -5rem":x==gSceneBedroom?Y.div.style.translate="0 1rem 2rem":Y.div.style.translate="-2rem 0 2rem",no(D),setTimeout((e=>{$e(d)}),200)}),g.div=K.createElement("div"),g.div.className="obj obj"+x.i+(r>55?" near":"")+(4==i?" mon":"")+(2==i?" zombie":""),(y=g.div.style).fontSize=y.height=a+"rem",y.zIndex=r+(3==s?0:2e3)|0;var c=e;i&&(c=`<div><div class=flipper><div class=walker>${e}${4==i?`<div style="position:absolute;top:0;width:0;overflow:hidden" class="zombie">${e}</div>`:""}</div></div></div>`);g.div.innerHTML=c;var h=r>1?gLayer2:gLayer1;if(!s||2==s){g.shadowDiv=K.createElement("div"),g.shadowDiv.className="shadow0 obj obj"+x.i+(r>55?" near":"")+(4==i?" mon":""),(w=g.shadowDiv.style).fontSize=w.height=a+"rem",w.zIndex=100+~~r;c=i?"<div><div class=shadow"+(2==s?"OnWall":"")+"><div class=flipper><div class=walker>"+e+"</div></div></div></div>":`<div class=shadow${2==s?"OnWall":""}>${e}</div>`,g.shadowDiv.innerHTML=c,h.appendChild(g.shadowDiv)}return h.appendChild(g.div),ue(g),m&&(10==S&&(e=>{var o=Y.mons.includes(e)?-3:6,t=e.hpObj=ve("<div style='width:3.5rem;height:.5rem;background:#000;margin:.05rem;position:relative'><div style='height:100%'></div></div>❤<span style='font-family:comic sans ms'></span>",R+o,1,55,1.6,1);e.hpDiv=t.div.lastChild,e.hpBarDiv=t.div.firstChild.firstChild})(g),me(g,g.hpMax=m.hp),g.reloadMax=50*m.reload,g.reload=5),g},pe=(e,o)=>{e.z=o,e.div.style.zIndex=2e3+~~o},ue=e=>{var o,t=e.x,r=e.y,a=e.z,s=r+4*e.offsetY,n=e.div.style,i=e.shadowDiv?.style,l=e=>`translate3d(calc(var(--youX) + ${t}rem - var(--cameraX)),calc(${e}rem - 100%),${a}rem)`,d=e=>`translate3d(calc(var(--youX) - var(--cameraX) - 3.5rem),calc(${e}rem - 100%),${a}rem)`;a>1?(r+=53,s+=53,1==e.kind?(n.transform=d(s),o=d(r)):4==e.kind?(n.transform=l(s),o=l(r)):(n.transform=`translate3d(calc(${t}rem - var(--cameraX)),calc(${s}rem - 100%),${a}rem)`,o=`translate3d(calc(${t}rem - var(--cameraX)),calc(${r}rem - 100%),${a}rem)`,3==e.shadowNo&&(n.transform+="rotateX(90deg)"),4==e.shadowNo&&(n.transform+="rotateY(90deg)"))):(n.transform=`translate3d(${t}rem,${s}rem,${a}rem)`,o=`translate3d(${t}rem,${r}rem,${a}rem)`),i&&(i.transform=o)},fe=e=>{k&&no(X),gSpeech.style.opacity=0,gSpeech.firstChild.style.transform="scale(0)",k=0,M&&setTimeout(M,300),1!=S&&(gButGo.style.display="none"),gbns.style.display="none"},ye=(e,o,t)=>{var r=o||e.speech,a=1.9;r.length>45&&(a/=1+(r.length-45)/99),gSpeechText.style.fontSize=a+"rem",gSpeechText.innerHTML=r,e==Y&&(Y.x=R-50);var s=e.x-12.5+(Y.mons.includes(e)?R:0),n=R-((e==Y?0:23)+oe/100/10)*G/100,i=e.x<P+50;i&&(s+=14),s<n&&(s=n),gSpeech.style.opacity=1,gSpeech.firstChild.firstChild.style.transform=`scaleX(${i?-1:1})`,gSpeech.firstChild.style.transformOrigin=(i?0:100)+"% 100%",gSpeech.firstChild.style.transform="scale("+(G>99?1:.7)+")",gSpeech.style.transform=`translate3d(calc(${s}rem - var(--cameraX)),calc(${e.y+55-e.sizeY}rem - 100%),`+(e.z+1)+"rem)",gSpeech.style.zIndex=2001+~~e.z,(k=e).talkTime=b,M=t,J&&4!=S&&setTimeout((e=>gButGo.style.display="block"),400),no(C)},we=(e,o)=>{Se(e.div,"walking",o),Se(e.shadowDiv,"walking",o)},be=(e,o)=>{e.going=1,e.x+=o;var t,r=o>=0;return e.goRight!=r&&(e.goRight=r,t=1,Se(e.shadowDiv,"flipped",r),Se(e.div,"flipped",r)),e!=Y&&ue(e),t},Se=(e,o,t)=>{t?e.classList.add(o):e.classList.remove(o)},xe=e=>{var o=4;return Y.mons.length>oe/33&&(o/=Y.mons.length/(oe/33)),e*-o*(Y.goRight?1:-1)-2},Le=(e,o)=>{e.div.style.transitionDuration=e.shadowDiv.style.transitionDuration=o+"s"},Me=e=>{var o=1;for(var t of Y.mons){if(t!=p){Se(t.div,"flipped",Y.goRight==!t.monKind?.flip),Se(t.shadowDiv,"flipped",Y.goRight==!t.monKind?.flip);var r=t.x;t.x=xe(o);var a=_e(r-t.x);Le(t,a/20),ue(t)}o++}},ke=e=>{k&&Y.mons.includes(k)&&fe(),be(Y,e)&&Me(),R+=1*e;var o=x.startX||4;1==S&&x==gSceneLab&&l.x<888&&!Y.mons[0]&&(o=20),R>x.endX?R=x.endX:R<o&&(R=o),o-=oe/2*.7;var t=Math.max(o,x.endX-oe/2*1.23-(G-80)/2);(P=R-oe/2)>t?P=t:P<o&&(P=o);var r,n=R;if(1==S){for(var i of se)i.scene==x&&n>i.x-1&&n<i.x+i.sizeY+1&&(r=i);if(L!=r){if(L){var d=L.div;L.kind&&(d=d.firstChild),d.style.filter="unset",k!=L&&k!=Y||L.onLeave?.()}if(L=r){d=L.div;L.kind&&(d=d.firstChild),d.style.filter="brightness(1.1) contrast(1.2) drop-shadow(0 0 .5rem #9F0)"}J&&(gButGo.style.display=L?"block":"none")}}if(N>-4&&(m=(R-2)/5|0)!=g){g=m;var c=x.grass[m];c&&(no(I),c.div.firstChild.classList.add("sway"),c.shadowDiv.firstChild.firstChild.classList.add("sway"),setTimeout((e=>{c.div.firstChild.classList.remove("sway"),c.shadowDiv.firstChild.firstChild.classList.remove("sway")}),501),Y.mons[0]||1!=S?mo(1)<.15*Y.mons[0].monKind.repel&&(e=>{ke(.001),gButR.style.display=gButL.style.display="none",De(10),K.body.style.filter="brightness(1.5)",Ie(42),ze(72),K.body.classList.add("zoom"),setTimeout((e=>K.body.classList.add("zoom2")),501),setTimeout((e=>K.body.style.filter="none"),101);var o=3,t=_e(O-12)<7,r=ne.length;R<444&&mo(1)<.5&&(o=t?4:5,mo()<.02&&(o=6)),x==gSceneForest&&(o=0|mo(r-5),mo()<.01&&(o=t?r-5:r-4));var n=ne[o],i=a=ve(n,R+6,.4,55,4,0,.05,2);Le(i,.5),s=Y.mons[0],setTimeout((e=>{var o=Y.mons[0];Le(o,.5),ye(Y,`Zombie ${n.name} appeared!`,(e=>{for(var t of(o.x+=3.2,Y.mons))t.x+=4,ue(t);ye(Y,`Go ${o.monKind.name}!`,(e=>{Le(o,.1),De(11)})),fo(vo,2)})),no($)}),500)})():(De(5),be(l,100-l.x),Xe(l,x),l.div.style.transition=l.shadowDiv.style.transition="all 1s ease",setTimeout((e=>{be(l,25),setTimeout((e=>{ye(l,"Hey! Wait! Don't go out!",(e=>{be(l,10),setTimeout((e=>{ye(l,"It's unsafe! Zombie emojis live in tall grass!",(e=>{ye(l,"You need your own emojis for your protection. I know! Here, come with me!",(e=>{De(7)}))}))}),999)}))}),999)}),33)))}gLayer2.style.setProperty("--youX",R+"rem"),gLayer2.style.setProperty("--cameraX",P+"rem"),x==gSceneLab&&(R>l.x+4?be(l,.001):be(l,-.001))},Te=e=>{var o=0,t=0;e||=O,x!=gSceneWorld&&x!=gSceneForest&&(e=14),e>5&&e<=19&&(o=130*(.5-(e-5)/14),t=1,e<=6&&(t=e-6),e>18&&(t=19-e)),e>=20&&(o=65-13*(e-20),t=1,e<21&&(t=e-20)),e<=5&&(o=13*-e,t=1,e>4&&(t=5-e)),x!=gSceneWorld&&x!=gSceneForest&&(t=1),gLayer2.style.setProperty("--shadowSkew",o+"deg"),gLayer2.style.setProperty("--shadowOpacity",.4*t)},je=e=>{b=Date.now(),Y.going=0;var o=U[32]||U[13]||U[40]||U[83]||f==gButGo;if(o&&k&&3!=S&&b-k.talkTime>400&&(fe(),o=0,U=[],gButGo.style.display="none"),1==S)(Z[87]||Z[38])&&(A||(A=-.8)),o&&L&&k!=L&&(gButGo.style.display="none",L.onPress());else if(3==S)(U[27]||f==gButNo)&&(Ye(),De(1),gButGo.style.display=gButNo.style.display="none"),o&&(We(),gButGo.style.display=gButNo.style.display="none");else if(7==S)ke(-.8),l.scene==x&&(be(l,-.8),R<110&&(l.div.style.transition=l.shadowDiv.style.transition="none",be(l,-.8),Xe(l,gSceneLab),be(l,61-l.x))),R<106&&(De(8),d.onPress(),i.speech="You have to pick one, there's an invisible wall.");else if(11==S){var t=n;if(t){if(Y.mons.splice(Y.mons.indexOf(t),1),Y.mons.unshift(t),Me(),s=t,t.x=1.2,ue(t),t.reload=-5,t.div.style.filter="",n.monKind==gMonKindCure)return De(19),setTimeout((e=>{if(ie(Y.mons.shift()),mo(1)>a.hp/a.hpMax){ie(a);var o=he(a.monKind);me(o,a.hp),De(18),ye(o,"🥰",ge)}else ye(Y,"Failed! The zombie is too strong!",ce),De(17)}),500),void(n=0);n=0}s.reload++,s.reload>=s.reloadMax?(De(14),s.reload=0,s.x++,ue(s),setTimeout((e=>{a.x+=.3,ue(a),le(s),me(a,a.hp-de(s)),a.hp<=0?(De(15),setTimeout((e=>{ve("🪦",a.x,0,53,4),ie(a),ge()}),999)):setTimeout((e=>{14==S&&(s.x--,ue(s),a.x-=.3,ue(a),De(11))}),111)}),111)):(a.reload++,a.reload>=a.reloadMax&&(De(15),a.reload=0,a.x--,Le(a,.1),ue(a),setTimeout((e=>{s.x-=.3,ue(s),le(a),me(s,s.hp-de(a)),s.hp<=0?(De(15),setTimeout((e=>{ce()}),999)):setTimeout((e=>{15==S&&(a.x++,ue(a),s.x+=.3,ue(s),De(11))}),111)}),111)))}else 8==S?b-ae>999&&(ke(1),R>i.x+7&&(De(9),ye(i,"Gramps! I'm fed up with waiting!",(e=>{ye(l,"Rival? Let me think...",(e=>{ye(l,"Oh that's right I told you to come! Just wait!",(e=>{ye(l,"There are three zombies here. Haha!",(e=>{ye(l,"A heart will cure a zombie, then it will be yours!",(e=>{he(gMonKindCure),ye(l,"Use this heart "+gMonKindCure.emoji+" on one. Go on, choose!"),De(1),ke(.01),x.startX=39,gMom.speech="I see you got your first emoji! Tap it to rename it."}))}))}))}))})))):4==S&&Y.targetX&&(R>Y.targetX?ke(-1):(ke(.1),Y.targetX=0));if(N+=A,A+=.08,N>0&&(N=0,A=0),1==S&&((Z[65]||Z[37]||c&&h==gButL)&&ke(-1),(Z[68]||Z[39]||c&&h==gButR)&&ke(1)),Y.going0!=Y.going)for(var r of(Y.going0=Y.going,we(Y,Y.going),Y.mons))we(r,Y.going);E!=N&&(Y.div.style.top=N+"rem",E=N,Y.shadowDiv.style.transform="translate3d(calc(var(--youX) - var(--cameraX) - 3.5rem),calc("+(Y.y+53)+"rem - 100%),"+(Y.z-N/2)+"rem)"),O+=.01,~~(O%=24)!=_&&(gClock.innerHTML="&#"+(128336+~~(O-1)%12)+";",_=~~O,Te(),Be()),scrollTo(0,0),U=[],q=[],f=0},Be=e=>{if(x!=gSceneWorld&&x!=gSceneForest)return gLayer1.style.background="#DDD",void(gLayer2.style.filter=gGround.style.filter="brightness(1)");var o=O/24*Q*2+1.5*Q;gSun.div.style.left=(Math.cos(o)+1)/2*100+"%",gSun.div.style.top=44*(1-Math.sin(o))-10+"rem",o+=Q,gMoon.div.style.left=(Math.cos(o)+1)/2*100+"%",gMoon.div.style.top=44*(1-Math.sin(o))-10+"rem";var t=1;if(O>5&&O<9||O>16&&O<19){var r=O<9?(O-5)/4:1-(O-16)/3;gLayer1.style.background="linear-gradient(rgb("+(200-60*r)+",204,"+(222+33*r)+") "+(14+10*r)+"rem, rgb(255,"+(70+180*r)+","+(20+230*r)+") 54rem)",t=1-.4*(1-r**2)}else if(O<=5||O>=19){r=0;O<=5&&O>3&&(r=(O-3)/2),O>=19&&O<21&&(r=1-(O-19)/2),gLayer1.style.background="linear-gradient(rgb("+(10+190*r)+","+(24+180*r)+","+(42+180*r)+") "+(24-10*r)+"rem, rgb("+(65+190*r)+","+(110-40*r)+","+(150-130*r)+") 54rem)",t=.6}else gLayer1.style.background="linear-gradient(#9cf 24rem, #FFF 54rem)";gLayer2.style.filter=gGround.style.filter=`brightness(${t})`},Ce=e=>{gGoldDiv.innerHTML=o=e},De=e=>{console.log("gStateSet from",S,"to",e),S=e,ae=b},Xe=(e,o)=>{var t=[e.div,e.shadowDiv];for(var r of(e.scene=o,t))r&&(r.classList.remove("obj"+x.i),r.classList.add("obj"+o.i))},$e=e=>{var o=[...Y.mons,Y];for(var t of o)Xe(t,e);var r=x;if(x&&(x.youX=R),R=11,x!=gSceneWorld)for(var t of se)t.scene==e&&t.sceneGo==x&&(R=t.x+t.sizeY/2);x=e,Y.div.style.transition="none",Y.div.style.translate="none",gGround.style.background=e.bgColor,gLayer1.style.height=(e!=gSceneWorld&&e!=gSceneForest?70:44)+"rem",K.body.className="scene"+e.i,De(re),ke(.1),Be(),Te(),fo(x.song,2),r&&Je()},ze=e=>{gLayer2.style.perspective=(G=e)+"rem"},Ie=e=>{F=e,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&(e-=50),gLayer2.style.perspectiveOrigin=`center ${e}rem`},He=[],Ke=e=>{var o={i:He.length+1,bgColor:e,song:ho,cameraY:40,cameraZ:80,grass:[]};return He.push(o),x=o},We=0,Ye=0,Pe=(e,o)=>{De(3),gButGo.style.display=gButNo.style.display="block",We=e,Ye=o},Fe=e=>{for(var o of ne)if(o.emoji==e)return o},Ge=e=>{v&&Se(v,"sel"),(v=e)&&Se(e,"sel",1)},Re=e=>{p&&(r||(ye(p,p.monKind.name+`<br>❤${p.hp}/${p.hpMax} 🗡${p.monKind.pow}`),gbns.style.display="block",u=p.monKind.id),p.div.style.filter="unset",pe(p,Y.z),p.y=0,ue(p),p=0,Me()),c=0,Ge()},Ae=e=>{if(r=0,c=1,h=f=e.target,Ge(h),(1==S||4==S||a)&&!h?.classList.contains("but"))for(var o of Y.mons)if(Oe(o,e.clientX,e.clientY)){a?o!=s&&o.hp&&(n=o,o.div.style.filter="brightness(1.1) contrast(1.2) drop-shadow(0 0 .1rem #0F0)"):(p=o,Le(o,0),o.div.style.filter="brightness(1.1) contrast(1.2) drop-shadow(0 0 .1rem #000)",pe(o,Y.z+2),o.y=-2,ue(o));break}if(h==gMuteBut&&qe(),"gbns"==h.id&&oo(u),h==gNearBut&&eo(),!uo[0]){for(var t=11;t--;)uo[t]=new AudioContext;fo(x.song,2),1!=lo("mute")&&qe()}for(var i of uo)"suspended"==i.state&&i.resume();ao.resume()},Ne=e=>{if(r=1,h=K.elementFromPoint(e.clientX,e.clientY),p){fe(),h=0,p.x=Ee(e.clientX,0,p.z)[0]-2-R;for(var o,t,a=Y.mons.indexOf(p),s=-1;t=Y.mons[++s];)if(s>a&&_e(p.x)>_e(t.x)&&(o=s),s<a&&_e(p.x)<_e(t.x)){o=s;break}o>=0&&(Y.mons.splice(a,1),Y.mons.splice(o,0,p),Me()),ue(p),e.clientY<te/3&&Y.mons.length>1&&(confirm("Set Free?")&&(Y.mons.splice(Y.mons.indexOf(p),1),p.kind=3,p.x=R,p.y=0,pe(p,52),ue(p)),Re())}h!=v&&Ge(h)},Ee=(e,o,t)=>{var r=(o-te/2)/V*(1-t/G);return r+=te/V/4.3-28,r+=-1.5*(F-30)*(te/V-100)/150,[P+oe/2+(e-ee/2)/V*(1-t/G),r+=(F-42)/2]},Oe=(e,o,t)=>{var r=Ee(o,t,e.z);return _e(r[0]-R-2-e.x)<2&&_e(r[1]-2-e.y)<3},_e=Math.abs,Ze=(e,o,t="",r="")=>{for(;e--;)t+=o>1?"💠":"🔷";for(;o--;)r+=t+"<br>";return r},Ue=-1,qe=e=>{Ue=!Ue,gMuteBut.innerHTML=Ue?"🔇":"🔊",io("mute",+Ue)},Je=e=>{io("monIds",Y.mons.map((e=>e.monKind.id))),io("monHps",Y.mons.map((e=>e.hp))),io("x",R),io("scene",x.i),io("gold",o),io("quest",t),io("hour",O)},Qe=nearApi,Ve=e=>{gNearBut.style.textShadow="0 0 5px "+(j.isSignedIn()?"#0f0":"red"),ro()},eo=e=>{Je(),j.getAccountId()?j.signOut():j.requestSignIn("pets.vertfromage.testnet",W)},oo=e=>{for(var o of ne)if(o.id==e)break;var t=prompt(`Enter new name for ${o.name} (max 20 letters)`);fe(),t&&(o.name=t.substr(0,20),j.getAccountId()?to(o,o.name):alert("Name set, but you aren't logged into NEAR, so the name won't be set online for everyone."))},to=(e,o)=>{T.change_pet_name({pet_id:e.id,pet_name:e.name=o},"70000000000000","10000000000000000000000")},ro=e=>{T.get_all_pets({}).then((e=>{for(var o of e)for(var t of ne)t.id==o[0]&&(t.name=o[1])}))},ao=new AudioContext,so=e=>{for(var o=0,t=0;t<e.length;t+=5)o+=e[t+2];var r=ao.sampleRate,a=Math.round(r*o),s=ao.createBuffer(1,a,r),n=s.getChannelData(0),i=new Float32Array(a),l=0,d=0,m=0,g=2*Math.PI;for(t=0;t<e.length;t+=5){d=r*e[t+3]/100|0,l-=Math.min(m,d),m=r*e[t+4]/100|0;for(var c=g*e[t]*10/r,h=g*e[t+1]*10/r,v=r*e[t+2]|0,p=t/5%2?i:n,u=0;u<v;u++){var f=u/v,y=u*(h*f+c*(1-f)),w=Math.sin(y);u<d?w*=u/d:u>v-m&&(w*=(v-u)/m),p[l++]=w}}for(t=0;t<a;t++)n[t]=(n[t]+i[t])/2;return s},no=e=>{if(!Ue){var o=ao.createBufferSource();if(!o)return;o.buffer=e;var t=ao.createGain();o.connect(t),t.connect(ao.destination),o.start(0)}},io=(e,o)=>{localStorage[W+e]=o},lo=e=>localStorage[W+e],mo=e=>Math.random()*e,go=e=>{for(var o of Y.mons)me(o,o.hpMax);De(1)};onmousedown=Ae,onmouseup=Re,onmousemove=e=>c&&Ne(e),addEventListener("touchstart",(e=>{J=1;var o=e.changedTouches[0];return o&&Ae(o),gButL.style.display=gButR.style.display="block",e.preventDefault(),!1}),{passive:!1}),addEventListener("touchend",(e=>(Re(),e.preventDefault(),!1)),{passive:!1}),addEventListener("touchmove",(e=>{var o=e.changedTouches[0];return o&&Ne(o),e.preventDefault(),!1}),{passive:!1}),addEventListener("keydown",(e=>{var o=e.keyCode;Z[o]||(U[o]=Z[o]=1)})),addEventListener("keyup",(e=>{var o=e.keyCode;Z[o]=0,q[o]=1})),onresize=e=>{ee=innerWidth,te=innerHeight,V=Math.min(ee,te)/100,oe=ee/V,Y.div&&ke(0)},onload=r=>{for(var a of(Ce(1),D=so([15,16,.1,.2,.1,15,18,.1,2,1]),C=so([18,26,.1,.04,.04]),X=so([24,19,.05,.02,.02]),B=so([17,17,.08,.2,2,21,21,.08,.2,2,25,27,.1,.2,2]),z=so([25,24,.1,2,2,17,17,.1,2,2,14,12,.3,3,9]),$=so([25,25,.1,2,2,22,22,.1,2,2,35,35,.2,3,9]),I=so([15,17,.03,.1,.1,16,16,.03,.1,.1,15,15,.03,.1,.1]),Qe.nearInitPromise=(async e=>{let o=await Qe.connect({nodeUrl:"https://rpc.testnet.near.org",walletUrl:"https://wallet.testnet.near.org",helperUrl:"https://helper.testnet.near.org",explorerUrl:"https://explorer.testnet.near.org",networkId:"testnet",keyStore:new nearApi.keyStores.BrowserLocalStorageKeyStore(localStorage,W)});e=(j=new Qe.WalletConnection(o)).isSignedIn()?j.account():new Qe.Account(o.connection,"pets.vertfromage.testnet"),T=new Qe.Contract(e,"pets.vertfromage.testnet",{viewMethods:["get_all_pets"],changeMethods:["change_pet_name"]})})().then(Ve),ne))if(a.id=a.name,a.reload||=1,a.repel||=1,a.pow.sub){var s=parseInt(a.pow);a.powKind=a.pow.substr(`${s}`.length),a.pow=s}onresize(),H.gSceneWorld=Ke("#583"),H.gSceneHouseYou=Ke("#822"),H.gSceneBedroom=Ke("#822"),H.gSceneHouseRival=Ke("#822"),H.gSceneLab=Ke("#def"),H.gSceneCenter1=Ke("#def"),H.gSceneMart1=Ke("#def"),H.gSceneIntro=Ke("#fff");var n=ve("👨🦼",20,0,53,9,0,0,3,"!"),m=ve("🐒",-20,0,48,6,0,0,3);Le(m,.5),H.gSceneForest=Ke("#583"),x.endX=277,ve("🧍♂️",16,0,53,7,0,.03,3,"The Final Forest. I once saw a dragon in the moonlight."),ve("🔷",0,0,58,6,3,0,0,"",gSceneWorld);var g="🏔";for(v=4;v--;)g+=g;for(ve(g,-100,0,20,42,1),y.whiteSpace="nowrap",y.letterSpacing="-15rem",v=0;v<33;v++){var c=36;v<5&&(c+=6),ve("🌲",11*(v+.5+mo(.03))-22,0,25+mo(15),15+mo(2)),ve("🌲",11*(v+mo(.03))-22,0,c+mo(10),15+mo(2)),ve("🌲",33+11*(v+mo(.03)),0,64+mo(10),15+mo(2))}for(v=55;v-- >5;){p=ve("<div>🌾</div>",(b=5*v)+mo(3),0,55.5,6),x.grass[b/5|0]=p}gSceneForest.cameraY=30,gSceneForest.cameraZ=100,gSceneWorld.cameraY=30,gSceneWorld.cameraZ=100,(x=gSceneWorld).endX=531,x.song=[6,,9,,12,,9,,14,,9,,16,,9,,14,,9,,14,,9,,14,,16,,18,,16,,14,,12,,14,,9,,16,,9,,14,,9,,18,,9,,14,,9,,18,19,18,,16,,9,,14,,9,,18,19,18,,21,,9,,18,,9,,16,,9,,18,,16,,14,,9];for(var h=20;h--;)H.gStar=ve("•",mo(oe),mo(30),0,1.5,1),y.color="#9cf";H.gSun=ve("<div style='transform:translateX(-50%)'>🌞</div>",0,0,0,20,1),y.textShadow="0 0 2rem #FA4",y.transition="all 1s ease",H.gMoon=ve("<div style='transform:translateX(-50%)'>🌕</div>",0,0,0,15,1),y.textShadow="0 0 2rem #FFF",y.transition="all 1s ease",ve(Ze(23,1),-11,0,58,6,3),y.filter="grayscale(.9) brightness(1.3)";var v=-122;for(c=20;v<533;){var p=ve("🏔",v,0,c,42,1);mo(.2),mo(.2);(v+=mo(16)+22)>-50&&c>4&&(c-=4,v-=15)}for(ve("🌲",35,0,40,16),ve("🌲",40,0,30,16),ve("🌲",60,0,40,16),v=0;v<23;v++){c=36;v<5&&(c+=6),ve("🌲",122+11*(v+.5+mo(.03)),0,25+mo(15),18+mo(2)),ve("🌲",122+11*(v+mo(.03)),0,c+mo(10),18+mo(2))}for(var u=0;u<4;u++){var f=4;for(0==u&&(f=6),1==u&&(f=2),v=0;v<f;v++){var b=66*u+5*v+145,S=-2;0==u&&(S=0);for(c=S;c<=2;c++)p=ve("<div>🌾</div>",b+mo(3),0,55.5+5*c,6),0==c&&(x.grass[b/5|0]=p)}}for(v=0;v<2;v++)for(c=0;c<2;c++)ve("🌼🌼🌼🌼",71*v-10,0,47+3*c,3);ve("",-194,0,71,70,3),x.startX=-42,y.width="150rem",y.background="#69D",ve("🏡",3,0,50,27,0,.2,0,"",gSceneHouseYou),ve("📫",3,0,50,5),ve("🪧",184,0,53,6,0,.07,0,"Route 1:<br>To Green-Blue City"),ve("🪧",75,0,52,6,0,.07,0,"Color Palette Town:<br>Shades of your journey are belong to us!"),ve("🏠",34,0,50,27,0,.2,0,"",gSceneHouseRival),d=ve("🏢",87,-1,50,38,0,0,0,"",gSceneLab),(Y=ve("🚶",0,0,55,7,0,.04,1)).shadowDiv.className="shadow0",Y.mons=[],ve("🏥",400,0,50,30,0,.2,0,"",gSceneCenter1),ve("🏪",436,0,50,30,0,.2,0,"",gSceneMart1),ve("🚛",468,0,50,15,0,.2);var L=ve("🏯",485,0,50,33,0,.1,""," ");for(L.onPress=e=>{ye(Y,"The door is locked."),ke(-1)},L.onLeave=fe,ve("🌳",525,0,50,20,0,.2,0,"",gSceneForest),ve("🪧",380,0,53,6,0,.07,0,"Green-Blue City: The Greenish Blue Paradise"),ve(Ze(23,1),380,0,58,6,3),x=gSceneLab,ve(Ze(18,3),9,0,51,6,3),y.opacity=.5,ve("🚪",0,0,54,11,0,0,0,"",gSceneWorld),ve("🗄",17.1,0,53,6,0,.03),ve("👨🔬",22,-5.7,52.5,3.5,1,0,3,"I study emojis as professor X's AIDE."),ve("🗄",21.1,0,53,6,0,.03),ve("🗄",25.1,0,53,6,0,.03),ve("👩🔬",30,-5.7,52.5,3.5,1,0,3,"Professor X is the authority on emoji. Many emoji trainers hold him in high regard."),ve("🗄",29.1,0,53,6,0,.03),ve("🗄",33.1,0,53,6,0,.03),ve("📊",110,-6,45,6,2),ve("📠",114,-6,55,3.5,1),ve("🗄",x.endX=112.9,0,54,6,0,.03),h=8;h--;)ve("🪟",9+12*h,-7,45,12,2);i=ve("🧍♂️",52,0,53,7,0,.03,3,"Yo! Gramps isn't around!"),l=ve("👨🦼",999,0,53,9,0,0,3,"Which emoji do you want?");h=0;var M=["🐡","🦣","🐓"].map(Fe);for(var k of M){v=73+7.5*h;var P=ve(k.emoji,v,.4,52.5,4,0,.05,3,"Brains?");P.div.classList.add("zombie"),P.monKind=k,function(e){e.onPress=o=>{l.x>888||Y.mons[0].monKind!=gMonKindCure?ye(e):(ye(l,"You want the "+e.monKind.t.join("/")+` emoji, ${e.monKind.name}?`),Pe((o=>{De(4),e.cage.div.style.opacity=e.cage.shadowDiv.style.opacity=0,setTimeout((o=>{ie(Y.mons[0]),Y.mons=[],ie(e),he(e.monKind),setTimeout((e=>ye(Y.mons[0],"😍")),111),setTimeout((e=>{fe(),De(1),l.speech="To save every type of emoji in the world... That was my dream!",i.speech="Alright gramps! Leave it all to me!",x.startX=0}),999)}),333)}),fe))}}(P),P.cage=ve("🌐",v-1.6,0,53,6.5,0,.04),w.transition=y.transition="opacity 1s ease",y.opacity=.7,h++}x=gSceneHouseRival,ve("🚪",0,0,50,11,0,0,0,"",gSceneWorld),ve("🧘",38,0,53,4.5,0,.02,3,"Hi! Rival is out at grandpa's lab."),ve("🔲",35,0,57,11,3),ve("🪑",33,0,51,5),ve("🫕",45,0,52,4),ve("🗾",15,-8,45,8,2),ve("🧭",30,-8,45,8,2),ve("🌎",45,-8,45,8,2),ve("📺",1+(x.endX=55),0,55,5),x=gSceneBedroom,ve("🪟",1,-7,45,12,2),(L=ve("🛏",1,0,50,11,0,0,0,"!")).onPress=e=>{Y.mons.length||ye(Y,"I've slept enough!"),go()},ve("☮",20,-8,45,8,2),ve("🌉",30,-8,45,8,2);var F=ve("📺",20,0,47,6,0,0,0,"!");F.onPress=e=>{ye(F,"Dragon Warrior II",(e=>{ye(Y,"Would be cool if you could catch any monster and add it to your party.")}))},ve("🎮",21,0,51,3),ve("🕳",45,2,54.5,5,1),ve("🪜",45,0,54.6,5,0,0,0,"",gSceneHouseYou),x.endX=50,x=gSceneHouseYou,ve("🧻",89,-3.5,52,2.4,1),ve("🚽",x.endX=88,0,53,6),H.gMom=ve("🧍",41,0,53,8,0,0,3,"Right!<br>All boys leave home some day."),ve("📺",48,0,50,5,0,0,0,"There's a movie on TV. Four boys are walking on railroad tracks."),L=ve("🪜🪜🪜",x.youX=75,-8,46,5,2,0,0,"",gSceneBedroom),w.width=y.width=y.height,w.lineHeight=y.lineHeight=.9,ve("🛋",32,0,50,12),ve("🖼",22,-10,45,6,2),ve("🖼",32,-10,45,6,2),ve("🪟",62,-7,45,8,2),ve("🚪",0,0,50,11,0,0,0,"",gSceneWorld),ve("🪴",13,0,50,5),x=gSceneCenter1,ve("🚪",0,0,50,11,0,0,0,"",gSceneWorld),ve("🪴",13,0,50,5),ve("🪴",19,0,50,5),ve("🪑",25,0,51,5),ve("🪑",30,0,51,5),ve("🧘",30,0,51.1,5,0,-.35,3,"Emoji Centers heal your emojis."),ve("🗄",(v=54)-8-.9,0,53,6,0,.03),ve("🗄",v-4-.9,0,53,6,0,.03);var G=ve("👩⚕️",v,-5.7,52,3.5,1,0,3,"!");for(G.onPress=e=>{De(12),ye(G,"Welcome to our Emoji Center!",(e=>{ye(G,"Heal your emojis back to perfect health?"),Pe((e=>{go(),ye(G,"Healed! We hope to see you again.")}),(e=>{fe(),De(1)}))}))},ve("🗄",v-.9,0,53,6,0,.03),ve("🗄",v+4-.9,0,53,6,0,.03),ve("🗄",v+8-.9,0,53,6,0,.03),ve("💻",75,0,53,6),h=4;h--;)ve("🪟",9+18*h,-7,45,12,2);ve(Ze(12,3),9,0,51,6,3),ve("🧍♂️",70,0,53,7,0,.03,3,"No need for the computer. To drop an emoji, just swipe it upwards!"),x.endX=77,x=gSceneMart1,ve("🚪",0,0,50,11,0,0,0,"",gSceneWorld),ve("🧾",40,-6,45,3,2);var A=ve("👨💼",v=30,-5.5,51,3.5,1,0,3,"!");A.onPress=o=>{t?ye(A,"That's all I have?"):(De(13),ye(A,"Hey! You came from Color Palette Town?",(o=>{ye(A,"You know professor X right? His order came in. Will you take it to him?"),Pe((o=>{t=1,l.speech="My package! Too bad the emojidex doesn't fit into 13KB.",De(1),ye(A,e.emoji),he(e)}),(e=>{ye(A,"You're not supposed to say no! Get out of my shop!"),De(1)}))})))};for(var N=3;N--;)for(c=3;c--;)ve("📦",v+1.8*c,-2-.8*c+1.6*N,53-c-.1*N,4,1),c>0&&ve("📦",v-1.4*c,-2-.8*c+1.6*N,53-c-.1*N,4,1);for(ve(gMonKindCure.emoji,v-10+.2,0,50.5,4,0,0,3,"!").onPress=e=>{ye(A,"Buy for 1 coin?"),Pe((e=>{o>0&&(Ce(o-1),he(gMonKindCure)),fe(),De(1)}),(e=>{fe(),De(1)}))},h=3;h--;)ve("🪟",9+18*h,-7,45,12,2);if(ve(Ze(8,3),9,0,51,6,3),y.filter="hue-rotate(133deg)",x.endX=55,x=0,lo("scene")){t=1*lo("gQuest"),O=1*lo("gHour")||0;var E=lo("monIds").split(","),_=lo("monHps").split(",");h=0;for(var Z of E)for(var U of ne)U.id==Z&&me(he(U),1*_[h++]);Ce(1*lo("gold"));var q=He[lo("scene")-1];Ie(q.cameraY),ze(q.cameraZ),$e(q),R=1*lo("x"),ke(0)}else Ie(gSceneIntro.cameraY),ze(gSceneIntro.cameraZ),$e(gSceneIntro),gButR.style.display=gButL.style.display="none",De(0),setTimeout((e=>{ye(n,`Welcome to the ${W}!`,(e=>{ye(n,"My name is X, people call me the Emoji Professor!",(e=>{m.x=17,ue(m),ye(n,"This world is inhabited by creatures called emojis!",(e=>{ye(n,"Most of them are zombies. But we have a cure!",(e=>{ye(n,"Turns out you need to smack them with a non-zombie emoji, then throw a heart.",(e=>{ye(n,"A world of dreams and adventures with emojis awaits! Lets go!",(e=>{K.body.style.filter="brightness(0)",setTimeout((e=>{K.body.style.filter="brightness(1)",gButR.style.display=gButL.style.display="block",$e(gSceneBedroom)}),999)}))}))}))}))}))}))}),888);setInterval(je,33)};var co,ho=[5,,,,6,,,,8,,,,9,,,,10,,9,,10,,1,1,8,,6,,8,,1,1,6,,5,,6,,5,,6,,8,,10,,,],vo=[5,5,11,,6,6,11,,7,7,11,,8,8,11,,8,3,11,3,7,3,11,3,6,3,11],po=0,uo=(setInterval((e=>{co&&!Ue&&(po>=co.length?po=0:(yo(po),po++))}),200),[]),fo=(e,o)=>{if(uo[0]){co=[];for(var t=0;t<e.length;t++)e[t]?(co.push(uo[t%10].createBuffer(1,1e6,44100)),co[t].getChannelData(0).set(wo(e[t],o))):co.push(0)}},yo=e=>{if(co[e]){var o=e%10,t=uo[o].createBufferSource();t.buffer=co[e],t.connect(uo[o].destination),t.start()}},wo=(e,o)=>{e=130.81*1.06**e;for(var t=o,r=(e,o,t,r)=>Math.sin(e/o*6.28*t+r),a=(e,o)=>.1*Math.sin(e/44100*o*6.28+r(e,44100,o,0)**2+.75*r(e,44100,o,.25)+.1*r(e,44100,o,.5)),s=[],n=0;n<44100*t;n++)s[n]=n<88?n/88.2*a(n,e):(1-(n-88.2)/(44100*(t-.002)))**((.5*Math.log(1e4*e/44100))**2)*a(n,e);return s};