forked from dekzeh/calc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproduction.min.js
1 lines (1 loc) · 110 KB
/
production.min.js
1
var _this=this;!function(){"use strict";var e={};e.toID=function(e){return(""+e).toLowerCase().replace(/[^a-z0-9]+/g,"")},e.error=function(e,a){if(e)throw new Error(a);console.log(a)},e.assignWithout=function(e,a,t){for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&!t.has(i)&&(e[i]=a[i])};var a={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error"},t=a.toString,i=a.hasOwnProperty;function r(e){return"function"===s(e)}function s(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?a[t.call(e)]||"object":typeof e}function o(e){if("object"!==s(e)||e.nodeType||function(e){return null!=e&&e===e.window}(e))return!1;try{if(e.constructor&&!i.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}return!0}e.extend=function e(){for(var a,t,i,s,n,l,h=[],c=0;c<arguments.length;c++)h[c]=arguments[c];var d=h[0]||{},u=1,y=!1,m=h.length;for("boolean"==typeof d&&(y=d,d=h[1]||{},u=2),"object"==typeof d||r(d)||(d={}),m===u&&(d=this,--u);u<m;u++)if(null!=(a=h[u]))for(t in a)i=d[t],d!==(s=a[t])&&(y&&s&&(o(s)||(n=Array.isArray(s)))?(n?(n=!1,l=i&&Array.isArray(i)?i:[]):l=i&&o(i)?i:{},d[t]=e(y,l,s)):void 0!==s&&(d[t]=s));return d};var n=e,l=["hp","atk","def","spa","spd","spe"],h=l,c=l,d=l,u=l,y=l,m=l,p=l;e.STATS=[[],["hp","atk","def","spc","spe"],l,h,c,d,u,y,m,p];var f=["Fighting","Flying","Poison","Ground","Rock","Bug","Ghost","Steel","Fire","Water","Grass","Electric","Psychic","Ice","Dragon","Dark"],b={Bug:{ivs:{atk:30,def:30,spd:30},dvs:{atk:13,def:13}},Dark:{ivs:{},dvs:{}},Dragon:{ivs:{atk:30},dvs:{def:14}},Electric:{ivs:{spa:30},dvs:{atk:14}},Fighting:{ivs:{def:30,spa:30,spd:30,spe:30},dvs:{atk:12,def:12}},Fire:{ivs:{atk:30,spa:30,spe:30},dvs:{atk:14,def:12}},Flying:{ivs:{hp:30,atk:30,def:30,spa:30,spd:30},dvs:{atk:12,def:13}},Ghost:{ivs:{def:30,spd:30},dvs:{atk:13,def:14}},Grass:{ivs:{atk:30,spa:30},dvs:{atk:14,def:14}},Ground:{ivs:{spa:30,spd:30},dvs:{atk:12}},Ice:{ivs:{atk:30,def:30},dvs:{def:13}},Poison:{ivs:{def:30,spa:30,spd:30},dvs:{atk:12,def:14}},Psychic:{ivs:{atk:30,spe:30},dvs:{def:12}},Rock:{ivs:{def:30,spd:30,spe:30},dvs:{atk:13,def:12}},Steel:{ivs:{spd:30},dvs:{atk:13}},Water:{ivs:{atk:30,def:30,spa:30},dvs:{atk:14,def:13}}};e.Stats=new(function(){function a(){}return a.prototype.displayStat=function(e){switch(e){case"hp":return"HP";case"atk":return"Atk";case"def":return"Def";case"spa":return"SpA";case"spd":return"SpD";case"spe":return"Spe";case"spc":return"Spc";default:throw new Error("unknown stat ".concat(e))}},a.prototype.shortForm=function(e){switch(e){case"hp":return"hp";case"atk":return"at";case"def":return"df";case"spa":return"sa";case"spd":return"sd";case"spe":return"sp";case"spc":return"sl"}},a.prototype.getHPDV=function(e){return this.IVToDV(e.atk)%2*8+this.IVToDV(e.def)%2*4+this.IVToDV(e.spe)%2*2+this.IVToDV(e.spc)%2},a.prototype.IVToDV=function(e){return Math.floor(e/2)},a.prototype.DVToIV=function(e){return 2*e},a.prototype.DVsToIVs=function(a){var t,i={};for(t in a)i[t]=e.Stats.DVToIV(a[t]);return i},a.prototype.calcStat=function(e,a,t,i,r,s,o){if(e.num<1||e.num>9)throw new Error("Invalid generation ".concat(e.num));return e.num<3?this.calcStatRBY(a,t,i,s):this.calcStatADV(e.natures,a,t,i,r,s,o)},a.prototype.calcStatADV=function(e,a,t,i,r,s,o){if("hp"===a)return 1===t?t:Math.floor((2*t+i+Math.floor(r/4))*s/100)+s+10;var l=[void 0,void 0];if(o){var h=e.get((0,n.toID)(o));l=[null==h?void 0:h.plus,null==h?void 0:h.minus]}var c=l[0]===a&&l[1]===a?1:l[0]===a?1.1:l[1]===a?.9:1;return Math.floor((Math.floor((2*t+i+Math.floor(r/4))*s/100)+5)*c)},a.prototype.calcStatRBY=function(e,a,t,i){return this.calcStatRBYFromDV(e,a,this.IVToDV(t),i)},a.prototype.calcStatRBYFromDV=function(e,a,t,i){return"hp"===e?Math.floor((2*(a+t)+63)*i/100)+i+10:Math.floor((2*(a+t)+63)*i/100)+5},a.prototype.getHiddenPowerIVs=function(a,t){var i=b[t];if(i)return 2===a.num?e.Stats.DVsToIVs(i.dvs):i.ivs},a.prototype.getHiddenPower=function(e,a){var t=function(e,a){return void 0===a&&(a=0),a?(e>>>0)%Math.pow(2,a):e>>>0};if(e.num<=2){var i=t(a.atk/2),r=t(a.def/2),s=t(a.spe/2),o=t(a.spa/2);return{type:f[i%4*4+r%4],power:t((5*((o>>3)+2*(s>>3)+4*(r>>3)+8*(i>>3))+o%4)/2+31)}}var n=0,l=0,h=1;for(var c in{hp:31,atk:31,def:31,spe:31,spa:31,spd:31})n+=h*(a[c]%2),l+=h*(t(a[c]/2)%2),h*=2;return{type:f[t(15*n/63)],power:e.num&&e.num<6?t(40*l/63)+30:60}},a}());var g=e,S=_this&&_this.__assign||function(){return S=Object.assign||function(e){for(var a,t=1,i=arguments.length;t<i;t++)for(var r in a=arguments[t])Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r]);return e},S.apply(this,arguments)},v=_this&&_this.__values||function(e){var a="function"==typeof Symbol&&Symbol.iterator,t=a&&e[a],i=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")},k=["hp","atk","def","spa","spd","spe"],A=new Set(["spc"]),P=function(){function e(a,t,i){var r,s,o;void 0===i&&(i={}),this.species=(0,n.extend)(!0,{},a.species.get((0,n.toID)(t)),i.overrides),this.gen=a,this.name=i.name||t,this.types=this.species.types,this.weightkg=this.species.weightkg,this.level=i.level||100,this.gender=i.gender||this.species.gender||"M",this.ability=i.ability||(null===(o=this.species.abilities)||void 0===o?void 0:o[0])||void 0,this.abilityOn=!!i.abilityOn,this.isDynamaxed=!!i.isDynamaxed,this.isSaltCure=!!i.isSaltCure,this.alliesFainted=i.alliesFainted,this.teraType=i.teraType,this.item=i.item,this.nature=i.nature||"Serious",this.ivs=e.withDefault(a,i.ivs,31),this.evs=e.withDefault(a,i.evs,a.num>=3?0:252),this.boosts=e.withDefault(a,i.boosts,0,!1),0===this.weightkg&&!this.isDynamaxed&&this.species.baseSpecies&&(this.weightkg=a.species.get((0,n.toID)(this.species.baseSpecies)).weightkg),a.num<3&&(this.ivs.hp=g.Stats.DVToIV(g.Stats.getHPDV({atk:this.ivs.atk,def:this.ivs.def,spe:this.ivs.spe,spc:this.ivs.spa}))),this.rawStats={},this.stats={};try{for(var l=v(k),h=l.next();!h.done;h=l.next()){var c=h.value,d=this.calcStat(a,c);this.rawStats[c]=d,this.stats[c]=d}}catch(e){r={error:e}}finally{try{h&&!h.done&&(s=l.return)&&s.call(l)}finally{if(r)throw r.error}}var u=i.curHP||i.originalCurHP;this.originalCurHP=u&&u<=this.rawStats.hp?u:this.rawStats.hp,this.status=i.status||"",this.toxicCounter=i.toxicCounter||0,this.moves=i.moves||[]}return e.prototype.maxHP=function(e){return void 0===e&&(e=!1),!e&&this.isDynamaxed&&1!==this.species.baseStats.hp?2*this.rawStats.hp:this.rawStats.hp},e.prototype.curHP=function(e){return void 0===e&&(e=!1),!e&&this.isDynamaxed&&1!==this.species.baseStats.hp?2*this.originalCurHP:this.originalCurHP},e.prototype.hasAbility=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return!(!this.ability||!e.includes(this.ability))},e.prototype.hasItem=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return!(!this.item||!e.includes(this.item))},e.prototype.hasStatus=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return!(!this.status||!e.includes(this.status))},e.prototype.hasType=function(){for(var e,a,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];try{for(var r=v(t),s=r.next();!s.done;s=r.next()){var o=s.value;if(this.teraType?this.teraType===o:this.types.includes(o))return!0}}catch(a){e={error:a}}finally{try{s&&!s.done&&(a=r.return)&&a.call(r)}finally{if(e)throw e.error}}return!1},e.prototype.hasOriginalType=function(){for(var e,a,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];try{for(var r=v(t),s=r.next();!s.done;s=r.next()){var o=s.value;if(this.types.includes(o))return!0}}catch(a){e={error:a}}finally{try{s&&!s.done&&(a=r.return)&&a.call(r)}finally{if(e)throw e.error}}return!1},e.prototype.named=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return e.includes(this.name)},e.prototype.clone=function(){return new e(this.gen,this.name,{level:this.level,ability:this.ability,abilityOn:this.abilityOn,isDynamaxed:this.isDynamaxed,isSaltCure:this.isSaltCure,alliesFainted:this.alliesFainted,item:this.item,gender:this.gender,nature:this.nature,ivs:(0,n.extend)(!0,{},this.ivs),evs:(0,n.extend)(!0,{},this.evs),boosts:(0,n.extend)(!0,{},this.boosts),originalCurHP:this.originalCurHP,status:this.status,teraType:this.teraType,toxicCounter:this.toxicCounter,moves:this.moves.slice(),overrides:this.species})},e.prototype.calcStat=function(e,a){return g.Stats.calcStat(e,a,this.species.baseStats[a],this.ivs[a],this.evs[a],this.level,this.nature)},e.getForme=function(e,a,t,i){var r=e.species.get((0,n.toID)(a));if(!(null==r?void 0:r.otherFormes))return a;var s=0;return t&&(t.includes("ite")&&!t.includes("ite Y")||"Groudon"===a&&"Red Orb"===t||"Kyogre"===a&&"Blue Orb"===t)||i&&"Meloetta"===a&&"Relic Song"===i||"Rayquaza"===a&&"Dragon Ascent"===i?s=1:(null==t?void 0:t.includes("ite Y"))&&(s=2),s?r.otherFormes[s-1]:r.name},e.withDefault=function(e,a,t,i){void 0===i&&(i=!0);var r={};if(a&&((0,n.assignWithout)(r,a,A),a.spc&&(r.spa=a.spc,r.spd=a.spc),i&&e.num<=2&&a.spa!==a.spd))throw new Error("Special Attack and Special Defense must match before Gen 3");return S({hp:t,atk:t,def:t,spa:t,spd:t,spe:t},r)},e}();e.Pokemon=P;var M=_this&&_this.__read||function(e,a){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var i,r,s=t.call(e),o=[];try{for(;(void 0===a||a-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(t=s.return)&&t.call(s)}finally{if(r)throw r.error}}return o},T=function(){function e(e){void 0===e&&(e={}),this.gameType=e.gameType||"Singles",this.terrain=e.terrain,this.weather=e.weather,this.isMagicRoom=!!e.isMagicRoom,this.isWonderRoom=!!e.isWonderRoom,this.isGravity=!!e.isGravity,this.isAuraBreak=e.isAuraBreak||!1,this.isFairyAura=e.isFairyAura||!1,this.isDarkAura=e.isDarkAura||!1,this.isBeadsOfRuin=e.isBeadsOfRuin||!1,this.isSwordOfRuin=e.isSwordOfRuin||!1,this.isTabletsOfRuin=e.isTabletsOfRuin||!1,this.isVesselOfRuin=e.isVesselOfRuin||!1,this.attackerSide=new w(e.attackerSide||{}),this.defenderSide=new w(e.defenderSide||{})}return e.prototype.hasWeather=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return!(!this.weather||!e.includes(this.weather))},e.prototype.hasTerrain=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return!(!this.terrain||!e.includes(this.terrain))},e.prototype.swap=function(){var e;return e=M([this.defenderSide,this.attackerSide],2),this.attackerSide=e[0],this.defenderSide=e[1],this},e.prototype.clone=function(){return new e({gameType:this.gameType,weather:this.weather,terrain:this.terrain,isMagicRoom:this.isMagicRoom,isWonderRoom:this.isWonderRoom,isGravity:this.isGravity,attackerSide:this.attackerSide,defenderSide:this.defenderSide,isAuraBreak:this.isAuraBreak,isDarkAura:this.isDarkAura,isFairyAura:this.isFairyAura,isBeadsOfRuin:this.isBeadsOfRuin,isSwordOfRuin:this.isSwordOfRuin,isTabletsOfRuin:this.isTabletsOfRuin,isVesselOfRuin:this.isVesselOfRuin})},e}();e.Field=T;var w=function(){function e(e){void 0===e&&(e={}),this.spikes=e.spikes||0,this.steelsurge=!!e.steelsurge,this.vinelash=!!e.vinelash,this.wildfire=!!e.wildfire,this.cannonade=!!e.cannonade,this.volcalith=!!e.volcalith,this.isSR=!!e.isSR,this.isReflect=!!e.isReflect,this.isLightScreen=!!e.isLightScreen,this.isProtected=!!e.isProtected,this.isSeeded=!!e.isSeeded,this.isForesight=!!e.isForesight,this.isTailwind=!!e.isTailwind,this.isHelpingHand=!!e.isHelpingHand,this.isFlowerGift=!!e.isFlowerGift,this.isFriendGuard=!!e.isFriendGuard,this.isAuroraVeil=!!e.isAuroraVeil,this.isBattery=!!e.isBattery,this.isPowerSpot=!!e.isPowerSpot,this.isSwitching=e.isSwitching}return e.prototype.clone=function(){return new e(this)},e}();e.Side=w;var B=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],R=function(){function e(e,a,t){var i,r;void 0===t&&(t={}),a=t.name||a,this.originalName=a;var s=(0,n.extend)(!0,{name:a},e.moves.get((0,n.toID)(a)),t.overrides);if(this.hits=1,t.useMax&&s.maxMove){var o=G(s.type,t.species,!("Status"!==s.category),t.ability),l=e.moves.get((0,n.toID)(o));s=(0,n.extend)(!0,{},l,{name:o,basePower:["G-Max Drum Solo","G-Max Fire Ball","G-Max Hydrosnipe"].includes(o)?160:10===l.basePower||"Max Flare"===o?s.maxMove.basePower:l.basePower,category:s.category})}if(t.useZ&&(null===(i=s.zMove)||void 0===i?void 0:i.basePower)){var h=x(s.name,s.type,t.item),c=e.moves.get((0,n.toID)(h));s=(0,n.extend)(!0,{},c,{name:h,basePower:1===c.basePower?s.zMove.basePower:c.basePower,category:s.category})}else s.multihit&&("number"==typeof s.multihit?this.hits=s.multihit:t.hits?this.hits=t.hits:this.hits="Skill Link"===t.ability?s.multihit[1]:s.multihit[0]+1),this.timesUsedWithMetronome=t.timesUsedWithMetronome;this.gen=e,this.name=s.name,this.ability=t.ability,this.item=t.item,this.useZ=t.useZ,this.useMax=t.useMax,this.overrides=t.overrides,this.species=t.species,this.bp=s.basePower;var d=e.num>=2&&"struggle"===s.id||e.num<=4&&["futuresight","doomdesire"].includes(s.id);this.type=d?"???":s.type,this.category=s.category||(e.num<4?B.includes(s.type)?"Special":"Physical":"Status");var u="Special"===this.category?"spa":"atk";(null===(r=s.self)||void 0===r?void 0:r.boosts)&&s.self.boosts[u]&&s.self.boosts[u]<0&&(this.dropsStats=Math.abs(s.self.boosts[u])),this.timesUsed=this.dropsStats&&t.timesUsed||1,this.secondaries=s.secondaries,this.target=s.target||"any",this.recoil=s.recoil,this.hasCrashDamage=!!s.hasCrashDamage,this.mindBlownRecoil=!!s.mindBlownRecoil,this.struggleRecoil=!!s.struggleRecoil,this.isCrit=!!t.isCrit||!!s.willCrit||1===e.num&&["crabhammer","razorleaf","slash","karate chop"].includes(s.id),this.drain=s.drain,this.flags=s.flags,this.priority=s.priority||0,this.ignoreDefensive=!!s.ignoreDefensive,this.overrideOffensiveStat=s.overrideOffensiveStat,this.overrideDefensiveStat=s.overrideDefensiveStat,this.overrideOffensivePokemon=s.overrideOffensivePokemon,this.overrideDefensivePokemon=s.overrideDefensivePokemon,this.breaksProtect=!!s.breaksProtect,this.isZ=!!s.isZ,this.isMax=!!s.isMax,this.bp||["return","frustration","pikapapow","veeveevolley"].includes(s.id)&&(this.bp=102)}return e.prototype.named=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return e.includes(this.name)},e.prototype.hasType=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return e.includes(this.type)},e.prototype.clone=function(){return new e(this.gen,this.originalName,{ability:this.ability,item:this.item,species:this.species,useZ:this.useZ,useMax:this.useMax,isCrit:this.isCrit,hits:this.hits,timesUsed:this.timesUsed,timesUsedWithMetronome:this.timesUsedWithMetronome,overrides:this.overrides})},e}();function x(e,a,t){if(t=t||"",e.includes("Hidden Power"))return"Breakneck Blitz";if("Clanging Scales"===e&&"Kommonium Z"===t)return"Clangorous Soulblaze";if("Darkest Lariat"===e&&"Incinium Z"===t)return"Malicious Moonsault";if("Giga Impact"===e&&"Snorlium Z"===t)return"Pulverizing Pancake";if("Moongeist Beam"===e&&"Lunalium Z"===t)return"Menacing Moonraze Maelstrom";if("Photon Geyser"===e&&"Ultranecrozium Z"===t)return"Light That Burns the Sky";if("Play Rough"===e&&"Mimikium Z"===t)return"Let's Snuggle Forever";if("Psychic"===e&&"Mewnium Z"===t)return"Genesis Supernova";if("Sparkling Aria"===e&&"Primarium Z"===t)return"Oceanic Operetta";if("Spectral Thief"===e&&"Marshadium Z"===t)return"Soul-Stealing 7-Star Strike";if("Spirit Shackle"===e&&"Decidium Z"===t)return"Sinister Arrow Raid";if("Stone Edge"===e&&"Lycanium Z"===t)return"Splintered Stormshards";if("Sunsteel Strike"===e&&"Solganium Z"===t)return"Searing Sunraze Smash";if("Volt Tackle"===e&&"Pikanium Z"===t)return"Catastropika";if("Nature's Madness"===e&&"Tapunium Z"===t)return"Guardian of Alola";if("Thunderbolt"===e){if("Aloraichium Z"===t)return"Stoked Sparksurfer";if("Pikashunium Z"===t)return"10,000,000 Volt Thunderbolt"}return F[a]}e.Move=R,e.getZMoveName=x;var F={Bug:"Savage Spin-Out",Dark:"Black Hole Eclipse",Dragon:"Devastating Drake",Electric:"Gigavolt Havoc",Fairy:"Twinkle Tackle",Fighting:"All-Out Pummeling",Fire:"Inferno Overdrive",Flying:"Supersonic Skystrike",Ghost:"Never-Ending Nightmare",Grass:"Bloom Doom",Ground:"Tectonic Rage",Ice:"Subzero Slammer",Normal:"Breakneck Blitz",Poison:"Acid Downpour",Psychic:"Shattered Psyche",Rock:"Continental Crush",Steel:"Corkscrew Crash",Water:"Hydro Vortex"};function G(e,a,t,i){if(t)return"Max Guard";if("Normalize"===i)return"Max Strike";if("Fire"===e){if("Charizard-Gmax"===a)return"G-Max Wildfire";if("Centiskorch-Gmax"===a)return"G-Max Centiferno";if("Cinderace-Gmax"===a)return"G-Max Fire Ball"}if("Normal"===e){if("Eevee-Gmax"===a)return"G-Max Cuddle";if("Meowth-Gmax"===a)return"G-Max Gold Rush";if("Snorlax-Gmax"===a)return"G-Max Replenish";if("Pixilate"===i)return"Max Starfall";if("Aerilate"===i)return"Max Airstream";if("Refrigerate"===i)return"Max Hailstorm";if("Galvanize"===i)return"Max Lightning"}if("Fairy"===e){if("Alcremie-Gmax"===a)return"G-Max Finale";if("Hatterene-Gmax"===a)return"G-Max Smite"}if("Steel"===e){if("Copperajah-Gmax"===a)return"G-Max Steelsurge";if("Melmetal-Gmax"===a)return"G-Max Meltdown"}if("Electric"===e){if("Pikachu-Gmax"===a)return"G-Max Volt Crash";if((null==a?void 0:a.startsWith("Toxtricity"))&&(null==a?void 0:a.endsWith("Gmax")))return"G-Max Stun Shock"}if("Grass"===e){if("Appletun-Gmax"===a)return"G-Max Sweetness";if("Flapple-Gmax"===a)return"G-Max Tartness";if("Rillaboom-Gmax"===a)return"G-Max Drum Solo";if("Venusaur-Gmax"===a)return"G-Max Vine Lash"}if("Water"===e){if("Blastoise-Gmax"===a)return"G-Max Cannonade";if("Drednaw-Gmax"===a)return"G-Max Stonesurge";if("Inteleon-Gmax"===a)return"G-Max Hydrosnipe";if("Kingler-Gmax"===a)return"G-Max Foam Burst";if("Urshifu-Rapid-Strike-Gmax"===a)return"G-Max Rapid Flow"}if("Dark"===e){if("Grimmsnarl-Gmax"===a)return"G-Max Snooze";if("Urshifu-Gmax"===a)return"G-Max One Blow"}return"Poison"===e&&"Garbodor-Gmax"===a?"G-Max Malodor":"Fighting"===e&&"Machamp-Gmax"===a?"G-Max Chi Strike":"Ghost"===e&&"Gengar-Gmax"===a?"G-Max Terror":"Ice"===e&&"Lapras-Gmax"===a?"G-Max Resonance":"Flying"===e&&"Corviknight-Gmax"===a?"G-Max Wind Rage":"Dragon"===e&&"Duraludon-Gmax"===a?"G-Max Depletion":"Psychic"===e&&"Orbeetle-Gmax"===a?"G-Max Gravitas":"Rock"===e&&"Coalossal-Gmax"===a?"G-Max Volcalith":"Ground"===e&&"Sandaconda-Gmax"===a?"G-Max Sandblast":"Dark"===e&&"Grimmsnarl-Gmax"===a?"G-Max Snooze":"Max "+I[e]}e.getMaxMoveName=G;var I={Bug:"Flutterby",Dark:"Darkness",Dragon:"Wyrmwind",Electric:"Lightning",Fairy:"Starfall",Fighting:"Knuckle",Fire:"Flare",Flying:"Airstream",Ghost:"Phantasm",Grass:"Overgrowth",Ground:"Quake",Ice:"Hailstorm",Normal:"Strike",Poison:"Ooze",Psychic:"Mindstorm",Rock:"Rockfall",Steel:"Steelspike",Water:"Geyser"};e.SEED_BOOSTED_STAT={"Electric Seed":"def","Grassy Seed":"def","Misty Seed":"spd","Psychic Seed":"spd"},e.getItemBoostType=function(e){switch(e){case"Draco Plate":case"Dragon Fang":return"Dragon";case"Dread Plate":case"Black Glasses":return"Dark";case"Earth Plate":case"Soft Sand":return"Ground";case"Fist Plate":case"Black Belt":return"Fighting";case"Flame Plate":case"Charcoal":return"Fire";case"Icicle Plate":case"Never-Melt Ice":return"Ice";case"Insect Plate":case"Silver Powder":return"Bug";case"Iron Plate":case"Metal Coat":return"Steel";case"Meadow Plate":case"Rose Incense":case"Miracle Seed":return"Grass";case"Mind Plate":case"Odd Incense":case"Twisted Spoon":return"Psychic";case"Pixie Plate":return"Fairy";case"Sky Plate":case"Sharp Beak":return"Flying";case"Splash Plate":case"Sea Incense":case"Wave Incense":case"Mystic Water":return"Water";case"Spooky Plate":case"Spell Tag":return"Ghost";case"Stone Plate":case"Rock Incense":case"Hard Stone":return"Rock";case"Toxic Plate":case"Poison Barb":return"Poison";case"Zap Plate":case"Magnet":return"Electric";case"Silk Scarf":case"Pink Bow":case"Polkadot Bow":return"Normal";default:return}},e.getBerryResistType=function(e){switch(e){case"Chilan Berry":return"Normal";case"Occa Berry":return"Fire";case"Passho Berry":return"Water";case"Wacan Berry":return"Electric";case"Rindo Berry":return"Grass";case"Yache Berry":return"Ice";case"Chople Berry":return"Fighting";case"Kebia Berry":return"Poison";case"Shuca Berry":return"Ground";case"Coba Berry":return"Flying";case"Payapa Berry":return"Psychic";case"Tanga Berry":return"Bug";case"Charti Berry":return"Rock";case"Kasib Berry":return"Ghost";case"Haban Berry":return"Dragon";case"Colbur Berry":return"Dark";case"Babiri Berry":return"Steel";case"Roseli Berry":return"Fairy";default:return}};var D=new Set(["TR24","TR28","TR34","TR39","TR53","TR55","TR64","TR66","TR72","TR73"]),H=new Set(["Hard Stone","Room Service","Claw Fossil","Dome Fossil","Helix Fossil","Old Amber","Root Fossil","Armor Fossil","Old Amber","Fossilized Bird","Fossilized Dino","Fossilized Drake","Fossilized Fish","Plume Fossil","Jaw Fossil","Cover Fossil","Sail Fossil","Rare Bone","Skull Fossil","TR10","TR31","TR75"]),W=new Set(["Deep Sea Tooth","Thick Club","TR02","TR04","TR05","TR08","TR11","TR22","TR35","TR42","TR45","TR50","TR61","TR65","TR67","TR86","TR90","TR96"]),C=new Set(["TR01","TR41","TR62","TR93","TR97","TR98"]),O=new Set(["Assault Vest","Blunder Policy","Chipped Pot","Cracked Pot","Heavy-Duty Boots","Weakness Policy","Quick Claw","Dawn Stone","Dusk Stone","Electirizer","Magmarizer","Oval Stone","Protector","Sachet","Whipped Dream","Razor Claw","Shiny Stone","TR16","TR18","TR19","TR25","TR32","TR33","TR47","TR56","TR57","TR58","TR59","TR60","TR63","TR69","TR70","TR74","TR84","TR87","TR92","TR95","TR99"]),E=new Set(["Poison Barb","Dragon Fang","Power Anklet","Power Band","Power Belt","Power Bracer","Power Lens","Power Weight"]),L=new Set(["Adamant Orb","Damp Rock","Heat Rock","Leek","Lustrous Orb","Macho Brace","Rocky Helmet","Stick","Utility Umbrella","Terrain Extender"]),V=new Set(["Absorb Bulb","Black Belt","Black Sludge","Black Glasses","Cell Battery","Charcoal","Deep Sea Scale","Flame Orb","King's Rock","Life Orb","Light Ball","Light Clay","Magnet","Metal Coat","Miracle Seed","Mystic Water","Never-Melt Ice","Razor Fang","Scope Lens","Soul Dew","Spell Tag","Sweet Apple","Tart Apple","Throat Spray","Toxic Orb","Twisted Spoon","Dragon Scale","Energy Powder","Fire Stone","Leaf Stone","Moon Stone","Sun Stone","Thunder Stone","Up-Grade","Water Stone","Berry Juice","Black Sludge","Prism Scale","Ice Stone","Gold Bottle Cap","Luminous Moss","Eject Button","Snowball","Bottle Cap"]),N=new Set(["Air Balloon","Berry Sweet","Choice Band","Choice Scarf","Choice Specs","Clover Sweet","Destiny Knot","Electric Seed","Expert Belt","Flower Sweet","Focus Band","Focus Sash","Full Incense","Grassy Seed","Lagging Tail","Lax Incense","Leftovers","Love Sweet","Mental Herb","Metal Powder","Mint Berry","Miracle Berry","Misty Seed","Muscle Band","Power Herb","Psychic Seed","Odd Incense","Quick Powder","Reaper Cloth","Red Card","Ribbon Sweet","Ring Target","Rock Incense","Rose Incense","Sea Incense","Shed Shell","Silk Scarf","Silver Powder","Smooth Rock","Soft Sand","Soothe Bell","Star Sweet","Strawberry Sweet","Wave Incense","White Herb","Wide Lens","Wise Glasses","Zoom Lens","Silver Powder","Power Herb","TR00","TR07","TR12","TR13","TR14","TR17","TR20","TR21","TR23","TR26","TR27","TR29","TR30","TR37","TR38","TR40","TR44","TR46","TR48","TR49","TR51","TR52","TR54","TR68","TR76","TR77","TR79","TR80","TR83","TR85","TR88","TR91"]);e.getFlingPower=function(e){return e?["Iron Ball","TR43","TR71"].includes(e)?130:D.has(e)?85:["TR03","TR06","TR09","TR15","TR89"].includes(e)?110:H.has(e)?100:["TR36","TR78","TR81","TR94"].includes(e)?95:e.includes("Plate")||W.has(e)?90:C.has(e)?85:O.has(e)?80:E.has(e)?70:L.has(e)?60:["Eject Pack","Sharp Beak","Dubious Disc"].includes(e)?50:["Icy Rock","Eviolite","Lucky Punch"].includes(e)?40:V.has(e)?30:"TR82"===e?20:e.includes("Berry")||N.has(e)?10:0:0},e.getNaturalGift=function(e,a){var t,i=null===(t=e.items.get((0,n.toID)(a)))||void 0===t?void 0:t.naturalGift;return i?{t:i.type,p:i.basePower}:{t:"Normal",p:1}},e.getTechnoBlast=function(e){switch(e){case"Burn Drive":return"Fire";case"Chill Drive":return"Ice";case"Douse Drive":return"Water";case"Shock Drive":return"Electric";default:return}},e.getMultiAttack=function(e){if(e.includes("Memory"))return e.substring(0,e.indexOf(" "))};var U=_this&&_this.__spreadArray||function(e,a,t){if(t||2===arguments.length)for(var i,r=0,s=a.length;r<s;r++)!i&&r in a||(i||(i=Array.prototype.slice.call(a,0,r)),i[r]=a[r]);return e.concat(i||Array.prototype.slice.call(a))},z=["Macho Brace","Power Anklet","Power Band","Power Belt","Power Bracer","Power Lens","Power Weight"];function K(e,a,t){if(t&&t.num<3){if(a>=0){e=Math.floor(e*[1,1.5,2,2.5,3,3.5,4][a])}else{e=Math.floor(e*[100,66,50,40,33,28,25][-a]/100)}return Math.min(999,Math.max(1,e))}var i=[[2,8],[2,7],[2,6],[2,5],[2,4],[2,3],[2,2],[3,2],[4,2],[5,2],[6,2],[7,2],[8,2]];return e=J(e*i[6+a][0]),e=Math.floor(e/i[6+a][1])}function Z(e,a,t,i){var r=t.weather||"",s=t.terrain,o=K(a.rawStats.spe,a.boosts.spe,e),n=[];return i.isTailwind&&n.push(8192),a.hasAbility("Unburden")&&a.abilityOn||a.hasAbility("Chlorophyll")&&r.includes("Sun")||a.hasAbility("Sand Rush")&&"Sand"===r||a.hasAbility("Swift Swim")&&r.includes("Rain")||a.hasAbility("Slush Rush")&&["Hail","Snow"].includes(r)||a.hasAbility("Surge Surfer")&&"Electric"===s?n.push(8192):a.hasAbility("Quick Feet")&&a.status?n.push(6144):a.hasAbility("Slow Start")&&a.abilityOn?n.push(2048):"spe"===_(a,e)&&(a.hasAbility("Protosynthesis")&&(r.includes("Sun")||a.hasItem("Booster Energy"))||a.hasAbility("Quark Drive")&&("Electric"===s||a.hasItem("Booster Energy")))&&n.push(6144),a.hasItem("Choice Scarf")?n.push(6144):a.hasItem.apply(a,U(["Iron Ball"],M(z),!1))?n.push(2048):a.hasItem("Quick Powder")&&a.named("Ditto")&&n.push(8192),o=Q(Y(o*j(n,410,131172)/4096)),a.hasStatus("par")&&!a.hasAbility("Quick Feet")&&(o=Math.floor(Q(o*(e.num,25))/100)),o=Math.min(e.num<=2?999:1e4,o),Math.max(0,o)}function j(e,a,t){var i,r,s=4096;try{for(var o=v(e),n=o.next();!n.done;n=o.next()){var l=n.value;4096!==l&&(s=s*l+2048>>12)}}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return Math.max(Math.min(s,t),a)}function _(e,a){var t,i,r="atk";try{for(var s=v(["def","spa","spd","spe"]),o=s.next();!o.done;o=s.next()){var n=o.value;K(e.rawStats[n],e.boosts[n],a)>K(e.rawStats[r],e.boosts[r],a)&&(r=n)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return r}function Y(e){return e%1>.5?Math.ceil(e):Math.floor(e)}function J(e){return e>65535?e%65536:e}function Q(e){return e>4294967295?e%4294967296:e}e.isGrounded=function(e,a){return a.isGravity||e.hasItem("Iron Ball")||!e.hasType("Flying")&&!e.hasAbility("Levitate")&&!e.hasItem("Air Balloon")},e.getModifiedStat=K,e.computeFinalStats=function(e,a,t,i){for(var r,s,o,n,l=[],h=4;h<arguments.length;h++)l[h-4]=arguments[h];var c=[[a,i.attackerSide],[t,i.defenderSide]];try{for(var d=v(c),u=d.next();!u.done;u=d.next()){var y=M(u.value,2),m=y[0],p=y[1];try{for(var f=(o=void 0,v(l)),b=f.next();!b.done;b=f.next()){var g=b.value;"spe"===g?m.stats.spe=Z(e,m,i,p):m.stats[g]=K(m.rawStats[g],m.boosts[g],e)}}catch(e){o={error:e}}finally{try{b&&!b.done&&(n=f.return)&&n.call(f)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}},e.getFinalSpeed=Z,e.getMoveEffectiveness=function(e,a,t,i,r,s){return(s||i)&&"Ghost"===t&&a.hasType("Normal","Fighting")||(s||r)&&"Flying"===t&&a.hasType("Ground")?1:a.named("Freeze-Dry")&&"Water"===t?2:a.named("Flying Press")?e.types.get("fighting").effectiveness[t]*e.types.get("flying").effectiveness[t]:e.types.get((0,n.toID)(a.type)).effectiveness[t]},e.checkAirLock=function(e,a){e.hasAbility("Air Lock","Cloud Nine")&&(a.weather=void 0)},e.checkForecast=function(e,a){if(e.hasAbility("Forecast")&&e.named("Castform"))switch(a){case"Sun":case"Harsh Sunshine":e.types=["Fire"];break;case"Rain":case"Heavy Rain":e.types=["Water"];break;case"Hail":case"Snow":e.types=["Ice"];break;default:e.types=["Normal"]}},e.checkItem=function(e,a){(e.hasAbility("Klutz")&&!z.includes(e.item)||a)&&(e.item="")},e.checkWonderRoom=function(e,a){var t;a&&(t=M([e.rawStats.spd,e.rawStats.def],2),e.rawStats.def=t[0],e.rawStats.spd=t[1])},e.checkIntimidate=function(e,a,t){var i=t.hasAbility("Clear Body","White Smoke","Hyper Cutter","Full Metal Body")||e.num>=8&&t.hasAbility("Inner Focus","Own Tempo","Oblivious","Scrappy")||t.hasItem("Clear Amulet");a.hasAbility("Intimidate")&&a.abilityOn&&!i&&(t.hasAbility("Contrary","Defiant","Guard Dog")?t.boosts.atk=Math.min(6,t.boosts.atk+1):t.hasAbility("Simple")?t.boosts.atk=Math.max(-6,t.boosts.atk-2):t.boosts.atk=Math.max(-6,t.boosts.atk-1),t.hasAbility("Competitive")&&(t.boosts.spa=Math.min(6,t.boosts.spa+2)))},e.checkDownload=function(e,a,t){var i;if(e.hasAbility("Download")){var r=a.stats.def,s=a.stats.spd;t&&(r=(i=M([s,r],2))[0],s=i[1]),s<=r?e.boosts.spa=Math.min(6,e.boosts.spa+1):e.boosts.atk=Math.min(6,e.boosts.atk+1)}},e.checkIntrepidSword=function(e,a){e.hasAbility("Intrepid Sword")&&a.num<9&&(e.boosts.atk=Math.min(6,e.boosts.atk+1))},e.checkDauntlessShield=function(e,a){e.hasAbility("Dauntless Shield")&&a.num<9&&(e.boosts.def=Math.min(6,e.boosts.def+1))},e.checkInfiltrator=function(e,a){e.hasAbility("Infiltrator")&&(a.isReflect=!1,a.isLightScreen=!1,a.isAuroraVeil=!1)},e.checkSeedBoost=function(e,a){if(e.item&&a.terrain&&e.item.includes("Seed")){var t=e.item.substring(0,e.item.indexOf(" "));a.hasTerrain(t)&&("Grassy"===t||"Electric"===t?e.boosts.def=e.hasAbility("Contrary")?Math.max(-6,e.boosts.def-1):Math.min(6,e.boosts.def+1):e.boosts.spd=e.hasAbility("Contrary")?Math.max(-6,e.boosts.spd-1):Math.min(6,e.boosts.spd+1))}},e.checkMultihitBoost=function(e,a,t,i,r,s,o){void 0===o&&(o=!1),i.named("Gyro Ball","Electro Ball")&&t.hasAbility("Gooey","Tangling Hair")?a.hasItem("White Herb")&&!o?(s.attackerItem=a.item,o=!0):(a.boosts.spe=Math.max(a.boosts.spe-1,-6),a.stats.spe=Z(e,a,r,r.attackerSide),s.defenderAbility=t.ability):i.named("Power-Up Punch")&&(a.boosts.atk=Math.min(a.boosts.atk+1,6),a.stats.atk=K(a.rawStats.atk,a.boosts.atk,e)),t.hasAbility("Stamina")?a.hasAbility("Unaware")?s.attackerAbility=a.ability:(t.boosts.def=Math.min(t.boosts.def+1,6),t.stats.def=K(t.rawStats.def,t.boosts.def,e),s.defenderAbility=t.ability):t.hasAbility("Weak Armor")&&(a.hasAbility("Unaware")?s.attackerAbility=a.ability:t.hasItem("White Herb")&&!o?(s.defenderItem=t.item,o=!0):(t.boosts.def=Math.max(t.boosts.def-1,-6),t.stats.def=K(t.rawStats.def,t.boosts.def,e)),t.boosts.spe=Math.min(t.boosts.spe+2,6),t.stats.spe=Z(e,t,r,r.defenderSide),s.defenderAbility=t.ability);var n=a.hasAbility("Simple")?2:1;if(i.dropsStats)if(a.hasAbility("Unaware"))s.attackerAbility=a.ability;else{var l="Special"===i.category?"spa":"atk",h=a.boosts[l];a.hasAbility("Contrary")?(h=Math.min(6,h+i.dropsStats),s.attackerAbility=a.ability):(h=Math.max(-6,h-i.dropsStats*n),n>1&&(s.attackerAbility=a.ability)),a.hasItem("White Herb")&&a.boosts[l]<0&&!o&&(h+=i.dropsStats*n,s.attackerItem=a.item,o=!0),a.boosts[l]=h,a.stats[l]=K(a.rawStats[l],t.boosts[l],e)}return o},e.chainMods=j,e.getBaseDamage=function(e,a,t,i){return Math.floor(Q(Math.floor(Q(Q(Math.floor(2*e/5+2)*a)*t)/i)/50+2))},e.getMostProficientStat=_,e.getFinalDamage=function(e,a,t,i,r,s,o){var n=Math.floor(Q(e*(85+a))/100);return 4096!==r&&(n=Q(n*r)/4096),n=Math.floor(Q(Y(n)*t)),i&&(n=Math.floor(n/2)),o&&(n=Y(Q(1024*n)/4096)),J(Y(Math.max(1,Q(n*s)/4096)))},e.getShellSideArmCategory=function(e,a){return e.stats.atk/a.stats.def>e.stats.spa/a.stats.spd?"Physical":"Special"},e.getWeightFactor=function(e){return e.hasAbility("Heavy Metal")?2:e.hasAbility("Light Metal")||e.hasItem("Float Stone")?.5:1},e.countBoosts=function(e,a){var t,i,r=0,s=1===e.num?["atk","def","spa","spe"]:["atk","def","spa","spd","spe"];try{for(var o=v(s),n=o.next();!n.done;n=o.next()){var l=a[n.value];l&&l>0&&(r+=l)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return r},e.getEVDescriptionText=function(e,a,t,i){var r=e.natures.get((0,n.toID)(i));return a.ivs[t]+(r.plus===r.minus?"":r.plus===t?"+":r.minus===t?"-":"")+" "+g.Stats.displayStat(t)},e.handleFixedDamageMoves=function(e,a){return a.named("Seismic Toss","Night Shade")?e.level:a.named("Dragon Rage")?40:a.named("Sonic Boom")?20:0},e.pokeRound=Y,e.OF16=J,e.OF32=Q;var q=function(){function e(e,a,t,i,r,s,o){this.gen=e,this.attacker=a,this.defender=t,this.move=i,this.field=r,this.damage=s,this.rawDesc=o}return e.prototype.desc=function(){return this.fullDesc()},e.prototype.range=function(){var e=X(this.damage);if("number"==typeof e[0])return e;var a=e;return[a[0][0]+a[0][1],a[1][0]+a[1][1]]},e.prototype.fullDesc=function(e,a){return void 0===e&&(e="%"),void 0===a&&(a=!0),(0,ce.display)(this.gen,this.attacker,this.defender,this.move,this.field,this.damage,this.rawDesc,e,a)},e.prototype.moveDesc=function(e){return void 0===e&&(e="%"),(0,ce.displayMove)(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.recovery=function(e){return void 0===e&&(e="%"),(0,ce.getRecovery)(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.recoil=function(e){return void 0===e&&(e="%"),(0,ce.getRecoil)(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.kochance=function(e){return void 0===e&&(e=!0),(0,ce.getKOChance)(this.gen,this.attacker,this.defender,this.move,this.field,this.damage,e)},e}();function X(e){if("number"==typeof e)return[e,e];if(e.length>2){var a=e;return a[0]>a[a.length-1]?[Math.min.apply(Math,U([],M(a),!1)),Math.max.apply(Math,U([],M(a),!1))]:[a[0],a[a.length-1]]}if("number"==typeof e[0]&&"number"==typeof e[1])return[[e[0],e[1]],[e[0],e[1]]];var t=e;return t[0][0]>t[0][t[0].length-1]&&(t[0]=t[0].slice().sort()),t[1][0]>t[1][t[1].length-1]&&(t[1]=t[1].slice().sort()),[[t[0][0],t[1][0]],[t[0][t[0].length-1],t[1][t[1].length-1]]]}e.Result=q,e.damageRange=X;var $=e,ee=e;function ae(e,a,t,i,r,s){void 0===s&&(s="%");var o=M((0,$.damageRange)(r),2),n=o[0],l=o[1],h="number"==typeof n?[n]:n,c="number"==typeof l?[l]:l,d=[0,0],u="",y=3===e.num&&i.named("Doom Desire","Future Sight");if(a.hasItem("Shell Bell")&&!y)for(var m=Math.round(t.maxHP()/8),p=0;p<h.length;p++)d[0]+=Math.min(Math.round(h[p]*i.hits/8),m),d[1]+=Math.min(Math.round(c[p]*i.hits/8),m);if(i.named("G-Max Finale")&&(d[0]=d[1]=Math.round(a.maxHP()/6)),i.drain){var f=i.drain[0]/i.drain[1];for(m=Math.round(t.maxHP()*f),p=0;p<h.length;p++)d[0]+=Math.min(Math.round(h[p]*i.hits*f),m),d[1]+=Math.min(Math.round(c[p]*i.hits*f),m)}if(0===d[1])return{recovery:d,text:u};var b=he(s,d[0],a.maxHP()),g=he(s,d[1],a.maxHP());return{recovery:d,text:u="".concat(b," - ").concat(g).concat(s," recovered")}}function te(e,a,t,i,r,s){void 0===s&&(s="%");var o=M((0,$.damageRange)(r),2),n=o[0],l=o[1],h=("number"==typeof n?n:n[0]+n[1])*i.hits,c=("number"==typeof l?l:l[0]+l[1])*i.hits,d=[0,0],u="",y=n>t.curHP()||l>t.curHP();if(i.recoil){var m=i.recoil[0]/i.recoil[1]*100,p=void 0,f=void 0;y?(p=he(s,t.curHP()*m,a.maxHP(),100),f=he(s,t.curHP()*m,a.maxHP(),100)):(p=he(s,Math.min(h,t.curHP())*m,a.maxHP(),100),f=he(s,Math.min(c,t.curHP())*m,a.maxHP(),100)),a.hasAbility("Rock Head")||(d=[p,f],u="".concat(p," - ").concat(f).concat(s," recoil damage"))}else if(i.hasCrashDamage){var b=2===e.num?12.5:e.num>=3?50:1;p=void 0,f=void 0;switch(y&&2!==e.num?(p=he(s,t.curHP()*b,a.maxHP(),100),f=he(s,t.curHP()*b,a.maxHP(),100)):(p=he(s,Math.min(h,t.maxHP())*b,a.maxHP(),100),f=he(s,Math.min(c,t.maxHP())*b,a.maxHP(),100)),d=[p,f],e.num){case 1:d=he(s,1,a.maxHP()),u="1hp damage on miss";break;case 2:case 3:case 4:if(t.hasType("Ghost"))if(4===e.num){var g=Math.floor(.5*t.maxHP()/a.maxHP()*100);d="%"===s?g:Math.floor(g/100*48),u="".concat(g,"% crash damage")}else d=0,u="no crash damage on Ghost types";else u="".concat(p," - ").concat(f).concat(s," crash damage on miss");break;default:d="%"===s?24:50,u="50% crash damage"}}else i.struggleRecoil?(d="%"===s?12:25,u="25% struggle damage",4===e.num&&(u+=" (rounded down)")):i.mindBlownRecoil&&(d="%"===s?24:50,u="50% recoil damage");return{recoil:d,text:u}}function ie(e,a,t,i,r,s,o){if(void 0===o&&(o=!0),s=function(e){if("number"==typeof e)return[e];if(e.length>2)return e[0]>e[e.length-1]&&(e=e.slice().sort()),e;if("number"==typeof e[0]&&"number"==typeof e[1])return[e[0]+e[1]];for(var a=e,t=[],i=0;i<a[0].length;i++)for(var r=0;r<a[1].length;r++)t.push(a[0][i]+a[1][r]);return t.sort()}(s),isNaN(s[0]))return(0,n.error)(o,"damage[0] must be a number."),{chance:0,n:0,text:""};if(0===s[s.length-1])return(0,n.error)(o,"damage[damage.length - 1] === 0."),{chance:0,n:0,text:""};if(void 0===i.timesUsed&&(i.timesUsed=1),void 0===i.timesUsedWithMetronome&&(i.timesUsedWithMetronome=1),s[0]>=t.maxHP()&&1===i.timesUsed&&1===i.timesUsedWithMetronome)return{chance:1,n:1,text:"guaranteed OHKO"};var l=function(e,a,t){var i=0,r=[];if(a.hasItem("Heavy-Duty Boots"))return{damage:i,texts:r};if(t.isSR&&!a.hasAbility("Magic Guard","Mountaineer")){var s=e.types.get("rock"),o=s.effectiveness[a.types[0]]*(a.types[1]?s.effectiveness[a.types[1]]:1);i+=Math.floor(o*a.maxHP()/8),r.push("Stealth Rock")}if(t.steelsurge&&!a.hasAbility("Magic Guard","Mountaineer")){var n=e.types.get("steel");o=n.effectiveness[a.types[0]]*(a.types[1]?n.effectiveness[a.types[1]]:1);i+=Math.floor(o*a.maxHP()/8),r.push("Steelsurge")}a.hasType("Flying")||a.hasAbility("Magic Guard","Levitate")||a.hasItem("Air Balloon")||(1===t.spikes?(i+=Math.floor(a.maxHP()/8),2===e.num?r.push("Spikes"):r.push("1 layer of Spikes")):2===t.spikes?(i+=Math.floor(a.maxHP()/6),r.push("2 layers of Spikes")):3===t.spikes&&(i+=Math.floor(a.maxHP()/4),r.push("3 layers of Spikes")));isNaN(i)&&(i=0);return{damage:i,texts:r}}(e,t,r.defenderSide),h=function(e,a,t,i,r){var s=0,o=[];r.hasWeather("Sun","Harsh Sunshine")?t.hasAbility("Dry Skin","Solar Power")&&(s-=Math.floor(t.maxHP()/8),o.push(t.ability+" damage")):r.hasWeather("Rain","Heavy Rain")?t.hasAbility("Dry Skin")?(s+=Math.floor(t.maxHP()/8),o.push("Dry Skin recovery")):t.hasAbility("Rain Dish")&&(s+=Math.floor(t.maxHP()/16),o.push("Rain Dish recovery")):r.hasWeather("Sand")?t.hasType("Rock","Ground","Steel")||t.hasAbility("Magic Guard","Overcoat","Sand Force","Sand Rush","Sand Veil")||t.hasItem("Safety Goggles")||(s-=Math.floor(t.maxHP()/(2===e.num?8:16)),o.push("sandstorm damage")):r.hasWeather("Hail","Snow")&&(t.hasAbility("Ice Body")?(s+=Math.floor(t.maxHP()/16),o.push("Ice Body recovery")):t.hasType("Ice")||t.hasAbility("Magic Guard","Overcoat","Snow Cloak")||t.hasItem("Safety Goggles")||!r.hasWeather("Hail")||(s-=Math.floor(t.maxHP()/16),o.push("hail damage")));var n=i.named("Knock Off")&&!t.hasAbility("Sticky Hold");t.hasItem("Leftovers")&&!n?(s+=Math.floor(t.maxHP()/16),o.push("Leftovers recovery")):t.hasItem("Black Sludge")&&!n?t.hasType("Poison")?(s+=Math.floor(t.maxHP()/16),o.push("Black Sludge recovery")):t.hasAbility("Magic Guard","Klutz")||(s-=Math.floor(t.maxHP()/8),o.push("Black Sludge damage")):t.hasItem("Sticky Barb")&&(s-=Math.floor(t.maxHP()/8),o.push("Sticky Barb damage"));r.defenderSide.isSeeded&&(t.hasAbility("Magic Guard")||(s-=Math.floor(t.maxHP()/(e.num>=2?8:16)),o.push("Leech Seed damage")));r.attackerSide.isSeeded&&!a.hasAbility("Magic Guard")&&(a.hasAbility("Liquid Ooze")?(s-=Math.floor(a.maxHP()/(e.num>=2?8:16)),o.push("Liquid Ooze damage")):(s+=Math.floor(a.maxHP()/(e.num>=2?8:16)),o.push("Leech Seed recovery")));r.hasTerrain("Grassy")&&(0,ee.isGrounded)(t,r)&&(s+=Math.floor(t.maxHP()/16),o.push("Grassy Terrain recovery"));t.hasStatus("psn")?t.hasAbility("Poison Heal")?(s+=Math.floor(t.maxHP()/8),o.push("Poison Heal")):t.hasAbility("Magic Guard")||(s-=Math.floor(t.maxHP()/(1===e.num?16:8)),o.push("poison damage")):t.hasStatus("tox")?t.hasAbility("Poison Heal")?(s+=Math.floor(t.maxHP()/8),o.push("Poison Heal")):t.hasAbility("Magic Guard")||o.push("toxic damage"):t.hasStatus("brn")?t.hasAbility("Heatproof")?(s-=Math.floor(t.maxHP()/(e.num>6?32:16)),o.push("reduced burn damage")):t.hasAbility("Magic Guard")||(s-=Math.floor(t.maxHP()/(1===e.num||e.num>6?16:8)),o.push("burn damage")):(t.hasStatus("slp")||t.hasAbility("Comatose"))&&a.hasAbility("isBadDreams")&&!t.hasAbility("Magic Guard")&&(s-=Math.floor(t.maxHP()/8),o.push("Bad Dreams"));!t.hasAbility("Magic Guard")&&re.includes(i.name)&&(a.hasItem("Binding Band")?(s-=e.num>5?Math.floor(t.maxHP()/6):Math.floor(t.maxHP()/8),o.push("trapping damage")):(s-=e.num>5?Math.floor(t.maxHP()/8):Math.floor(t.maxHP()/16),o.push("trapping damage")));if(t.isSaltCure&&!t.hasAbility("Magic Guard")){var l=t.hasType("Water","Steel")||t.teraType&&["Water","Steel"].includes(t.teraType);s-=Math.floor(t.maxHP()/(l?4:8)),o.push("Salt Cure")}t.hasType("Fire")||t.hasAbility("Magic Guard")||!i.named("Fire Pledge (Grass Pledge Boosted)","Grass Pledge (Fire Pledge Boosted)")||(s-=Math.floor(t.maxHP()/8),o.push("Sea of Fire damage"));t.hasAbility("Magic Guard")||t.hasType("Grass")||!r.defenderSide.vinelash&&!i.named("G-Max Vine Lash")||(s-=Math.floor(t.maxHP()/6),o.push("Vine Lash damage"));t.hasAbility("Magic Guard")||t.hasType("Fire")||!r.defenderSide.wildfire&&!i.named("G-Max Wildfire")||(s-=Math.floor(t.maxHP()/6),o.push("Wildfire damage"));t.hasAbility("Magic Guard")||t.hasType("Water")||!r.defenderSide.cannonade&&!i.named("G-Max Cannonade")||(s-=Math.floor(t.maxHP()/6),o.push("Cannonade damage"));t.hasAbility("Magic Guard")||t.hasType("Rock")||!r.defenderSide.volcalith&&!i.named("G-Max Volcalith")||(s-=Math.floor(t.maxHP()/6),o.push("Volcalith damage"));return{damage:s,texts:o}}(e,a,t,i,r),c=t.hasStatus("tox")&&!t.hasAbility("Magic Guard")?t.toxicCounter:0,d="";i.hits>1&&(d="approx. ",s=function(e,a,t,i){void 0===i&&(i=!0);if(1===a.length)return[a[0]*t];if(1===e.num){for(var r=[],s=0;s<a.length;s++)r[s]=a[s]*t;return r}if(16===a.length)switch(t){case 2:return[2*a[0],a[2]+a[3],a[4]+a[4],a[4]+a[5],a[5]+a[6],a[6]+a[6],a[6]+a[7],a[7]+a[7],a[8]+a[8],a[8]+a[9],a[9]+a[9],a[9]+a[10],a[10]+a[11],a[11]+a[11],a[12]+a[13],2*a[15]];case 3:return[3*a[0],a[3]+a[3]+a[4],a[4]+a[4]+a[5],a[5]+a[5]+a[6],a[5]+a[6]+a[6],a[6]+a[6]+a[7],a[6]+a[7]+a[7],a[7]+a[7]+a[8],a[7]+a[8]+a[8],a[8]+a[8]+a[9],a[8]+a[9]+a[9],a[9]+a[9]+a[10],a[9]+a[10]+a[10],a[10]+a[11]+a[11],a[11]+a[12]+a[12],3*a[15]];case 4:return[4*a[0],4*a[4],a[4]+a[5]+a[5]+a[5],a[5]+a[5]+a[6]+a[6],4*a[6],a[6]+a[6]+a[7]+a[7],4*a[7],a[7]+a[7]+a[7]+a[8],a[7]+a[8]+a[8]+a[8],4*a[8],a[8]+a[8]+a[9]+a[9],4*a[9],a[9]+a[9]+a[10]+a[10],a[10]+a[10]+a[10]+a[11],4*a[11],4*a[15]];case 5:return[5*a[0],a[4]+a[4]+a[4]+a[5]+a[5],a[5]+a[5]+a[5]+a[5]+a[6],a[5]+a[6]+a[6]+a[6]+a[6],a[6]+a[6]+a[6]+a[6]+a[7],a[6]+a[6]+a[7]+a[7]+a[7],5*a[7],a[7]+a[7]+a[7]+a[8]+a[8],a[7]+a[7]+a[8]+a[8]+a[8],5*a[8],a[8]+a[8]+a[8]+a[9]+a[9],a[8]+a[9]+a[9]+a[9]+a[9],a[9]+a[9]+a[9]+a[9]+a[10],a[9]+a[10]+a[10]+a[10]+a[10],a[10]+a[10]+a[11]+a[11]+a[11],5*a[15]];case 10:return[10*a[0],10*a[4],3*a[4]+7*a[5],5*a[5]+5*a[6],10*a[6],5*a[6]+5*a[7],10*a[7],7*a[7]+3*a[8],3*a[7]+7*a[8],10*a[8],5*a[8]+5*a[9],4*a[9],5*a[9]+5*a[10],7*a[10]+3*a[11],10*a[11],10*a[15]];default:return(0,n.error)(i,"Unexpected # of hits: ".concat(t)),a}else{if(39!==a.length){if(256===a.length){t>1&&(0,n.error)(i,"Unexpected # of hits for Parental Bond: ".concat(t));for(r=[],s=0;s<16;s++){for(var o=0,l=0;l<16;l++)o+=a[s+l];r[s]=Math.round(o/16)}return r}return(0,n.error)(i,"Unexpected # of possible damage values: ".concat(a.length)),a}switch(t){case 2:return[2*a[0],2*a[7],2*a[10],2*a[12],2*a[14],a[15]+a[16],2*a[17],a[18]+a[19],a[19]+a[20],2*a[21],a[22]+a[23],2*a[24],2*a[26],2*a[28],2*a[31],2*a[38]];case 3:return[3*a[0],3*a[9],3*a[12],3*a[13],3*a[15],3*a[16],3*a[17],3*a[18],3*a[20],3*a[21],3*a[22],3*a[23],3*a[25],3*a[26],3*a[29],3*a[38]];case 4:return[4*a[0],2*a[10]+2*a[11],4*a[13],4*a[14],2*a[15]+2*a[16],2*a[16]+2*a[17],2*a[17]+2*a[18],2*a[18]+2*a[19],2*a[19]+2*a[20],2*a[20]+2*a[21],2*a[21]+2*a[22],2*a[22]+2*a[23],4*a[24],4*a[25],2*a[27]+2*a[28],4*a[38]];case 5:return[5*a[0],5*a[11],5*a[13],5*a[15],5*a[16],5*a[17],5*a[18],5*a[19],5*a[19],5*a[20],5*a[21],5*a[22],5*a[23],5*a[25],5*a[27],5*a[38]];case 10:return[10*a[0],10*a[11],10*a[13],10*a[15],10*a[16],10*a[17],10*a[18],10*a[19],10*a[19],10*a[20],10*a[21],10*a[22],10*a[23],10*a[25],10*a[27],10*a[38]];default:return(0,n.error)(i,"Unexpected # of hits: ".concat(t)),a}}}(e,s,i.hits,o));var u,y=l.texts.length>0?" after "+ne(l.texts):"",m=l.texts.length>0||h.texts.length>0?" after "+ne(l.texts.concat(h.texts)):"";if(!(1===i.timesUsed&&1===i.timesUsedWithMetronome||i.isZ))return 1===(u=se(s,t.maxHP()-l.damage,h.damage,i.hits||1,i.timesUsed||1,t.maxHP(),c))?{chance:u,n:i.timesUsed,text:"".concat(d||"guaranteed ","KO in ").concat(i.timesUsed," turns").concat(m)}:u>0?{chance:u,n:i.timesUsed,text:d+Math.round(1e3*u)/10+"% chance to ".concat(i.timesUsed,"HKO").concat(m)}:oe(s[0],h.damage,i.hits,i.timesUsed,c,t.maxHP())>=t.curHP()-l.damage?{chance:1,n:i.timesUsed,text:"".concat(d||"guaranteed ","KO in ").concat(i.timesUsed," turns").concat(m)}:oe(s[s.length-1],h.damage,i.hits,i.timesUsed,c,t.maxHP())>=t.curHP()-l.damage?{n:i.timesUsed,text:d+"possible KO in ".concat(i.timesUsed," turns").concat(m)}:{n:i.timesUsed,text:d+"not a KO"};if(1===(u=se(s,t.curHP()-l.damage,0,1,1,t.maxHP(),c)))return{chance:u,n:1,text:"guaranteed OHKO".concat(y)};if(u>0)return{chance:u,n:1,text:d+Math.round(1e3*u)/10+"% chance to OHKO".concat(y)};256===s.length&&(d="approx. ");for(var p=2;p<=4;p++){var f=se(s,t.curHP()-l.damage,h.damage,p,1,t.maxHP(),c);if(1===f)return{chance:f,n:p,text:"".concat(d||"guaranteed ").concat(p,"HKO").concat(m)};if(f>0)return{chance:f,n:p,text:d+Math.round(1e3*f)/10+"% chance to ".concat(p,"HKO").concat(m)}}for(p=5;p<=9;p++){if(oe(s[0],h.damage,p,1,c,t.maxHP())>=t.curHP()-l.damage)return{chance:1,n:p,text:"".concat(d||"guaranteed ").concat(p,"HKO").concat(m)};if(oe(s[s.length-1],h.damage,p,1,c,t.maxHP())>=t.curHP()-l.damage)return{n:p,text:d+"possible ".concat(p,"HKO").concat(m)}}return{chance:0,n:0,text:""}}e.display=function(e,a,t,i,r,s,o,n,l){void 0===n&&(n="%"),void 0===l&&(l=!0);var h=M((0,$.damageRange)(s),2),c=h[0],d=h[1],u=("number"==typeof c?c:c[0]+c[1])*i.hits,y=("number"==typeof d?d:d[0]+d[1])*i.hits,m=he(n,u,t.maxHP()),p=he(n,y,t.maxHP()),f=function(e,a,t){var i=M(function(e,a){if(e.level!==a.level)return[100===e.level?"":"Lvl ".concat(e.level),100===a.level?"":"Lvl ".concat(a.level)];var t=[100,50,5].includes(e.level),i=t?"":"Lvl ".concat(e.level);return[i,i]}(a,t),2),r=i[0],s=i[1],o="";e.attackBoost&&(e.attackBoost>0&&(o+="+"),o+=e.attackBoost+" ");o=le(o,r),o=le(o,e.attackEVs),o=le(o,e.attackerItem),o=le(o,e.attackerAbility),o=le(o,e.rivalry),e.isBurned&&(o+="burned ");e.alliesFainted&&(o+=Math.min(5,e.alliesFainted)+" ".concat(1===e.alliesFainted?"ally":"allies"," fainted "));e.attackerTera&&(o+="Tera ".concat(e.attackerTera," "));e.isBeadsOfRuin&&(o+="Beads of Ruin ");e.isSwordOfRuin&&(o+="Sword of Ruin ");o+=e.attackerName+" ",e.isHelpingHand&&(o+="Helping Hand ");e.isFlowerGiftAttacker&&(o+=" with an ally's Flower Gift ");e.isBattery&&(o+=" Battery boosted ");e.isPowerSpot&&(o+=" Power Spot boosted ");e.isSwitching&&(o+=" switching boosted ");o+=e.moveName+" ",e.moveBP&&e.moveType?o+="("+e.moveBP+" BP "+e.moveType+") ":e.moveBP?o+="("+e.moveBP+" BP) ":e.moveType&&(o+="("+e.moveType+") ");e.hits&&(o+="("+e.hits+" hits) ");o=le(o,e.moveTurns),o+="vs. ",e.defenseBoost&&(e.defenseBoost>0&&(o+="+"),o+=e.defenseBoost+" ");o=le(o,s),o=le(o,e.HPEVs),e.defenseEVs&&(o+="/ "+e.defenseEVs+" ");o=le(o,e.defenderItem),o=le(o,e.defenderAbility),e.isTabletsOfRuin&&(o+="Tablets of Ruin ");e.isVesselOfRuin&&(o+="Vessel of Ruin ");e.isProtected&&(o+="protected ");e.isDefenderDynamaxed&&(o+="Dynamax ");e.defenderTera&&(o+="Tera ".concat(e.defenderTera," "));o+=e.defenderName,e.weather&&e.terrain||(e.weather?o+=" in "+e.weather:e.terrain&&(o+=" in "+e.terrain+" Terrain"));e.isReflect?o+=" through Reflect":e.isLightScreen&&(o+=" through Light Screen");e.isFlowerGiftDefender&&(o+=" with an ally's Flower Gift");e.isFriendGuard&&(o+=" with an ally's Friend Guard");e.isAuroraVeil&&(o+=" with an ally's Aurora Veil");e.isCritical&&(o+=" on a critical hit");e.isWonderRoom&&(o+=" in Wonder Room");return o}(o,a,t),b="".concat(u,"-").concat(y," (").concat(m," - ").concat(p).concat(n,")");if("Status"===i.category&&!i.named("Nature Power"))return"".concat(f,": ").concat(b);var g=ie(e,a,t,i,r,s,l).text;return g?"".concat(f,": ").concat(b," -- ").concat(g):"".concat(f,": ").concat(b)},e.displayMove=function(e,a,t,i,r,s){void 0===s&&(s="%");var o=M((0,$.damageRange)(r),2),n=o[0],l=o[1],h=("number"==typeof n?n:n[0]+n[1])*i.hits,c=("number"==typeof l?l:l[0]+l[1])*i.hits,d=he(s,h,t.maxHP()),u=he(s,c,t.maxHP()),y=ae(e,a,t,i,r,s).text,m=te(e,a,t,i,r,s).text;return"".concat(d," - ").concat(u).concat(s).concat(y&&" (".concat(y,")")).concat(m&&" (".concat(m,")"))},e.getRecovery=ae,e.getRecoil=te,e.getKOChance=ie;var re=["Bind","Clamp","Fire Spin","Infestation","Magma Storm","Sand Tomb","Thunder Cage","Whirlpool","Wrap","G-Max Sandblast","G-Max Centiferno"];function se(e,a,t,i,r,s,o){var n=e.length;if(1===i)for(var l=0;l<n;l++){if(e[n-1]<a)return 0;if(e[l]>=a)return(n-l)/n}var h=0;o>0&&(h=Math.floor(o*s/16),o++);var c=0,d=0;for(l=0;l<n;l++){var u=void 0;if(1===(u=0===l||e[l]!==e[l-1]?se(e,a-e[l]+t-h,t,i-1,r,s,o):d)){c+=n-l;break}c+=u,d=u}return c/n}function oe(e,a,t,i,r,s){var o=0;if(r>0)for(var n=0;n<t-1;n++)o+=Math.floor((r+n)*s/16);return t>1&&1===i?e*t-a*(t-1)+o:e-a*(t-1)+o}function ne(e){if(0===e.length)return"";if(1===e.length)return e[0];if(2===e.length)return e[0]+" and "+e[1];for(var a="",t=0;t<e.length-1;t++)a+=e[t]+", ";return a+"and "+e[e.length-1]}function le(e,a){return a?"".concat(e).concat(a," "):e}function he(e,a,t,i){return void 0===i&&(i=1),"%"===e?Math.floor(a*(1e3/i)/t)/10:Math.floor(a*(48/i)/t)}var ce=e,de=e;function ue(e,a,t,i,r,s,o){var n,l,h=a.stats.spe>t.stats.spe?"first":"last";switch(i.name){case"Payback":l=i.bp*("last"===h?2:1),o.moveBP=l;break;case"Bolt Beak":case"Fishious Rend":l=i.bp*("last"!==h?2:1),o.moveBP=l;break;case"Pursuit":var c="out"===r.defenderSide.isSwitching;l=i.bp*(c?2:1),c&&(o.isSwitching="out"),o.moveBP=l;break;case"Electro Ball":var d=Math.floor(a.stats.spe/t.stats.spe);l=d>=4?150:d>=3?120:d>=2?80:d>=1?60:40,0===t.stats.spe&&(l=40),o.moveBP=l;break;case"Gyro Ball":l=Math.min(150,Math.floor(25*t.stats.spe/a.stats.spe)+1),0===a.stats.spe&&(l=1),o.moveBP=l;break;case"Punishment":l=Math.min(200,60+20*(0,ee.countBoosts)(e,t.boosts)),o.moveBP=l;break;case"Low Kick":case"Grass Knot":var u=t.weightkg*(0,ee.getWeightFactor)(t);l=u>=200?120:u>=100?100:u>=50?80:u>=25?60:u>=10?40:20,o.moveBP=l;break;case"Hex":case"Infernal Parade":l=i.bp*(t.status||t.hasAbility("Comatose")?2:1),o.moveBP=l;break;case"Barb Barrage":l=i.bp*(t.hasStatus("psn","tox")?2:1),o.moveBP=l;break;case"Heavy Slam":case"Heat Crash":var y=a.weightkg*(0,ee.getWeightFactor)(a)/(t.weightkg*(0,ee.getWeightFactor)(t));l=y>=5?120:y>=4?100:y>=3?80:y>=2?60:40,o.moveBP=l;break;case"Stored Power":case"Power Trip":l=20+20*(0,ee.countBoosts)(e,a.boosts),o.moveBP=l;break;case"Acrobatics":l=i.bp*(a.hasItem("Flying Gem")||!a.item?2:1),o.moveBP=l;break;case"Assurance":l=i.bp*(t.hasAbility("Parental Bond (Child)")?2:1);break;case"Wake-Up Slap":l=i.bp*(t.hasStatus("slp")||t.hasAbility("Comatose")?2:1),o.moveBP=l;break;case"Smelling Salts":l=i.bp*(t.hasStatus("par")?2:1),o.moveBP=l;break;case"Weather Ball":l=i.bp*(r.weather&&!r.hasWeather("Strong Winds")?2:1),r.hasWeather("Sun","Harsh Sunshine","Rain","Heavy Rain")&&a.hasItem("Utility Umbrella")&&(l=i.bp),o.moveBP=l;break;case"Terrain Pulse":l=i.bp*((0,ee.isGrounded)(a,r)&&r.terrain?2:1),o.moveBP=l;break;case"Rising Voltage":l=i.bp*((0,ee.isGrounded)(t,r)&&r.hasTerrain("Electric")?2:1),o.moveBP=l;break;case"Fling":l=(0,de.getFlingPower)(a.item),o.moveBP=l,o.attackerItem=a.item;break;case"Dragon Energy":case"Eruption":case"Water Spout":l=Math.max(1,Math.floor(150*a.curHP()/a.maxHP())),o.moveBP=l;break;case"Flail":case"Reversal":var m=Math.floor(48*a.curHP()/a.maxHP());l=m<=1?200:m<=4?150:m<=9?100:m<=16?80:m<=32?40:20,o.moveBP=l;break;case"Natural Gift":if(null===(n=a.item)||void 0===n?void 0:n.includes("Berry"))l=(0,de.getNaturalGift)(e,a.item).p,o.attackerItem=a.item,o.moveBP=i.bp;else l=i.bp;break;case"Nature Power":switch(i.category="Special",i.secondaries=!0,r.terrain){case"Electric":l=90,o.moveName="Thunderbolt";break;case"Grassy":l=90,o.moveName="Energy Ball";break;case"Misty":l=95,o.moveName="Moonblast";break;case"Psychic":l=90,o.moveName="Psychic";break;default:l=80,o.moveName="Tri Attack"}break;case"Water Shuriken":l=a.named("Greninja-Ash")&&a.hasAbility("Battle Bond")?20:15,o.moveBP=l;break;case"Triple Axel":l=2===i.hits?30:3===i.hits?40:20,o.moveBP=l;break;case"Triple Kick":l=2===i.hits?15:3===i.hits?30:10,o.moveBP=l;break;case"Crush Grip":case"Wring Out":l=100*Math.floor(4096*t.curHP()/t.maxHP()),l=Math.floor(Math.floor((120*l+2048-1)/4096)/100)||1,o.moveBP=l;break;default:l=i.bp}if(0===l)return 0;i.named("Breakneck Blitz","Bloom Doom","Inferno Overdrive","Hydro Vortex","Gigavolt Havoc","Subzero Slammer","Supersonic Skystrike","Savage Spin-Out","Acid Downpour","Tectonic Rage","Continental Crush","All-Out Pummeling","Shattered Psyche","Never-Ending Nightmare","Devastating Drake","Black Hole Eclipse","Corkscrew Crash","Twinkle Tackle")&&(o.moveBP=i.bp);var p=ye(e,a,t,i,r,o,l,s,h);return l=(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(l*(0,ee.chainMods)(p,41,2097152)/4096))),a.teraType&&i.type===a.teraType&&a.hasType(a.teraType)&&1===i.hits&&i.priority<=0&&i.bp>0&&!i.named("Dragon Energy","Eruption","Water Spout")&&l<60&&e.num>=9&&(l=60,o.moveBP=60),l}function ye(e,a,t,i,r,s,o,l,h){var c=[],d=!t.item||t.named("Dialga-Origin")&&t.hasItem("Adamant Crystal")||t.named("Palkia-Origin")&&t.hasItem("Lustrous Globe")||t.name.includes("Giratina-Origin")&&t.item.includes("Griseous")||t.name.includes("Arceus")&&t.item.includes("Plate")||t.name.includes("Genesect")&&t.item.includes("Drive")||t.named("Groudon","Groudon-Primal")&&t.hasItem("Red Orb")||t.named("Kyogre","Kyogre-Primal")&&t.hasItem("Blue Orb")||t.name.includes("Silvally")&&t.item.includes("Memory")||t.item.includes(" Z")||t.named("Zacian")&&t.hasItem("Rusted Sword")||t.named("Zamazenta")&&t.hasItem("Rusted Shield")||t.named("Venomicon-Epilogue")&&t.hasItem("Vile Vial");if(!d&&t.item){var u=e.items.get((0,n.toID)(t.item));d=!!u.megaEvolves&&t.name.includes(u.megaEvolves)}if(i.named("Facade")&&a.hasStatus("brn","par","psn","tox")||i.named("Brine")&&t.curHP()<=t.maxHP()/2||i.named("Venoshock")&&t.hasStatus("psn","tox")||i.named("Lash Out")&&(0,ee.countBoosts)(e,a.boosts)<0)c.push(8192),s.moveBP=2*o;else if(i.named("Expanding Force")&&(0,ee.isGrounded)(a,r)&&r.hasTerrain("Psychic"))i.target="allAdjacentFoes",c.push(6144),s.moveBP=1.5*o;else if(i.named("Knock Off")&&!d||i.named("Misty Explosion")&&(0,ee.isGrounded)(a,r)&&r.hasTerrain("Misty")||i.named("Grav Apple")&&r.isGravity)c.push(6144),s.moveBP=1.5*o;else if(i.named("Solar Beam","Solar Blade")&&r.hasWeather("Rain","Heavy Rain","Sand","Hail","Snow"))c.push(2048),s.moveBP=o/2,s.weather=r.weather;else if(i.named("Collision Course","Electro Drift")){var y=a.hasAbility("Scrappy")||r.defenderSide.isForesight,m=t.hasItem("Ring Target")&&!t.hasAbility("Klutz");(0,ee.getMoveEffectiveness)(e,i,t.types[0],y,r.isGravity,m)*(t.types[1]?(0,ee.getMoveEffectiveness)(e,i,t.types[0],y,r.isGravity,m):1)>=2&&(c.push(5461),s.moveBP=o*(5461/4096))}r.attackerSide.isHelpingHand&&(c.push(6144),s.isHelpingHand=!0);(0,ee.isGrounded)(a,r)&&(r.hasTerrain("Electric")&&i.hasType("Electric")||r.hasTerrain("Grassy")&&i.hasType("Grass")||r.hasTerrain("Psychic")&&i.hasType("Psychic"))&&(c.push(6144),s.terrain=r.terrain),(0,ee.isGrounded)(t,r)&&(r.hasTerrain("Misty")&&i.hasType("Dragon")||r.hasTerrain("Grassy")&&i.named("Bulldoze","Earthquake"))&&(c.push(2048),s.terrain=r.terrain),(a.hasAbility("Technician")&&o<=60||a.hasAbility("Flare Boost")&&a.hasStatus("brn")&&"Special"===i.category||a.hasAbility("Toxic Boost")&&a.hasStatus("psn","tox")&&"Physical"===i.category||a.hasAbility("Mega Launcher")&&i.flags.pulse||a.hasAbility("Strong Jaw")&&i.flags.bite||a.hasAbility("Steely Spirit")&&i.hasType("Steel")||a.hasAbility("Sharpness")&&i.flags.slicing)&&(c.push(6144),s.attackerAbility=a.ability);var p="".concat(i.type," Aura"),f=a.hasAbility(p),b=t.hasAbility(p),g=a.hasAbility("Aura Break")||t.hasAbility("Aura Break"),S=r.isAuraBreak,v=r.isFairyAura&&"Fairy"===i.type,k=r.isDarkAura&&"Dark"===i.type;if((f||b||v||k)&&(S||g?(c.push(3072),s.attackerAbility=a.ability,s.defenderAbility=t.ability):(c.push(5448),f&&(s.attackerAbility=a.ability),b&&(s.defenderAbility=t.ability))),(a.hasAbility("Sheer Force")&&(i.secondaries||i.named("Jet Punch","Order Up"))&&!i.isMax||a.hasAbility("Sand Force")&&r.hasWeather("Sand")&&i.hasType("Rock","Ground","Steel")||a.hasAbility("Analytic")&&("first"!==h||"out"===r.defenderSide.isSwitching)||a.hasAbility("Tough Claws")&&i.flags.contact||a.hasAbility("Punk Rock")&&i.flags.sound)&&(c.push(5325),s.attackerAbility=a.ability),r.attackerSide.isBattery&&"Special"===i.category&&(c.push(5325),s.isBattery=!0),r.attackerSide.isPowerSpot&&(c.push(5325),s.isPowerSpot=!0),a.hasAbility("Rivalry")&&![a.gender,t.gender].includes("N")&&(a.gender===t.gender?(c.push(5120),s.rivalry="buffed"):(c.push(3072),s.rivalry="nerfed"),s.attackerAbility=a.ability),!i.isMax&&l&&c.push(4915),(a.hasAbility("Reckless")&&(i.recoil||i.hasCrashDamage)||a.hasAbility("Iron Fist")&&i.flags.punch)&&(c.push(4915),s.attackerAbility=a.ability),a.hasItem("Punching Glove")&&i.flags.punch&&(c.push(4506),s.attackerItem=a.item),t.hasAbility("Heatproof")&&i.hasType("Fire")?(c.push(2048),s.defenderAbility=t.ability):t.hasAbility("Dry Skin")&&i.hasType("Fire")&&(c.push(5120),s.defenderAbility=t.ability),a.hasAbility("Supreme Overlord")&&a.alliesFainted){c.push([4096,4506,4915,5325,5734,6144][Math.min(5,a.alliesFainted)]),s.attackerAbility=a.ability,s.alliesFainted=a.alliesFainted}return a.hasItem("".concat(i.type," Gem"))?(c.push(6144),s.attackerItem=a.item):a.hasItem("Adamant Crystal")&&a.named("Dialga-Origin")||a.hasItem("Adamant Orb")&&a.named("Dialga")&&i.hasType("Steel","Dragon")||a.hasItem("Lustrous Orb")&&a.named("Palkia")||a.hasItem("Lustrous Globe")&&a.named("Palkia-Origin")&&i.hasType("Water","Dragon")||(a.hasItem("Griseous Orb")||a.hasItem("Griseous Core"))&&(a.named("Giratina-Origin")||a.named("Giratina"))&&i.hasType("Ghost","Dragon")||a.hasItem("Vile Vial")&&a.named("Venomicon-Epilogue")&&i.hasType("Poison","Flying")||a.item&&i.hasType((0,de.getItemBoostType)(a.item))?(c.push(4915),s.attackerItem=a.item):(a.hasItem("Muscle Band")&&"Physical"===i.category||a.hasItem("Wise Glasses")&&"Special"===i.category)&&(c.push(4505),s.attackerItem=a.item),c}function me(e,a,t,i,r,s,o){var n;void 0===o&&(o=!1);var l=i.named("Foul Play")?t:a;(i.named("Photon Geyser","Light That Burns The Sky")||i.named("Tera Blast")&&l.teraType)&&(i.category=l.stats.atk>l.stats.spa?"Physical":"Special");var h=i.named("Shell Side Arm")&&"Physical"===(0,ee.getShellSideArmCategory)(a,t)?"atk":i.named("Body Press")?"def":"Special"===i.category?"spa":"atk";s.attackEVs=i.named("Foul Play")?(0,ee.getEVDescriptionText)(e,t,h,t.nature):(0,ee.getEVDescriptionText)(e,a,h,a.nature),0===l.boosts[h]||o&&l.boosts[h]<0?n=l.rawStats[h]:t.hasAbility("Unaware")?(n=l.rawStats[h],s.defenderAbility=t.ability):(n=l.stats[h],s.attackBoost=l.boosts[h]),a.hasAbility("Hustle")&&"Physical"===i.category&&(n=(0,ee.pokeRound)(3*n/2),s.attackerAbility=a.ability);var c=pe(e,a,t,i,r,s);return n=(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(n*(0,ee.chainMods)(c,410,131072)/4096)))}function pe(e,a,t,i,r,s){var o=[];a.hasAbility("Slow Start")&&a.abilityOn&&("Physical"===i.category||"Special"===i.category&&i.isZ)||a.hasAbility("Defeatist")&&a.curHP()<=a.maxHP()/2?(o.push(2048),s.attackerAbility=a.ability):a.hasAbility("Solar Power")&&r.hasWeather("Sun","Harsh Sunshine")&&"Special"===i.category||a.named("Cherrim")&&a.hasAbility("Flower Gift")&&r.hasWeather("Sun","Harsh Sunshine")&&"Physical"===i.category||a.hasAbility("Gorilla Tactics")&&"Physical"===i.category&&!a.isDynamaxed?(o.push(6144),s.attackerAbility=a.ability,s.weather=r.weather):r.attackerSide.isFlowerGift&&r.hasWeather("Sun","Harsh Sunshine")&&"Physical"===i.category?(o.push(6144),s.weather=r.weather,s.isFlowerGiftAttacker=!0):a.hasAbility("Guts")&&a.status&&"Physical"===i.category||a.curHP()<=a.maxHP()/3&&(a.hasAbility("Overgrow")&&i.hasType("Grass")||a.hasAbility("Blaze")&&i.hasType("Fire")||a.hasAbility("Torrent")&&i.hasType("Water")||a.hasAbility("Swarm")&&i.hasType("Bug"))||"Special"===i.category&&a.abilityOn&&a.hasAbility("Plus","Minus")?(o.push(6144),s.attackerAbility=a.ability):a.hasAbility("Flash Fire")&&a.abilityOn&&i.hasType("Fire")?(o.push(6144),s.attackerAbility="Flash Fire"):a.hasAbility("Steelworker")&&i.hasType("Steel")||a.hasAbility("Dragon's Maw")&&i.hasType("Dragon")||a.hasAbility("Transistor")&&i.hasType("Electric")||a.hasAbility("Rocky Payload")&&i.hasType("Rock")?(o.push(6144),s.attackerAbility=a.ability):(a.hasAbility("Stakeout")&&a.abilityOn||a.hasAbility("Water Bubble")&&i.hasType("Water")||a.hasAbility("Huge Power","Pure Power")&&"Physical"===i.category)&&(o.push(8192),s.attackerAbility=a.ability),(t.hasAbility("Thick Fat")&&i.hasType("Fire","Ice")||t.hasAbility("Water Bubble")&&i.hasType("Fire")||t.hasAbility("Purifying Salt")&&i.hasType("Ghost"))&&(o.push(2048),s.defenderAbility=t.ability);var n=t.hasAbility("Tablets of Ruin")||r.isTabletsOfRuin,l=t.hasAbility("Vessel of Ruin")||r.isVesselOfRuin;return(n&&"Physical"===i.category||l&&"Special"===i.category)&&(t.hasAbility("Tablets of Ruin")||t.hasAbility("Vessel of Ruin")?s.defenderAbility=t.ability:s["Special"===i.category?"isVesselOfRuin":"isTabletsOfRuin"]=!0,o.push(3072)),(a.hasAbility("Protosynthesis")&&(r.hasWeather("Sun")||a.hasItem("Booster Energy"))||a.hasAbility("Quark Drive")&&(r.hasTerrain("Electric")||a.hasItem("Booster Energy")))&&("Physical"===i.category&&"atk"===(0,ee.getMostProficientStat)(a)||"Special"===i.category&&"spa"===(0,ee.getMostProficientStat)(a))&&(o.push(5325),s.attackerAbility=a.ability),(a.hasAbility("Hadron Engine")&&"Special"===i.category&&r.hasTerrain("Electric")&&(0,ee.isGrounded)(a,r)||a.hasAbility("Orichalcum Pulse")&&"Physical"===i.category&&r.hasWeather("Sun","Harsh Sunshine")&&!a.hasItem("Utility Umbrella"))&&(o.push(5461),s.attackerAbility=a.ability),a.hasItem("Thick Club")&&a.named("Cubone","Marowak","Marowak-Alola","Marowak-Alola-Totem")&&"Physical"===i.category||a.hasItem("Deep Sea Tooth")&&a.named("Clamperl")&&"Special"===i.category||a.hasItem("Light Ball")&&a.name.includes("Pikachu")&&!i.isZ?(o.push(8192),s.attackerItem=a.item):i.isZ||i.isMax||!(a.hasItem("Choice Band")&&"Physical"===i.category||a.hasItem("Choice Specs")&&"Special"===i.category||a.hasItem("Soul Dew")&&"Special"===i.category&&a.named("Latios","Latias","Latios-Mega","Latias-Mega"))||(o.push(6144),s.attackerItem=a.item),o}function fe(e,a,t,i,r,s,o){var n;void 0===o&&(o=!1);var l="def"===i.overrideDefensiveStat||"Physical"===i.category||i.named("Shell Side Arm")&&"Physical"===(0,ee.getShellSideArmCategory)(a,t),h=l?"def":"spd";s.defenseEVs=(0,ee.getEVDescriptionText)(e,t,h,t.nature),0===t.boosts[h]||o&&t.boosts[h]>0||i.ignoreDefensive?n=t.rawStats[h]:a.hasAbility("Unaware")?(n=t.rawStats[h],s.attackerAbility=a.ability):(n=t.stats[h],s.defenseBoost=t.boosts[h]),r.hasWeather("Sand")&&t.hasType("Rock")&&!l&&(n=(0,ee.pokeRound)(3*n/2),s.weather=r.weather),r.hasWeather("Snow")&&t.hasType("Ice")&&l&&(n=(0,ee.pokeRound)(3*n/2),s.weather=r.weather);var c=be(e,a,t,i,r,s,o,l);return(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(n*(0,ee.chainMods)(c,410,131072)/4096)))}function be(e,a,t,i,r,s,o,l){var h;void 0===o&&(o=!1),void 0===l&&(l=!1);var c=[];t.hasAbility("Marvel Scale")&&t.status&&l?(c.push(6144),s.defenderAbility=t.ability):t.named("Cherrim")&&t.hasAbility("Flower Gift")&&r.hasWeather("Sun","Harsh Sunshine")&&!l?(c.push(6144),s.defenderAbility=t.ability,s.weather=r.weather):r.defenderSide.isFlowerGift&&r.hasWeather("Sun","Harsh Sunshine")&&!l?(c.push(6144),s.weather=r.weather,s.isFlowerGiftDefender=!0):t.hasAbility("Grass Pelt")&&r.hasTerrain("Grassy")&&l?(c.push(6144),s.defenderAbility=t.ability):t.hasAbility("Fur Coat")&&l&&(c.push(8192),s.defenderAbility=t.ability);var d=a.hasAbility("Sword of Ruin")||r.isSwordOfRuin,u=a.hasAbility("Beads of Ruin")||r.isBeadsOfRuin;return(d&&l||u&&!l)&&(a.hasAbility("Sword of Ruin")||a.hasAbility("Beads of Ruin")?s.attackerAbility=a.ability:s[l?"isSwordOfRuin":"isBeadsOfRuin"]=!0,c.push(3072)),i.named("Explosion","Self-Destruct","Misty Explosion")&&c.push(2048),(t.hasAbility("Protosynthesis")&&(r.hasWeather("Sun")||a.hasItem("Booster Energy"))||t.hasAbility("Quark Drive")&&(r.hasTerrain("Electric")||a.hasItem("Booster Energy")))&&(l&&"def"===(0,ee.getMostProficientStat)(t)||!l&&"spd"===(0,ee.getMostProficientStat)(t))&&(s.defenderAbility=t.ability,c.push(5324)),t.hasItem("Eviolite")&&(null===(h=e.species.get((0,n.toID)(t.name)))||void 0===h?void 0:h.nfe)||!l&&t.hasItem("Assault Vest")||t.hasItem("Soul Dew")&&"Special"===i.category&&t.named("Latios","Latias","Latios-Mega","Latias-Mega")?(c.push(6144),s.defenderItem=t.item):(t.hasItem("Metal Powder")&&t.named("Ditto")&&l||t.hasItem("Deep Sea Scale")&&t.named("Clamperl")&&!l)&&(c.push(8192),s.defenderItem=t.item),c}function ge(e,a,t,i,r,s,o,n){void 0===o&&(o=!1);var l=[];if(!r.defenderSide.isReflect||"Physical"!==i.category||o||r.defenderSide.isAuroraVeil?!r.defenderSide.isLightScreen||"Special"!==i.category||o||r.defenderSide.isAuroraVeil||(l.push("Singles"!==r.gameType?2732:2048),s.isLightScreen=!0):(l.push("Singles"!==r.gameType?2732:2048),s.isReflect=!0),r.defenderSide.isAuroraVeil&&!o&&(l.push("Singles"!==r.gameType?2732:2048),s.isAuroraVeil=!0),a.hasAbility("Neuroforce")&&n>1?(l.push(5120),s.attackerAbility=a.ability):a.hasAbility("Sniper")&&o?(l.push(6144),s.attackerAbility=a.ability):a.hasAbility("Tinted Lens")&&n<1&&(l.push(8192),s.attackerAbility=a.ability),t.isDynamaxed&&i.named("Dynamax Cannon","Behemoth Blade","Behemoth Bash")&&l.push(8192),!t.hasAbility("Multiscale","Shadow Shield")||t.curHP()!==t.maxHP()||r.defenderSide.isSR||r.defenderSide.spikes&&!t.hasType("Flying")||a.hasAbility("Parental Bond (Child)")||(l.push(2048),s.defenderAbility=t.ability),(t.hasAbility("Fluffy")&&i.flags.contact&&!a.hasAbility("Long Reach")||t.hasAbility("Punk Rock")&&i.flags.sound||t.hasAbility("Ice Scales")&&"Special"===i.category)&&(l.push(2048),s.defenderAbility=t.ability),t.hasAbility("Solid Rock","Filter","Prism Armor")&&n>1&&(l.push(3072),s.defenderAbility=t.ability),r.defenderSide.isFriendGuard&&(l.push(3072),s.isFriendGuard=!0),t.hasAbility("Fluffy")&&i.hasType("Fire")&&(l.push(8192),s.defenderAbility=t.ability),a.hasItem("Expert Belt")&&n>1&&!i.isZ)l.push(4915),s.attackerItem=a.item;else if(a.hasItem("Life Orb"))l.push(5324),s.attackerItem=a.item;else if(a.hasItem("Metronome")&&i.timesUsedWithMetronome>=1){var h=Math.floor(i.timesUsedWithMetronome);h<=4?l.push(4096+819*h):l.push(8192),s.attackerItem=a.item}return i.hasType((0,de.getBerryResistType)(t.item))&&(n>1||i.hasType("Normal"))&&!a.hasAbility("Unnerve","As One (Glastrier)","As One (Spectrier)")&&(t.hasAbility("Ripen")?l.push(1024):l.push(2048),s.defenderItem=t.item),l}function Se(e,a){var t=Math.min(6,Math.max(-6,2*a));return t>0?Math.floor(e*(2+t)/2):t<0?Math.floor(2*e/(2-t)):e}e.calculateSMSSSV=function e(a,t,i,r,s){(0,ee.checkAirLock)(t,s),(0,ee.checkAirLock)(i,s),(0,ee.checkForecast)(t,s.weather),(0,ee.checkForecast)(i,s.weather),(0,ee.checkItem)(t,s.isMagicRoom),(0,ee.checkItem)(i,s.isMagicRoom),(0,ee.checkWonderRoom)(t,s.isWonderRoom),(0,ee.checkWonderRoom)(i,s.isWonderRoom),(0,ee.checkSeedBoost)(t,s),(0,ee.checkSeedBoost)(i,s),(0,ee.checkDauntlessShield)(t,a),(0,ee.checkDauntlessShield)(i,a),(0,ee.computeFinalStats)(a,t,i,s,"def","spd","spe"),(0,ee.checkIntimidate)(a,t,i),(0,ee.checkIntimidate)(a,i,t),(0,ee.checkDownload)(t,i,s.isWonderRoom),(0,ee.checkDownload)(i,t,s.isWonderRoom),(0,ee.checkIntrepidSword)(t,a),(0,ee.checkIntrepidSword)(i,a),(0,ee.computeFinalStats)(a,t,i,s,"atk","spa"),(0,ee.checkInfiltrator)(t,s.defenderSide),(0,ee.checkInfiltrator)(i,s.attackerSide);var o={attackerName:t.name,attackerTera:t.teraType,moveName:r.name,defenderName:i.name,defenderTera:i.teraType,isDefenderDynamaxed:i.isDynamaxed,isWonderRoom:s.isWonderRoom},l=new $.Result(a,t,i,r,s,0,o);if("Status"===r.category&&!r.named("Nature Power"))return l;var h=r.breaksProtect||r.isZ||t.isDynamaxed||t.hasAbility("Unseen Fist")&&r.flags.contact;if(s.defenderSide.isProtected&&!h)return o.isProtected=!0,l;var c=i.hasAbility("Full Metal Body","Neutralizing Gas","Prism Armor","Shadow Shield"),d=t.hasAbility("Mold Breaker","Teravolt","Turboblaze"),u=r.named("G-Max Drum Solo","G-Max Fire Ball","G-Max Hydrosnipe","Light That Burns the Sky","Menacing Moonraze Maelstrom","Moongeist Beam","Photon Geyser","Searing Sunraze Smash","Sunsteel Strike");c||i.hasAbility("Poison Heal")||(d&&(i.ability="",o.attackerAbility=t.ability),u&&(i.ability=""));var y=!i.hasAbility("Battle Armor","Shell Armor")&&(r.isCrit||t.hasAbility("Merciless")&&i.hasStatus("psn","tox"))&&1===r.timesUsed,m=r.type;if(r.named("Weather Ball")){var p=t.hasItem("Utility Umbrella");m=s.hasWeather("Sun","Harsh Sunshine")&&!p?"Fire":s.hasWeather("Rain","Heavy Rain")&&!p?"Water":s.hasWeather("Sand")?"Rock":s.hasWeather("Hail","Snow")?"Ice":"Normal",o.weather=s.weather,o.moveType=m}else if(r.named("Judgment")&&t.item&&t.item.includes("Plate"))m=(0,de.getItemBoostType)(t.item);else if(r.named("Techno Blast")&&t.item&&t.item.includes("Drive"))m=(0,de.getTechnoBlast)(t.item);else if(r.named("Multi-Attack")&&t.item&&t.item.includes("Memory"))m=(0,de.getMultiAttack)(t.item);else if(r.named("Natural Gift")&&t.item&&t.item.includes("Berry")){m=(0,de.getNaturalGift)(a,t.item).t,o.moveType=m,o.attackerItem=t.item}else r.named("Nature Power")||r.named("Terrain Pulse")&&(0,ee.isGrounded)(t,s)?(m=s.hasTerrain("Electric")?"Electric":s.hasTerrain("Grassy")?"Grass":s.hasTerrain("Misty")?"Fairy":s.hasTerrain("Psychic")?"Psychic":"Normal",o.terrain=s.terrain,o.moveType=m):r.named("Revelation Dance")?m=t.types[0]:r.named("Aura Wheel")?t.named("Morpeko")?m="Electric":t.named("Morpeko-Hangry")&&(m="Dark"):r.named("Raging Bull")&&(t.named("Tauros-Paldea-Combat")?m="Fighting":t.named("Tauros-Paldea-Blaze")?m="Fire":t.named("Tauros-Paldea-Aqua")&&(m="Water"));var f=!1,b=!1,g=!1,S=!1,v=!1,k=!1,A=!1,P=r.named("Revelation Dance","Judgment","Nature Power","Techno Blast","Multi Attack","Natural Gift","Weather Ball","Terrain Pulse")||r.named("Tera Blast")&&t.teraType;if(!r.isZ&&!P){var M=r.hasType("Normal");(b=t.hasAbility("Aerilate")&&M)?m="Flying":(v=t.hasAbility("Galvanize")&&M)?m="Electric":(k=t.hasAbility("Liquid Voice")&&!!r.flags.sound)?m="Water":(g=t.hasAbility("Pixilate")&&M)?m="Fairy":(S=t.hasAbility("Refrigerate")&&M)?m="Ice":(A=t.hasAbility("Normalize"))&&(m="Normal"),v||g||S||b||A?(o.attackerAbility=t.ability,f=!0):k&&(o.attackerAbility=t.ability)}r.named("Tera Blast")&&t.teraType&&(m=t.teraType),r.type=m,(t.hasAbility("Triage")&&r.drain||t.hasAbility("Gale Wings")&&r.hasType("Flying")&&t.curHP()===t.maxHP())&&(r.priority=1,o.attackerAbility=t.ability);var T=t.hasAbility("Scrappy")||s.defenderSide.isForesight,w=i.hasItem("Ring Target")&&!i.hasAbility("Klutz"),B=(0,ee.getMoveEffectiveness)(a,r,i.types[0],T,s.isGravity,w)*(i.types[1]?(0,ee.getMoveEffectiveness)(a,r,i.types[1],T,s.isGravity,w):1);if(i.teraType&&(B=(0,ee.getMoveEffectiveness)(a,r,i.teraType,T,s.isGravity,w)),0===B&&r.hasType("Ground")&&i.hasItem("Iron Ball")&&!i.hasAbility("Klutz")&&(B=1),0===B&&r.named("Thousand Arrows")&&(B=1),0===B)return l;if(r.named("Sky Drop")&&(i.hasType("Flying")||i.weightkg>=200||s.isGravity)||r.named("Synchronoise")&&!i.hasType(t.types[0])&&(!t.types[1]||!i.hasType(t.types[1]))||r.named("Dream Eater")&&!i.hasStatus("slp")&&!i.hasAbility("Comatose")||r.named("Steel Roller")&&!s.terrain||r.named("Poltergeist")&&!i.item)return l;if(s.hasWeather("Harsh Sunshine")&&r.hasType("Water")||s.hasWeather("Heavy Rain")&&r.hasType("Fire"))return o.weather=s.weather,l;if(s.hasWeather("Strong Winds")&&i.hasType("Flying")&&a.types.get((0,n.toID)(r.type)).effectiveness.Flying>1&&(B/=2,o.weather=s.weather),i.hasAbility("Wonder Guard")&&B<=1||r.hasType("Grass")&&i.hasAbility("Sap Sipper")||r.hasType("Fire")&&i.hasAbility("Flash Fire","Well-Baked Body")||r.hasType("Water")&&i.hasAbility("Dry Skin","Storm Drain","Water Absorb")||r.hasType("Electric")&&i.hasAbility("Lightning Rod","Motor Drive","Volt Absorb")||r.hasType("Ground")&&!s.isGravity&&!r.named("Thousand Arrows")&&!i.hasItem("Iron Ball")&&i.hasAbility("Levitate")||r.flags.bullet&&i.hasAbility("Bulletproof")||r.flags.sound&&!r.named("Clangorous Soul")&&i.hasAbility("Soundproof")||r.priority>0&&i.hasAbility("Queenly Majesty","Dazzling","Armor Tail")||r.hasType("Ground")&&i.hasAbility("Earth Eater")||r.flags.wind&&i.hasAbility("Wind Rider"))return o.defenderAbility=i.ability,l;if(r.hasType("Ground")&&!r.named("Thousand Arrows")&&!s.isGravity&&i.hasItem("Air Balloon"))return o.defenderItem=i.item,l;if(r.priority>0&&s.hasTerrain("Psychic")&&(0,ee.isGrounded)(i,s))return o.terrain=s.terrain,l;var R=r.named("Heat Crash","Heavy Slam","Low Kick","Grass Knot");if(i.isDynamaxed&&R)return l;o.HPEVs="".concat(i.ivs.hp," HP");var x=(0,ee.handleFixedDamageMoves)(t,r);if(x)return t.hasAbility("Parental Bond")?(l.damage=[x,x],o.attackerAbility=t.ability):l.damage=x,l;if(r.named("Final Gambit"))return l.damage=t.curHP(),l;if(r.named("Guardian of Alola")){var F=Math.floor(3*i.curHP()/4);return s.defenderSide.isProtected&&t.item&&t.item.includes(" Z")&&(F=Math.ceil(F/4-.5)),l.damage=F,l}if(r.named("Nature's Madness")){var G=s.defenderSide.isProtected?0:Math.floor(i.curHP()/2);return l.damage=G,l}if(r.named("Spectral Thief")){var I=void 0;for(I in i.boosts)i.boosts[I]&&(t.boosts[I]+=t.hasAbility("Contrary")?-i.boosts[I]:i.boosts[I],t.boosts[I]>6&&(t.boosts[I]=6),t.boosts[I]<-6&&(t.boosts[I]=-6),t.stats[I]=(0,ee.getModifiedStat)(t.rawStats[I],t.boosts[I]))}r.hits>1&&(o.hits=r.hits),t.stats.spe,i.stats.spe;var D=ue(a,t,i,r,s,f,o);if(0===D)return l;var H=me(a,t,i,r,s,o,y),W=r.named("Foul Play")?i:t;(r.named("Photon Geyser","Light That Burns The Sky")||r.named("Tera Blast")&&W.teraType)&&(r.category=W.stats.atk>W.stats.spa?"Physical":"Special");var C=r.named("Shell Side Arm")&&"Physical"===(0,ee.getShellSideArmCategory)(t,i)?"atk":r.named("Body Press")?"def":"Special"===r.category?"spa":"atk",O=fe(a,t,i,r,s,o,y),E="def"===r.overrideDefensiveStat||"Physical"===r.category||r.named("Shell Side Arm")&&"Physical"===(0,ee.getShellSideArmCategory)(t,i)?"def":"spd",L=(0,ee.getBaseDamage)(t.level,D,H,O),V="Singles"!==s.gameType&&["allAdjacent","allAdjacentFoes"].includes(r.target);V&&(L=(0,ee.pokeRound)((0,ee.OF32)(3072*L)/4096)),t.hasAbility("Parental Bond (Child)")&&(L=(0,ee.pokeRound)((0,ee.OF32)(1024*L)/4096));var N=i.hasItem("Utility Umbrella");!N&&(s.hasWeather("Sun","Harsh Sunshine")&&r.hasType("Fire")||s.hasWeather("Rain","Heavy Rain")&&r.hasType("Water"))?(L=(0,ee.pokeRound)((0,ee.OF32)(6144*L)/4096),o.weather=s.weather):!N&&(s.hasWeather("Sun")&&r.hasType("Water")||s.hasWeather("Rain")&&r.hasType("Fire"))&&(L=(0,ee.pokeRound)((0,ee.OF32)(2048*L)/4096),o.weather=s.weather),i.hasItem("Electric Seed","Misty Seed","Grassy Seed","Psychic Seed")&&s.hasTerrain(i.item.substring(0,i.item.indexOf(" ")))&&de.SEED_BOOSTED_STAT[i.item]===E&&(o.defenderItem=i.item),y&&(L=Math.floor((0,ee.OF32)(1.5*L)),o.isCritical=y);var U=4096;t.hasOriginalType(r.type)?U+=2048:t.hasAbility("Protean","Libero")&&!t.teraType&&(U+=2048,o.attackerAbility=t.ability);var z=t.teraType;z===r.type&&(U+=2048,o.attackerTera=z),t.hasAbility("Adaptability")&&t.hasType(r.type)&&(U+=z&&t.hasOriginalType(z)?1024:2048,o.attackerAbility=t.ability);var K=t.hasStatus("brn")&&"Physical"===r.category&&!t.hasAbility("Guts")&&!r.named("Facade");o.isBurned=K;var Z=ge(a,t,i,r,s,o,y,B),j=!1;s.defenderSide.isProtected&&(t.isDynamaxed||r.isZ&&t.item&&t.item.includes(" Z"))&&(j=!0,o.isProtected=!0);var _,Y=(0,ee.chainMods)(Z,41,131072);if(t.hasAbility("Parental Bond")&&1===r.hits&&!V){var J=t.clone();J.ability="Parental Bond (Child)",(0,ee.checkMultihitBoost)(a,J,i,r,s,o),_=e(a,J,i,r,s).damage,o.attackerAbility=t.ability}for(var Q=[],q=0;q<16;q++)Q[q]=(0,ee.getFinalDamage)(L,q,B,K,U,Y,j);if(r.dropsStats&&r.timesUsed>1){var X=t.hasAbility("Simple")?2:1;o.moveTurns="over ".concat(r.timesUsed," turns");for(var ae=t.hasItem("White Herb"),te=!1,ie=t.boosts[C],re=function(e){var a=(0,ee.getModifiedStat)(H,ie),i=0;Q=Q.map((function(r){if(e){var s=(0,ee.getBaseDamage)(t.level,D,a,O),o=(0,ee.getFinalDamage)(s,i,B,K,U,Y,j);return i++,r+o}return r})),t.hasAbility("Contrary")?(ie=Math.min(6,ie+r.dropsStats),o.attackerAbility=t.ability):(ie=Math.max(-6,ie-r.dropsStats*X),t.hasAbility("Simple")&&(o.attackerAbility=t.ability)),ae&&t.boosts[C]<0&&!te&&(ie+=r.dropsStats*X,te=!0,o.attackerItem=t.item)},se=0;se<r.timesUsed;se++)re(se)}return o.attackBoost=r.named("Foul Play")?i.boosts[C]:t.boosts[C],l.damage=_?[Q,_]:Q,l},e.calculateBasePowerSMSSSV=ue,e.calculateBPModsSMSSSV=ye,e.calculateAttackSMSSSV=me,e.calculateAtModsSMSSSV=pe,e.calculateDefenseSMSSSV=fe,e.calculateDfModsSMSSSV=be,e.calculateFinalModsSMSSSV=ge,e.calculateBWXY=function e(a,t,i,r,s){var o;(0,ee.checkAirLock)(t,s),(0,ee.checkAirLock)(i,s),(0,ee.checkForecast)(t,s.weather),(0,ee.checkForecast)(i,s.weather),(0,ee.checkItem)(t,s.isMagicRoom),(0,ee.checkItem)(i,s.isMagicRoom),(0,ee.checkWonderRoom)(t,s.isWonderRoom),(0,ee.checkWonderRoom)(i,s.isWonderRoom),(0,ee.checkSeedBoost)(t,s),(0,ee.checkSeedBoost)(i,s),(0,ee.computeFinalStats)(a,t,i,s,"def","spd","spe"),(0,ee.checkIntimidate)(a,t,i),(0,ee.checkIntimidate)(a,i,t),(0,ee.checkDownload)(t,i,s.isWonderRoom),(0,ee.checkDownload)(i,t,s.isWonderRoom),(0,ee.computeFinalStats)(a,t,i,s,"atk","spa"),(0,ee.checkInfiltrator)(t,s.defenderSide),(0,ee.checkInfiltrator)(i,s.attackerSide);var l={attackerName:t.name,moveName:r.name,defenderName:i.name,isWonderRoom:s.isWonderRoom},h=new $.Result(a,t,i,r,s,0,l);if("Status"===r.category&&!r.named("Nature Power"))return h;if(s.defenderSide.isProtected&&!r.breaksProtect)return l.isProtected=!0,h;t.hasAbility("Mold Breaker","Teravolt","Turboblaze")&&(i.ability="",l.attackerAbility=t.ability);var c=r.isCrit&&!i.hasAbility("Battle Armor","Shell Armor")&&1===r.timesUsed;if(r.named("Weather Ball"))r.type=s.hasWeather("Sun","Harsh Sunshine")?"Fire":s.hasWeather("Rain","Heavy Rain")?"Water":s.hasWeather("Sand")?"Rock":s.hasWeather("Hail")?"Ice":"Normal",l.weather=s.weather,l.moveType=r.type;else if(r.named("Judgment")&&t.item&&t.item.includes("Plate"))r.type=(0,de.getItemBoostType)(t.item);else if(r.named("Techno Blast")&&t.item&&t.item.includes("Drive"))r.type=(0,de.getTechnoBlast)(t.item);else if(r.named("Natural Gift")&&t.item&&t.item.includes("Berry")){var d=(0,de.getNaturalGift)(a,t.item);r.type=d.t,r.bp=d.p,l.attackerItem=t.item,l.moveBP=r.bp,l.moveType=r.type}else r.named("Nature Power")&&(5===a.num?r.type="Ground":r.type=s.hasTerrain("Electric")?"Electric":s.hasTerrain("Grassy")?"Grass":s.hasTerrain("Misty")?"Fairy":"Normal");var u=!1,y=!1,m=!1,p=!1,f=r.named("Judgment","Nature Power","Techo Blast","Natural Gift","Weather Ball");if(!r.isZ&&!f){var b=r.hasType("Normal");(u=t.hasAbility("Aerilate")&&b)?r.type="Flying":(y=t.hasAbility("Pixilate")&&b)?r.type="Fairy":(m=t.hasAbility("Refrigerate")&&b)?r.type="Ice":(p=t.hasAbility("Normalize"))&&(r.type="Normal"),(y||m||u||p)&&(l.attackerAbility=t.ability)}t.hasAbility("Gale Wings")&&r.hasType("Flying")&&(r.priority=1,l.attackerAbility=t.ability);var g=t.hasAbility("Scrappy")||s.defenderSide.isForesight,S=(0,ee.getMoveEffectiveness)(a,r,i.types[0],g,s.isGravity),v=i.types[1]?(0,ee.getMoveEffectiveness)(a,r,i.types[1],g,s.isGravity):1,k=S*v,A=!i.item||i.named("Giratina-Origin")&&i.hasItem("Griseous Orb")||i.name.includes("Arceus")&&i.item.includes("Plate")||i.name.includes("Genesect")&&i.item.includes("Drive")||i.named("Groudon","Groudon-Primal")&&i.hasItem("Red Orb")||i.named("Kyogre","Kyogre-Primal")&&i.hasItem("Blue Orb");if(!A&&i.item){var P=a.items.get((0,n.toID)(i.item));A=!(!P.megaEvolves||!i.name.includes(P.megaEvolves))}if(0===k&&r.named("Thousand Arrows"))k=1;else if(0===k&&r.hasType("Ground")&&i.hasItem("Iron Ball")&&!i.hasAbility("Klutz"))k=1;else if(0===k&&i.hasItem("Ring Target")){var M=a.types.get((0,n.toID)(r.type)).effectiveness;0===M[i.types[0]]?k=v:i.types[1]&&0===M[i.types[1]]&&(k=S)}if(0===k)return h;if(r.named("Sky Drop")&&(i.hasType("Flying")||i.weightkg>=200||s.isGravity)||r.named("Synchronoise")&&!i.hasType(t.types[0])&&(!t.types[1]||!i.hasType(t.types[1]))||r.named("Dream Eater")&&!i.hasStatus("slp"))return h;if(s.hasWeather("Harsh Sunshine")&&r.hasType("Water")||s.hasWeather("Heavy Rain")&&r.hasType("Fire"))return l.weather=s.weather,h;if(s.hasWeather("Strong Winds")&&i.hasType("Flying")&&a.types.get((0,n.toID)(r.type)).effectiveness.Flying>1&&(k/=2,l.weather=s.weather),i.hasAbility("Wonder Guard")&&k<=1||r.hasType("Grass")&&i.hasAbility("Sap Sipper")||r.hasType("Fire")&&i.hasAbility("Flash Fire")||r.hasType("Water")&&i.hasAbility("Dry Skin","Storm Drain","Water Absorb")||r.hasType("Electric")&&i.hasAbility("Lightning Rod","Motor Drive","Volt Absorb")||r.hasType("Ground")&&!s.isGravity&&!r.named("Thousand Arrows")&&!i.hasItem("Iron Ball")&&i.hasAbility("Levitate")||r.flags.bullet&&i.hasAbility("Bulletproof")||r.flags.sound&&i.hasAbility("Soundproof"))return l.defenderAbility=i.ability,h;if(r.hasType("Ground")&&!r.named("Thousand Arrows")&&!s.isGravity&&i.hasItem("Air Balloon"))return l.defenderItem=i.item,h;if(r.priority>0&&s.hasTerrain("Psychic")&&(0,ee.isGrounded)(i,s))return l.terrain=s.terrain,h;l.HPEVs="".concat(i.evs.hp," HP");var T=(0,ee.handleFixedDamageMoves)(t,r);if(T)return t.hasAbility("Parental Bond")?(h.damage=[T,T],l.attackerAbility=t.ability):h.damage=T,h;if(r.named("Final Gambit"))return h.damage=t.curHP(),h;r.hits>1&&(l.hits=r.hits);var w,B=t.stats.spe>i.stats.spe?"first":"last";switch(r.name){case"Payback":w=r.bp*("last"===B?2:1),l.moveBP=w;break;case"Pursuit":var R="out"===s.defenderSide.isSwitching;w=r.bp*(R?2:1),R&&(l.isSwitching="out"),l.moveBP=w;break;case"Electro Ball":0===i.stats.spe&&(i.stats.spe=1);var x=Math.floor(t.stats.spe/i.stats.spe);w=x>=4?150:x>=3?120:x>=2?80:x>=1?60:40,l.moveBP=w;break;case"Gyro Ball":0===t.stats.spe&&(t.stats.spe=1),w=Math.min(150,Math.floor(25*i.stats.spe/t.stats.spe)+1),l.moveBP=w;break;case"Punishment":w=Math.min(200,60+20*(0,ee.countBoosts)(a,i.boosts)),l.moveBP=w;break;case"Low Kick":case"Grass Knot":var F=i.weightkg*(0,ee.getWeightFactor)(i);w=F>=200?120:F>=100?100:F>=50?80:F>=25?60:F>=10?40:20,l.moveBP=w;break;case"Hex":w=r.bp*(i.status?2:1),l.moveBP=w;break;case"Heavy Slam":case"Heat Crash":var G=t.weightkg*(0,ee.getWeightFactor)(t)/(i.weightkg*(0,ee.getWeightFactor)(i));w=G>=5?120:G>=4?100:G>=3?80:G>=2?60:40,l.moveBP=w;break;case"Stored Power":case"Power Trip":w=20+20*(0,ee.countBoosts)(a,t.boosts),l.moveBP=w;break;case"Acrobatics":w=r.bp*(t.hasItem("Flying Gem")||!t.item?2:1),l.moveBP=w;break;case"Assurance":w=r.bp*(i.hasAbility("Parental Bond (Child)")?2:1);break;case"Wake-Up Slap":w=r.bp*(i.hasStatus("slp")?2:1),l.moveBP=w;break;case"Smelling Salts":w=r.bp*(i.hasStatus("par")?2:1),l.moveBP=w;break;case"Weather Ball":w=r.bp*(s.weather&&!s.hasWeather("Strong Winds")?2:1),l.moveBP=w;break;case"Fling":w=(0,de.getFlingPower)(t.item),l.moveBP=w,l.attackerItem=t.item;break;case"Eruption":case"Water Spout":w=Math.max(1,Math.floor(150*t.curHP()/t.maxHP())),l.moveBP=w;break;case"Flail":case"Reversal":var I=Math.floor(48*t.curHP()/t.maxHP());w=I<=1?200:I<=4?150:I<=9?100:I<=16?80:I<=32?40:20,l.moveBP=w;break;case"Nature Power":if(5===a.num)r.category="Physical",r.target="allAdjacent",w=100,l.moveName="Earthquake";else switch(r.category="Special",r.secondaries=!0,s.terrain){case"Electric":w=90,l.moveName="Thunderbolt";break;case"Grassy":w=90,l.moveName="Energy Ball";break;case"Misty":w=95,l.moveName="Moonblast";break;default:w=80,l.moveName="Tri Attack"}break;case"Triple Kick":w=2===r.hits?15:3===r.hits?30:10,l.moveBP=w;break;case"Crush Grip":case"Wring Out":w=100*Math.floor(4096*i.curHP()/i.maxHP()),w=Math.floor(Math.floor((120*w+2048-1)/4096)/100)||1,l.moveBP=w;break;default:w=r.bp}if(0===w)return h;var D=[];t.hasAbility("Technician")&&w<=60||t.hasAbility("Flare Boost")&&t.hasStatus("brn")&&"Special"===r.category||t.hasAbility("Toxic Boost")&&t.hasStatus("psn","tox")&&"Physical"===r.category?(D.push(6144),l.attackerAbility=t.ability):t.hasAbility("Analytic")&&"first"!==B?(D.push(5325),l.attackerAbility=t.ability):t.hasAbility("Sand Force")&&s.hasWeather("Sand")&&r.hasType("Rock","Ground","Steel")?(D.push(5325),l.attackerAbility=t.ability,l.weather=s.weather):(t.hasAbility("Reckless")&&(r.recoil||r.hasCrashDamage)||t.hasAbility("Iron Fist")&&r.flags.punch)&&(D.push(4915),l.attackerAbility=t.ability),i.hasAbility("Heatproof")&&r.hasType("Fire")?(D.push(2048),l.defenderAbility=i.ability):i.hasAbility("Dry Skin")&&r.hasType("Fire")&&(D.push(5120),l.defenderAbility=i.ability),t.hasAbility("Sheer Force")&&r.secondaries&&(D.push(5325),l.attackerAbility=t.ability),t.hasAbility("Rivalry")&&![t.gender,i.gender].includes("N")&&(t.gender===i.gender?(D.push(5120),l.rivalry="buffed"):(D.push(3072),l.rivalry="nerfed"),l.attackerAbility=t.ability),t.item&&(0,de.getItemBoostType)(t.item)===r.type?(D.push(4915),l.attackerItem=t.item):t.hasItem("Muscle Band")&&"Physical"===r.category||t.hasItem("Wise Glasses")&&"Special"===r.category?(D.push(4505),l.attackerItem=t.item):t.hasItem("Adamant Orb")&&t.named("Dialga")&&r.hasType("Steel","Dragon")||t.hasItem("Lustrous Orb")&&t.named("Palkia")&&r.hasType("Water","Dragon")||t.hasItem("Griseous Orb")&&t.named("Giratina-Origin")&&r.hasType("Ghost","Dragon")?(D.push(4915),l.attackerItem=t.item):t.hasItem("".concat(r.type," Gem"))&&(D.push(a.num>5?5325:6144),l.attackerItem=t.item),r.named("Facade")&&t.hasStatus("brn","par","psn","tox")||r.named("Brine")&&i.curHP()<=i.maxHP()/2||r.named("Venoshock")&&i.hasStatus("psn","tox")?(D.push(8192),l.moveBP=2*w):a.num>5&&r.named("Knock Off")&&!A?(D.push(6144),l.moveBP=1.5*w):r.named("Solar Beam")&&s.hasWeather("Rain","Heavy Rain","Sand","Hail")&&(D.push(2048),l.moveBP=w/2,l.weather=s.weather),s.attackerSide.isHelpingHand&&(D.push(6144),l.isHelpingHand=!0),u||y||m||p?(D.push(5325),l.attackerAbility=t.ability):t.hasAbility("Mega Launcher")&&r.flags.pulse||t.hasAbility("Strong Jaw")&&r.flags.bite?(D.push(6144),l.attackerAbility=t.ability):t.hasAbility("Tough Claws")&&r.flags.contact&&(D.push(5325),l.attackerAbility=t.ability);var H,W="".concat(r.type," Aura"),C=t.hasAbility(W),O=i.hasAbility(W),E=t.hasAbility("Aura Break")||i.hasAbility("Aura Break"),L=s.isAuraBreak,V=s.isFairyAura&&"Fairy"===r.type,N=s.isDarkAura&&"Dark"===r.type;(C||O||V||N)&&(L||E?(D.push(3072),l.attackerAbility=t.ability,l.defenderAbility=i.ability):(D.push(5448),C&&(l.attackerAbility=t.ability),O&&(l.defenderAbility=i.ability))),(0,ee.isGrounded)(t,s)&&(s.hasTerrain("Electric")&&r.hasType("Electric")||s.hasTerrain("Grassy")&&r.hasType("Grass"))&&(D.push(6144),l.terrain=s.terrain),(0,ee.isGrounded)(i,s)&&(s.hasTerrain("Misty")&&r.hasType("Dragon")||s.hasTerrain("Grassy")&&r.named("Bulldoze","Earthquake"))&&(D.push(2048),l.terrain=s.terrain),w=(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(w*(0,ee.chainMods)(D,41,2097152)/4096)));var U=r.named("Foul Play")?i:t,z="Special"===r.category?"spa":"atk";l.attackEVs=r.named("Foul Play")?(0,ee.getEVDescriptionText)(a,i,z,i.nature):(0,ee.getEVDescriptionText)(a,t,z,t.nature),0===U.boosts[z]||c&&U.boosts[z]<0?H=U.rawStats[z]:i.hasAbility("Unaware")?(H=U.rawStats[z],l.defenderAbility=i.ability):(H=U.stats[z],l.attackBoost=U.boosts[z]),t.hasAbility("Hustle")&&"Physical"===r.category&&(H=(0,ee.pokeRound)(3*H/2),l.attackerAbility=t.ability);var K,Z=[];i.hasAbility("Thick Fat")&&r.hasType("Fire","Ice")&&(Z.push(2048),l.defenderAbility=i.ability),t.hasAbility("Guts")&&t.status&&"Physical"===r.category||t.curHP()<=t.maxHP()/3&&(t.hasAbility("Overgrow")&&r.hasType("Grass")||t.hasAbility("Blaze")&&r.hasType("Fire")||t.hasAbility("Torrent")&&r.hasType("Water")||t.hasAbility("Swarm")&&r.hasType("Bug"))||"Special"===r.category&&t.abilityOn&&t.hasAbility("Plus","Minus")?(Z.push(6144),l.attackerAbility=t.ability):t.hasAbility("Flash Fire")&&t.abilityOn&&r.hasType("Fire")?(Z.push(6144),l.attackerAbility="Flash Fire"):t.hasAbility("Solar Power")&&s.hasWeather("Sun","Harsh Sunshine")&&"Special"===r.category||t.named("Cherrim")&&t.hasAbility("Flower Gift")&&s.hasWeather("Sun","Harsh Sunshine")&&"Physical"===r.category?(Z.push(6144),l.attackerAbility=t.ability,l.weather=s.weather):s.attackerSide.isFlowerGift&&s.hasWeather("Sun","Harsh Sunshine")&&"Physical"===r.category?(Z.push(6144),l.weather=s.weather,l.isFlowerGiftAttacker=!0):t.hasAbility("Defeatist")&&t.curHP()<=t.maxHP()/2||t.hasAbility("Slow Start")&&t.abilityOn&&"Physical"===r.category?(Z.push(2048),l.attackerAbility=t.ability):t.hasAbility("Huge Power","Pure Power")&&"Physical"===r.category&&(Z.push(8192),l.attackerAbility=t.ability),t.hasItem("Thick Club")&&t.named("Cubone","Marowak","Marowak-Alola")&&"Physical"===r.category||t.hasItem("Deep Sea Tooth")&&t.named("Clamperl")&&"Special"===r.category||t.hasItem("Light Ball")&&t.name.startsWith("Pikachu")&&!r.isZ?(Z.push(8192),l.attackerItem=t.item):(t.hasItem("Soul Dew")&&t.named("Latios","Latias","Latios-Mega","Latias-Mega")&&"Special"===r.category||t.hasItem("Choice Band")&&"Physical"===r.category||t.hasItem("Choice Specs")&&"Special"===r.category)&&(Z.push(6144),l.attackerItem=t.item),H=(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(H*(0,ee.chainMods)(Z,410,131072)/4096)));var j=r.overrideDefensiveStat||"Physical"===r.category?"def":"spd",_="def"===j;l.defenseEVs=(0,ee.getEVDescriptionText)(a,i,j,i.nature),0===i.boosts[j]||c&&i.boosts[j]>0||r.ignoreDefensive?K=i.rawStats[j]:t.hasAbility("Unaware")?(K=i.rawStats[j],l.attackerAbility=t.ability):(K=i.stats[j],l.defenseBoost=i.boosts[j]),s.hasWeather("Sand")&&i.hasType("Rock")&&!_&&(K=(0,ee.pokeRound)(3*K/2),l.weather=s.weather);var Y=[];i.hasAbility("Marvel Scale")&&i.status&&_?(Y.push(6144),l.defenderAbility=i.ability):i.named("Cherrim")&&i.hasAbility("Flower Gift")&&s.hasWeather("Sun","Harsh Sunshine")&&!_?(Y.push(6144),l.defenderAbility=i.ability,l.weather=s.weather):s.defenderSide.isFlowerGift&&s.hasWeather("Sun","Harsh Sunshine")&&!_&&(Y.push(6144),l.weather=s.weather,l.isFlowerGiftDefender=!0),s.hasTerrain("Grassy")&&i.hasAbility("Grass Pelt")&&_&&(Y.push(6144),l.defenderAbility=i.ability),(!_&&i.hasItem("Soul Dew")&&i.named("Latios","Latias","Latios-Mega","Latias-Mega")||i.hasItem("Eviolite")&&(null===(o=a.species.get((0,n.toID)(i.name)))||void 0===o?void 0:o.nfe)||!_&&i.hasItem("Assault Vest"))&&(Y.push(6144),l.defenderItem=i.item),(i.hasItem("Metal Powder")&&i.named("Ditto")&&_||i.hasItem("Deep Sea Scale")&&i.named("Clamperl")&&!_)&&(Y.push(8192),l.defenderItem=i.item),i.hasAbility("Fur Coat")&&_&&(Y.push(8192),l.defenderAbility=i.ability),K=(0,ee.OF16)(Math.max(1,(0,ee.pokeRound)(K*(0,ee.chainMods)(Y,410,131072)/4096)));var J=(0,ee.getBaseDamage)(t.level,w,H,K),Q="Singles"!==s.gameType&&["allAdjacent","allAdjacentFoes"].includes(r.target);Q&&(J=(0,ee.pokeRound)((0,ee.OF32)(3072*J)/4096)),t.hasAbility("Parental Bond (Child)")&&(J=(0,ee.pokeRound)((0,ee.OF32)(2048*J)/4096)),s.hasWeather("Sun","Harsh Sunshine")&&r.hasType("Fire")||s.hasWeather("Rain","Heavy Rain")&&r.hasType("Water")?(J=(0,ee.pokeRound)((0,ee.OF32)(6144*J)/4096),l.weather=s.weather):(s.hasWeather("Sun")&&r.hasType("Water")||s.hasWeather("Rain")&&r.hasType("Fire"))&&(J=(0,ee.pokeRound)((0,ee.OF32)(2048*J)/4096),l.weather=s.weather),c&&(J=Math.floor((0,ee.OF32)(J*(a.num>5?1.5:2))),l.isCritical=c);var q=4096;t.hasType(r.type)?t.hasAbility("Adaptability")?(q=8192,l.attackerAbility=t.ability):q=6144:t.hasAbility("Protean")&&(q=6144,l.attackerAbility=t.ability);var X=t.hasStatus("brn")&&"Physical"===r.category&&!t.hasAbility("Guts")&&!(r.named("Facade")&&6===a.num);l.isBurned=X;var ae=[];if(s.defenderSide.isReflect&&"Physical"===r.category&&!c?(ae.push("Singles"!==s.gameType?a.num>5?2732:2703:2048),l.isReflect=!0):s.defenderSide.isLightScreen&&"Special"===r.category&&!c&&(ae.push("Singles"!==s.gameType?a.num>5?2732:2703:2048),l.isLightScreen=!0),!i.hasAbility("Multiscale")||i.curHP()!==i.maxHP()||s.defenderSide.isSR||s.defenderSide.spikes&&!i.hasType("Flying")||t.hasAbility("Parental Bond (Child)")||(ae.push(2048),l.defenderAbility=i.ability),t.hasAbility("Tinted Lens")&&k<1&&(ae.push(8192),l.attackerAbility=t.ability),s.defenderSide.isFriendGuard&&(ae.push(3072),l.isFriendGuard=!0),t.hasAbility("Sniper")&&c&&(ae.push(6144),l.attackerAbility=t.ability),i.hasAbility("Solid Rock","Filter")&&k>1&&(ae.push(3072),l.defenderAbility=i.ability),t.hasItem("Metronome")&&r.timesUsedWithMetronome>=1){var te=Math.floor(r.timesUsedWithMetronome);te<=4?ae.push(4096+819*te):ae.push(8192),l.attackerItem=t.item}t.hasItem("Expert Belt")&&k>1&&!r.isZ?(ae.push(4915),l.attackerItem=t.item):t.hasItem("Life Orb")&&(ae.push(5324),l.attackerItem=t.item),r.hasType((0,de.getBerryResistType)(i.item))&&(k>1||r.hasType("Normal"))&&!t.hasAbility("Unnerve")&&(ae.push(2048),l.defenderItem=i.item),s.defenderSide.isProtected&&r.isZ&&t.item&&t.item.includes(" Z")&&(ae.push(1024),l.isProtected=!0);var ie,re=(0,ee.chainMods)(ae,41,131072);if(t.hasAbility("Parental Bond")&&1===r.hits&&!Q){var se=t.clone();se.ability="Parental Bond (Child)",(0,ee.checkMultihitBoost)(a,se,i,r,s,l),ie=e(a,se,i,r,s).damage,l.attackerAbility=t.ability}for(var oe=[],ne=0;ne<16;ne++)oe[ne]=(0,ee.getFinalDamage)(J,ne,k,X,q,re);if(r.dropsStats&&(r.timesUsed||0)>1){var le=t.hasAbility("Simple")?2:1;l.moveTurns="over ".concat(r.timesUsed," turns");for(var he=t.hasItem("White Herb"),ce=!1,ue=t.boosts[z],ye=function(e){var a=(0,ee.getModifiedStat)(H,ue),i=0;oe=oe.map((function(r){if(e){var s=(0,ee.getBaseDamage)(t.level,w,a,K),o=(0,ee.getFinalDamage)(s,i,k,X,q,re);return i++,r+o}return r})),t.hasAbility("Contrary")?(ue=Math.min(6,ue+r.dropsStats),l.attackerAbility=t.ability):(ue=Math.max(-6,ue-r.dropsStats*le),t.hasAbility("Simple")&&(l.attackerAbility=t.ability)),he&&t.boosts[z]<0&&!ce&&(ue+=r.dropsStats*le,ce=!0,l.attackerItem=t.item)},me=0;me<r.timesUsed;me++)ye(me)}return l.attackBoost=r.named("Foul Play")?i.boosts[z]:t.boosts[z],h.damage=ie?[oe,ie]:oe,h},e.calculateDPP=function(e,a,t,i,r){(0,n.checkAirLock)(a,r),(0,n.checkAirLock)(t,r),(0,n.checkForecast)(a,r.weather),(0,n.checkForecast)(t,r.weather),(0,n.checkItem)(a),(0,n.checkItem)(t),(0,n.checkIntimidate)(e,a,t),(0,n.checkIntimidate)(e,t,a),(0,n.checkDownload)(a,t),(0,n.checkDownload)(t,a),a.stats.spe=(0,n.getFinalSpeed)(e,a,r,r.attackerSide),t.stats.spe=(0,n.getFinalSpeed)(e,t,r,r.defenderSide);var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new $.Result(e,a,t,i,r,0,s);if("Status"===i.category&&!i.named("Nature Power"))return o;if(r.defenderSide.isProtected&&!i.breaksProtect)return s.isProtected=!0,o;a.hasAbility("Mold Breaker")&&(t.ability="",s.attackerAbility=a.ability);var l=i.isCrit&&!t.hasAbility("Battle Armor","Shell Armor"),h=i.bp;if(i.named("Weather Ball"))r.hasWeather("Sun")?(i.type="Fire",h*=2):r.hasWeather("Rain")?(i.type="Water",h*=2):r.hasWeather("Sand")?(i.type="Rock",h*=2):r.hasWeather("Hail")?(i.type="Ice",h*=2):i.type="Normal",s.weather=r.weather,s.moveType=i.type,s.moveBP=h;else if(i.named("Judgment")&&a.item&&a.item.includes("Plate"))i.type=(0,de.getItemBoostType)(a.item);else if(i.named("Natural Gift")&&a.item&&a.item.includes("Berry")){var c=(0,de.getNaturalGift)(e,a.item);i.type=c.t,i.bp=c.p,s.attackerItem=a.item,s.moveBP=i.bp,s.moveType=i.type}a.hasAbility("Normalize")&&(i.type="Normal",s.attackerAbility=a.ability);var d=a.hasAbility("Scrappy")||r.defenderSide.isForesight,u=(0,n.getMoveEffectiveness)(e,i,t.types[0],d,r.isGravity),y=t.types[1]?(0,n.getMoveEffectiveness)(e,i,t.types[1],d,r.isGravity):1,m=u*y;if(0===m&&i.hasType("Ground")&&t.hasItem("Iron Ball")&&(0===u?u=1:t.types[1]&&0===y&&(y=1),m=u*y),0===m)return o;if(!(i.hasType("???")||i.named("Fire Fang"))&&t.hasAbility("Wonder Guard")&&m<=1||i.hasType("Fire")&&t.hasAbility("Flash Fire")||i.hasType("Water")&&t.hasAbility("Dry Skin","Water Absorb")||i.hasType("Electric")&&t.hasAbility("Motor Drive","Volt Absorb")||i.hasType("Ground")&&!r.isGravity&&!t.hasItem("Iron Ball")&&t.hasAbility("Levitate")||i.flags.sound&&t.hasAbility("Soundproof"))return s.defenderAbility=t.ability,o;s.HPEVs="".concat(t.evs.hp," HP");var p=(0,n.handleFixedDamageMoves)(a,i);if(p)return o.damage=p,o;i.hits>1&&(s.hits=i.hits);var f=a.stats.spe>t.stats.spe?"first":"last";switch(i.name){case"Brine":t.curHP()<=t.maxHP()/2&&(h*=2,s.moveBP=h);break;case"Eruption":case"Water Spout":h=Math.max(1,Math.floor(h*a.curHP()/a.maxHP())),s.moveBP=h;break;case"Facade":a.hasStatus("par","psn","tox","brn")&&(h=2*i.bp,s.moveBP=h);break;case"Flail":case"Reversal":var b=Math.floor(64*a.curHP()/a.maxHP());h=b<=1?200:b<=5?150:b<=12?100:b<=21?80:b<=42?40:20,s.moveBP=h;break;case"Fling":h=(0,de.getFlingPower)(a.item),s.moveBP=h,s.attackerItem=a.item;break;case"Grass Knot":case"Low Kick":var g=t.weightkg;h=g>=200?120:g>=100?100:g>=50?80:g>=25?60:g>=10?40:20,s.moveBP=h;break;case"Gyro Ball":h=Math.min(150,Math.floor(25*t.stats.spe/a.stats.spe)),s.moveBP=h;break;case"Payback":"first"!==f&&(h*=2,s.moveBP=h);break;case"Punishment":h=Math.min(200,60+20*(0,n.countBoosts)(e,t.boosts)),s.moveBP=h;break;case"Wake-Up Slap":t.hasStatus("slp")&&(h*=2,s.moveBP=h);break;case"Nature Power":i.category="Special",i.secondaries=!0,h=80,s.moveName="Tri Attack";break;case"Crush Grip":case"Wring Out":h=Math.floor(120*t.curHP()/t.maxHP())+1,s.moveBP=h;break;default:h=i.bp}if(0===h)return o;r.attackerSide.isHelpingHand&&(h=Math.floor(1.5*h),s.isHelpingHand=!0);var S="Physical"===i.category;a.hasItem("Muscle Band")&&S||a.hasItem("Wise Glasses")&&!S?(h=Math.floor(1.1*h),s.attackerItem=a.item):(i.hasType((0,de.getItemBoostType)(a.item))||a.hasItem("Adamant Orb")&&a.named("Dialga")&&i.hasType("Steel","Dragon")||a.hasItem("Lustrous Orb")&&a.named("Palkia")&&i.hasType("Water","Dragon")||a.hasItem("Griseous Orb")&&a.named("Giratina-Origin")&&i.hasType("Ghost","Dragon"))&&(h=Math.floor(1.2*h),s.attackerItem=a.item),a.hasAbility("Reckless")&&(i.recoil||i.hasCrashDamage)||a.hasAbility("Iron Fist")&&i.flags.punch?(h=Math.floor(1.2*h),s.attackerAbility=a.ability):(a.curHP()<=a.maxHP()/3&&(a.hasAbility("Overgrow")&&i.hasType("Grass")||a.hasAbility("Blaze")&&i.hasType("Fire")||a.hasAbility("Torrent")&&i.hasType("Water")||a.hasAbility("Swarm")&&i.hasType("Bug"))||a.hasAbility("Technician")&&h<=60)&&(h=Math.floor(1.5*h),s.attackerAbility=a.ability),t.hasAbility("Heatproof")&&i.hasType("Fire")||t.hasAbility("Thick Fat")&&i.hasType("Fire","Ice")?(h=Math.floor(.5*h),s.defenderAbility=t.ability):t.hasAbility("Dry Skin")&&i.hasType("Fire")&&(h=Math.floor(1.25*h),s.defenderAbility=t.ability);var v,k=S?"atk":"spa";s.attackEVs=(0,n.getEVDescriptionText)(e,a,k,a.nature);var A=a.boosts[k],P=a.rawStats[k];0===A||l&&A<0?v=P:t.hasAbility("Unaware")?(v=P,s.defenderAbility=t.ability):a.hasAbility("Simple")?(v=Se(P,A),s.attackerAbility=a.ability,s.attackBoost=A):(v=(0,n.getModifiedStat)(P,A),s.attackBoost=A),S&&a.hasAbility("Pure Power","Huge Power")?(v*=2,s.attackerAbility=a.ability):r.hasWeather("Sun")&&a.hasAbility(S?"Flower Gift":"Solar Power")?(v=Math.floor(1.5*v),s.attackerAbility=a.ability,s.weather=r.weather):r.attackerSide.isFlowerGift&&r.hasWeather("Sun")&&S?(v=Math.floor(1.5*v),s.weather=r.weather,s.isFlowerGiftAttacker=!0):S&&(a.hasAbility("Hustle")||a.hasAbility("Guts")&&a.status)||!S&&a.abilityOn&&a.hasAbility("Plus","Minus")?(v=Math.floor(1.5*v),s.attackerAbility=a.ability):S&&a.hasAbility("Slow Start")&&a.abilityOn&&(v=Math.floor(v/2),s.attackerAbility=a.ability),(S?a.hasItem("Choice Band"):a.hasItem("Choice Specs"))||!S&&a.hasItem("Soul Dew")&&a.named("Latios","Latias")?(v=Math.floor(1.5*v),s.attackerItem=a.item):(a.hasItem("Light Ball")&&a.named("Pikachu")||a.hasItem("Thick Club")&&a.named("Cubone","Marowak")&&S||a.hasItem("Deep Sea Tooth")&&a.named("Clamperl")&&!S)&&(v*=2,s.attackerItem=a.item);var T,w=S?"def":"spd";s.defenseEVs=(0,n.getEVDescriptionText)(e,t,w,t.nature);var B=t.boosts[w],R=t.rawStats[w];0===B||l&&B>0?T=R:a.hasAbility("Unaware")?(T=R,s.attackerAbility=a.ability):t.hasAbility("Simple")?(T=Se(R,B),s.defenderAbility=t.ability,s.defenseBoost=B):(T=(0,n.getModifiedStat)(R,B),s.defenseBoost=B),t.hasAbility("Marvel Scale")&&t.status&&S?(T=Math.floor(1.5*T),s.defenderAbility=t.ability):t.hasAbility("Flower Gift")&&r.hasWeather("Sun")&&!S?(T=Math.floor(1.5*T),s.defenderAbility=t.ability,s.weather=r.weather):r.defenderSide.isFlowerGift&&r.hasWeather("Sun")&&!S&&(T=Math.floor(1.5*T),s.weather=r.weather,s.isFlowerGiftDefender=!0),t.hasItem("Soul Dew")&&t.named("Latios","Latias")&&!S?(T=Math.floor(1.5*T),s.defenderItem=t.item):(t.hasItem("Deep Sea Scale")&&t.named("Clamperl")&&!S||t.hasItem("Metal Powder")&&t.named("Ditto")&&S)&&(T*=2,s.defenderItem=t.item),r.hasWeather("Sand")&&t.hasType("Rock")&&!S&&(T=Math.floor(1.5*T),s.weather=r.weather),(i.named("Explosion")||i.named("Self-Destruct"))&&(T=Math.floor(.5*T)),T<1&&(T=1);var x=Math.floor(Math.floor(Math.floor(2*a.level/5+2)*h*v/50)/T);if(a.hasStatus("brn")&&S&&!a.hasAbility("Guts")&&(x=Math.floor(.5*x),s.isBurned=!0),!l){var F="Singles"!==r.gameType?2/3:.5;S&&r.defenderSide.isReflect?(x=Math.floor(x*F),s.isReflect=!0):!S&&r.defenderSide.isLightScreen&&(x=Math.floor(x*F),s.isLightScreen=!0)}"Singles"!==r.gameType&&["allAdjacent","allAdjacentFoes"].includes(i.target)&&(x=Math.floor(3*x/4)),r.hasWeather("Sun")&&i.hasType("Fire")||r.hasWeather("Rain")&&i.hasType("Water")?(x=Math.floor(1.5*x),s.weather=r.weather):(r.hasWeather("Sun")&&i.hasType("Water")||r.hasWeather("Rain")&&i.hasType("Fire")||i.named("Solar Beam")&&r.hasWeather("Rain","Sand","Hail"))&&(x=Math.floor(.5*x),s.weather=r.weather),a.hasAbility("Flash Fire")&&a.abilityOn&&i.hasType("Fire")&&(x=Math.floor(1.5*x),s.attackerAbility="Flash Fire"),x+=2,l&&(a.hasAbility("Sniper")?(x*=3,s.attackerAbility=a.ability):x*=2,s.isCritical=l),a.hasItem("Life Orb")&&(x=Math.floor(1.3*x),s.attackerItem=a.item),i.named("Pursuit")&&"out"===r.defenderSide.isSwitching&&(a.hasAbility("Technician")?x=Math.floor(1*x):(x=Math.floor(2*x),s.isSwitching="out"));var G=1;i.hasType.apply(i,U([],M(a.types),!1))&&(a.hasAbility("Adaptability")?(G=2,s.attackerAbility=a.ability):G=1.5);var I=1;t.hasAbility("Filter","Solid Rock")&&m>1&&(I=.75,s.defenderAbility=t.ability);var D=1;a.hasItem("Expert Belt")&&m>1&&(D=1.2,s.attackerItem=a.item);var H=1;a.hasAbility("Tinted Lens")&&m<1&&(H=2,s.attackerAbility=a.ability);var W=1;i.hasType((0,de.getBerryResistType)(t.item))&&(m>1||i.hasType("Normal"))&&(W=.5,s.defenderItem=t.item);for(var C=[],O=0;O<16;O++)C[O]=Math.floor(x*(85+O)/100),C[O]=Math.floor(C[O]*G),C[O]=Math.floor(C[O]*u),C[O]=Math.floor(C[O]*y),C[O]=Math.floor(C[O]*I),C[O]=Math.floor(C[O]*D),C[O]=Math.floor(C[O]*H),C[O]=Math.floor(C[O]*W),C[O]=Math.max(1,C[O]);return o.damage=C,o},e.calculateADV=function(e,a,t,i,r){(0,ee.checkAirLock)(a,r),(0,ee.checkAirLock)(t,r),(0,ee.checkForecast)(a,r.weather),(0,ee.checkForecast)(t,r.weather),(0,ee.checkIntimidate)(e,a,t),(0,ee.checkIntimidate)(e,t,a),a.stats.spe=(0,ee.getFinalSpeed)(e,a,r,r.attackerSide),t.stats.spe=(0,ee.getFinalSpeed)(e,t,r,r.defenderSide);var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new $.Result(e,a,t,i,r,0,s);if("Status"===i.category&&!i.named("Nature Power"))return o;if(r.defenderSide.isProtected)return s.isProtected=!0,o;i.named("Weather Ball")&&(i.type=r.hasWeather("Sun")?"Fire":r.hasWeather("Rain")?"Water":r.hasWeather("Sand")?"Rock":r.hasWeather("Hail")?"Ice":"Normal",i.category="Rock"===i.type?"Physical":"Special",s.weather=r.weather,s.moveType=i.type,s.moveBP=i.bp);var n=(0,ee.getMoveEffectiveness)(e,i,t.types[0],r.defenderSide.isForesight)*(t.types[1]?(0,ee.getMoveEffectiveness)(e,i,t.types[1],r.defenderSide.isForesight):1);if(0===n)return o;if(t.hasAbility("Flash Fire")&&i.hasType("Fire")||t.hasAbility("Levitate")&&i.hasType("Ground")||t.hasAbility("Volt Absorb")&&i.hasType("Electric")||t.hasAbility("Water Absorb")&&i.hasType("Water")||t.hasAbility("Wonder Guard")&&!i.hasType("???")&&n<=1||t.hasAbility("Soundproof")&&i.flags.sound)return s.defenderAbility=t.ability,o;s.HPEVs="".concat(t.evs.hp," HP");var l=(0,ee.handleFixedDamageMoves)(a,i);if(l)return o.damage=l,o;i.hits>1&&(s.hits=i.hits);var h=i.bp;switch(i.name){case"Flail":case"Reversal":var c=Math.floor(48*a.curHP()/a.maxHP());h=c<=1?200:c<=4?150:c<=9?100:c<=16?80:c<=32?40:20,s.moveBP=h;break;case"Eruption":case"Water Spout":h=Math.max(1,Math.floor(150*a.curHP()/a.maxHP())),s.moveBP=h;break;case"Low Kick":var d=t.weightkg;h=d>=200?120:d>=100?100:d>=50?80:d>=25?60:d>=10?40:20,s.moveBP=h;break;case"Facade":a.hasStatus("par","psn","tox","brn")&&(h=2*i.bp,s.moveBP=h);break;case"Nature Power":i.category="Physical",h=60,s.moveName="Swift";break;default:h=i.bp}if(0===h)return o;var u="Physical"===i.category,y=u?"atk":"spa";s.attackEVs=(0,ee.getEVDescriptionText)(e,a,y,a.nature);var m=u?"def":"spd";s.defenseEVs=(0,ee.getEVDescriptionText)(e,t,m,t.nature);var p=a.rawStats[y],f=t.rawStats[m];u&&a.hasAbility("Huge Power","Pure Power")&&(p*=2,s.attackerAbility=a.ability),!a.hasItem("Sea Incense")&&i.hasType((0,de.getItemBoostType)(a.item))?(p=Math.floor(1.1*p),s.attackerItem=a.item):a.hasItem("Sea Incense")&&i.hasType("Water")?(p=Math.floor(1.05*p),s.attackerItem=a.item):u&&a.hasItem("Choice Band")||!u&&a.hasItem("Soul Dew")&&a.named("Latios","Latias")?(p=Math.floor(1.5*p),s.attackerItem=a.item):(!u&&a.hasItem("Deep Sea Tooth")&&a.named("Clamperl")||!u&&a.hasItem("Light Ball")&&a.named("Pikachu")||u&&a.hasItem("Thick Club")&&a.named("Cubone","Marowak"))&&(p*=2,s.attackerItem=a.item),!u&&t.hasItem("Soul Dew")&&t.named("Latios","Latias")?(f=Math.floor(1.5*f),s.defenderItem=t.item):(!u&&t.hasItem("Deep Sea Scale")&&t.named("Clamperl")||u&&t.hasItem("Metal Powder")&&t.named("Ditto"))&&(f*=2,s.defenderItem=t.item),t.hasAbility("Thick Fat")&&i.hasType("Fire","Ice")?(p=Math.floor(p/2),s.defenderAbility=t.ability):u&&t.hasAbility("Marvel Scale")&&t.status&&(f=Math.floor(1.5*f),s.defenderAbility=t.ability),u&&(a.hasAbility("Hustle")||a.hasAbility("Guts")&&a.status)||!u&&a.abilityOn&&a.hasAbility("Plus","Minus")?(p=Math.floor(1.5*p),s.attackerAbility=a.ability):a.curHP()<=a.maxHP()/3&&(a.hasAbility("Overgrow")&&i.hasType("Grass")||a.hasAbility("Blaze")&&i.hasType("Fire")||a.hasAbility("Torrent")&&i.hasType("Water")||a.hasAbility("Swarm")&&i.hasType("Bug"))&&(h=Math.floor(1.5*h),s.attackerAbility=a.ability),i.named("Explosion","Self-Destruct")&&(f=Math.floor(f/2));var b=i.isCrit&&!t.hasAbility("Battle Armor","Shell Armor"),g=a.boosts[y],S=t.boosts[m];(g>0||!b&&g<0)&&(p=(0,ee.getModifiedStat)(p,g),s.attackBoost=g),(S<0||!b&&S>0)&&(f=(0,ee.getModifiedStat)(f,S),s.defenseBoost=S);var v=a.level,k=Math.floor(Math.floor(Math.floor(2*v/5+2)*p*h/f)/50);if(a.hasStatus("brn")&&u&&!a.hasAbility("Guts")&&(k=Math.floor(k/2),s.isBurned=!0),!b){var A="Singles"!==r.gameType?2/3:.5;u&&r.defenderSide.isReflect?(k=Math.floor(k*A),s.isReflect=!0):!u&&r.defenderSide.isLightScreen&&(k=Math.floor(k*A),s.isLightScreen=!0)}i.named("Pursuit")&&"out"===r.defenderSide.isSwitching&&(k=Math.floor(2*k),s.isSwitching="out"),"Singles"!==r.gameType&&"allAdjacentFoes"===i.target&&(k=Math.floor(k/2)),r.hasWeather("Sun")&&i.hasType("Fire")||r.hasWeather("Rain")&&i.hasType("Water")?(k=Math.floor(1.5*k),s.weather=r.weather):(r.hasWeather("Sun")&&i.hasType("Water")||r.hasWeather("Rain")&&i.hasType("Fire")||i.named("Solar Beam")&&r.hasWeather("Rain","Sand","Hail"))&&(k=Math.floor(k/2),s.weather=r.weather),a.hasAbility("Flash Fire")&&a.abilityOn&&i.hasType("Fire")&&(k=Math.floor(1.5*k),s.attackerAbility="Flash Fire"),k=("Physical"===i.category?Math.max(1,k):k)+2,b&&(k*=2,s.isCritical=!0),i.named("Weather Ball")&&r.weather&&(k*=2,s.moveBP=2*h),r.attackerSide.isHelpingHand&&(k=Math.floor(1.5*k),s.isHelpingHand=!0),i.hasType.apply(i,U([],M(a.types),!1))&&(k=Math.floor(1.5*k)),k=Math.floor(k*n),o.damage=[];for(var P=85;P<=100;P++)o.damage[P-85]=Math.max(1,Math.floor(k*P/100));return o},e.calculateRBYGSC=function(e,a,t,i,r){(0,ee.computeFinalStats)(e,a,t,r,"atk","def","spa","spd","spe");var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new $.Result(e,a,t,i,r,0,s);if("Status"===i.category)return o;if(r.defenderSide.isProtected)return s.isProtected=!0,o;if(1===e.num&&(n=(0,ee.handleFixedDamageMoves)(a,i)))return o.damage=n,o;var n,l=(0,ee.getMoveEffectiveness)(e,i,t.types[0],r.defenderSide.isForesight),h=t.types[1]?(0,ee.getMoveEffectiveness)(e,i,t.types[1],r.defenderSide.isForesight):1,c=l*h;if(0===c)return o;if(2===e.num&&(n=(0,ee.handleFixedDamageMoves)(a,i)))return o.damage=n,o;if(i.hits>1&&(s.hits=i.hits),i.named("Flail","Reversal")){i.isCrit=!1;var d=Math.floor(48*a.curHP()/a.maxHP());i.bp=d<=1?200:d<=4?150:d<=9?100:d<=16?80:d<=32?40:20,s.moveBP=i.bp}else i.named("Present")&&!i.bp&&(i.bp=40);if(0===i.bp)return o;var u="Physical"===i.category,y=u?"atk":"spa",m=u?"def":"spd",p=a.stats[y],f=t.stats[m],b=i.isCrit&&(1===e.num||2===e.num&&a.boosts[y]<=t.boosts[m]),g=a.level;if(b?(p=a.rawStats[y],f=t.rawStats[m],1===e.num&&(g*=2,s.isCritical=!0)):(0!==a.boosts[y]&&(s.attackBoost=a.boosts[y]),0!==t.boosts[m]&&(s.defenseBoost=t.boosts[m]),u&&a.hasStatus("brn")&&(p=Math.floor(p/2),s.isBurned=!0)),i.named("Explosion","Self-Destruct")&&(f=Math.floor(f/2)),b||(u&&r.defenderSide.isReflect?(f*=2,s.isReflect=!0):!u&&r.defenderSide.isLightScreen&&(f*=2,s.isLightScreen=!0)),(a.named("Pikachu")&&a.hasItem("Light Ball")&&!u||a.named("Cubone","Marowak")&&a.hasItem("Thick Club")&&u)&&(p*=2,s.attackerItem=a.item),(p>255||f>255)&&(p=Math.floor(p/4)%256,f=Math.floor(f/4)%256),i.named("Present")){var S={Normal:0,Fighting:1,Flying:2,Poison:3,Ground:4,Rock:5,Bug:7,Ghost:8,Steel:9,"???":19,Fire:20,Water:21,Grass:22,Electric:23,Psychic:24,Ice:25,Dragon:26,Dark:27};p=10,f=Math.max(S[a.types[1]?a.types[1]:a.types[0]],1),g=Math.max(S[t.types[1]?t.types[1]:t.types[0]],1)}t.named("Ditto")&&t.hasItem("Metal Powder")&&(f=Math.floor(1.5*f),s.defenderItem=t.item);var v=Math.floor(Math.floor(Math.floor(2*g/5+2)*Math.max(1,p)*i.bp/Math.max(1,f))/50);2===e.num&&i.isCrit&&(v*=2,s.isCritical=!0),i.named("Pursuit")&&"out"===r.defenderSide.isSwitching&&(v=Math.floor(2*v),s.isSwitching="out");var k=a.hasItem("Dragon Fang")?void 0:(0,de.getItemBoostType)(a.hasItem("Dragon Scale")?"Dragon Fang":a.item);if(i.hasType(k)&&(v=Math.floor(1.1*v),s.attackerItem=a.item),v=Math.min(997,v)+2,r.hasWeather("Sun")&&i.hasType("Fire")||r.hasWeather("Rain")&&i.hasType("Water")?(v=Math.floor(1.5*v),s.weather=r.weather):(r.hasWeather("Sun")&&i.hasType("Water")||r.hasWeather("Rain")&&(i.hasType("Fire")||i.named("Solar Beam")))&&(v=Math.floor(v/2),s.weather=r.weather),i.hasType.apply(i,U([],M(a.types),!1))&&(v=Math.floor(1.5*v)),1===e.num?(v=Math.floor(v*l),v=Math.floor(v*h)):v=Math.floor(v*c),i.named("Flail","Reversal"))return o.damage=v,o;o.damage=[];for(var A=217;A<=255;A++)2===e.num?o.damage[A-217]=Math.max(1,Math.floor(v*A/255)):o.damage[A-217]=1===v?1:Math.floor(v*A/255);return o};var ve=e,ke=e,Ae=e,Pe=e,Me=e,Te=[function(){},ke.calculateRBYGSC,ke.calculateRBYGSC,Ae.calculateADV,Pe.calculateDPP,Me.calculateBWXY,Me.calculateBWXY,gen789_1.calculateSMSSSV,gen789_1.calculateSMSSSV,gen789_1.calculateSMSSSV];e.calculate=function(e,a,t,i,r){return Te[e.num](e,a.clone(),t.clone(),i.clone(),r?r.clone():new ve.Field)},window.calc=Object.assign(window.calc||{},{Field:e.Field,Side:e.Side,Pokemon:e.Pokemon,Move:e.Move,calculate:e.calculate,Result:e.Result,toID:e.toID,STATS:e.STATS,Stats:e.Stats})}();