pokemon / 162.bundle.js
akhaliq's picture
akhaliq HF staff
Upload 8 files
89d3000 verified
"use strict";(self.webpackChunkpokemon_red_clone=self.webpackChunkpokemon_red_clone||[]).push([[162],{162:(e,t,s)=>{s.r(t),s.d(t,{default:()=>a});class a{constructor(e){this.name=e.name||"MissingNo",this.level=e.level||1,this.type=e.type||"normal",this.secondaryType=e.secondaryType||null,this.stats={hp:e.stats?.hp||10,maxHp:e.stats?.maxHp||10,attack:e.stats?.attack||5,defense:e.stats?.defense||5,speed:e.stats?.speed||5,special:e.stats?.special||5},this.moves=e.moves||[{name:"Tackle",type:"normal",power:40,accuracy:100,pp:35,maxPp:35}],this.exp=e.exp||0,this.expToNextLevel=this.calculateExpToNextLevel(),this.evolution=e.evolution||null,this.evolutionLevel=e.evolutionLevel||null,this.status="normal",this.frontSpriteIndex=e.frontSpriteIndex||0,this.backSpriteIndex=e.backSpriteIndex||0}calculateExpToNextLevel(){return Math.pow(this.level+1,3)}takeDamage(e){return this.stats.hp=Math.max(0,this.stats.hp-e),this.stats.hp}heal(e){return this.stats.hp=Math.min(this.stats.maxHp,this.stats.hp+e),this.stats.hp}useMove(e){if(e<0||e>=this.moves.length)return null;const t=this.moves[e];return t.pp<=0?{success:!1,message:`${this.name} has no PP left for ${t.name}!`}:(t.pp--,100*Math.random()>t.accuracy?{success:!1,message:`${this.name}'s attack missed!`}:{success:!0,move:t,message:`${this.name} used ${t.name}!`})}calculateDamage(e,t){const s=2*this.level/5+2,a=this.stats.attack/t.stats.defense,o=s*e.power*a/50+2,i=this.getTypeEffectiveness(e.type,t.type,t.secondaryType),n=Math.random()<.0625?1.5:1,r=.85+.15*Math.random();return{damage:Math.floor(o*i*n*r),typeEffectiveness:i,isCritical:n>1}}getTypeEffectiveness(e,t,s){const a={normal:{rock:.5,ghost:0},fire:{fire:.5,water:.5,grass:2,ice:2,bug:2,rock:.5,dragon:.5},water:{fire:2,water:.5,grass:.5,ground:2,rock:2,dragon:.5},electric:{water:2,electric:.5,grass:.5,ground:0,flying:2,dragon:.5},grass:{fire:.5,water:2,grass:.5,poison:.5,ground:2,flying:.5,bug:.5,rock:2,dragon:.5},ice:{fire:.5,water:.5,grass:2,ice:.5,ground:2,flying:2,dragon:2},fighting:{normal:2,ice:2,poison:.5,flying:.5,psychic:.5,bug:.5,rock:2,ghost:0},poison:{grass:2,poison:.5,ground:.5,bug:2,rock:.5,ghost:.5},ground:{fire:2,electric:2,grass:.5,poison:2,flying:0,bug:.5,rock:2},flying:{electric:.5,grass:2,fighting:2,bug:2,rock:.5},psychic:{fighting:2,poison:2,psychic:.5},bug:{fire:.5,grass:2,fighting:.5,poison:2,flying:.5,psychic:2,ghost:.5},rock:{fire:2,ice:2,fighting:.5,ground:.5,flying:2,bug:2},ghost:{normal:0,fighting:0,poison:.5,bug:.5,ghost:2},dragon:{dragon:2}};let o=1;return a[e]&&a[e][t]&&(o*=a[e][t]),s&&a[e]&&a[e][s]&&(o*=a[e][s]),o}gainExp(e){return this.exp+=e,this.exp>=this.expToNextLevel&&(this.levelUp(),!0)}levelUp(){return this.level++,this.stats.maxHp+=Math.floor(3*Math.random())+1,this.stats.attack+=Math.floor(2*Math.random())+1,this.stats.defense+=Math.floor(2*Math.random())+1,this.stats.speed+=Math.floor(2*Math.random())+1,this.stats.special+=Math.floor(2*Math.random())+1,this.stats.hp=this.stats.maxHp,this.expToNextLevel=this.calculateExpToNextLevel(),this.evolutionLevel&&this.level>=this.evolutionLevel?{leveledUp:!0,canEvolve:!0,evolution:this.evolution}:{leveledUp:!0,canEvolve:!1}}evolve(){if(!this.evolution)return!1;const e=this.name;return this.name=this.evolution,this.stats.maxHp+=5,this.stats.hp=this.stats.maxHp,this.stats.attack+=3,this.stats.defense+=3,this.stats.speed+=3,this.stats.special+=3,this.evolution=null,this.evolutionLevel=null,{oldName:e,newName:this.name}}static createFromTemplate(e,t){const s=t/e.baseLevel,o={hp:Math.floor(e.baseStats.hp*s),maxHp:Math.floor(e.baseStats.hp*s),attack:Math.floor(e.baseStats.attack*s),defense:Math.floor(e.baseStats.defense*s),speed:Math.floor(e.baseStats.speed*s),special:Math.floor(e.baseStats.special*s)};return new a({name:e.name,level:t,type:e.type,secondaryType:e.secondaryType,stats:o,moves:e.moves,evolution:e.evolution,evolutionLevel:e.evolutionLevel,frontSpriteIndex:e.frontSpriteIndex,backSpriteIndex:e.backSpriteIndex})}}}}]);