!function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:.5;return this.next()>t}},{key:"getPercentage",value:function(){return 100*this.next()}}]),e}(),L=[],X={},j=new B(o);function q(){for(var t=0;t<3;t++){for(var e=j.getPercentage(),i=j.getPercentage(),n=void 0,h=void 0,l=0;l=100*l/y.length&&e<100*(l+1)/y.length){n=y[l];break}for(var s=0;s=100*s/w.length&&i<100*(s+1)/w.length){h=w[s].f;break}var a=h.map((function(t){return t.map((function(t){return 0===t?j.getBooleanChance()>.5:1!==t&&(2===t||void 0)}))})),o=h.map((function(t){return t.map((function(t){return 0===t?j.getBooleanChance()>.5:1!==t&&(2===t||void 0)}))}));L.push({color:n,form1:a,form2:o})}}function I(){X.color="#D0D265",X.form=x.map((function(t,e){return t.map((function(t,e){return 0===t?j.getBooleanChance()>.5:1!==t&&(2===t||void 0)}))}))}q(),I();var O=document.getElementById("blk");function J(t,e){return t&&e&&t.p.xe.p.x&&t.p.ye.p.y}function N(){C=3,b=0,D=1,u=null,P=0,M.length=0,A.length=0}function U(t,e,i){r.fillStyle=t,e.forEach((function(t,e){t.forEach((function(t,n){t&&(r.fillRect(i.x+4*n,i.y+8*e,4,8),r.fillRect(i.x+44-4*(n+1),i.y+8*e,4,8))}))}))}function Y(t){r.fillStyle=X.color,X.form.forEach((function(e,i){e.forEach((function(e,n){e&&(r.fillRect(t.x+4*n,t.y+8*i,4,8),r.fillRect(t.x+60-4*(n+1),t.y+8*i,4,8))}))}))}function z(){var t={x:n.width/2-100,y:30},e=6.25;r.fillStyle=v,r.fillRect(t.x,t.y,50,25),r.fillRect(t.x+25,t.y,25,87.5),r.fillRect(t.x,t.y+62.5,50,25),r.fillRect(t.x+9*e,t.y,25,87.5),r.fillRect(t.x+9*e,t.y+62.5,9*e,25),r.fillRect(t.x+87.5,t.y,25,87.5),r.fillRect(t.x+19*e,t.y,25,87.5),r.fillRect(t.x+150,t.y,25,87.5),r.fillRect(t.x+150,t.y+62.5,50,25),r.fillRect(t.x+150,t.y+5*e,50,25)}O&&O.addEventListener("input",(function(t){o=t.target.value,j=new B(o),L.length=0,u=null,q(),I(),F||R||T||et()}));var G=function(){function e(){t(this,e),this.w=55,this.h=22,this.p={x:n.width/2-this.w/2,y:n.height-this.h},this.v=0,this.laser,this.damaged=!1}return i(e,[{key:"draw",value:function(){r.fillStyle=this.damaged?p:d,r.fillRect(this.p.x,this.p.y+1*this.h/3,this.w,2*this.h/3),r.fillRect(this.p.x+1*this.w/11,this.p.y,9*this.w/11,1*this.h/3),r.fillRect(this.p.x+4*this.w/11,this.p.y-1*this.h/3,3*this.w/11,1*this.h/3),r.fillRect(this.p.x+5*this.w/11,this.p.y-2*this.h/3,1*this.w/11,1*this.h/3)}},{key:"update",value:function(){this.draw(),(this.p.x>0&&this.v<0||this.p.x0)&&(this.p.x+=this.v*S)}},{key:"shoot",value:function(){this.laser=new H(c.p.x+c.w/2,c.p.y)}},{key:"damage",value:function(){var t=this;this.damaged=!0,setTimeout((function(){t.damaged=!1}),300)}}]),e}(),H=function(){function e(i,n){t(this,e),this.w=5,this.h=25,this.p={x:i-this.w/2,y:n-this.h}}return i(e,[{key:"draw",value:function(){r.fillStyle=p,r.fillRect(this.p.x,this.p.y,this.w,this.h)}},{key:"update",value:function(){this.draw(),this.p.y-=5*S}}]),e}(),K=function(){function e(i,n){t(this,e),this.w=5,this.h=25,this.p={x:i,y:n},this.speed=f.invaders.length<=5?3:2}return i(e,[{key:"draw",value:function(){r.fillStyle=v,r.fillRect(this.p.x,this.p.y,this.w,this.h)}},{key:"update",value:function(){this.draw(),this.p.y+=this.speed*S}}]),e}(),Q=function(){function e(i,n,h,l){t(this,e),this.w=44,this.h=48,this.p={x:i,y:n},this.score=h,this.row=l,this.reloading=!1,this.reloadingSpeed=1e3*Math.pow(.9,D-1),this.altForm=!1,this.draw()}return i(e,[{key:"draw",value:function(){U(L[this.row].color,this.altForm?L[this.row].form2:L[this.row].form1,this.p)}},{key:"shoot",value:function(){var t=this;!this.reloading&&f.canShoot&&(this.reloading=!0,setTimeout((function(){t.reloading=!1}),1e3),M.push(new K(this.p.x+this.w/2,this.p.y+this.h)))}},{key:"die",value:function(){b+=this.score,A.push(new Z(this.p.x+this.w/2,this.p.y+this.h/2,this.score))}}]),e}(),V=function(){function e(){var i=this;t(this,e),this.cols=E[Math.floor(Math.random()*E.length)],this.p={x:n.width/2-59*this.cols/2+7.5,y:100+12.6*(D-1)/2},this.d=1,this.delta=(new Date).getTime(),this.invaders=[],this.canShoot=!1,setTimeout((function(){i.canShoot=!0}),1e3),this.shootingRate=.005+.001*D,this.initialSpeed=666*Math.pow(.97,D-1),this.currentSpeed=this.initialSpeed;for(var h=0;hthis.currentSpeed){this.delta=e;var i=!0;this.invaders.forEach((function(e,h){if(1===t.d&&e.p.x+44>=n.width-10||-1===t.d&&e.p.x<=10)return i=!1,void t.advance()})),i&&this.move()}}},{key:"move",value:function(){var t=this;this.invaders.forEach((function(e){e.p.x+=11*t.d,e.altForm=!e.altForm}))}},{key:"advance",value:function(){this.d*=-1,this.invaders.forEach((function(t){t.p.y+=12.6,t.altForm=!t.altForm,t.p.y+t.h>=c.p.y-1.5*c.h&&(C=0)})),this.currentSpeed*=.97}}]),e}(),W=function(){function e(){t(this,e),this.w=60,this.h=24,this.d=Math.random()<.5?-1:1,this.p={x:-1===this.d?n.width:-this.w,y:50},this.score=k[Math.floor(Math.random()*k.length)]}return i(e,[{key:"draw",value:function(){Y(this.p)}},{key:"update",value:function(){this.draw(),this.p.x+=2*this.d*S}},{key:"die",value:function(){b+=this.score,P++,A.push(new Z(this.p.x+this.w/2,this.p.y+this.h/2,this.score))}}]),e}(),Z=function(){function e(i,n,h){var l=this;t(this,e),this.w=44,this.h=48,this.p={x:i,y:n},this.score=h,this.inProgress=!0,setTimeout((function(){l.inProgress=!1}),300)}return i(e,[{key:"draw",value:function(){r.fillStyle=v,r.font="24px "+g,r.textAlign="center",r.fillText(this.score+"",this.p.x,this.p.y)}},{key:"update",value:function(){this.draw()}}]),e}();function $(){c=new G,f=new V}l.addEventListener("click",(function(){R?(F||et(),R=!1):T?(N(),$(),F=!0,T=!1):F&&!c.laser?c.shoot():F||(N(),F=!0,$(),tt())})),a.addEventListener("click",(function(){R=!0,nt()}));var _=(new Date).getTime();function tt(){var t=(new Date).getTime(),e=t-_;_=t,S=60/(1e3/e),requestAnimationFrame(tt),R?nt():T?it():(r.clearRect(0,0,n.width,n.height),r.fillStyle="black",r.fillRect(0,0,n.width,n.height),c.draw(),c.update(),c.laser&&c.laser.p.y+c.laser.h<=0?c.laser=null:c.laser&&c.laser.update(),0===f.invaders.length?(D++,f=new V):f.update(),f.invaders.length>0&&Math.random()=n.height||t.p.y<=0?M.splice(e,1):t.update(),J(t,c)&&!c.damaged&&(C--,c.damage(),M.splice(e,1))})),!u&&Math.random()<.002*S/(P+2-D)&&(u=new W),u&&(-1===u.d&&u.p.x<-u.w||1===u.d&&u.p.x>n.width?u=null:u.update(),c.laser&&J(c.laser,u)&&(u.die(),u=null,c.laser=null)),A.forEach((function(t,e){t.inProgress?t.update():A.splice(e,1)})),r.fillStyle=v,r.font="24px "+g,r.textAlign="left",r.fillText("Score: "+b,20,30),function(){r.fillStyle=d;for(var t=3-C;t<3;t++)r.fillRect(n.width-35-30*t,15,20,20)}(),C<=0&&(T=!0,it()))}function et(){r.fillStyle="black",r.fillRect(0,0,n.width,n.height),z();for(var t=0;t<3;t++){U(L[t].color,L[t].form1,{x:75+100*t,y:190});var e=m[m.length-1-t];r.fillStyle=v,r.font="16px "+g,r.textAlign="center",r.fillText(e+" PTS",95+100*t,275)}Y({x:375,y:210}),r.fillStyle=v,r.font="16px "+g,r.textAlign="center",r.fillText("???",405,275),r.fillStyle=v,r.font="32px "+g,r.textAlign="center",r.fillText("Press X to start",n.width/2,375)}function it(){F=!1,r.fillStyle="black",r.fillRect(0,0,n.width,n.height),z(),r.fillStyle=v,r.font="32px "+g,r.textAlign="center",r.fillText("Your score:",n.width/2,200),r.font="48px "+g,r.fillText(b,n.width/2,275),r.font="32px "+g,r.fillText("Press X to restart",n.width/2,375)}function nt(){r.fillStyle="black",r.fillRect(0,0,n.width,n.height),z(),r.fillStyle=v,r.font="24px "+g,r.textAlign="center",r.fillText("This token is upgradable.",n.width/2,200),r.fillText("Join CULT:",n.width/2,250),r.fillText("x.com/CultBTC",n.width/2,280),r.font="32px "+g,r.fillText("Press X to return",n.width/2,375)}[{el:h,d:-1},{el:s,d:1}].forEach((function(t){var e=t.el,i=t.d;["mousedown","touchstart"].forEach((function(t){e.addEventListener(t,(function(){c&&(c.v=4*i)}))})),["mouseup","mouseleave","touchend","touchcancel"].forEach((function(t){e.addEventListener(t,(function(){c&&(c.v=0)}))}))})),et()}()}();