-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparadisecafe.js
1 lines (1 loc) · 72.4 KB
/
paradisecafe.js
1
class Resources{static async init(e){const t=e.scores.find((e=>"paradisecafe"===e.name)).scores;Resources.scoresData=JSON.parse(t);let s=0;for(let e=0;e<Resources.scoresData.length;e++){const t=parseInt(Resources.scoresData[e].score);t>s&&(s=t)}Resources.HIGH_SCORE=s;try{const t=e.media.images.length;for(let s=0;s<t;s++){const i=e.media.images[s],o=await fetch(i.path),a=await o.blob();Loader.update({text:"loading images",value:s/t});const h=new Image;h.src=URL.createObjectURL(a),i.imageData=h}Resources.imagesData=e.media.images}catch(e){console.error("Error loading images!",e)}try{e.media.audios.forEach((async e=>{const t=await fetch(e.path),s=await t.blob();e.audioData=window.URL.createObjectURL(s)})),Resources.audioData=e.media.audios}catch(e){console.error("Error loading audios!",e)}Resources.initialized=!0}static getImages(e=null){return e?Resources.imagesData.filter((t=>t.name.includes(`${e}_`))):Resources.imagesData}static getImage(e){return Resources.imagesData.find((t=>t.name.includes(e)))}static getTrack(e){return Resources.audioData.find((t=>t.name.includes(e)))}static resetPlayerInventory(){Resources.PLAYER_INVENTORY={wallet:!0,gun:!1,cash:30,points:0,drugs:0,expense:null}}}Resources.DIALOG_SPEED=1e3,Resources.imagesData=null,Resources.audioData=null,Resources.labelsData=null,Resources.scoresData=null,Resources.VERIFY_AGE_LINK="https://www.youtube.com/watch?v=Yzvr9nww1gg",Resources.initialized=!1,Resources.HIGH_SCORE=0,Resources.PLAYER_INVENTORY={wallet:!0,gun:!1,cash:30,points:0,drugs:0,expense:null};class Utils{static checkTopFive(e,t){let s=!1;for(let i=0;i<e.length;i++){if(t>=parseInt(e[i].score)){s=!0;break}}return s}static getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}static getRandomTrueFalse(){return Utils.getRandomItem([!0,!1,!1,!0,!1,!0,!0,!1,!0,!1,!1,!0,!1,!0,!1,!0,!0,!1])}static clearItemsFrom(e,t){let s=[];for(let i=0;i<e.length;i++){const o=e[i];o.name.includes(t)||s.push(o)}return s}static shuffle(e){e.map((e=>[Math.random(),e])).sort(((e,t)=>e[0]-t[0])).map((e=>e[1]))}static transition(e,t,s){let i=32,o=null;const a=document.querySelector("#transition-image");a.onload=()=>{t.height=a.height/4,t.width=a.width/4,e.drawImage(a,0,0,t.width,t.height),o=setInterval((()=>{(()=>{t.height=a.height,t.width=a.width;let h=i/100,r=t.width*h,n=t.height*h;e.msImageSmoothingEnabled=!1,e.mozImageSmoothingEnabled=!1,e.webkitImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e.drawImage(a,0,0,r,n),e.drawImage(t,0,0,r,n,0,0,t.width,t.height),i-=4,i<=0&&(s(),clearInterval(o),o=null)})()}),Game.CURRENT_SPEED)},a.src=t.toDataURL()}}class Component{constructor(e,t){this.callback=e,this.name=t,this.index=null,this.isEnabled=!1,this.images=Resources.getImages(this.name),this.actions=[],this.currentAction=null;const s=document.querySelector("canvas");this.canvasW=s.width,this.canvasH=s.height,this.animID=null,this.x=0,this.y=0,this.images.length>0?(this.width=this.images[0].imageData.width,this.height=this.images[0].imageData.height):(this.width=0,this.height=0),this.currentCycle=null,this.loopCurrentCycle=!1,this.setCurrentCycle()}moveTo(e,t=null){this.x=e,null!==t&&(this.y=t)}setCurrentCycle(e=null,t=!0){this.currentCycle=e,this.loopCurrentCycle=t,this.tick=0,this.currentCycle?(this.width=this.currentCycle[this.tick].imageData.width,this.height=this.currentCycle[this.tick].imageData.height):(this.width=0,this.height=0)}update(e){this.isEnabled&&(this.tick++,this.tick===this.currentCycle.length&&(this.loopCurrentCycle?this.tick=-1:this.tick=this.currentCycle.length-1))}getImagesByName(e){return this.images.filter((t=>t.name.includes(e)))}enable(){this.isEnabled=!0}disable(){this.currentAction=null,this.isEnabled=!1,this.animID=null,this.currentCycle=null,this.loopCurrentCycle=!1}get imageData(){return this.tick<0&&(this.tick=0),this.currentCycle[this.tick].imageData}}class Door extends Component{constructor(e){super(e,Door.NAME),this.cafeDoorImages=this.getImagesByName("door_cafe"),this.doorScrollImage=this.getImagesByName("door_scroll.png"),this.crackhouseScrollImage=this.getImagesByName("door_crackhouse_scroll"),this.doorOpenImages=this.getImagesByName("door_open"),this.doorCloseImages=[...this.doorOpenImages].reverse(),this.crackhouseDoorOpenImages=this.getImagesByName("door_crackhouse_open"),this.crackhouseDoorCloseImages=[...this.crackhouseDoorOpenImages].reverse(),this.currentScrollImage=this.doorScrollImage,this.isOpened=!1,this.scrollTick=0,this.actions=[Door.Actions.PARADISECAFE,Door.Actions.POLICE,Door.Actions.WHORE,Door.Actions.THIEF,Door.Actions.SCOUT,Door.Actions.CRACKHOUSE,Door.Actions.OLD_LADY,Door.Actions.SCROLL],this.currentAction=Door.Actions.SCROLL}doMove(){this.currentCycle!==this.currentScrollImage&&this.setCurrentCycle(this.currentScrollImage),this.x=this.canvasW-15*this.scrollTick,this.x<-this.width&&(this.scrollTick=0,this.currentAction=this.actions[Math.floor(Math.random()*this.actions.length)],this.currentAction===Door.Actions.CRACKHOUSE?this.currentScrollImage=this.crackhouseScrollImage:this.currentScrollImage=this.doorScrollImage),this.scrollTick++}doOpenDoor(){this.isOpened||(this.x=80,this.currentAction===Door.Actions.CRACKHOUSE?this.currentCycle!==this.crackhouseDoorOpenImages&&this.setCurrentCycle(this.crackhouseDoorOpenImages,!1):this.currentCycle!==this.doorOpenImages&&this.setCurrentCycle(this.doorOpenImages,!1),this.tick===this.currentCycle.length-1&&(this.isOpened=!0))}doCloseDoor(){this.isOpened&&(this.currentAction===Door.Actions.CRACKHOUSE?this.currentCycle!==this.crackhouseDoorCloseImages&&this.setCurrentCycle(this.crackhouseDoorCloseImages,!1):this.currentCycle!==this.doorCloseImages&&this.setCurrentCycle(this.doorCloseImages,!1),this.tick===this.currentCycle.length-1&&(this.isOpened=!1))}doParadiseCafe(){this.currentCycle!==this.cafeDoorImages&&this.setCurrentCycle(this.cafeDoorImages)}get hasAction(){if(this.x<80&&this.x>65){const e=this.actions[Math.floor(Math.random()*this.actions.length)];if(e!==Door.Actions.SCROLL)return e}return null}disable(){super.disable(),this.isOpened=!1}}Door.NAME="door",Door.Actions={PARADISECAFE:"paradise_cafe",POLICE:"police",WHORE:"whore",THIEF:"thief",SCOUT:"scout",CRACKHOUSE:"crackhouse",OLD_LADY:"oldlady",SCROLL:"scroll"};class Keyboard{static init(){Keyboard.ExitKey=document.querySelector("#exit-scene-button"),Keyboard.ExitKey.innerText=Resources.labelsData.EXIT,Keyboard.ExitKey.onclick=()=>{Keyboard.onChange(Resources.labelsData.EXIT)}}static onChange(e){}static build(e){const t=document.querySelector("#keyboard");t.innerHTML="";for(let s=0;s<e.length;s++){const i=e[s],o=document.createElement("button");o.innerText=i.text,o.action=i.action,o.onclick=()=>{Keyboard.onChange(o.action)},t.appendChild(o)}}static updateButtonText(e,t=!1){const s=document.querySelector("#keyboard").querySelector("button");s.innerText=e,t&&(s.action=e)}static show(e){e&&Keyboard.build(e),document.querySelector("#keyboard").style.transform="translateY(0)",Keyboard.isShown=!0,Keyboard.exitEnabled&&Keyboard.hideExit()}static showExit(e){Keyboard.ExitKey.className="visible",Keyboard.isExitShown=!0,Keyboard.ExitKey.onclick=e}static hideExit(){Keyboard.ExitKey.className="invisible",Keyboard.isExitShown=!1,Keyboard.ExitKey.onclick=null}static hide(){document.querySelector("#keyboard").style.transform="translateY(100%)",Keyboard.onChange=()=>{},Keyboard.isShown=!1,Keyboard.exitEnabled&&Keyboard.showExit()}}Keyboard.isShown=!1,Keyboard.isExitShown=!1,Keyboard.ExitKey=null,Keyboard.exitEnabled=!1;class AudioSource{constructor(){this.player=new Audio,this.currentSrc=null,this.player.onended=async()=>{await this.play(this.currentSrc)},this.mutedVolume=0}async play(e=null){e&&e!==this.currentSrc&&(this.player.paused||this.stop(),this.currentSrc=this.player.src=e,await this.player.play())}stop(){this.player.pause()}set volume(e){this.player.volume=e}mute(){0===this.mutedVolume?(this.mutedVolume=this.player.volume,this.player.volume=0):(this.player.volume=this.mutedVolume,this.mutedVolume=0)}}class Background extends Component{constructor(e,t=null){super(e,t);const s=`${t}_${Background.NAME}`;this.images=this.images.filter((e=>e.name.includes(s))),this.images.length>0?(this.width=this.images[0].imageData.width,this.height=this.images[0].imageData.height):(this.width=0,this.height=0),this.currentCycle=this.images,this.isEnabled=!0}updateTimed(e=1e3){this.animID||(this.animID=setTimeout((()=>{this.animID=null}),e),super.update(!0))}disable(){super.disable()}}Background.NAME="bckgrd";class HUD extends Component{static init(){HUD.canvas=document.querySelector("canvas"),HUD.ctx=HUD.canvas.getContext("2d"),HUD.ctx.imageSmoothingEnabled=!1,HUD.scoresBackgroundImage=Resources.getImage("hud_score_bckgrd"),HUD.walletONIcon=Resources.getImage("icons_wallet_on").imageData,HUD.walletOFFIcon=Resources.getImage("icons_wallet_off").imageData,HUD.gunONIcon=Resources.getImage("icons_gun_on").imageData,HUD.gunOFFIcon=Resources.getImage("icons_gun_off").imageData,HUD.hiScorewsX=0,HUD.isEnabled=!0}static drawHiScores(){const e=HUD.canvas.height-35,t=HUD.canvas.width-HUD.hiScorewsX;HUD.ctx.drawImage(HUD.scoresBackgroundImage.imageData,0,e,HUD.canvas.width,10);const s=`${Resources.labelsData.HISCORE} = ${Resources.HIGH_SCORE}`;let i=HUD.ctx.measureText(s);HUD.ctx.fillStyle="#bdbdbd",HUD.ctx.fillRect(t,e,i.width,10),HUD.ctx.fillStyle="#000000",HUD.ctx.fillRect(t-10,e,10,10),HUD.ctx.fillText(s,t,e+8),HUD.ctx.fillRect(t+i.width,e,10,10),HUD.ctx.fillStyle="#ffffff",HUD.hiScorewsX+=3,HUD.hiScorewsX>HUD.canvas.width+(i.width+20)&&(HUD.hiScorewsX=0)}static drawExpense(e){const t=`${Resources.labelsData.EXPENSE}=${e}$`,s=HUD.ctx.measureText(t);HUD.ctx.fillText(t,HUD.canvas.width-s.width,HUD.canvas.height-35)}static update(e){if(!HUD.isEnabled)return;HUD.hiScoresEnabled?HUD.drawHiScores():HUD.hiScorewsX=0,null!==e.expense&&HUD.drawExpense(e.expense),HUD.ctx.font="20px Mono",HUD.ctx.fillStyle="#ffffff";let t=HUD.canvas.height-16,s=HUD.canvas.height-3;const i=`${Resources.labelsData.POINTS}=${e.points}`;let o=HUD.ctx.measureText(i);HUD.ctx.fillText(i,0,t);const a=`${Resources.labelsData.CASH}=${e.cash}$`;o=HUD.ctx.measureText(a),HUD.ctx.fillText(a,HUD.canvas.width-o.width,t),HUD.ctx.fillText(`${Resources.labelsData.DRUGS}=${e.drugs}`,0,s),e.wallet?HUD.ctx.drawImage(this.walletONIcon,0,0,HUD.canvas.width,HUD.canvas.height+2):HUD.ctx.drawImage(this.walletOFFIcon,0,0,HUD.canvas.width,HUD.canvas.height+2),e.gun?HUD.ctx.drawImage(this.gunONIcon,0,0,HUD.canvas.width,HUD.canvas.height+2):HUD.ctx.drawImage(this.gunOFFIcon,0,0,HUD.canvas.width,HUD.canvas.height+2)}}HUD.NAME="hud",HUD.ctx=null,HUD.canvas=null,HUD.scoresBackgroundImage=null,HUD.walletONIcon=null,HUD.walletOFFIcon=null,HUD.gunONIcon=null,HUD.gunOFFIcon=null,HUD.hiScoresEnabled=!0,HUD.hiScorewsX=0;class Loader{static init(){Loader.canvas=document.querySelector("canvas"),Loader.ctx=Loader.canvas.getContext("2d")}static update(e){const t=Loader.canvas.width,s=Loader.canvas.height;let i=t*e.value-20;i<0&&(i=0),Loader.ctx.font="28px Mono",Loader.ctx.fillStyle="#ffffff",Loader.ctx.clearRect(0,0,t,s),Loader.ctx.fillText(`A CARREGAR: ${Math.floor(100*e.value)}%`,10,s/2+40),Loader.ctx.fillRect(10,s/2,i,20),Loader.ctx.strokeStyle="#ffffff",Loader.ctx.rect(5,s/2-5,t-10,30),Loader.ctx.stroke()}static clear(){Loader.ctx.clearRect(0,0,Loader.canvas.width,Loader.canvas.height)}}Loader.canvas=null,Loader.ctx=null,Loader.callback=null,Loader.Events={START:"loadereventsstart",END:"loadereventsend"};class Renderer{constructor(e){this.callback=e,this.canvas=document.querySelector("canvas"),this.ctx=this.canvas.getContext("2d"),this.width=this.canvas.width,this.height=this.canvas.height}render(e){this.ctx.clearRect(0,0,this.width,this.height),e.forEach((e=>{this.ctx.drawImage(e.imageData,e.x,e.y,e.width,e.height)}))}}class Balloon extends Component{constructor(e){super(e,Balloon.NAME),this.isBalloon=!1,Balloon.EMPTY_BALLON=Resources.getImage("empty"),this.currentCycle=[Balloon.EMPTY_BALLON],this.width=Balloon.EMPTY_BALLON.imageData.width,this.height=Balloon.EMPTY_BALLON.imageData.height,this.isDialog=!1}clear(){this.animID&&clearInterval(this.animID),this.animID=null,this.isDialog=!1,this.currentCycle=[Balloon.EMPTY_BALLON]}doDialog(e,t=!0,s=null){if(e.length||(e=[e]),this.isDialog=!0,!t)return this.currentCycle=[e[0]],void(this.isDialog=!1);let i=0;const o=()=>{this.animID=setTimeout((()=>{if(i++,i===e.length)return this.isDialog=!1,this.currentCycle=[Balloon.EMPTY_BALLON],this.animID=null,void(s&&s(Balloon.Events.BALLONS_DONE));this.currentCycle=[e[i]],o()}),Balloon.TIMEOUT)};this.currentCycle=[e[i]],o()}}Balloon.Events={BALLONS_DONE:"ballooneventsdone"},Balloon.EMPTY_BALLON=null,Balloon.TIMEOUT=2e3,Balloon.NAME="balloon";class Controller{constructor(e){this.callback=e,this.isShown=!1,this.view=document.querySelector("#controller"),document.querySelector("#menu-button").onclick=e=>{this.callback(Controller.Events.MENU)}}show(){this.isShown||(this.view.style.transform="translateY(0)",this.isShown=!0)}hide(){this.isShown&&(this.view.style.transform="translateY(-100%)",this.isShown=!1)}}Controller.Events={MENU:"controllereventsmenu"};class SwipeDoor extends Component{constructor(e){super(e,SwipeDoor.NAME),this.swipeOpenImages=this.getImagesByName(SwipeDoor.NAME),this.swipeCloseImages=[...this.swipeOpenImages].reverse(),this.currentCycle=[this.swipeCloseImages[this.swipeCloseImages.length-1]]}doOpen(){this.isOpened||(this.currentCycle!==this.swipeOpenImages&&this.setCurrentCycle(this.swipeOpenImages,!1),this.tick===this.currentCycle.length-1&&(this.isOpened=!0))}doClose(e=!1){(this.isOpened||e)&&(this.currentCycle!==this.swipeCloseImages&&this.setCurrentCycle(this.swipeCloseImages,!1),this.tick===this.currentCycle.length-1&&(this.isOpened=!1))}enable(){super.enable()}disable(){super.disable(),this.isOpened=!1}}SwipeDoor.NAME="swipe";class Menu{constructor(e){this.view=document.querySelector("#menu-container"),this.isOpen=!1,document.querySelector("#music-button").onclick=t=>{const s=t.target;s.innerText.includes("X")?(s.innerHTML=`${Resources.labelsData.MUSIC}[ ]`,e(Menu.Actions.MUSIC_OFF)):(s.innerHTML=`${Resources.labelsData.MUSIC}[<span class="highlight">X</span>]`,e(Menu.Actions.MUSIC_ON)),this.close()},this.nButton=document.querySelector("#nspeed-button"),this.nButton.onclick=t=>{e(this.updateSpeed(this.nButton)),this.close()},this.currentSpeedButton=this.nButton,this.tButton=document.querySelector("#tspeed-button"),this.tButton.onclick=t=>{e(this.updateSpeed(this.tButton)),this.close()},document.querySelector("#about-button").onclick=t=>{e(Menu.Actions.ABOUT),this.close()},document.querySelector("#exit-button").onclick=t=>{e(Menu.Actions.EXIT),this.close()},document.querySelector("#close-button").onclick=e=>{this.close()}}updateSpeed(e){if(e!==this.currentSpeedButton)return this.currentSpeedButton=e,this.nButton===e?(this.nButton.innerHTML=`${Resources.labelsData.NORMAL}[<span class="highlight">X</span>]`,this.tButton.innerHTML=`${Resources.labelsData.TURBO}[ ]`,Menu.Actions.NORMAL_SPEED):(this.tButton.innerHTML=`${Resources.labelsData.TURBO}[<span class="highlight">X</span>]`,this.nButton.innerHTML=`${Resources.labelsData.NORMAL}[ ]`,Menu.Actions.TURBO_SPEED)}open(){this.isOpen||(this.isOpen=!0,this.view.style.transform="translateX(0)")}close(){this.isOpen&&(this.isOpen=!1,this.view.style.transform="translateX(100%)")}}Menu.Actions={MUSIC_ON:"menuactionsmusicon",MUSIC_OFF:"menuactionsmusicoff",NORMAL_SPEED:"menuactionsnormalspeed",TURBO_SPEED:"menuactionsturbospeed",ABOUT:"menuactionsabout",EXIT:"menuactionsexit"};class Scene{constructor(e,t){if(this.callback=e,this.name=t,this.tick=null,this.balloon=null,this.background=null,Resources.initialized){this.background=new Background((e=>{}),this.name);const e=Resources.getTrack(`${this.name}_track`);this.music=e?e.path:null}this.hero=null,this.NPCs=[],this.currentNPCIndex=0,this.props=[],this.currentPropIndex=0,this.animID=null,this.lighting=null,this.renderStack=[],this.reset()}update(e,t=!1){this.renderStack=[],this.background&&(t||this.background.update(),this.renderStack.push({imageData:this.background.imageData,x:this.background.x,y:this.background.y,width:this.background.width,height:this.background.height})),this.props.length>0&&this.props.forEach((e=>{e.isEnabled&&this.renderStack.push({imageData:e.imageData,x:e.x,y:e.y,width:e.width,height:e.height})})),this.NPCs.length>0&&this.NPCs.forEach((e=>{e.isEnabled&&this.renderStack.push({imageData:e.imageData,x:e.x,y:e.y,width:e.width,height:e.height})})),this.hero&&this.hero.isEnabled&&this.renderStack.push({imageData:this.hero.imageData,x:this.hero.x,y:this.hero.y,width:this.hero.width,height:this.hero.height}),this.lighting&&this.renderStack.push({imageData:this.lighting.imageData,x:this.background.x,y:this.background.y,width:this.background.width,height:this.background.height}),this.balloon&&this.renderStack.push({imageData:this.balloon.imageData,x:this.balloon.x,y:this.balloon.y,width:this.balloon.width,height:this.balloon.height})}reset(){this.tick=-1,this.animID=null}enable(){document.querySelector("html").style.backgroundColor=`var(--${this.name}scene-color)`,this.isEnabled=!0,this.hero&&(this.hero.inventory=Resources.PLAYER_INVENTORY)}disable(){this.isEnabled=!1,this.hero&&(Resources.PLAYER_INVENTORY=this.hero.inventory)}}Scene.ANIM_TIMEOUT=1e3;class LandingScene extends Scene{constructor(e){super(e,LandingScene.NAME),this.isBlink=!0,this.canvas=document.querySelector("canvas"),this.width=this.canvas.width,this.height=this.canvas.height,this.ctx=this.canvas.getContext("2d")}update(){let e;this.animID||(this.animID=setTimeout((()=>{this.isBlink=!this.isBlink,this.animID=null}),Scene.ANIM_TIMEOUT)),this.ctx.clearRect(0,0,this.width,this.height),this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.width,this.height),e=this.isBlink?"red":"rgba(255,0,0,0.5)",this.ctx.fillStyle=e,this.ctx.font="bold 33px Mono";let t=Resources.labelsData.NO_ACCESS_WARNING.split(","),s=this.ctx.measureText(t[0]);this.ctx.fillText(t[0],this.width/2-s.width/2,this.height/2-20),s=this.ctx.measureText(t[1]),this.ctx.fillText(t[1],this.width/2-s.width/2,this.height/2),this.ctx.fillStyle="white",this.ctx.font="24px Mono",t=Resources.labelsData.AGE_VERIFY,s=this.ctx.measureText(t),this.ctx.fillText(t,this.width/2-s.width/2,this.height/2+40)}enable(){super.enable(),Keyboard.show([{text:Resources.labelsData.YES,action:Resources.labelsData.YES},{text:Resources.labelsData.NO,action:Resources.labelsData.NO}]),Keyboard.onChange=e=>{e!==Resources.labelsData.NO&&Keyboard.hide(),this.callback(e)}}disable(){this.animID&&clearTimeout(this.animID),super.disable()}}LandingScene.NAME="landing";class SplashScene extends Scene{constructor(e){super(e,SplashScene.NAME),this.loadingCanvas=null,this.loadingCtx=null,this.width=document.body.offsetWidth,this.height=document.body.offsetHeight,this.animTick=0,this.yPos=0,this.FX1Colors=["rgb(0, 255, 255)","rgb(192, 0, 0)"],this.FX2Colors=["rgb(255, 255, 0)","rgb(0, 0, 255)"],this.FX3Colors=["rgb(0, 0, 0)","rgb(0, 0, 192)","rgb(192, 0, 0)","rgb(192, 0, 192)","rgb(0, 0, 255)","rgb(255, 0, 0)","rgb(255, 0, 255)","rgb(0, 192, 0)","rgb(0, 192, 192)","rgb(192, 192, 0)","rgb(192, 192, 192)","rgb(0, 255, 0)","rgb(0, 255, 255)","rgb(255, 255, 0)","rgb(255, 255, 255)"],this.SCENE_TIME=14,this.SCENE_TIMEOUT=0}update(e){super.update(e),this.SCENE_TIMEOUT++,this.SCENE_TIMEOUT>=this.SCENE_TIME&&this.callback()}renderBackground(){let e,t=null;const s=i=>{this.isEnabled&&(t||(t=i),e=i-t,this.loadingCtx.fillStyle="rgb(0, 0, 0)",this.loadingCtx.fillRect(0,0,this.width,this.height),e<597?this.FX1():e>=596&&e<4446?this.FX2():e>=4446&&this.FX3(),this.isEnabled&&window.requestAnimationFrame(s))};s()}FX1(){let e=0;for(let t=0;t<this.height;t++){if(e>=this.FX1Colors.length&&(e=0),this.loadingCtx.fillStyle=this.FX1Colors[e],this.loadingCtx.fillRect(0,this.yPos,this.width,32),this.yPos>=this.height+32){this.yPos=-64;break}this.yPos+=32,e++}this.animTick++,64===this.animTick&&(this.animTick=0),this.yPos+=this.animTick}FX2(){let e=0;const t=[8,16,32,32,64];let s;for(let i=0;i<this.height;i++){if(s=Utils.getRandomItem(t),e>=this.FX2Colors.length&&(e=0),this.loadingCtx.fillStyle=this.FX2Colors[e],this.loadingCtx.fillRect(0,this.yPos,this.width,s),this.yPos>=this.height){this.yPos=0;break}this.yPos+=s,e++}}FX3(){for(let e=0;e<this.height;e++){if(this.loadingCtx.fillStyle=Utils.getRandomItem(this.FX3Colors),this.loadingCtx.fillRect(0,this.yPos,this.width,4),this.yPos>=this.height){this.yPos=0;break}this.yPos+=4}}enable(){this.loadingCanvas=document.createElement("canvas"),this.loadingCanvas.className="v-canvas",this.loadingCanvas.width=this.width,this.loadingCanvas.height=this.height,document.querySelector("#main-container").appendChild(this.loadingCanvas),this.loadingCtx=this.loadingCanvas.getContext("2d"),super.enable(),this.renderBackground()}disable(){document.body.querySelector("#main-container").removeChild(this.loadingCanvas),this.loadingCanvas=null,this.loadingCtx=null,super.disable()}}SplashScene.NAME="splash";class MainScene extends Scene{constructor(e){super(e,MainScene.NAME),this.blink=!0}update(e){this.renderStack=[],this.blink=!this.blink,this.blink&&this.background.update(),this.renderStack=[this.background]}enable(){super.enable(),Keyboard.show([{text:Resources.labelsData.PLAY,action:Resources.labelsData.PLAY},{text:Resources.labelsData.HISCORES,action:Resources.labelsData.HISCORES}]),Keyboard.onChange=e=>{Keyboard.hide(),this.callback(e)}}disable(){super.disable()}}MainScene.NAME="main";class ScoresScene extends Scene{constructor(e){super(e,ScoresScene.NAME),this.scoresData=[{id:0,name:"TST",score:1e4,date_created:"23-ABR-2016"}],this.blink=!0,this.canvas=document.querySelector("canvas"),this.width=this.canvas.width,this.height=this.canvas.height,this.ctx=this.canvas.getContext("2d")}update(){this.ctx.clearRect(0,0,this.width,this.height),this.blink=!this.blink,this.blink?this.ctx.drawImage(this.background.images[0].imageData,0,0):this.ctx.drawImage(this.background.images[1].imageData,0,0),this.ctx.font="28px Mono",this.ctx.fillStyle="black",this.ctx.fillText(Resources.labelsData.HI_SCORES,80,40),this.ctx.font="20px Mono",this.ctx.fillText(Resources.labelsData.NAME,40,60),this.ctx.fillText(Resources.labelsData.SCORE,145,60);for(let e=0;e<ScoresScene.MAX_SCORES;e++){const t=this.scoresData[e];let s,i;t?(this.ctx.fillStyle="white",s=t.name,i=t.score):(this.ctx.fillStyle="black",s="---",i="-------"),this.ctx.fillText(s,40,80+10*e),this.ctx.fillText(i,145,80+10*e)}}async enable(){super.enable(),this.scoresData=Resources.scoresData,Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.HOME,action:Resources.labelsData.HOME}]),Keyboard.onChange=e=>{Keyboard.hide(),this.callback()})}disable(){super.disable(),this.scoresTick=0}}ScoresScene.NAME="scores",ScoresScene.MAX_SCORES=5;class StreetScene extends Scene{constructor(e){super(e,StreetScene.NAME),this.balloon=new Balloon,this.hero=new Hero,this.door=new Door,this.props.push(this.door),this.door.index=this.props.length-1,this.thief=new Thief,this.NPCs.push(this.thief),this.thief.index=this.NPCs.length-1,this.whore=new Whore,this.NPCs.push(this.whore),this.whore.index=this.NPCs.length-1,this.scout=new Scout,this.NPCs.push(this.scout),this.scout.index=this.NPCs.length-1,this.oldLady=new OldLady,this.NPCs.push(this.oldLady),this.oldLady.index=this.NPCs.length-1,this.police=new Police,this.NPCs.push(this.police),this.police.index=this.NPCs.length-1,this.currentAction=null,this.endAction=!1,this.changeAction(Door.Actions.SCROLL)}doPolice(){if(!this.balloon.isDialog){if(this.endAction)return this.police.hasArrest?void this.callback(JailScene.NAME):this.police.isOutside?void this.police.doEnterDoor():(this.police.disable(),this.door.isOpened?void this.door.doCloseDoor():void this.changeAction(Door.Actions.SCROLL));if(this.hero.doIdleStreet(),this.door.isOpened)return this.police.isOutside?this.police.isAskDocs?(Resources.PLAYER_INVENTORY.wallet?(this.hero.doShowDocs(),this.balloon.doDialog([Balloon.EMPTY_BALLON,this.police.getBalloon("ok_you_can_go")]),this.police.isAskDocs=!1):(this.balloon.doDialog([this.hero.getBalloon("no_wallet"),this.police.getBalloon("come_with_me")]),this.hero.doIdleStreet(0),this.police.hasArrest=!0),void(this.endAction=!0)):void(this.police.currentAction===Police.Actions.ASK_PAPERS?(this.balloon.doDialog(this.police.getBalloon("ask_docs")),this.police.doAskDocs(),this.hero.doIdleStreet(0)):(this.balloon.doDialog([this.police.getBalloon("salute"),this.hero.getBalloon("everything_fine")]),this.endAction=!0)):(this.police.isEnabled||this.police.enable(),void this.police.doExitDoor());this.door.doOpenDoor()}}doOldLady(){if(this.balloon.isDialog)this.hero.isUndressed&&this.hero.doOldLadyRape();else{if(this.endAction)return this.oldLady.isRobbed?(this.hero.updateInventory({points:this.oldLady.inventory.points,cash:this.oldLady.currentStash.cash}),this.oldLady.isRobbed=!1):this.oldLady.isRaped&&(this.hero.updateInventory({points:this.oldLady.inventory.points}),this.oldLady.isRaped=!1,this.hero.isDone=!1),this.oldLady.isOutside?void this.oldLady.doEnterDoor():(this.hero.doIdleStreet(0),this.door.isOpened?(this.oldLady.disable(),void this.door.doCloseDoor()):void this.changeAction(Door.Actions.SCROLL));if(!this.door.isOpened)return this.hero.doIdleStreet(0),void this.door.doOpenDoor();if(!this.oldLady.isOutside)return this.oldLady.isEnabled||this.oldLady.enable(),void this.oldLady.doExitDoor();if(this.oldLady.isRobbed)return this.hero.doRobOldLady(),this.balloon.doDialog([this.hero.getBalloon("this_is_a_robbery"),this.oldLady.getBalloon("ho_my_god"),this.oldLady.currentStash.balloon]),void(this.endAction=!0);if(this.oldLady.isRaped)if(this.oldLady.isFear)if(this.hero.isDone){if(this.hero.isUndressed)return this.oldLady.doUnbend(),void this.hero.doDress();this.oldLady.doIdleStreet(),this.hero.doIdleStreet(0),this.balloon.doDialog(this.oldLady.getBalloon("deserves5")),this.endAction=!0}else{if(!this.hero.isUndressed)return this.oldLady.doBend(),void this.hero.doUndress();this.balloon.doDialog([Balloon.EMPTY_BALLON,this.oldLady.getBalloon("so_big"),Balloon.EMPTY_BALLON,this.hero.getBalloon("its_done")]),this.hero.isDone=!0}else this.hero.doRobOldLady(),this.balloon.doDialog([this.hero.getBalloon("turn_around"),this.oldLady.getBalloon("ho_my_god")]),this.oldLady.isFear=!0;else this.hero.doIdleStreet(),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.RAPE,action:Resources.labelsData.RAPE},{text:Resources.labelsData.ROB,action:Resources.labelsData.ROB},{text:Resources.labelsData.CONTINUE,action:Resources.labelsData.CONTINUE}]),Keyboard.onChange=e=>{if(Keyboard.hide(),e!==Resources.labelsData.CONTINUE&&!Resources.PLAYER_INVENTORY.gun)return this.balloon.doDialog(this.hero.getBalloon("no_gun")),this.hero.doIdleStreet(2),void(this.endAction=!0);e===Resources.labelsData.RAPE?this.oldLady.isRaped=!0:e===Resources.labelsData.ROB?this.oldLady.isRobbed=!0:(this.hero.updateInventory({lossPoints:this.oldLady.inventory.lossPoints}),this.endAction=!0)})}}doScout(){if(!this.balloon.isDialog){if(this.endAction)return this.scout.isOutside?(this.scout.isRobbed?this.hero.updateInventory({points:this.scout.inventory.points,cash:this.scout.currentStash.cash}):this.hero.updateInventory({lossPoints:this.scout.inventory.lossPoints}),void this.scout.doEnterDoor()):this.door.isOpened?void this.door.doCloseDoor():(this.changeAction(Door.Actions.SCROLL),void this.scout.disable());if(!this.door.isOpened)return this.hero.doIdleStreet(),void this.door.doOpenDoor();if(!this.scout.isOutside)return this.scout.isEnabled||this.scout.enable(),void this.scout.doExitDoor();if(this.scout.isSalute)return this.scout.isRobbed?(this.scout.doIdleFear(),this.hero.isDone?(this.balloon.doDialog([this.hero.getBalloon("whats_in_pack"),this.scout.currentStash.balloon]),void(this.endAction=!0)):void this.hero.doRobScout()):void(Keyboard.isShown||(this.balloon.doDialog([this.scout.getBalloon("scout_hi_friend")],!1),Keyboard.show([{text:Resources.labelsData.ROB,action:Resources.labelsData.ROB},{text:Resources.labelsData.CONTINUE,action:Resources.labelsData.CONTINUE}]),Keyboard.onChange=e=>{this.balloon.clear(),e===Resources.labelsData.ROB?this.scout.isRobbed=!0:this.endAction=!0,Keyboard.hide()}));this.scout.doSalute()}}doCrackhouse(){if(!this.balloon.isDialog)if(this.endAction)if("cont"===this.hero.act)this.changeAction(Door.Actions.SCROLL),this.hero.act=void 0;else{if(!this.door.isOpened)return void this.door.doOpenDoor();if(this.hero.isOutside)return void this.hero.doEnterDoor();this.callback(CrackhouseScene.NAME),this.changeAction(Door.Actions.SCROLL)}else this.hero.doIdleStreet(),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.RENT,action:Resources.labelsData.RENT},{text:Resources.labelsData.CONTINUE,action:Resources.labelsData.CONTINUE}]),Keyboard.onChange=e=>{e===Resources.labelsData.RENT?0===Resources.PLAYER_INVENTORY.drugs?(this.balloon.doDialog([this.hero.getBalloon("no_drugs")]),this.hero.act="cont",this.hero.doIdleStreet(2)):Resources.PLAYER_INVENTORY.cash<CrackhouseScene.RENT_COST&&(this.balloon.doDialog([this.hero.getBalloon("no_cash")]),this.hero.act="cont",this.hero.doIdleStreet(2)):this.hero.act="cont",this.endAction=!0,Keyboard.hide()})}doWhore(){if(!this.balloon.isDialog)if(this.endAction)if(this.whore.isAccepted){if(this.whore.isOutside)return void this.whore.doEnterDoor();if(this.hero.isOutside)return void this.hero.doEnterDoor();if(this.door.isOpened)return void this.door.doCloseDoor();this.callback(BrothelScene.NAME),this.changeAction(Door.Actions.SCROLL)}else{if(this.whore.isOutside)return void this.whore.doEnterDoor();if(this.whore.disable(),this.door.isOpened)return void this.door.doCloseDoor();this.balloon.doDialog([this.hero.getBalloon("hero_pussy")]),this.hero.updateInventory({lossPoints:this.whore.inventory.lossPoints}),this.hero.doIdleStreet(2),this.changeAction(Door.Actions.SCROLL)}else if(this.hero.doIdleStreet(0),this.door.isOpened){if(this.hero.doIdleStreet(),!this.whore.isOutside)return this.whore.isEnabled||this.whore.enable(),void this.whore.doExitDoor();Keyboard.isShown||(this.balloon.doDialog([this.whore.getRandomBalloon("street_question")],!1),Keyboard.show([{text:Resources.labelsData.ACCEPT,action:Resources.labelsData.ACCEPT},{text:Resources.labelsData.CONTINUE,action:Resources.labelsData.CONTINUE}]),Keyboard.onChange=e=>{e===Resources.labelsData.ACCEPT?(this.whore.isAccepted=!0,this.balloon.doDialog([this.whore.getBalloon("come_on_then")])):this.balloon.clear(),this.endAction=!0,Keyboard.hide()})}else this.door.doOpenDoor()}doThief(){if(!this.balloon.isDialog){if(this.endAction)return this.thief.currentAction===Thief.Actions.ROB?void(this.thief.isOutside?this.thief.doEnterDoor():(Resources.PLAYER_INVENTORY.gun?this.balloon.doDialog([this.hero.getBalloon("dont_have_gun")]):this.balloon.doDialog([this.hero.getBalloon("shit")]),this.hero.doIdleStreet(2),this.thief.currentAction=null,this.thief.disable(),this.hero.updateInventory({lossPoints:this.thief.inventory.lossPoints,wallet:!1}))):this.thief.currentAction===Thief.Actions.HURT?(this.hero.updateInventory({points:this.thief.inventory.points}),this.balloon.doDialog([this.thief.getBalloon("only_wanted_light")]),void(this.thief.currentAction=null)):(this.thief.currentAction=null,this.hero.doIdleStreet(0),this.thief.isOutside?void this.thief.doEnterDoor():this.door.isOpened?void this.door.doCloseDoor():void this.changeAction(Door.Actions.SCROLL));if(this.hero.doIdleStreet(0),this.door.isOpened){if(!this.thief.isOutside)return this.thief.isEnabled||this.thief.enable(),void this.thief.doExitDoor();switch(this.thief.currentAction){case Thief.Actions.ASK_LIGHT:this.balloon.doDialog([this.thief.getBalloon("ask_light"),this.hero.getBalloon("dont_smoke")]),this.endAction=!0;break;case Thief.Actions.ROB:if(this.thief.doShowGun(),!Resources.PLAYER_INVENTORY.gun)return this.balloon.doDialog([this.thief.getBalloon("give_me_wallet")]),void(this.endAction=!0);if(this.balloon.doDialog([this.thief.getBalloon("give_me_wallet")],!1),this.animID)return;let e=Thief.ACTION_TIMEOUT;this.animID=setInterval((()=>{if(0===e)return clearInterval(this.animID),this.animID=null,Keyboard.hide(),void(this.endAction=!0);e--,Keyboard.updateButtonText(`${Resources.labelsData.DEFEND} ${e}`)}),1e3),Keyboard.isShown||(Keyboard.show([{text:`${Resources.labelsData.DEFEND} ${Thief.ACTION_TIMEOUT}`,action:Resources.labelsData.DEFEND}]),Keyboard.onChange=e=>{this.animID&&(clearInterval(this.animID),this.animID=null),this.balloon.animID&&this.balloon.clear(),Keyboard.hide(),this.thief.currentAction=Thief.Actions.HURT});break;case Thief.Actions.HURT:if(!this.thief.isHurted)return void this.thief.doHurt();this.endAction=!0}}else this.door.doOpenDoor()}}doParadiseCafe(){return this.endAction?this.hero.doAction?void(this.hero.isOutside?this.hero.doEnterDoor():this.hero.doAction=!1):this.door.isOpened?void this.door.doCloseDoor():void(this.hero.isOutside?this.changeAction(Door.Actions.SCROLL):this.callback(ParadiseCafeScene.NAME)):this.door.isOpened?(this.door.doParadiseCafe(),this.hero.doIdleStreet(),void(Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.ENTER,action:Resources.labelsData.ENTER},{text:Resources.labelsData.CONTINUE,action:Resources.labelsData.CONTINUE}]),Keyboard.onChange=e=>{e===Resources.labelsData.ENTER&&(this.hero.doAction=!0),this.endAction=!0,Keyboard.hide()}))):(this.door.doOpenDoor(),void this.hero.doIdleStreet(0))}doScroll(){this.balloon.isDialog||(this.door.doMove(),this.hero.doWalk(),this.door.hasAction&&this.changeAction(this.door.currentAction))}changeAction(e){switch(e){case Door.Actions.SCROLL:this.currentNPCIndex=null,this.currentAction=this.doScroll;break;case Door.Actions.PARADISECAFE:this.currentNPCIndex=null,this.currentAction=this.doParadiseCafe;break;case Door.Actions.THIEF:this.currentNPCIndex=this.thief.index,this.currentAction=this.doThief;break;case Door.Actions.WHORE:this.currentNPCIndex=this.whore.index,this.currentAction=this.doWhore;break;case Door.Actions.CRACKHOUSE:this.currentNPCIndex=null,this.currentAction=this.doCrackhouse;break;case Door.Actions.SCOUT:this.currentNPCIndex=this.scout.index,this.currentAction=this.doScout;break;case Door.Actions.OLD_LADY:this.currentNPCIndex=this.oldLady.index,this.currentAction=this.doOldLady;break;case Door.Actions.POLICE:this.currentNPCIndex=this.police.index,this.currentAction=this.doPolice}this.endAction=!1}update(e){this.currentAction(),this.door.update(),this.hero.update(),null!==this.currentNPCIndex&&this.NPCs[this.currentNPCIndex].update(),super.update(e)}enable(){super.enable(),this.hero.enable(),this.door.enable(),this.changeAction(Door.Actions.SCROLL),HUD.hiScoresEnabled=!0}disable(){super.disable(),this.hero.disable(),this.door.disable(),this.whore.disable(),this.police.disable(),this.scout.disable(),this.thief.disable(),this.oldLady.disable(),this.currentAction=null,this.endAction=!1}}StreetScene.NAME="street";class ParadiseCafeScene extends Scene{constructor(e){super(e,ParadiseCafeScene.NAME),this.balloon=new Balloon,this.hero=new Hero,this.waiter=new Waiter,this.NPCs.push(this.waiter),this.waiter.index=this.NPCs.length-1,this.dealer=new Dealer,this.NPCs.push(this.dealer),this.dealer.index=this.NPCs.length-1}doIdle(){if(!this.balloon.isDialog){if(this.endAction)return Keyboard.exitEnabled&&Keyboard.hideExit(),this.waiter.isEnabled||this.waiter.enable(),this.waiter.isOutside?void(Resources.PLAYER_INVENTORY.cash<Resources.PLAYER_INVENTORY.expense?(this.waiter.doShowBill(),this.balloon.doDialog([this.waiter.getBalloon("your_bill"),this.hero.getBalloon("hero_no_cash_cafe"),this.waiter.getBalloon("wait_there")],!0,(()=>{this.callback(JailScene.NAME)}))):(this.waiter.doShowBill(),this.balloon.doDialog(this.waiter.getBalloon("your_bill"),!1),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.PAY,action:Resources.labelsData.PAY}]),Keyboard.onChange=e=>{this.hero.updateInventory({cash:-Resources.PLAYER_INVENTORY.expense}),Keyboard.hide(),Keyboard.hideExit(),this.callback(StreetScene.NAME)}))):void this.waiter.doShow();Keyboard.isExitShown||Keyboard.showExit((e=>{this.endAction=!0})),ParadiseCafeScene.IDLE_TICK===ParadiseCafeScene.IDLE_TIMEOUT?(this.hero.hasDrink?(this.hero.currentState=Hero.States.PARADISE_CAFE_DRINKING,this.changeAction(this.hero.currentState)):this.changeAction(Utils.getRandomItem([Dealer.States.DEAL,Waiter.States.SERVE,Dealer.States.DEAL])),ParadiseCafeScene.IDLE_TICK=0):(this.hero.doIdleParadiseCafe(),ParadiseCafeScene.IDLE_TICK++)}}doDeal(){if(!this.balloon.isDialog)if(this.endAction){if(this.dealer.isOutside)return void this.dealer.doHide();if(this.dealer.currentDeal.status)switch(this.dealer.currentDeal.dealType){case"sell_wallet":this.hero.updateInventory({wallet:!0,cash:-this.dealer.currentDeal.value});break;case"sell_gun":this.hero.updateInventory({gun:!0,cash:-this.dealer.currentDeal.value});break;case"sell":Resources.PLAYER_INVENTORY.cash>this.dealer.currentDeal.value&&this.hero.updateInventory({drugs:1,cash:-this.dealer.currentDeal.value});break;case"buy":this.hero.updateInventory({drugs:-1,cash:this.dealer.currentDeal.value})}this.changeAction(Hero.States.IDLE_PARADISE_CAFE)}else this.dealer.isEnabled||this.dealer.enable(),this.dealer.isOutside?this.dealer.hasDeal?this.dealer.currentDeal.value<Resources.PLAYER_INVENTORY.cash?(this.balloon.doDialog(this.dealer.currentDeal.valueBalloon,!1),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.ACCEPT,action:Resources.labelsData.ACCEPT},{text:Resources.labelsData.REFUSE,action:Resources.labelsData.REFUSE}]),Keyboard.onChange=e=>{e===Resources.labelsData.ACCEPT?(this.dealer.currentDeal.status=!0,this.balloon.doDialog(this.hero.getBalloon("hero_accept")),this.hero.updateInventory({points:this.dealer.inventory.points})):(this.balloon.doDialog(this.hero.getBalloon("hero_refuse")),this.hero.updateInventory({lossPoints:this.dealer.inventory.lossPoints})),this.endAction=!0,Keyboard.hide()})):(this.balloon.doDialog([this.dealer.currentDeal.valueBalloon,this.hero.getBalloon("hero_no_cash_cafe")]),this.endAction=!0):(this.dealer.getDeal(Resources.PLAYER_INVENTORY.wallet,Resources.PLAYER_INVENTORY.gun,Resources.PLAYER_INVENTORY.drugs),this.balloon.doDialog(this.dealer.currentDeal.offerBalloon)):this.dealer.doShow()}doServe(){this.balloon.isDialog||(this.waiter.isEnabled||this.waiter.enable(),this.waiter.hasServed?this.waiter.isOutside?this.waiter.doHide():(this.hero.hasDrink=!0,this.waiter.hasServed=!1,this.hero.updateInventory({expense:this.waiter.inventory.drink_value}),this.changeAction(Hero.States.IDLE_PARADISE_CAFE)):this.waiter.isOutside?this.waiter.hasServed||(this.waiter.doServe(),this.balloon.doDialog(Balloon.EMPTY_BALLON)):this.waiter.doShow())}doDrink(){this.balloon.isDialog||(this.hero.currentState===Hero.States.PARADISE_CAFE_DRINKING?this.hero.doParadiseCafeDrink():(this.changeAction(this.hero.currentState),this.hero.hasDrink=!1))}changeAction(e){switch(Keyboard.isExitShown&&Keyboard.hideExit(),this.NPCs.forEach((e=>e.disable())),e){case Hero.States.IDLE_PARADISE_CAFE:this.currentNPCIndex=null,this.currentAction=this.doIdle;break;case Hero.States.PARADISE_CAFE_DRINKING:this.currentNPCIndex=null,this.currentAction=this.doDrink;break;case Dealer.States.DEAL:this.currentNPCIndex=null,this.currentAction=this.doDeal;break;case Waiter.States.SERVE:this.currentNPCIndex=null,this.currentAction=this.doServe}this.endAction=!1}update(e){this.currentAction(),this.hero.update(),this.background.updateTimed(),this.NPCs.forEach((e=>{e.isEnabled&&e.update()})),super.update(e)}enable(){super.enable(),this.hero.enable(),this.hero.currentState=Hero.States.IDLE_PARADISE_CAFE,this.changeAction(this.hero.currentState),HUD.hiScoresEnabled=!1,Resources.PLAYER_INVENTORY.expense=2,Keyboard.exitEnabled=!0}disable(){super.disable(),this.hero.disable(),this.waiter.disable(),this.dealer.disable(),this.currentAction=null,this.balloon.clear(),this.endAction=!1,ParadiseCafeScene.IDLE_TICK=2,Resources.PLAYER_INVENTORY.expense=null,Keyboard.exitEnabled=!1}}ParadiseCafeScene.NAME="paradisecafe",ParadiseCafeScene.IDLE_TIMEOUT=50,ParadiseCafeScene.IDLE_TICK=0;class CrackhouseScene extends Scene{constructor(e){super(e,CrackhouseScene.NAME),this.balloon=new Balloon,this.lightOn=Resources.getImage(`${CrackhouseScene.NAME}_light_on`),this.lightOff=Resources.getImage(`${CrackhouseScene.NAME}_light_off`),this.hero=new Hero,this.lighting=this.lightOff,this.swipeDoor=new SwipeDoor((()=>{})),this.props.push(this.swipeDoor),this.swipeDoor.index=this.props.length-1,this.police=new Police((e=>{e===Police.Actions.REACH_END_STREET&&this.changeNPC()})),this.NPCs.push(this.police),this.police.index=this.NPCs.length-1,this.junkie=new Junkie((e=>{0===Resources.PLAYER_INVENTORY.drugs?this.changeAction(CrackhouseScene.States.DRUGS_END):this.changeNPC()})),this.NPCs.push(this.junkie),this.junkie.index=this.NPCs.length-1,this.currentNPC=this.junkie,this.dealSuccess=!1}doDealing(){if(this.balloon.isDialog)this.dealSuccess&&this.junkie.doGive();else{if(this.endAction)return this.currentNPC===this.police?this.callback(CrackhouseScene.States.FAIL):this.changeAction(CrackhouseScene.States.STREET),void(this.dealSuccess=!1);if(this.hero.isDealing)if(this.currentNPC===this.police)this.balloon.doDialog([this.police.getBalloon("selling_drugs"),this.hero.getBalloon("no_officer"),this.police.getBalloon("under_arrest")]),this.endAction=!0;else{if(this.junkie.isWaiting)return void(Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.ACCEPT,action:Resources.labelsData.ACCEPT},{text:Resources.labelsData.REFUSE,action:Resources.labelsData.REFUSE}]),Keyboard.onChange=e=>{e===Resources.labelsData.ACCEPT?(this.hero.updateInventory({cash:this.junkie.currentDeal.cash,points:this.junkie.inventory.points,drugs:-1}),this.balloon.doDialog(Balloon.EMPTY_BALLON),this.dealSuccess=!0):(this.balloon.doDialog(this.hero.getBalloon("too_cheap")),this.hero.updateInventory({lossPoints:this.junkie.inventory.lossPoints}),this.dealSuccess=!1),Keyboard.hide(),this.hero.isDealing=!1,this.endAction=!0}));const e=this.junkie.getDealDialog();this.balloon.doDialog(e[0],!0,(t=>{this.balloon.doDialog(e[1],!1),this.junkie.isWaiting=!0}))}else Keyboard.isShown&&(Keyboard.hide(),Keyboard.hideExit()),this.currentNPC.doCrackhouseIdle(),this.balloon.doDialog([this.hero.getBalloon("psst"),this.hero.getBalloon("want_drug")]),this.hero.isDealing=!0}}doDrugsEnd(){this.balloon.doDialog([this.hero.getBalloon("drugs_end")]),Keyboard.isShown&&Keyboard.hide(),this.junkie.disable()}doStreet(){this.currentNPC.isEnabled||this.currentNPC.enable(),this.currentNPC.doWalk(),this.swipeDoor.isOpened&&this.currentNPC.x<136&&this.currentNPC.x>126&&this.changeAction(CrackhouseScene.States.DEALING),Keyboard.isShown||(Keyboard.showExit((e=>{Keyboard.hide(),Keyboard.hideExit(),this.hero.updateInventory({cash:-CrackhouseScene.RENT_COST}),this.callback(CrackhouseScene.States.SUCCESS)})),Keyboard.show([{text:Resources.labelsData.CLOSE,action:Resources.labelsData.CLOSE}]),Keyboard.onChange=e=>{e===Resources.labelsData.OPEN?this.changeAction(CrackhouseScene.States.OPENED):this.changeAction(CrackhouseScene.States.CLOSED)})}doSwipeOpen(){Keyboard.updateButtonText(Resources.labelsData.CLOSE,!0),this.lighting=this.lightOn,this.doStreet(),this.swipeDoor.isOpened||this.swipeDoor.doOpen()}doSwipeClose(e=!1){Keyboard.updateButtonText(Resources.labelsData.OPEN,!0),this.doStreet(),this.swipeDoor.isOpened?this.swipeDoor.doClose():this.lighting=this.lightOff}changeAction(e){switch(this.currentNPCIndex=null,e){case CrackhouseScene.States.STREET:this.currentAction=this.doStreet;break;case CrackhouseScene.States.OPENED:this.currentAction=this.doSwipeOpen;break;case CrackhouseScene.States.CLOSED:this.currentAction=this.doSwipeClose;break;case CrackhouseScene.States.DEALING:this.currentAction=this.doDealing;break;case CrackhouseScene.States.DRUGS_END:this.currentAction=this.doDrugsEnd}this.endAction=!1}changeNPC(){this.currentNPC=Utils.getRandomItem([this.junkie,this.police])}update(e){this.currentAction(),this.swipeDoor.update(),this.currentNPC&&this.currentNPC.update(),super.update(e)}enable(){super.enable(),this.swipeDoor.enable(),HUD.hiScoresEnabled=!0,this.swipeDoor.doClose(!0),this.currentAction=this.doSwipeClose,Keyboard.showExit((e=>{Keyboard.hide(),Keyboard.hideExit(),this.hero.updateInventory({cash:-CrackhouseScene.RENT_COST}),this.callback(CrackhouseScene.States.SUCCESS)})),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.OPEN,action:Resources.labelsData.OPEN}]),Keyboard.onChange=e=>{e===Resources.labelsData.OPEN?this.changeAction(CrackhouseScene.States.OPENED):this.changeAction(CrackhouseScene.States.CLOSED)})}disable(){super.disable(),this.swipeDoor.disable(),this.junkie.disable(),this.police.disable(),this.currentAction=null,this.endAction=!1}}CrackhouseScene.States={OPENED:"crackhousestatesopened",CLOSED:"crackhousestatesclosed",DEALING:"crackhousestatesdealing",SUCCESS:"crackhousestatessuccess",FAIL:"crackhousestatesfail",STREET:"crackhousestatesstreet",DRUGS_END:"crackhousestatesdrugsend"},CrackhouseScene.RENT_COST=200,CrackhouseScene.NAME="crackhouse";class BrothelScene extends Scene{constructor(e){super(e,BrothelScene.NAME),this.balloon=new Balloon,this.hero=new Hero,this.whore=new Whore,this.NPCs.push(this.whore),this.whore.index=this.NPCs.length-1,this.pimp=new Pimp,this.NPCs.push(this.pimp),this.pimp.index=this.NPCs.length-1,this.currentAction=null,this.endAction=!1,this.changeAction()}doIdle(){this.balloon.isDialog||(this.endAction?this.changeAction(this.whore.currentService.name):(this.whore.isEnabled||this.whore.enable(),this.hero.doIdleBrothel(),this.whore.doIdleBrothel(),Keyboard.isShown||(this.balloon.doDialog(this.whore.getBalloon("what_you_want"),!1),Keyboard.show([{text:Resources.labelsData.ORAL,action:Resources.labelsData.ORAL},{text:Resources.labelsData.SEX,action:Resources.labelsData.SEX},{text:Resources.labelsData.ANAL,action:Resources.labelsData.ANAL}]),Keyboard.onChange=e=>{switch(Keyboard.hide(),this.endAction=!0,this.balloon.clear(),e){case Resources.labelsData.ORAL:this.balloon.doDialog(this.hero.getBalloon("do_me_blowjob")),this.whore.setService(Whore.Actions.ORAL);break;case Resources.labelsData.SEX:this.balloon.doDialog(this.hero.getBalloon("eat_your_pussy")),this.whore.setService(Whore.Actions.SEX);break;case Resources.labelsData.ANAL:this.balloon.doDialog(this.hero.getBalloon("eat_your_ass")),this.whore.setService(Whore.Actions.ANAL)}})))}doPimp(){if(this.balloon.isDialog)return this.pimp.hasRape&&!this.hero.isDone?(this.hero.doPimpRape(),void this.pimp.doHeroRape()):void 0;if(this.endAction)this.hero.isDone?(this.hero.doPimpRape(),this.pimp.doHeroRape(),this.hero.isDone=!0,this.hero.updateInventory({lossPoints:10*this.whore.inventory.lossPoints}),this.callback(StreetScene.NAME)):this.pimp.hasRape?this.balloon.doDialog([Balloon.EMPTY_BALLON,this.hero.getBalloon("what_a_dick"),Balloon.EMPTY_BALLON],!0,(e=>{this.hero.isDone=!0})):(this.pimp.doIdleBrothel(),this.balloon.doDialog([this.pimp.getBalloon("whats_going_on"),this.whore.getBalloon("this_no_pay"),this.pimp.getBalloon("he_will_see")],!0,(e=>{this.pimp.hasRape=!0})));else{if(!this.pimp.hasSalute)return this.pimp.isEnabled||this.pimp.enable(),void this.pimp.doSalute();this.balloon.doDialog(this.pimp.getBalloon("pimp_hello")),this.endAction=!0}}doOral(){return this.balloon.isDialog?(this.hero.doBlowjob(),void this.whore.doBlowjob()):this.endAction?(this.currentAction=this.doFinish,void(this.endAction=!1)):(this.whore.doIdleBrothel(),this.balloon.doDialog([Balloon.EMPTY_BALLON,this.hero.getBalloon("hero_suck_it_all"),Balloon.EMPTY_BALLON,this.hero.getBalloon("hero_so_good")]),void(this.endAction=!0))}doSex(){return this.balloon.isDialog?(this.hero.doSex(),void this.whore.doSex()):this.endAction?(this.currentAction=this.doFinish,void(this.endAction=!1)):(this.balloon.clear(),this.whore.doIdleBrothel(),this.balloon.doDialog([Balloon.EMPTY_BALLON,Balloon.EMPTY_BALLON,this.hero.getBalloon("hero_im_coming")]),void(this.endAction=!0))}doAnal(){return this.balloon.isDialog?(this.hero.doAnal(),void this.whore.doAnal()):this.endAction?(this.currentAction=this.doFinish,void(this.endAction=!1)):(this.whore.doIdleBrothel(),this.balloon.doDialog([Balloon.EMPTY_BALLON,this.whore.getBalloon("so_thick"),this.hero.getBalloon("hero_aaa")]),void(this.endAction=!0))}doFinish(){this.balloon.isDialog||(this.endAction?this.changeAction(Pimp.NAME):(this.hero.doIdleBrothel(),this.whore.doIdleBrothel(),this.balloon.doDialog(this.whore.currentService.balloon,!1),Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.PAY,action:Resources.labelsData.PAY}]),Keyboard.onChange=e=>{Keyboard.hide(),this.whore.currentService.value>this.hero.inventory.cash?(this.balloon.doDialog([this.hero.getBalloon("no_cash_brothel"),this.whore.getBalloon("call_pimp")]),this.endAction=!0):(this.hero.updateInventory({points:this.whore.inventory.points,cash:-this.whore.currentService.value}),this.callback(StreetScene.NAME))})))}changeAction(e){switch(e){case Whore.Actions.ORAL:this.currentNPCIndex=null,this.currentAction=this.doOral;break;case Whore.Actions.SEX:this.currentNPCIndex=null,this.currentAction=this.doSex;break;case Whore.Actions.ANAL:this.currentNPCIndex=null,this.currentAction=this.doAnal;break;case Pimp.NAME:this.currentNPCIndex=null,this.currentAction=this.doPimp;break;default:this.currentAction=this.doIdle}this.endAction=!1}update(e){this.currentAction&&this.currentAction(),this.hero.update();for(let e=0;e<this.NPCs.length;e++){const t=this.NPCs[e];t.isEnabled&&t.update()}super.update(e)}enable(){super.enable(),this.hero.enable(),this.whore.enable(),this.currentAction=this.doIdle,HUD.hiScoresEnabled=!1}disable(){super.disable(),this.hero.disable(),this.whore.disable(),this.pimp.disable(),this.currentAction=null,this.balloon.clear(),this.endAction=!1}}BrothelScene.NAME="brothel";class JailScene extends Scene{constructor(e){super(e,JailScene.NAME),this.bckgrdTick=0}update(){this.renderStack=[],this.blink=!this.blink,this.blink&&this.background.update(),this.renderStack=[this.background],Keyboard.isShown||(Keyboard.show([{text:Resources.labelsData.HOME,action:Resources.labelsData.HOME},{text:Resources.labelsData.HISCORES,action:Resources.labelsData.HISCORES}]),Keyboard.onChange=e=>{Keyboard.hide(),e===Resources.labelsData.HISCORES?this.callback(JailScene.Actions.HIGHSCORES):this.callback(JailScene.Actions.HOME)})}}JailScene.NAME="jail",JailScene.Actions={HIGHSCORES:"jailsceneactionshighscores",HOME:"jailsceneactionshighhome"};class NewScoreScene extends Scene{constructor(e){super(e,NewScoreScene.NAME),this.view=document.querySelector("#new-score"),this.input=this.view.querySelector("input")}update(){Keyboard.isShown||(console.log(Resources.labelsData),Keyboard.show([{text:Resources.labelsData.SAVE,action:Resources.labelsData.SAVE},{text:Resources.labelsData.EXIT,action:Resources.labelsData.EXIT}]),Keyboard.onChange=e=>{e===Resources.labelsData.SAVE?3===this.input.value.length&&(Keyboard.hide(),this.callback({action:NewScoreScene.ACTIONS.SAVE,name:this.input.value})):(Keyboard.hide(),this.callback({action:NewScoreScene.ACTIONS.EXIT}))})}async enable(){super.enable(),this.view.style.display="flex"}disable(){this.input.value="",this.view.style.display="none"}}NewScoreScene.NAME="newscore",NewScoreScene.ACTIONS={SAVE:"newscoresceneactionssave",EXIT:"newscoresceneactionsexit"};class Character extends Component{constructor(e,t){super(e,t),this.isOutside=!1,this.exitDoorCycle=this.getImagesByName(`${this.name}_show`),this.enterDoorCycle=[...this.exitDoorCycle].reverse(),this.balloonImages=this.images.filter((e=>e.name.includes("balloons"))),this.reset()}doEnterDoor(){this.currentCycle!==this.enterDoorCycle&&this.setCurrentCycle(this.enterDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1}doExitDoor(){this.currentCycle!==this.exitDoorCycle&&this.setCurrentCycle(this.exitDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1}getBalloon(e="emtpty"){return this.balloonImages.find((t=>t.name.includes(e)))}getRandomBalloon(e){const t=this.balloonImages.filter((t=>t.name.includes(e)));return Utils.getRandomItem(t)}reset(){this.doAction=!1,this.isOutside=!1}}class Hero extends Character{constructor(e){super(e,Hero.NAME),this.walkCycle=this.getImagesByName("hero_walk"),this.idleStreetCycle=this.getImagesByName("hero_idle_street"),this.idleBrothelCycle=this.getImagesByName("hero_idle_brothel")[0],this.enterDoorCycle=this.getImagesByName("hero_enter_door"),this.robScoutCycle=this.getImagesByName("hero_rob_scout"),this.pullGunCycle=this.getImagesByName("hero_idle_gun"),this.showDocsCycle=this.getImagesByName("hero_show_docs"),this.blowjobCycle=this.getImagesByName("hero_blowjob"),this.sexCycle=this.getImagesByName("hero_sex"),this.analCycle=this.getImagesByName("hero_anal");const t=this.getImagesByName("hero_rape");this.undressCycle=[t[0],t[1]],this.dressCycle=[...this.undressCycle].reverse(),this.oldLadyapeCycle=[t[2],t[3]],this.pimpRapeCycle=this.getImagesByName("hero_bend"),this.idleParadiseCafeCycle=this.getImagesByName("hero_idle_cafe"),this.drinkCycle=this.getImagesByName("hero_drink"),this.moanBalloons=[this.getBalloon("aaa"),this.getBalloon("suck_it_all"),this.getBalloon("im_coming"),this.getBalloon("so_good")],this.isDone=!1,this.hasdrink=!1,this.isDealing=!1,this.isUndressed=!1,this.animationTime=null,this.currentState=null}doShowDocs(){this.currentCycle!==this.showDocsCycle&&this.setCurrentCycle(this.showDocsCycle,!1)}doUndress(){this.currentCycle!==this.undressCycle&&this.setCurrentCycle(this.undressCycle,!1),this.isUndressed=this.tick===this.currentCycle.length-1}doDress(){this.currentCycle!==this.dressCycle&&this.setCurrentCycle(this.dressCycle,!1),this.isUndressed=this.tick===this.currentCycle.length-1}doOldLadyRape(){this.currentCycle!==this.oldLadyapeCycle&&this.setCurrentCycle(this.oldLadyapeCycle)}doPimpRape(){this.currentCycle!==this.pimpRapeCycle&&this.setCurrentCycle(this.pimpRapeCycle)}doBlowjob(){this.currentCycle!==[this.blowjobCycle[1]]&&this.setCurrentCycle([this.blowjobCycle[1]],!1)}doSex(){this.currentCycle!==this.sexCycle&&this.setCurrentCycle(this.sexCycle)}doAnal(){this.currentCycle!==this.analCycle&&this.setCurrentCycle(this.analCycle)}doRobOldLady(){this.currentCycle!==this.pullGunCycle&&this.setCurrentCycle(this.pullGunCycle,!1)}doRobScout(){this.currentCycle!==this.robScoutCycle&&this.setCurrentCycle(this.robScoutCycle,!1),this.isDone=this.tick===this.currentCycle.length-1}doWalk(){this.currentCycle!==this.walkCycle&&(this.isDone=!1,this.isUndressed=!1,this.setCurrentCycle(this.walkCycle)),this.isOutside=!0}doIdleBrothel(){this.currentCycle!==this.idleBrothelCycle&&this.setCurrentCycle([this.idleBrothelCycle],!1)}doIdleStreet(e=1){this.currentCycle!==this.idleStreetCycle&&this.setCurrentCycle([this.idleStreetCycle[e]],!1),this.isOutside=this.tick===this.currentCycle.length-1}doIdleParadiseCafe(){this.currentCycle!==this.idleParadiseCafeCycle&&this.setCurrentCycle(this.idleParadiseCafeCycle,!1)}doParadiseCafeDrink(){this.currentCycle!==this.drinkCycle&&this.setCurrentCycle(this.drinkCycle,!1),this.tick===this.drinkCycle.length-1&&(this.currentState=Hero.States.IDLE_PARADISE_CAFE)}doEnterDoor(){this.currentCycle!==this.enterDoorCycle&&this.setCurrentCycle(this.enterDoorCycle,!1),this.isOutside=this.tick<this.currentCycle.length-1}doExitDoor(){}getAnimationTime(){return(Date.now()-this.animationTime)/Hero.Constants.ANIM_TIMEOUT}updateInventory(e){e.points&&(Resources.PLAYER_INVENTORY.points+=e.points),e.lossPoints&&(Resources.PLAYER_INVENTORY.points-=e.lossPoints),e.cash&&(Resources.PLAYER_INVENTORY.cash+=e.cash),!1===e.wallet?(Resources.PLAYER_INVENTORY.wallet=!1,Resources.PLAYER_INVENTORY.cash=0):!0===e.wallet&&(Resources.PLAYER_INVENTORY.wallet=!0),!0===e.gun&&(Resources.PLAYER_INVENTORY.gun=!0),e.drugs&&(Resources.PLAYER_INVENTORY.drugs+=e.drugs),e.expense&&(Resources.PLAYER_INVENTORY.expense+=e.expense),Resources.PLAYER_INVENTORY.cash<0&&(Resources.PLAYER_INVENTORY.cash=0),Resources.PLAYER_INVENTORY.drugs<0&&(Resources.PLAYER_INVENTORY.drugs=0)}disable(){super.disable(),this.isDone=!1,this.isUndressed=!1,this.animationTime=null,this.currentState=null,this.hasdrink=!1,this.isDealing=!1}}Hero.States={IDLE_STREET:"herostateidlestreet",IDLE_PARADISE_CAFE:"herostateidleparadisecafe",WALK_CYCLE:"herostatewalkcycle",PARADISE_CAFE_DRINKING:"herostateparadisecafedrinking"},Hero.Constants={ANIM_TIMEOUT:3e3},Hero.NAME="hero";class Thief extends Character{constructor(e){super(e,Thief.NAME),this.exitDoorCycle=this.getImagesByName("thief_show"),this.enterDoorCycle=this.getImagesByName("thief_hide"),this.showGunCycle=this.getImagesByName("thief_gun"),this.hurtCycle=this.getImagesByName("thief_hurt"),this.isHurted=!1,this.inventory={lossPoints:3,points:4},this.animationTime=null}doIdle(){this.currentCycle!==this.idleStreetCycle&&this.setCurrentCycle([this.idleStreetCycle[dir]],!1),this.isOutside=this.tick===this.currentCycle.length-1}doEnterDoor(){this.currentCycle!==this.enterDoorCycle&&this.setCurrentCycle(this.enterDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1,this.isOutside||(this.isHurted=!1)}doExitDoor(){this.currentCycle!==this.exitDoorCycle&&this.setCurrentCycle(this.exitDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1,this.isOutside&&!this.currentAction&&(this.currentAction=Utils.getRandomItem([Thief.Actions.ASK_LIGHT,Thief.Actions.ROB,Thief.Actions.ASK_LIGHT]))}doShowGun(){this.currentCycle!==this.showGunCycle&&this.setCurrentCycle(this.showGunCycle,!1)}doHurt(){this.currentCycle!==this.hurtCycle&&this.setCurrentCycle(this.hurtCycle,!1),this.tick===this.currentCycle.length-1&&(this.isHurted=!0)}}Thief.Actions={ASK_LIGHT:"thiefactionsasklight",ROB:"thiefactionsrob",HURT:"thiefactionshurt"},Thief.ACTION_TIMEOUT=5,Thief.NAME="thief";class Whore extends Character{constructor(e){super(e,Whore.NAME),this.exitDoorCycle=this.getImagesByName("whore_show"),this.idleStreetCycle=[this.exitDoorCycle[this.exitDoorCycle.length-1]],this.idleBrothelCycle=this.getImagesByName("idle_brothel")[0],this.enterDoorCycle=[...this.exitDoorCycle].reverse(),this.blowjobCycle=this.getImagesByName("whore_blowjob"),this.sexCycle=this.getImagesByName("whore_sex"),this.analCycle=this.getImagesByName("whore_anal"),this.isAccepted=!1,this.currentService=null,this.inventory={lossPoints:3,points:50,stash:[{value:20,balloon:this.getBalloon("whore_cost_20")},{value:40,balloon:this.getBalloon("whore_cost_40")},{value:80,balloon:this.getBalloon("whore_cost_80")},{value:160,balloon:this.getBalloon("whore_cost_80")}]},this.animationTime=null}doBlowjob(){this.currentCycle!==this.blowjobCycle&&this.setCurrentCycle(this.blowjobCycle)}doSex(){this.currentCycle!==this.sexCycle&&this.setCurrentCycle(this.sexCycle)}doAnal(){this.currentCycle!==this.analCycle&&this.setCurrentCycle(this.analCycle)}doIdleBrothel(){this.currentCycle!==this.idleBrothelCycle&&this.setCurrentCycle([this.idleBrothelCycle],!1)}doIdleStreet(){this.currentCycle!==this.idleStreetCycle&&this.setCurrentCycle([this.idleStreetCycle[dir]],!1),this.isOutside=this.tick===this.currentCycle.length-1}setService(e=null){let t;switch(e){case Whore.Actions.ORAL:t=this.inventory.stash[0];break;case Whore.Actions.SEX:t=this.inventory.stash[1];break;case Whore.Actions.ANAL:t=Utils.getRandomItem([this.inventory.stash[2],this.inventory.stash[3]])}this.currentService=t,this.currentService.name=e}disable(){super.disable(),this.isAccepted=!1,this.currentService=null}}Whore.Actions={ORAL:"whoreactionsoral",SEX:"whoreactionssex",ANAL:"whoreactionsanal"},Whore.ACTION_TIMEOUT=5,Whore.NAME="whore";class Scout extends Character{constructor(e){super(e,Scout.NAME),this.exitDoorCycle=this.getImagesByName("scout_show"),this.enterDoorCycle=this.getImagesByName("scout_hide"),this.saluteCycle=this.getImagesByName("scout_salute"),this.fearCycle=this.getImagesByName("scout_fear"),this.isSalute=!1,this.isFear=!1,this.isRobbed=!1,this.currentStash=null,this.inventory={lossPoints:1,points:2,stash:[{cash:10,balloon:this.getBalloon("only_got_10")},{cash:0,balloon:this.getBalloon("only_got_cookies")},{cash:20,balloon:this.getBalloon("only_got_20")},{cash:50,balloon:this.getBalloon("only_got_50")}]}}doSalute(){this.currentCycle!==this.saluteCycle&&this.setCurrentCycle(this.saluteCycle,!1),this.isSalute=this.tick===this.currentCycle.length-1}doIdleFear(){this.currentCycle!==this.fearCycle&&this.setCurrentCycle(this.fearCycle,!1),this.isFear=this.tick===this.currentCycle.length-1}doEnterDoor(){this.currentCycle!==this.enterDoorCycle&&this.setCurrentCycle(this.enterDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1}doExitDoor(){this.currentCycle!==this.exitDoorCycle&&this.setCurrentCycle(this.exitDoorCycle,!1),this.isOutside=this.tick===this.currentCycle.length-1,this.isOutside&&!this.currentStash&&(this.currentStash=Utils.getRandomItem(this.inventory.stash))}disable(){super.disable(),this.isSalute=!1,this.isFear=!1,this.isRobbed=!1,this.currentStash=null}}Scout.NAME="scout",Scout.STASH="scout";class OldLady extends Character{constructor(e){super(e,OldLady.NAME),this.bendCycle=this.getImagesByName("oldlady_bended"),this.unbendCycle=[...this.bendCycle].reverse(),this.idleCycle=[this.exitDoorCycle[this.exitDoorCycle.length-1]],this.isRobbed=!1,this.isFear=!1,this.isBend=!1,this.isRaped=!1,this.currentStash=null,this.inventory={lossPoints:3,points:5,stash:[{cash:10,balloon:this.getBalloon("only_got_10")},{cash:30,balloon:this.getBalloon("only_got_30")}]}}doIdleStreet(){this.currentCycle!==this.idleCycle&&this.setCurrentCycle(this.idleCycle)}doBend(){this.currentCycle!==this.bendCycle&&this.setCurrentCycle(this.bendCycle,!1)}doUnbend(){this.currentCycle!==this.unbendCycle&&this.setCurrentCycle(this.unbendCycle,!1)}doExitDoor(){super.doExitDoor(),this.isOutside&&!this.currentStash&&(this.currentStash=Utils.getRandomItem(this.inventory.stash))}disable(){super.disable(),this.isRobbed=!1,this.isRaped=!1,this.isFear=!1,this.isBend=!1,this.currentStash=null}}OldLady.NAME="oldlady";class Police extends Character{constructor(e){super(e,Police.NAME),this.askPapersCycle=this.getImagesByName("action"),this.walkCycle=this.getImagesByName("walk"),this.idleCrackhouseCycle=this.getImagesByName("idle_crackhouse"),this.isAskDocs=!1,this.hasArrest=!1,this.walkTick=0,this.inventory={points:1,lossPoints:50}}doCrackhouseIdle(){this.currentCycle!==this.idleCrackhouseCycle&&this.setCurrentCycle(this.idleCrackhouseCycle,!1)}doWalk(){this.currentCycle!==this.walkCycle&&this.setCurrentCycle(this.walkCycle,!0),this.x=this.canvasW-5*this.walkTick,this.x<-this.width&&(this.callback(Police.Actions.REACH_END_STREET),this.walkTick=0),this.walkTick++}doAskDocs(){this.currentCycle!==this.askPapersCycle&&this.setCurrentCycle(this.askPapersCycle,!1),this.isAskDocs=!0}doExitDoor(){super.doExitDoor(),this.isOutside&&(this.currentAction=Utils.getRandomItem([Police.Actions.ASK_PAPERS,Police.Actions.SALUTE,Police.Actions.SALUTE]))}doEnterDoor(){super.doEnterDoor(),this.isOutside||(this.currentAction=null,this.isAskDocs=!1)}moveTo(e,t=null){super.moveTo(e),this.walkTick=0}disable(){super.disable(),this.isAskDocs=!1,this.hasArrest=!1,this.walkTick=0,this.x=0}}Police.Actions={ASK_PAPERS:"policeactionsaskpapers",SALUTE:"policeactiosnsalute",REACH_END_STREET:"policeactiosnreachendstreet"},Police.NAME="police";class Pimp extends Character{constructor(e){super(e,Pimp.NAME),this.saluteCycle=this.getImagesByName("pimp_show"),this.idleBrothelCycle=this.getImagesByName("pimp_idle"),this.heroRapeCycle=this.getImagesByName("pimp_rape"),this.hasSalute=!1,this.hasRape=!1,this.inventory={lossPoints:70}}doSalute(){this.currentCycle!==this.saluteCycle&&this.setCurrentCycle(this.saluteCycle,!1),this.hasSalute=this.tick===this.saluteCycle.length-1}doIdleBrothel(){this.currentCycle!==this.idleBrothelCycle&&this.setCurrentCycle(this.idleBrothelCycle,!1)}doHeroRape(){this.currentCycle!==this.heroRapeCycle&&this.setCurrentCycle(this.heroRapeCycle)}disable(){super.disable(),this.hasSalute=!1,this.hasRape=!1}}Pimp.Actions={},Pimp.NAME="pimp";class Waiter extends Character{constructor(e){super(e,Waiter.NAME),this.serveClycle=this.getImagesByName("serve"),this.showBillClycle=this.getImagesByName("show03"),this.hasServed=!1,this.inventory={drink_value:null}}doServe(){this.currentCycle!==this.serveClycle&&this.setCurrentCycle(this.serveClycle,!1),this.hasServed=this.tick===this.serveClycle.length-1,this.hasServed&&(this.inventory.drink_value=Utils.getRandomItem([10,5,20,3,5]))}doShowBill(){this.currentCycle!==this.showBillClycle&&this.setCurrentCycle(this.showBillClycle,!1)}doShow(){this.doExitDoor()}doHide(){this.doEnterDoor()}enable(){super.enable()}disable(){const e=this.currentCycle;super.disable(),this.hasServed=!1,this.inventory={drink_value:null},this.currentCycle=e}}Waiter.NAME="waiter",Waiter.States={SERVE:"waiterstatesserve"};class Dealer extends Character{constructor(e){super(e,Dealer.NAME),this.hasDeal=!1,this.deals={offers:{drugs:[{balloon:this.getImagesByName("dealer_got_lsd")},{balloon:this.getImagesByName("dealer_got_weed")}],wallet:{balloon:this.getImagesByName("dealer_got_wallet")},gun:{balloon:this.getImagesByName("dealer_got_gun")}},sell_values:[{value:20,balloon:this.getImagesByName("dealer_accept_20")},{value:30,balloon:this.getImagesByName("dealer_accept_30")},{value:40,balloon:this.getImagesByName("dealer_accept_40")},{value:50,balloon:this.getImagesByName("dealer_accept_50")}],buy_values:[{value:20,balloon:this.getImagesByName("dealer_offer_20")},{value:40,balloon:this.getImagesByName("dealer_offer_40")},{value:50,balloon:this.getImagesByName("dealer_offer_50")},{value:100,balloon:this.getImagesByName("dealer_offer_100")}]},this.inventory={points:2,lossPoints:2},this.currentDeal=null}getDeal(e=!0,t=!1,s=null){let i;if(this.currentDeal={type:null,dealType:null,offerBalloon:null,valueBalloon:null,value:null},e)if(t){let e;this.currentDeal.type=Dealer.States.DEALING_DRUGS,e=null!==s&&0!==s&&Utils.getRandomTrueFalse(),e?(this.currentDeal.dealType="buy",this.currentDeal.offerBalloon=this.getImagesByName("know_you_got_drugs")[0],i=Utils.getRandomItem(this.deals.buy_values)):(this.currentDeal.dealType="sell",i=Utils.getRandomItem(this.deals.offers.drugs),this.currentDeal.offerBalloon=i.balloon[0],i=Utils.getRandomItem(this.deals.sell_values))}else this.currentDeal.dealType="sell_gun",this.currentDeal.type=Dealer.States.DEALING_GUN,this.currentDeal.offerBalloon=this.getImagesByName("dealer_got_gun")[0],i=Utils.getRandomItem(this.deals.sell_values);else this.currentDeal.dealType="sell_wallet",this.currentDeal.type=Dealer.States.DEALING_WALLET,this.currentDeal.offerBalloon=this.getImagesByName("dealer_got_wallet")[0],i=Utils.getRandomItem(this.deals.sell_values);return this.currentDeal.valueBalloon=i.balloon[0],this.currentDeal.value=i.value,this.hasDeal=!0,this.currentDeal}doShow(){this.doExitDoor()}doHide(){this.doEnterDoor(),this.tick===this.currentCycle.length-1&&(console.log("dealer is hidden"),this.hasDeal=!1)}enable(){super.enable()}disable(){super.disable(),this.hasDeal=!1,this.currentDeal=null}}Dealer.States={DEALING_DRUGS:"dealerstatesdealingdrugs",DEALING_WALLET:"dealerstatesdealingwallet",DEALING_GUN:"dealerstatesdealinggun",ASKING_DRUGS:"dealerstatesdealingaskdrugs"},Dealer.NAME="dealer";class Junkie extends Character{constructor(e){super(e,Junkie.NAME),this.walkCycle=this.getImagesByName("walk"),this.idleCrackhouseCycle=this.getImagesByName("idle_crackhouse"),this.giveCycle=this.getImagesByName("give"),this.giveCycle=Utils.clearItemsFrom(this.giveCycle,"balloons"),this.walkTick=0,this.isWaiting=!1,this.currentDeal=null,this.inventory={points:3,lossPoints:4,answers:[this.getImagesByName("balloons_junkie_alright")[0],this.getImagesByName("balloons_junkie_hangover")[0]],deals:[{cash:140,balloon:this.getImagesByName("balloons_junkie_give_me_140")[0]},{cash:150,balloon:this.getImagesByName("balloons_junkie_give_me_150")[0]},{cash:200,balloon:this.getImagesByName("balloons_junkie_give_me_200")[0]}]}}doCrackhouseIdle(){this.currentCycle!==this.idleCrackhouseCycle&&this.setCurrentCycle(this.idleCrackhouseCycle,!1)}doGive(){console.log(this.width),this.currentCycle!==this.giveCycle&&this.setCurrentCycle(this.giveCycle,!1)}doWalk(){this.currentCycle!==this.walkCycle&&this.setCurrentCycle(this.walkCycle,!0),this.x=this.canvasW-5*this.walkTick,this.x<-this.width&&(this.isWaiting=!1,this.isDone=!1,this.currentDeal=null,this.walkTick=0,this.callback(Junkie.Actions.REACH_END_STREET)),this.walkTick++}getDealDialog(){return this.currentDeal=Utils.getRandomItem(this.inventory.deals),[Utils.getRandomItem(this.inventory.answers),this.currentDeal.balloon]}moveTo(e,t=null){super.moveTo(e),this.walkTick=0}disable(){super.disable(),this.walkTick=0,this.currentDeal=null,this.isWaiting=!1,this.isDone=!1,this.currentDeal=null}}Junkie.Actions={REACH_END_STREET:"junkieactiosnreachendstreet"},Junkie.NAME="junkie";class Game{constructor(){this.gameData=null,this.renderer=new Renderer((e=>{console.log("renderer event",e)})),this.audioSource=new AudioSource,this.menu=new Menu((async e=>{switch(e){case Menu.Actions.MUSIC_ON:case Menu.Actions.MUSIC_OFF:this.audioSource.mute();break;case Menu.Actions.NORMAL_SPEED:this.setSpeed(Game.SPEED.NORMAL);break;case Menu.Actions.TURBO_SPEED:this.setSpeed(Game.SPEED.FAST);break;case Menu.Actions.ABOUT:window.open("https://brunoperry.net/games/paradisecafe/about","_blank");break;case Menu.Actions.EXIT:this.pause(),this.audioSource.stop(),window.location="https://brunoperry.net/games"}})),this.currentState=Game.States.PAUSED,this.HUDUpdate=!1,this.controller=new Controller((e=>{this.menu.isOpen?this.menu.close():this.menu.open()})),this.isPlaying=!1,this.isTransition=!1}init(e){this.gameData=e,Resources.labelsData=this.gameData.labels,Loader.init(),Keyboard.init();const t=new LandingScene((async e=>{this.pause(),e===Resources.labelsData.YES?this.startGame():window.open(Resources.VERIFY_AGE_LINK,"_blank")}));this.intervalID=null,this.setSpeed(Game.SPEED.FAST),this.setScene(t),this.run()}async startGame(){await Resources.init(this.gameData),console.log(Resources.scoresData),HUD.init(),Loader.clear();const e=new SplashScene((e=>{this.setSpeed(Game.SPEED.FAST),this.HUDUpdate=!1,this.setScene(t),this.controller.show()})),t=new MainScene((e=>{switch(Resources.resetPlayerInventory(),e){case Resources.labelsData.PLAY:this.currentState=Game.States.PLAYING,this.HUDUpdate=!0,this.setScene(i,!0);break;case Resources.labelsData.HISCORES:this.currentState=Game.States.SCORES,this.HUDUpdate=!1,this.setScene(s,!0)}})),s=new ScoresScene((e=>{this.HUDUpdate=!1,this.currentState=Game.States.MAIN,this.setScene(t,!0)})),i=new StreetScene((e=>{switch(this.HUDUpdate=!0,e){case ParadiseCafeScene.NAME:this.setScene(h,!0);break;case CrackhouseScene.NAME:this.setScene(a,!0);break;case BrothelScene.NAME:this.setScene(o,!0);break;case JailScene.NAME:this.HUDUpdate=!1,this.setScene(r,!0)}})),o=new BrothelScene((e=>{this.HUDUpdate=!0,this.setScene(i,!0)})),a=new CrackhouseScene((e=>{this.HUDUpdate=!0,e===CrackhouseScene.States.FAIL?(this.HUDUpdate=!1,this.setScene(r,!0)):(this.currentState=Game.States.PLAYING,this.setScene(i,!0))})),h=new ParadiseCafeScene((e=>{this.currentState=Game.States.PLAYING,this.HUDUpdate=!0,e===JailScene.NAME?(this.HUDUpdate=!1,this.setScene(r,!0)):this.setScene(i,!0)})),r=new JailScene((e=>{this.HUDUpdate=!1;const i=Resources.PLAYER_INVENTORY.points;if(i>0&&Resources.scoresData.length<5)this.setScene(n);else if(i>0&&Utils.checkTopFive(Resources.scoresData,Resources.PLAYER_INVENTORY.points))this.setScene(n);else switch(e){case JailScene.Actions.HIGHSCORES:this.currentState=Game.States.SCORES,this.setScene(s,!0);break;case JailScene.Actions.HOME:this.setScene(t,!0)}})),n=new NewScoreScene((async e=>{if(e.action===NewScoreScene.ACTIONS.SAVE){const t=await fetch("data",{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify({name:e.name,score:""+Resources.PLAYER_INVENTORY.points})});await t.json()}else this.setScene(t)}));this.setSpeed(Game.SPEED.SLOW),this.setScene(e),this.currentState=Game.States.PLAYING,this.run()}async setScene(e,t=!1){if(t)return this.pause(),this.isTransition=!0,void Utils.transition(this.renderer.ctx,this.renderer.canvas,(async()=>{this.isTransition=!1,this.currentScene.disable(),this.currentScene=e,this.currentScene.enable(),await this.audioSource.play(this.currentScene.music),this.run()}));this.currentScene&&this.currentScene.disable(),this.currentScene=e,this.currentScene.enable(),await this.audioSource.play(this.currentScene.music)}setSpeed(e){Game.CURRENT_SPEED=e,this.intervalID&&(this.pause(),this.run())}run(){if(this.intervalID||this.isTransition)return;let e=0;this.intervalID=setInterval((()=>{if(!this.menu.isOpen){switch(this.currentScene.update(e),this.currentState){case Game.States.PLAYING:this.renderer.render(this.currentScene.renderStack),this.HUDUpdate&&HUD.update(Resources.PLAYER_INVENTORY);break;case Game.States.PAUSED:break;case Game.States.MAIN:this.renderer.render(this.currentScene.renderStack)}e++}}),Game.CURRENT_SPEED)}pause(){this.intervalID&&(clearInterval(this.intervalID),this.intervalID=null)}}Game.States={MAIN:"gamestatemain",PAUSED:"gamestatepaused",PLAYING:"gamestateplaying",ENDED:"gamestateended",SCORES:"gamestatescores"},Game.SPEED={SLOW:350,NORMAL:150,FAST:50},Game.CURRENT_SPEED=Game.SPEED.NORMAL,Game.Events={INITIALIZED:"gameeventinitialized"},window.onload=async()=>{document.body.style.opacity=1,initGame()};const initGame=async()=>{const e={tile:"Paradise Café",media:{images:null,audios:null,font:null},labels:null,scores:null};let t=await fetch("https://brunoperry.net/games/paradisecafe/data"),s=await t.json();e.media.images=s.data.images,e.media.audios=s.data.audios,e.media.font=s.data.font,e.labels=s.data.labels,e.scores=s.scores,await(new Game).init(e),console.log("brunoperry.net@2021")};