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;e.STATS=[[],["hp","atk","def","spc","spe"],l,h,c,d,u,y,m];var p=["Fighting","Flying","Poison","Ground","Rock","Bug","Ghost","Steel","Fire","Water","Grass","Electric","Psychic","Ice","Dragon","Dark"],f={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 "+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>8)throw new Error("Invalid generation "+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(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=f[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:p[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:p[t(15*n/63)],power:e.num&&e.num<6?t(40*l/63)+30:60}},a}());var b=e,g=_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.")},S=["hp","atk","def","spa","spd","spe"],v=new Set(["spc"]),k=function(){function e(a,t,i){var r,s,o;void 0===i&&(i={}),this.species=n.extend(!0,{},a.species.get(n.toID(t)),i.overrides),this.gen=a,this.name=i.name||t,this.types=this.species.types,this.isDynamaxed=!!i.isDynamaxed,this.weightkg=this.species.weightkg,0===this.weightkg&&!this.isDynamaxed&&this.species.baseSpecies&&(this.weightkg=a.species.get(n.toID(this.species.baseSpecies)).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.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),a.num<3&&(this.ivs.hp=b.Stats.DVToIV(b.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=g(S),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=g(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,item:this.item,gender:this.gender,nature:this.nature,ivs:n.extend(!0,{},this.ivs),evs:n.extend(!0,{},this.evs),boosts:n.extend(!0,{},this.boosts),originalCurHP:this.originalCurHP,status:this.status,toxicCounter:this.toxicCounter,moves:this.moves.slice(),overrides:this.species})},e.prototype.calcStat=function(e,a){return b.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(n.toID(a));if(!r||!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&&(n.assignWithout(r,a,v),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 Object.assign({hp:t,atk:t,def:t,spa:t,spd:t,spe:t},r)},e}();e.Pokemon=k;var A=_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},P=function(){function e(e){void 0===e&&(e={}),this.gameType=e.gameType||"Singles",this.terrain=e.terrain,this.weather=e.weather,this.isGravity=!!e.isGravity,this.attackerSide=new M(e.attackerSide||{}),this.defenderSide=new M(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=A([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,isGravity:this.isGravity,attackerSide:this.attackerSide,defenderSide:this.defenderSide})},e}();e.Field=P;var M=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.isFriendGuard=!!e.isFriendGuard,this.isAuroraVeil=!!e.isAuroraVeil,this.isBattery=!!e.isBattery,this.isSwitching=e.isSwitching}return e.prototype.clone=function(){return new e(this)},e}();e.Side=M;var T=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],w=function(){function e(e,a,t){var i,r;void 0===t&&(t={}),a=t.name||a,this.originalName=a;var s=n.extend(!0,{name:a},e.moves.get(n.toID(a)),t.overrides);if(this.hits=1,t.useMax&&s.maxMove){var o=F(s.type,t.species,!("Status"!==s.category)),l=e.moves.get(n.toID(o));s=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=B(s.name,s.type,t.item),c=e.moves.get(n.toID(h));s=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||"Grip Claw"===t.item?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?T.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"].includes(s.id),this.drain=s.drain,this.flags=s.flags,this.priority=s.priority||0,this.ignoreDefensive=!!s.ignoreDefensive,this.defensiveCategory=s.defensiveCategory||this.category,this.breaksProtect=!!s.breaksProtect,this.isZ=!!s.isZ,this.isMax=!!s.isMax,this.bp||(["return","frustration","pikapapow","veeveevolley"].includes(s.id)?this.bp=102:"naturepower"===s.id&&(this.bp=80,e.num>=5&&(this.secondaries=!0)))}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 B(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 x[a]}e.Move=w,e.getZMoveName=B;var x={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 F(e,a,t){if(t)return"Max Guard";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("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 "+G[e]}e.getMaxMoveName=F;var G={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"SilverPowder":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 R=new Set(["TR24","TR28","TR34","TR39","TR53","TR55","TR64","TR66","TR72","TR73"]),I=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"]),H=new Set(["Deep Sea Tooth","Thick Club","TR02","TR04","TR05","TR08","TR11","TR22","TR35","TR42","TR45","TR50","TR61","TR65","TR67","TR86","TR90","TR96"]),D=new Set(["TR01","TR41","TR62","TR93","TR97","TR98"]),W=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"]),C=new Set(["Poison Barb","Dragon Fang","Power Anklet","Power Band","Power Belt","Power Bracer","Power Lens","Power Weight"]),O=new Set(["Adamant Orb","Damp Rock","Heat Rock","Leek","Lustrous Orb","Macho Brace","Rocky Helmet","Stick","Utility Umbrella","Terrain Extender"]),E=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"]),L=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","SilverPowder","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:R.has(e)?85:["TR03","TR06","TR09","TR15","TR89"].includes(e)?110:I.has(e)?100:["TR36","TR78","TR81","TR94"].includes(e)?95:e.includes("Plate")||H.has(e)?90:D.has(e)?85:W.has(e)?80:C.has(e)?70:O.has(e)?60:["Eject Pack","Sharp Beak","Dubious Disc"].includes(e)?50:["Icy Rock","Eviolite","Lucky Punch"].includes(e)?40:E.has(e)?30:"TR82"===e?20:e.includes("Berry")||L.has(e)?10:0:0},e.getNaturalGift=function(e,a){var t,i=null===(t=e.items.get(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 V=_this&&_this.__spread||function(){for(var e=[],a=0;a<arguments.length;a++)e=e.concat(A(arguments[a]));return e},N=["Macho Brace","Power Anklet","Power Band","Power Belt","Power Bracer","Power Lens","Power Weight"];function U(e,a,t){var i=[1,1.5,2,2.5,3,3.5,4];if(t&&t.num<3){if(a>=0)e=Math.floor(e*i[a]);else{e=Math.floor(e*[100,66,50,40,33,28,25][-a]/100)}return Math.min(999,Math.max(1,e))}return e=a>=0?Math.floor(e*i[a]):Math.floor(e/i[-a])}function z(e,a,t,i){var r=t.weather||"",s=t.terrain,o=U(a.rawStats.spe,a.boosts.spe,e),n=1;return a.hasItem("Choice Scarf")?n*=1.5:a.hasItem.apply(a,V(["Iron Ball"],N))?n*=.5:a.hasItem("Quick Powder")&&a.named("Ditto")&&(n*=2),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"===r||a.hasAbility("Surge Surfer")&&"Electric"===s?o*=2:a.hasAbility("Quick Feet")&&a.status?n*=1.5:a.hasAbility("Slow Start")&&a.abilityOn&&(n*=.5),i.isTailwind&&(n*=2),o=K(o*n),a.hasStatus("par")&&!a.hasAbility("Quick Feet")&&(o=Math.floor(o*(e.num<7?.25:.5))),o=Math.min(e.num<=2?999:1e4,o),Math.max(1,o)}function K(e){return e%1>.5?Math.ceil(e):Math.floor(e)}function Z(e){return e>65535?e%65536:e}function j(e){return e>4294967295?e%4294967296:e}e.isGrounded=function(e,a){return a.isGravity||!e.hasType("Flying")&&!e.hasAbility("Levitate")&&!e.hasItem("Air Balloon")},e.getModifiedStat=U,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=g(c),u=d.next();!u.done;u=d.next()){var y=A(u.value,2),m=y[0],p=y[1];try{for(var f=(o=void 0,g(l)),b=f.next();!b.done;b=f.next()){var S=b.value;"spe"===S?m.stats.spe=z(e,m,i,p):m.stats[S]=U(m.rawStats[S],m.boosts[S],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){return i&&"Ghost"===t&&a.hasType("Normal","Fighting")||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(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":e.types=["Ice"];break;default:e.types=["Normal"]}},e.checkKlutz=function(e){e.hasAbility("Klutz")&&!N.includes(e.item)&&(e.item="")},e.checkIntimidate=function(e,a,t){var i=t.hasAbility("Clear Body","White Smoke","Hyper Cutter","Full Metal Body")||8===e.num&&t.hasAbility("Inner Focus","Own Tempo","Oblivious","Scrappy");a.hasAbility("Intimidate")&&a.abilityOn&&!i&&(t.hasAbility("Contrary","Defiant")?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))},e.checkDownload=function(e,a){e.hasAbility("Download")&&(a.stats.spd<=a.stats.def?e.boosts.spa=Math.min(6,e.boosts.spa+1):e.boosts.atk=Math.min(6,e.boosts.atk+1))},e.checkIntrepidSword=function(e){e.hasAbility("Intrepid Sword")&&(e.boosts.atk=Math.min(6,e.boosts.atk+1))},e.checkDauntlessShield=function(e){e.hasAbility("Dauntless Shield")&&(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=U(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=U(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=U(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]=U(a.rawStats[l],t.boosts[l],e)}return o},e.chainMods=function(e){var a,t,i=4096;try{for(var r=g(e),s=r.next();!s.done;s=r.next()){var o=s.value;4096!==o&&(i=i*o+2048>>12)}}catch(e){a={error:e}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return i},e.getBaseDamage=function(e,a,t,i){return Math.floor(j(Math.floor(j(j(Math.floor(2*e/5+2)*a)*t)/i)/50+2))},e.getFinalDamage=function(e,a,t,i,r,s,o){var n=Math.floor(j(e*(85+a))/100);return 4096!==r&&(n=j(n*r)/4096),n=Math.floor(j(K(n)*t)),i&&(n=Math.floor(n/2)),o&&(n=K(j(1024*n)/4096)),Z(K(Math.max(1,j(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=g(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(n.toID(i));return a.evs[t]+(r.plus===r.minus?"":r.plus===t?"+":r.minus===t?"-":"")+" "+b.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=K,e.OF16=Z,e.OF32=j;var _=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=Y(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),oe.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="%"),oe.displayMove(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.recovery=function(e){return void 0===e&&(e="%"),oe.getRecovery(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.recoil=function(e){return void 0===e&&(e="%"),oe.getRecoil(this.gen,this.attacker,this.defender,this.move,this.damage,e)},e.prototype.kochance=function(e){return void 0===e&&(e=!0),oe.getKOChance(this.gen,this.attacker,this.defender,this.move,this.field,this.damage,e)},e}();function Y(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,V(a)),Math.max.apply(Math,V(a))]:[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=_,e.damageRange=Y;var J=e,Q=e;function q(e,a,t,i,r,s){void 0===s&&(s="%");var o=A(J.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)}return 0===d[1]?{recovery:d,text:u}:{recovery:d,text:u=se(s,d[0],a.maxHP())+" - "+se(s,d[1],a.maxHP())+s+" recovered"}}function X(e,a,t,i,r,s){void 0===s&&(s="%");var o=A(J.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=se(s,t.curHP()*m,a.maxHP(),100),f=se(s,t.curHP()*m,a.maxHP(),100)):(p=se(s,Math.min(h,t.curHP())*m,a.maxHP(),100),f=se(s,Math.min(c,t.curHP())*m,a.maxHP(),100)),a.hasAbility("Rock Head")||(d=[p,f],u=p+" - "+f+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=se(s,t.curHP()*b,a.maxHP(),100),f=se(s,t.curHP()*b,a.maxHP(),100)):(p=se(s,Math.min(h,t.maxHP())*b,a.maxHP(),100),f=se(s,Math.min(c,t.maxHP())*b,a.maxHP(),100)),d=[p,f],e.num){case 1:d=se(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=g+"% crash damage"}else d=0,u="no crash damage on Ghost types";else u=p+" - "+f+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 $(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 n.error(o,"damage[0] must be a number."),{chance:0,n:0,text:""};if(0===s[s.length-1])return 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")&&(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")||(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")&&Q.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")&&ee.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")));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]];default:return n.error(i,"Unexpected # of hits: "+t),a}else{if(39!==a.length){if(256===a.length){t>1&&n.error(i,"Unexpected # of hits for Parental Bond: "+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 n.error(i,"Unexpected # of possible damage values: "+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]];default:return n.error(i,"Unexpected # of hits: "+t),a}}}(e,s,i.hits,o));var u,y=l.texts.length>0?" after "+ie(l.texts):"",m=l.texts.length>0||h.texts.length>0?" after "+ie(l.texts.concat(h.texts)):"";if(!(1===i.timesUsed&&1===i.timesUsedWithMetronome||i.isZ))return 1===(u=ae(s,t.maxHP()-l.damage,h.damage,i.hits||1,i.timesUsed||1,t.maxHP(),c))?{chance:u,n:i.timesUsed,text:(d||"guaranteed ")+"KO in "+i.timesUsed+" turns"+m}:u>0?{chance:u,n:i.timesUsed,text:d+Math.round(1e3*u)/10+"% chance to "+i.timesUsed+"HKO"+m}:te(s[0],h.damage,i.hits,i.timesUsed,c,t.maxHP())>=t.curHP()-l.damage?{chance:1,n:i.timesUsed,text:(d||"guaranteed ")+"KO in "+i.timesUsed+" turns"+m}:te(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 "+i.timesUsed+" turns"+m}:{n:i.timesUsed,text:d+"not a KO"};if(1===(u=ae(s,t.curHP()-l.damage,0,1,1,t.maxHP(),c)))return{chance:u,n:1,text:"guaranteed OHKO"+y};if(u>0)return{chance:u,n:1,text:d+Math.round(1e3*u)/10+"% chance to OHKO"+y};256===s.length&&(d="approx. ");for(var p=2;p<=4;p++){var f=ae(s,t.curHP()-l.damage,h.damage,p,1,t.maxHP(),c);if(1===f)return{chance:f,n:p,text:""+(d||"guaranteed ")+p+"HKO"+m};if(f>0)return{chance:f,n:p,text:d+Math.round(1e3*f)/10+"% chance to "+p+"HKO"+m}}for(p=5;p<=9;p++){if(te(s[0],h.damage,p,1,c,t.maxHP())>=t.curHP()-l.damage)return{chance:1,n:p,text:""+(d||"guaranteed ")+p+"HKO"+m};if(te(s[s.length-1],h.damage,p,1,c,t.maxHP())>=t.curHP()-l.damage)return{n:p,text:d+"possible "+p+"HKO"+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=A(J.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=se(n,u,t.maxHP()),p=se(n,y,t.maxHP()),f=function(e,a,t){var i=A(function(e,a){if(e.level!==a.level)return[100===e.level?"":"Lvl "+e.level,100===a.level?"":"Lvl "+a.level];var t=[100,50,5].includes(e.level)?"":"Lvl "+e.level;return[t,t]}(a,t),2),r=i[0],s=i[1],o="";e.attackBoost&&(e.attackBoost>0&&(o+="+"),o+=e.attackBoost+" ");o=re(o,r),o=re(o,e.attackEVs),o=re(o,e.attackerItem),o=re(o,e.attackerAbility),o=re(o,e.rivalry),e.isBurned&&(o+="burned ");o+=e.attackerName+" ",e.isHelpingHand&&(o+="Helping Hand ");e.isBattery&&(o+=" Battery 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=re(o,e.moveTurns),o+="vs. ",e.defenseBoost&&(e.defenseBoost>0&&(o+="+"),o+=e.defenseBoost+" ");o=re(o,s),o=re(o,e.HPEVs),e.defenseEVs&&(o+="/ "+e.defenseEVs+" ");o=re(o,e.defenderItem),o=re(o,e.defenderAbility),e.isProtected&&(o+="protected ");e.isDefenderDynamaxed&&(o+="Dynamax ");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.isFriendGuard&&(o+=" with an ally's Friend Guard");e.isAuroraVeil&&(o+=" with an ally's Aurora Veil");e.isCritical&&(o+=" on a critical hit");return o}(o,a,t),b=u+"-"+y+" ("+m+" - "+p+n+")";if("Status"===i.category&&!i.named("Nature Power"))return f+": "+b;var g=$(e,a,t,i,r,s,l).text;return g?f+": "+b+" -- "+g:f+": "+b},e.displayMove=function(e,a,t,i,r,s){void 0===s&&(s="%");var o=A(J.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=se(s,h,t.maxHP()),u=se(s,c,t.maxHP()),y=q(e,a,t,i,r,s).text,m=X(e,a,t,i,r,s).text;return d+" - "+u+s+(y&&" ("+y+")")+(m&&" ("+m+")")},e.getRecovery=q,e.getRecoil=X,e.getKOChance=$;var ee=["Bind","Clamp","Fire Spin","Infestation","Magma Storm","Sand Tomb","Whirlpool","Wrap","G-Max Sandblast","G-Max Centiferno"];function ae(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]?ae(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 te(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 ie(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 re(e,a){return a?""+e+a+" ":e}function se(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 oe=e,ne=e;function le(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.calculateSMSS=function e(a,t,i,r,s){var o;Q.checkAirLock(t,s),Q.checkAirLock(i,s),Q.checkForecast(t,s.weather),Q.checkForecast(i,s.weather),Q.checkKlutz(t),Q.checkKlutz(i),Q.checkSeedBoost(t,s),Q.checkSeedBoost(i,s),Q.computeFinalStats(a,t,i,s,"def","spd","spe"),Q.checkIntimidate(a,t,i),Q.checkIntimidate(a,i,t),Q.checkDownload(t,i),Q.checkDownload(i,t),Q.checkIntrepidSword(t),Q.checkIntrepidSword(i),Q.checkDauntlessShield(t),Q.checkDauntlessShield(i),Q.computeFinalStats(a,t,i,s,"atk","spa"),Q.checkInfiltrator(t,s.defenderSide),Q.checkInfiltrator(i,s.attackerSide);var l={attackerName:t.name,moveName:r.name,defenderName:i.name,isDefenderDynamaxed:i.isDynamaxed},h=new J.Result(a,t,i,r,s,0,l);if("Status"===r.category&&!r.named("Nature Power"))return h;var c=r.breaksProtect||r.isZ||t.isDynamaxed||t.hasAbility("Unseen Fist")&&r.flags.contact;if(s.defenderSide.isProtected&&!c)return l.isProtected=!0,h;var d=i.hasAbility("Full Metal Body","Neutralizing Gas","Prism Armor","Shadow Shield"),u=t.hasAbility("Mold Breaker","Teravolt","Turboblaze"),y=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");d||(u&&(i.ability="",l.attackerAbility=t.ability),y&&(i.ability=""));var m=!i.hasAbility("Battle Armor","Shell Armor")&&(r.isCrit||t.hasAbility("Merciless")&&i.hasStatus("psn","tox"))&&1===r.timesUsed;if(r.named("Weather Ball")){var p=t.hasItem("Utility Umbrella");r.type=s.hasWeather("Sun","Harsh Sunshine")&&!p?"Fire":s.hasWeather("Rain","Heavy Rain")&&!p?"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=ne.getItemBoostType(t.item);else if(r.named("Techno Blast")&&t.item&&t.item.includes("Drive"))r.type=ne.getTechnoBlast(t.item);else if(r.named("Multi-Attack")&&t.item&&t.item.includes("Memory"))r.type=ne.getMultiAttack(t.item);else if(r.named("Natural Gift")&&t.item&&t.item.includes("Berry")){var f=ne.getNaturalGift(a,t.item);r.type=f.t,r.bp=f.p,l.attackerItem=t.item,l.moveBP=r.bp,l.moveType=r.type}else r.named("Nature Power","Terrain Pulse")?r.type=s.hasTerrain("Electric")?"Electric":s.hasTerrain("Grassy")?"Grass":s.hasTerrain("Misty")?"Fairy":s.hasTerrain("Psychic")?"Psychic":"Normal":r.named("Revelation Dance")?r.type=t.types[0]:r.named("Aura Wheel")&&(t.named("Morpeko")?r.type="Electric":t.named("Morpeko-Hangry")&&(r.type="Dark"));var 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");if(!r.isZ&&!P){var M=r.hasType("Normal");(b=t.hasAbility("Aerilate")&&M)?r.type="Flying":(v=t.hasAbility("Galvanize")&&M)?r.type="Electric":(k=t.hasAbility("Liquid Voice")&&!!r.flags.sound)?r.type="Water":(g=t.hasAbility("Pixilate")&&M)?r.type="Fairy":(S=t.hasAbility("Refrigerate")&&M)?r.type="Ice":(A=t.hasAbility("Normalize"))&&(r.type="Normal"),(v||k||g||S||b||A)&&(l.attackerAbility=t.ability)}(t.hasAbility("Triage")&&r.drain||t.hasAbility("Gale Wings")&&r.hasType("Flying")&&t.curHP()===t.maxHP())&&(r.priority=1,l.attackerAbility=t.ability);var T=t.hasAbility("Scrappy")||s.defenderSide.isForesight,w=Q.getMoveEffectiveness(a,r,i.types[0],T,s.isGravity),B=i.types[1]?Q.getMoveEffectiveness(a,r,i.types[1],T,s.isGravity):1,x=w*B,F=!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")||i.name.includes("Silvally")&&i.item.includes("Memory")||i.item.includes(" Z")||i.named("Zacian")&&i.hasItem("Rusted Sword");if(!F&&i.item){var G=a.items.get(n.toID(i.item));F=!!G.megaEvolves&&i.name.includes(G.megaEvolves)}if(0===x&&r.named("Thousand Arrows"))x=1;else if(0===x&&i.hasItem("Ring Target")){var R=a.types.get(n.toID(r.type)).effectiveness;0===R[i.types[0]]?x=B:i.types[1]&&0===R[i.types[1]]&&(x=w)}if(0===x)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")&&!i.hasAbility("Comatose"))return h;if(i.hasAbility("Wonder Guard")&&x<=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.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"))return l.defenderAbility=i.ability,h;if(s.hasWeather("Strong Winds")&&i.hasType("Flying")&&a.types.get(n.toID(r.type)).effectiveness.Flying>1&&(x/=2,l.weather=s.weather),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")&&Q.isGrounded(i,s))return l.terrain=s.terrain,h;var I=r.named("Heat Crash","Heavy Slam","Low Kick","Grass Knot");if(i.isDynamaxed&&I)return h;l.HPEVs=i.evs.hp+" HP";var H=Q.handleFixedDamageMoves(t,r);if(H)return t.hasAbility("Parental Bond")?(h.damage=[H,H],l.attackerAbility=t.ability):h.damage=H,h;if(r.named("Final Gambit"))return h.damage=t.curHP(),h;if(r.named("Guardian of Alola")){var D=Math.floor(3*i.curHP()/4);return s.defenderSide.isProtected&&t.item&&t.item.includes(" Z")&&(D=Math.ceil(D/4-.5)),h.damage=D,h}if(r.named("Nature's Madness")){var W=s.defenderSide.isProtected?0:Math.floor(i.curHP()/2);return h.damage=W,h}if(r.named("Spectral Thief")){var C=void 0;for(C in i.boosts)i.boosts[C]&&(t.boosts[C]+=t.hasAbility("Contrary")?-i.boosts[C]:i.boosts[C],t.stats[C]=Q.getModifiedStat(t.rawStats[C],t.boosts[C]))}r.hits>1&&(l.hits=r.hits);var O,E=t.stats.spe>i.stats.spe?"first":"last";switch(r.name){case"Payback":O="last"===E?100:50,l.moveBP=O;break;case"Bolt Beak":case"Fishious Rend":O=r.bp*("last"!==E?2:1),l.moveBP=O;break;case"Electro Ball":var L=Math.floor(t.stats.spe/i.stats.spe);O=L>=4?150:L>=3?120:L>=2?80:L>=1?60:40,l.moveBP=O;break;case"Expanding Force":var V=Q.isGrounded(t,s)&&s.hasTerrain("Psychic");O=r.bp*(V?1.5:1),r.target=V?"allAdjacentFoes":"normal",l.moveBP=O;break;case"Misty Explosion":O=r.bp*(s.hasTerrain("Misty")?1.5:1),l.moveBP=O;break;case"Rising Voltage":O=Q.isGrounded(i,s)&&s.hasTerrain("Electric")?2*r.bp:r.bp,l.moveBP=O;break;case"Gyro Ball":O=Math.min(150,Math.floor(25*i.stats.spe/t.stats.spe)),l.moveBP=O;break;case"Poltergeist":O=r.bp*(i.item?1:0),l.moveBP=O;break;case"Punishment":O=Math.min(200,60+20*Q.countBoosts(a,i.boosts)),l.moveBP=O;break;case"Low Kick":case"Grass Knot":var N=i.weightkg*Q.getWeightFactor(i);O=N>=200?120:N>=100?100:N>=50?80:N>=25?60:N>=10?40:20,l.moveBP=O;break;case"Hex":O=r.bp*(i.status||i.hasAbility("Comatose")?2:1),l.moveBP=O;break;case"Heavy Slam":case"Heat Crash":var U=t.weightkg*Q.getWeightFactor(t)/(i.weightkg*Q.getWeightFactor(i));O=U>=5?120:U>=4?100:U>=3?80:U>=2?60:40,l.moveBP=O;break;case"Stored Power":case"Power Trip":O=20+20*Q.countBoosts(a,t.boosts),l.moveBP=O;break;case"Acrobatics":O=t.hasItem("Flying Gem")||!t.item?110:55,l.moveBP=O;break;case"Grav Apple":O=r.bp*(s.isGravity?1.5:1),l.moveBP=O;break;case"Steel Roller":O=r.bp*(s.terrain?1:0),l.moveBP=O;break;case"Assurance":O=r.bp*(i.hasAbility("Parental Bond (Child)")?2:1);break;case"Wake-Up Slap":O=r.bp*(i.hasStatus("slp")||i.hasAbility("Comatose")?2:1),l.moveBP=O;break;case"Weather Ball":O=s.weather&&!s.hasWeather("Strong Winds")?100:50,s.hasWeather("Sun","Harsh Sunshine","Rain","Heavy Rain")&&t.hasItem("Utility Umbrella")&&(O=50),l.moveBP=O;break;case"Terrain Pulse":O=r.bp*(s.terrain?2:1),l.moveBP=O;break;case"Fling":O=ne.getFlingPower(t.item),l.moveBP=O,l.attackerItem=t.item;break;case"Eruption":case"Water Spout":O=Math.max(1,Math.floor(150*t.curHP()/t.maxHP())),l.moveBP=O;break;case"Flail":case"Reversal":var z=Math.floor(48*t.curHP()/t.maxHP());O=z<=1?200:z<=4?150:z<=9?100:z<=16?80:z<=32?40:20,l.moveBP=O;break;case"Nature Power":O=s.terrain&&s.hasTerrain("Electric","Grassy","Psychic")?90:s.hasTerrain("Misty")?95:80;break;case"Water Shuriken":O=t.named("Greninja-Ash")&&t.hasAbility("Battle Bond")?20:15,l.moveBP=O;break;case"Triple Axel":O=2===r.hits?30:3===r.hits?40:20,l.moveBP=O;break;case"Lash Out":O=r.bp*(Q.countBoosts(a,t.boosts)<0?2:1),l.moveBP=O;break;case"Crush Grip":case"Wring Out":O=100*Math.floor(4096*i.curHP()/i.maxHP()),O=Math.floor(Math.floor((120*O+2048-1)/4096)/100)||1,l.moveBP=O;break;default:O=r.bp}if(0===O)return h;var K=[];8===a.num&&t.hasAbility("Technician")&&O<=60&&(K.push(6144),l.attackerAbility=t.ability);var Z=r.type+" Aura",j=t.hasAbility(Z),_=i.hasAbility(Z),Y=j||_,q=t.hasAbility("Aura Break")||i.hasAbility("Aura Break");Y&&q&&(K.push(3072),l.attackerAbility=t.ability,l.defenderAbility=i.ability),t.hasAbility("Rivalry")&&![t.gender,i.gender].includes("N")&&(t.gender===i.gender?(K.push(3072),l.rivalry="buffed"):(K.push(3277),l.rivalry="nerfed"),l.attackerAbility=t.ability),r.isZ||r.isMax||!(b||g||S||v||A)?(t.hasAbility("Reckless")&&(r.recoil||r.hasCrashDamage)||t.hasAbility("Iron Fist")&&r.flags.punch)&&(K.push(4915),l.attackerAbility=t.ability):(K.push(4915),l.attackerAbility=t.ability),s.attackerSide.isBattery&&"Special"===r.category&&(K.push(5325),l.isBattery=!0);var X=t.hasAbility("Analytic")&&("first"!==E||"out"===s.defenderSide.isSwitching);if(t.hasAbility("Sheer Force")&&r.secondaries&&!r.isMax?(K.push(5325),l.attackerAbility=t.ability):t.hasAbility("Sand Force")&&s.hasWeather("Sand")&&r.hasType("Rock","Ground","Steel")?(K.push(5325),l.attackerAbility=t.ability,l.weather=s.weather):(X||t.hasAbility("Tough Claws")&&r.flags.contact)&&(K.push(5325),l.attackerAbility=t.ability),Y&&!q&&(K.push(5448),j&&(l.attackerAbility=t.ability),_&&(l.defenderAbility=i.ability)),t.hasAbility("Steely Spirit")&&r.hasType("Steel")&&(K.push(6144),l.attackerAbility=t.ability),7===a.num){var $=Q.pokeRound(O*Q.chainMods(K)/4096);t.hasAbility("Technician")&&$<=60&&(K.push(6144),l.attackerAbility=t.ability)}(t.hasAbility("Flare Boost")&&t.hasStatus("brn")&&"Special"===r.category||t.hasAbility("Toxic Boost")&&t.hasStatus("psn","tox")&&"Physical"===r.category||t.hasAbility("Mega Launcher")&&r.flags.pulse||t.hasAbility("Strong Jaw")&&r.flags.bite)&&(K.push(6144),l.attackerAbility=t.ability),i.hasAbility("Heatproof")&&r.hasType("Fire")?(K.push(2048),l.defenderAbility=i.ability):i.hasAbility("Dry Skin")&&r.hasType("Fire")&&(K.push(5120),l.defenderAbility=i.ability),t.item&&r.hasType(ne.getItemBoostType(t.item))?(K.push(4915),l.attackerItem=t.item):t.hasItem("Muscle Band")&&"Physical"===r.category||t.hasItem("Wise Glasses")&&"Special"===r.category?(K.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")||t.hasItem("Soul Dew")&&t.named("Latios","Latias","Latios-Mega","Latias-Mega")&&r.hasType("Psychic","Dragon")?(K.push(4915),l.attackerItem=t.item):t.hasItem(r.type+" Gem")&&(K.push(5325),l.attackerItem=t.item),r.named("Solar Beam","Solar Blade")&&s.hasWeather("Rain","Heavy Rain","Sand","Hail")?(K.push(2048),l.moveBP=O/2,l.weather=s.weather):r.named("Knock Off")&&!F&&(K.push(6144),l.moveBP=1.5*O),s.attackerSide.isHelpingHand&&(K.push(6144),l.isHelpingHand=!0),(r.named("Facade")&&t.hasStatus("brn","par","psn","tox")||r.named("Brine")&&i.curHP()<=i.maxHP()/2||r.named("Venoshock")&&i.hasStatus("psn","tox"))&&(K.push(8192),l.moveBP=2*O);var ee,ae=a.num>7?5325:6144;Q.isGrounded(t,s)&&(s.hasTerrain("Electric")&&r.hasType("Electric")||s.hasTerrain("Grassy")&&r.hasType("Grass")||s.hasTerrain("Psychic")&&r.hasType("Psychic"))&&(K.push(ae),l.terrain=s.terrain),Q.isGrounded(i,s)&&(s.hasTerrain("Misty")&&r.hasType("Dragon")||s.hasTerrain("Grassy")&&r.named("Bulldoze","Earthquake"))&&(K.push(2048),l.terrain=s.terrain),r.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")&&(l.moveBP=r.bp),O=Q.OF16(Math.max(1,Q.pokeRound(O*Q.chainMods(K)/4096)));var te=r.named("Foul Play")?i:t;r.named("Photon Geyser","Light That Burns The Sky")&&(r.category=te.stats.atk>te.stats.spa?"Physical":"Special");var ie=r.named("Shell Side Arm")&&"Physical"===Q.getShellSideArmCategory(t,i)?"atk":r.named("Body Press")?"def":"Special"===r.category?"spa":"atk";l.attackEVs=r.named("Foul Play")?Q.getEVDescriptionText(a,i,ie,i.nature):Q.getEVDescriptionText(a,t,ie,t.nature),0===te.boosts[ie]||m&&te.boosts[ie]<0?ee=te.rawStats[ie]:i.hasAbility("Unaware")?(ee=te.rawStats[ie],l.defenderAbility=i.ability):(ee=te.stats[ie],l.attackBoost=te.boosts[ie]),t.hasAbility("Hustle")&&"Physical"===r.category&&(ee=Q.pokeRound(3*ee/2),l.attackerAbility=t.ability);var re,se=[];t.hasAbility("Slow Start")&&t.abilityOn&&("Physical"===r.category||"Special"===r.category&&r.isZ)||t.hasAbility("Defeatist")&&t.curHP()<=t.maxHP()/2?(se.push(2048),l.attackerAbility=t.ability):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||t.hasAbility("Gorilla Tactics")&&"Physical"===r.category&&!t.isDynamaxed?(se.push(6144),l.attackerAbility=t.ability,l.weather=s.weather):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")?(se.push(6144),l.attackerAbility=t.ability):t.hasAbility("Flash Fire")&&t.abilityOn&&r.hasType("Fire")?(se.push(6144),l.attackerAbility="Flash Fire"):t.hasAbility("Steelworker")&&r.hasType("Steel")?(se.push(6144),l.attackerAbility=t.ability):(t.hasAbility("Stakeout")&&t.abilityOn||t.hasAbility("Water Bubble")&&r.hasType("Water")||t.hasAbility("Huge Power","Pure Power")&&"Physical"===r.category)&&(se.push(8192),l.attackerAbility=t.ability),(i.hasAbility("Thick Fat")&&r.hasType("Fire","Ice")||i.hasAbility("Water Bubble")&&r.hasType("Fire"))&&(se.push(2048),l.defenderAbility=i.ability),r.named("Pursuit")&&"out"===s.defenderSide.isSwitching&&(t.hasAbility("Technician")?se.push(4096):(se.push(8192),l.isSwitching="out")),t.hasItem("Thick Club")&&t.named("Cubone","Marowak","Marowak-Alola","Marowak-Alola-Totem")&&"Physical"===r.category||t.hasItem("Deep Sea Tooth")&&t.named("Clamperl")&&"Special"===r.category||t.hasItem("Light Ball")&&t.named("Pikachu")&&!r.isZ?(se.push(8192),l.attackerItem=t.item):r.isZ||r.isMax||!(t.hasItem("Choice Band")&&"Physical"===r.category||t.hasItem("Choice Specs")&&"Special"===r.category)||(se.push(6144),l.attackerItem=t.item),ee=Q.OF16(Math.max(1,Q.pokeRound(ee*Q.chainMods(se)/4096)));var oe="Physical"===r.defensiveCategory||r.named("Shell Side Arm")&&"Physical"===Q.getShellSideArmCategory(t,i),le=oe?"def":"spd";l.defenseEVs=Q.getEVDescriptionText(a,i,le,i.nature),0===i.boosts[le]||m&&i.boosts[le]>0||r.ignoreDefensive?re=i.rawStats[le]:t.hasAbility("Unaware")?(re=i.rawStats[le],l.attackerAbility=t.ability):(re=i.stats[le],l.defenseBoost=i.boosts[le]),s.hasWeather("Sand")&&i.hasType("Rock")&&!oe&&(re=Q.pokeRound(3*re/2),l.weather=s.weather);var he=[];i.hasAbility("Marvel Scale")&&i.status&&oe?(he.push(6144),l.defenderAbility=i.ability):i.named("Cherrim")&&i.hasAbility("Flower Gift")&&s.hasWeather("Sun","Harsh Sunshine")&&!oe?(he.push(6144),l.defenderAbility=i.ability,l.weather=s.weather):i.hasAbility("Grass Pelt")&&s.hasTerrain("Grassy")&&oe?(he.push(6144),l.defenderAbility=i.ability):i.hasAbility("Fur Coat")&&oe&&(he.push(8192),l.defenderAbility=i.ability),i.hasItem("Eviolite")&&(null===(o=a.species.get(n.toID(i.name)))||void 0===o?void 0:o.nfe)||!oe&&i.hasItem("Assault Vest")?(he.push(6144),l.defenderItem=i.item):(i.hasItem("Metal Powder")&&i.named("Ditto")&&oe||i.hasItem("Deep Sea Scale")&&i.named("Clamperl")&&!oe)&&(he.push(8192),l.defenderItem=i.item),re=Q.OF16(Math.max(1,Q.pokeRound(re*Q.chainMods(he)/4096)));var ce=Q.getBaseDamage(t.level,O,ee,re),de="Singles"!==s.gameType&&["allAdjacent","allAdjacentFoes"].includes(r.target);de&&(ce=Q.pokeRound(Q.OF32(3072*ce)/4096)),t.hasAbility("Parental Bond (Child)")&&(ce=Q.pokeRound(Q.OF32(1024*ce)/4096));var ue=i.hasItem("Utility Umbrella");if(!ue&&s.hasWeather("Sun","Harsh Sunshine")&&r.hasType("Fire")||s.hasWeather("Rain","Heavy Rain")&&r.hasType("Water"))ce=Q.pokeRound(Q.OF32(6144*ce)/4096),l.weather=s.weather;else if(!ue&&s.hasWeather("Sun")&&r.hasType("Water")||s.hasWeather("Rain")&&r.hasType("Fire"))ce=Q.pokeRound(Q.OF32(2048*ce)/4096),l.weather=s.weather;else if(!ue&&s.hasWeather("Harsh Sunshine")&&r.hasType("Water")||s.hasWeather("Heavy Rain")&&r.hasType("Fire"))return h;i.hasItem("Electric Seed","Misty Seed","Grassy Seed","Psychic Seed")&&s.hasTerrain(i.item.substring(0,i.item.indexOf(" ")))&&ne.SEED_BOOSTED_STAT[i.item]===le&&(l.defenderItem=i.item),m&&(ce=Math.floor(Q.OF32(1.5*ce)),l.isCritical=m);var ye=4096;t.hasType(r.type)?t.hasAbility("Adaptability")?(ye=8192,l.attackerAbility=t.ability):ye=6144:t.hasAbility("Protean","Libero")&&(ye=6144,l.attackerAbility=t.ability);var me=t.hasStatus("brn")&&"Physical"===r.category&&!t.hasAbility("Guts")&&!r.named("Facade");l.isBurned=me;var pe=[];if(!s.defenderSide.isReflect||"Physical"!==r.category||m||s.defenderSide.isAuroraVeil?!s.defenderSide.isLightScreen||"Special"!==r.category||m||s.defenderSide.isAuroraVeil||(pe.push("Singles"!==s.gameType?2732:2048),l.isLightScreen=!0):(pe.push("Singles"!==s.gameType?2732:2048),l.isReflect=!0),s.defenderSide.isAuroraVeil&&!m&&(pe.push("Singles"!==s.gameType?2732:2048),l.isAuroraVeil=!0),t.hasAbility("Neuroforce")&&x>1?(K.push(5120),l.attackerAbility=t.ability):t.hasAbility("Sniper")&&m?(pe.push(6144),l.attackerAbility=t.ability):t.hasAbility("Tinted Lens")&&x<1&&(pe.push(8192),l.attackerAbility=t.ability),i.isDynamaxed&&r.named("Dynamax Cannon","Behemoth Blade","Behemoth Bash")&&pe.push(8192),!i.hasAbility("Multiscale","Shadow Shield")||i.curHP()!==i.maxHP()||s.defenderSide.isSR||s.defenderSide.spikes&&!i.hasType("Flying")||t.hasAbility("Parental Bond (Child)")||(pe.push(2048),l.defenderAbility=i.ability),(i.hasAbility("Fluffy")&&r.flags.contact&&!t.hasAbility("Long Reach")||i.hasAbility("Punk Rock")&&r.flags.sound||i.hasAbility("Ice Scales")&&"Special"===r.category)&&(pe.push(2048),l.defenderAbility=i.ability),r.flags.sound&&t.hasAbility("Punk Rock")&&(pe.push(5325),l.attackerAbility=t.ability),i.hasAbility("Solid Rock","Filter","Prism Armor")&&x>1&&(pe.push(3072),l.defenderAbility=i.ability),s.defenderSide.isFriendGuard&&(pe.push(3072),l.isFriendGuard=!0),i.hasAbility("Fluffy")&&r.hasType("Fire")&&(pe.push(8192),l.defenderAbility=i.ability),t.hasItem("Expert Belt")&&x>1&&!r.isZ)pe.push(4915),l.attackerItem=t.item;else if(t.hasItem("Life Orb"))pe.push(5324),l.attackerItem=t.item;else if(t.hasItem("Metronome")&&r.timesUsedWithMetronome>=1){var fe=Math.floor(r.timesUsedWithMetronome);fe<=4?pe.push(4096+819*fe):pe.push(8192),l.attackerItem=t.item}r.hasType(ne.getBerryResistType(i.item))&&(x>1||r.hasType("Normal"))&&!t.hasAbility("Unnerve")&&(pe.push(2048),l.defenderItem=i.item);var be=!1;s.defenderSide.isProtected&&(t.isDynamaxed||r.isZ&&t.item&&t.item.includes(" Z"))&&(be=!0,l.isProtected=!0);var ge,Se=Q.chainMods(pe);if(t.hasAbility("Parental Bond")&&1===r.hits&&!de){var ve=t.clone();ve.ability="Parental Bond (Child)",Q.checkMultihitBoost(a,ve,i,r,s,l),ge=e(a,ve,i,r,s).damage,l.attackerAbility=t.ability}for(var ke=[],Ae=0;Ae<16;Ae++)ke[Ae]=Q.getFinalDamage(ce,Ae,x,me,ye,Se,be);if(r.dropsStats&&r.timesUsed>1){var Pe=t.hasAbility("Simple")?2:1;l.moveTurns="over "+r.timesUsed+" turns";for(var Me=t.hasItem("White Herb"),Te=!1,we=t.boosts[ie],Be=function(e){var a=Q.getModifiedStat(ee,we),i=0;ke=ke.map((function(r){if(e){var s=Q.getBaseDamage(t.level,O,a,re),o=Q.getFinalDamage(s,i,x,me,ye,Se,be);return i++,r+o}return r})),t.hasAbility("Contrary")?(we=Math.min(6,we+r.dropsStats),l.attackerAbility=t.ability):(we=Math.max(-6,we-r.dropsStats*Pe),t.hasAbility("Simple")&&(l.attackerAbility=t.ability)),Me&&t.boosts[ie]<0&&!Te&&(we+=r.dropsStats*Pe,Te=!0,l.attackerItem=t.item)},xe=0;xe<r.timesUsed;xe++)Be(xe)}return l.attackBoost=r.named("Foul Play")?i.boosts[ie]:t.boosts[ie],h.damage=ge?[ke,ge]:ke,h},e.calculateBWXY=function e(a,t,i,r,s){var o;Q.checkAirLock(t,s),Q.checkAirLock(i,s),Q.checkForecast(t,s.weather),Q.checkForecast(i,s.weather),Q.checkKlutz(t),Q.checkKlutz(i),Q.checkSeedBoost(t,s),Q.checkSeedBoost(i,s),Q.computeFinalStats(a,t,i,s,"def","spd","spe"),Q.checkIntimidate(a,t,i),Q.checkIntimidate(a,i,t),Q.checkDownload(t,i),Q.checkDownload(i,t),Q.computeFinalStats(a,t,i,s,"atk","spa"),Q.checkInfiltrator(t,s.defenderSide),Q.checkInfiltrator(i,s.attackerSide);var l={attackerName:t.name,moveName:r.name,defenderName:i.name},h=new J.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=ne.getItemBoostType(t.item);else if(r.named("Techno Blast")&&t.item&&t.item.includes("Drive"))r.type=ne.getTechnoBlast(t.item);else if(r.named("Natural Gift")&&t.item&&t.item.includes("Berry")){var d=ne.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")&&(r.type=s.hasTerrain("Electric")?"Electric":s.hasTerrain("Grassy")?"Grass":s.hasTerrain("Misty")?"Fairy":s.hasTerrain("Psychic")?"Psychic":"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=Q.getMoveEffectiveness(a,r,i.types[0],g,s.isGravity),v=i.types[1]?Q.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(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&&i.hasItem("Ring Target")){var M=a.types.get(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(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.hasAbility("Levitate")||r.flags.bullet&&i.hasAbility("Bulletproof")||r.flags.sound&&i.hasAbility("Soundproof"))return l.defenderAbility=i.ability,h;if(s.hasWeather("Strong Winds")&&i.hasType("Flying")&&a.types.get(n.toID(r.type)).effectiveness.Flying>1&&(k/=2,l.weather=s.weather),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")&&Q.isGrounded(i,s))return l.terrain=s.terrain,h;l.HPEVs=i.evs.hp+" HP";var T=Q.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="last"===B?100:50,l.moveBP=w;break;case"Electro Ball":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":w=Math.min(150,Math.floor(25*i.stats.spe/t.stats.spe)),l.moveBP=w;break;case"Punishment":w=Math.min(200,60+20*Q.countBoosts(a,i.boosts)),l.moveBP=w;break;case"Low Kick":case"Grass Knot":var F=i.weightkg*Q.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*Q.getWeightFactor(t)/(i.weightkg*Q.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*Q.countBoosts(a,t.boosts),l.moveBP=w;break;case"Acrobatics":w=t.hasItem("Flying Gem")||!t.item?110:55,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"Weather Ball":w=s.weather&&!s.hasWeather("Strong Winds")?100:50,l.moveBP=w;break;case"Fling":w=ne.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 R=Math.floor(48*t.curHP()/t.maxHP());w=R<=1?200:R<=4?150:R<=9?100:R<=16?80:R<=32?40:20,l.moveBP=w;break;case"Nature Power":w=s.terrain&&s.hasTerrain("Electric","Grassy","Psychic")?90:s.hasTerrain("Misty")?95:80;break;case"Water Shuriken":w=t.named("Greninja-Ash")&&t.hasAbility("Battle Bond")?20:15,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 I=[];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?(I.push(6144),l.attackerAbility=t.ability):t.hasAbility("Analytic")&&"first"!==B?(I.push(5325),l.attackerAbility=t.ability):t.hasAbility("Sand Force")&&s.hasWeather("Sand")&&r.hasType("Rock","Ground","Steel")?(I.push(5325),l.attackerAbility=t.ability,l.weather=s.weather):(t.hasAbility("Reckless")&&(r.recoil||r.hasCrashDamage)||t.hasAbility("Iron Fist")&&r.flags.punch)&&(I.push(4915),l.attackerAbility=t.ability),i.hasAbility("Heatproof")&&r.hasType("Fire")?(I.push(2048),l.defenderAbility=i.ability):i.hasAbility("Dry Skin")&&r.hasType("Fire")&&(I.push(5120),l.defenderAbility=i.ability),t.hasAbility("Sheer Force")&&r.secondaries&&(I.push(5325),l.attackerAbility=t.ability),t.hasAbility("Rivalry")&&![t.gender,i.gender].includes("N")&&(t.gender===i.gender?(I.push(5120),l.rivalry="buffed"):(I.push(3277),l.rivalry="nerfed"),l.attackerAbility=t.ability),t.item&&ne.getItemBoostType(t.item)===r.type?(I.push(4915),l.attackerItem=t.item):t.hasItem("Muscle Band")&&"Physical"===r.category||t.hasItem("Wise Glasses")&&"Special"===r.category?(I.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")?(I.push(4915),l.attackerItem=t.item):t.hasItem(r.type+" Gem")&&(I.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")?(I.push(8192),l.moveBP=2*w):r.named("Solar Beam")&&s.hasWeather("Rain","Heavy Rain","Sand","Hail")?(I.push(2048),l.moveBP=w/2,l.weather=s.weather):a.num>5&&r.named("Knock Off")&&!A&&(I.push(6144),l.moveBP=1.5*w),s.attackerSide.isHelpingHand&&(I.push(6144),l.isHelpingHand=!0),s.attackerSide.isBattery&&"Special"===r.category&&(I.push(5324),l.isBattery=!0),u||y||m||p?(I.push(5325),l.attackerAbility=t.ability):t.hasAbility("Mega Launcher")&&r.flags.pulse||t.hasAbility("Strong Jaw")&&r.flags.bite?(I.push(6144),l.attackerAbility=t.ability):t.hasAbility("Tough Claws")&&r.flags.contact&&(I.push(5325),l.attackerAbility=t.ability);var H,D=r.type+" Aura",W=t.hasAbility(D),C=i.hasAbility(D);(W||C)&&(t.hasAbility("Aura Break")||i.hasAbility("Aura Break")?(I.push(3072),l.attackerAbility=t.ability,l.defenderAbility=i.ability):(I.push(5447),W&&(l.attackerAbility=t.ability),C&&(l.defenderAbility=i.ability))),Q.isGrounded(t,s)&&(s.hasTerrain("Electric")&&r.hasType("Electric")||s.hasTerrain("Grassy")&&r.hasType("Grass")||s.hasTerrain("Psychic")&&r.hasType("Psychic"))&&(I.push(6144),l.terrain=s.terrain),Q.isGrounded(i,s)&&(s.hasTerrain("Misty")&&r.hasType("Dragon")||s.hasTerrain("Grassy")&&r.named("Bulldoze","Earthquake"))&&(I.push(2048),l.terrain=s.terrain),w=Q.OF16(Math.max(1,Q.pokeRound(w*Q.chainMods(I)/4096)));var O=r.named("Foul Play")?i:t,E="Special"===r.category?"spa":"atk";l.attackEVs=r.named("Foul Play")?Q.getEVDescriptionText(a,i,E,i.nature):Q.getEVDescriptionText(a,t,E,t.nature),0===O.boosts[E]||c&&O.boosts[E]<0?H=O.rawStats[E]:i.hasAbility("Unaware")?(H=O.rawStats[E],l.defenderAbility=i.ability):(H=O.stats[E],l.attackBoost=O.boosts[E]),t.hasAbility("Hustle")&&"Physical"===r.category&&(H=Q.pokeRound(3*H/2),l.attackerAbility=t.ability);var L,V=[];i.hasAbility("Thick Fat")&&r.hasType("Fire","Ice")&&(V.push(2048),l.defenderAbility=i.ability),r.named("Pursuit")&&"out"===s.defenderSide.isSwitching&&(t.hasAbility("Technician")?V.push(4096):(V.push(8192),l.isSwitching="out")),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")?(V.push(6144),l.attackerAbility=t.ability):t.hasAbility("Flash Fire")&&t.abilityOn&&r.hasType("Fire")?(V.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?(V.push(6144),l.attackerAbility=t.ability,l.weather=s.weather):t.hasAbility("Defeatist")&&t.curHP()<=t.maxHP()/2||t.hasAbility("Slow Start")&&t.abilityOn&&"Physical"===r.category?(V.push(2048),l.attackerAbility=t.ability):t.hasAbility("Huge Power","Pure Power")&&"Physical"===r.category&&(V.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.named("Pikachu")&&!r.isZ?(V.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)&&(V.push(6144),l.attackerItem=t.item),H=Q.OF16(Math.max(1,Q.pokeRound(H*Q.chainMods(V)/4096)));var N="Physical"===r.defensiveCategory,U=N?"def":"spd";l.defenseEVs=Q.getEVDescriptionText(a,i,U,i.nature),0===i.boosts[U]||c&&i.boosts[U]>0||r.ignoreDefensive?L=i.rawStats[U]:t.hasAbility("Unaware")?(L=i.rawStats[U],l.attackerAbility=t.ability):(L=i.stats[U],l.defenseBoost=i.boosts[U]),s.hasWeather("Sand")&&i.hasType("Rock")&&!N&&(L=Q.pokeRound(3*L/2),l.weather=s.weather);var z=[];i.hasAbility("Marvel Scale")&&i.status&&N?(z.push(6144),l.defenderAbility=i.ability):i.named("Cherrim")&&i.hasAbility("Flower Gift")&&s.hasWeather("Sun","Harsh Sunshine")&&!N&&(z.push(6144),l.defenderAbility=i.ability,l.weather=s.weather),s.hasTerrain("Grassy")&&i.hasAbility("Grass Pelt")&&N&&(z.push(6144),l.defenderAbility=i.ability),(!N&&i.hasItem("Soul Dew")&&i.named("Latios","Latias","Latios-Mega","Latias-Mega")||i.hasItem("Eviolite")&&(null===(o=a.species.get(n.toID(i.name)))||void 0===o?void 0:o.nfe)||!N&&i.hasItem("Assault Vest"))&&(z.push(6144),l.defenderItem=i.item),(i.hasItem("Metal Powder")&&i.named("Ditto")&&N||i.hasItem("Deep Sea Scale")&&i.named("Clamperl")&&!N)&&(z.push(8192),l.defenderItem=i.item),i.hasAbility("Fur Coat")&&N&&(z.push(8192),l.defenderAbility=i.ability),L=Q.OF16(Math.max(1,Q.pokeRound(L*Q.chainMods(z)/4096)));var K=Q.getBaseDamage(t.level,w,H,L),Z="Singles"!==s.gameType&&["allAdjacent","allAdjacentFoes"].includes(r.target);if(Z&&(K=Q.pokeRound(Q.OF32(3072*K)/4096)),t.hasAbility("Parental Bond (Child)")&&(K=Q.pokeRound(Q.OF32(2048*K)/4096)),s.hasWeather("Sun","Harsh Sunshine")&&r.hasType("Fire")||s.hasWeather("Rain","Heavy Rain")&&r.hasType("Water"))K=Q.pokeRound(Q.OF32(6144*K)/4096),l.weather=s.weather;else if(s.hasWeather("Sun")&&r.hasType("Water")||s.hasWeather("Rain")&&r.hasType("Fire"))K=Q.pokeRound(Q.OF32(2048*K)/4096),l.weather=s.weather;else if(s.hasWeather("Harsh Sunshine")&&r.hasType("Water")||s.hasWeather("Heavy Rain")&&r.hasType("Fire"))return h;c&&(K=Math.floor(Q.OF32(K*(a.num>5?1.5:2))),l.isCritical=c);var j=4096;t.hasType(r.type)?t.hasAbility("Adaptability")?(j=8192,l.attackerAbility=t.ability):j=6144:t.hasAbility("Protean")&&(j=6144,l.attackerAbility=t.ability);var _=t.hasStatus("brn")&&"Physical"===r.category&&!t.hasAbility("Guts")&&!(r.named("Facade")&&6===a.num);l.isBurned=_;var Y=[];if(s.defenderSide.isReflect&&"Physical"===r.category&&!c?(Y.push("Singles"!==s.gameType?a.num>5?2732:2703:2048),l.isReflect=!0):s.defenderSide.isLightScreen&&"Special"===r.category&&!c&&(Y.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)")||(Y.push(2048),l.defenderAbility=i.ability),t.hasAbility("Tinted Lens")&&k<1&&(Y.push(8192),l.attackerAbility=t.ability),s.defenderSide.isFriendGuard&&(Y.push(3072),l.isFriendGuard=!0),t.hasAbility("Sniper")&&c&&(Y.push(6144),l.attackerAbility=t.ability),i.hasAbility("Solid Rock","Filter")&&k>1&&(Y.push(3072),l.defenderAbility=i.ability),t.hasItem("Metronome")&&r.timesUsedWithMetronome>=1){var q=Math.floor(r.timesUsedWithMetronome);q<=4?Y.push(4096+819*q):Y.push(8192),l.attackerItem=t.item}t.hasItem("Expert Belt")&&k>1&&!r.isZ?(Y.push(4915),l.attackerItem=t.item):t.hasItem("Life Orb")&&(Y.push(5324),l.attackerItem=t.item),r.hasType(ne.getBerryResistType(i.item))&&(k>1||r.hasType("Normal"))&&!t.hasAbility("Unnerve")&&(Y.push(2048),l.defenderItem=i.item),s.defenderSide.isProtected&&r.isZ&&t.item&&t.item.includes(" Z")&&(Y.push(1024),l.isProtected=!0);var X,$=Q.chainMods(Y);if(t.hasAbility("Parental Bond")&&1===r.hits&&!Z){var ee=t.clone();ee.ability="Parental Bond (Child)",Q.checkMultihitBoost(a,ee,i,r,s,l),X=e(a,ee,i,r,s).damage,l.attackerAbility=t.ability}for(var ae=[],te=0;te<16;te++)ae[te]=Q.getFinalDamage(K,te,k,_,j,$);if(r.dropsStats&&(r.timesUsed||0)>1){var ie=t.hasAbility("Simple")?2:1;l.moveTurns="over "+r.timesUsed+" turns";for(var re=t.hasItem("White Herb"),se=!1,oe=t.boosts[E],le=function(e){var a=Q.getModifiedStat(H,oe),i=0;ae=ae.map((function(r){if(e){var s=Q.getBaseDamage(t.level,w,a,L),o=Q.getFinalDamage(s,i,k,_,j,$);return i++,r+o}return r})),t.hasAbility("Contrary")?(oe=Math.min(6,oe+r.dropsStats),l.attackerAbility=t.ability):(oe=Math.max(-6,oe-r.dropsStats*ie),t.hasAbility("Simple")&&(l.attackerAbility=t.ability)),re&&t.boosts[E]<0&&!se&&(oe+=r.dropsStats*ie,se=!0,l.attackerItem=t.item)},he=0;he<r.timesUsed;he++)le(he)}return l.attackBoost=r.named("Foul Play")?i.boosts[E]:t.boosts[E],h.damage=X?[ae,X]:ae,h},e.calculateDPP=function(e,a,t,i,r){n.checkAirLock(a,r),n.checkAirLock(t,r),n.checkForecast(a,r.weather),n.checkForecast(t,r.weather),n.checkKlutz(a),n.checkKlutz(t),n.checkIntimidate(e,a,t),n.checkIntimidate(e,t,a),n.checkDownload(a,t),n.checkDownload(t,a),a.stats.spe=n.getFinalSpeed(e,a,r,r.attackerSide),t.stats.spe=n.getFinalSpeed(e,t,r,r.defenderSide);var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new J.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=ne.getItemBoostType(a.item);else if(i.named("Natural Gift")&&a.item&&a.item.includes("Berry")){var c=ne.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=n.getMoveEffectiveness(e,i,t.types[0],d,r.isGravity),y=t.types[1]?n.getMoveEffectiveness(e,i,t.types[1],d,r.isGravity):1,m=u*y;if(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.hasAbility("Levitate")||i.flags.sound&&t.hasAbility("Soundproof"))return s.defenderAbility=t.ability,o;s.HPEVs=t.evs.hp+" HP";var p=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(48*a.curHP()/a.maxHP());h=b<=1?200:b<=4?150:b<=9?100:b<=16?80:b<=32?40:20,s.moveBP=h;break;case"Fling":h=ne.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":var S=n.countBoosts(e,t.boosts);S>0&&(h=Math.min(200,h+20*S),s.moveBP=h);break;case"Wake-Up Slap":t.hasStatus("slp")&&(h*=2,s.moveBP=h);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 v="Physical"===i.category;a.hasItem("Muscle Band")&&v||a.hasItem("Wise Glasses")&&!v?(h=Math.floor(1.1*h),s.attackerItem=a.item):(i.hasType(ne.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 k,A=v?"atk":"spa";s.attackEVs=n.getEVDescriptionText(e,a,A,a.nature);var P=a.boosts[A],M=a.rawStats[A];0===P||l&&P<0?k=M:t.hasAbility("Unaware")?(k=M,s.defenderAbility=t.ability):a.hasAbility("Simple")?(k=le(M,P),s.attackerAbility=a.ability,s.attackBoost=P):(k=n.getModifiedStat(M,P),s.attackBoost=P),v&&a.hasAbility("Pure Power","Huge Power")?(k*=2,s.attackerAbility=a.ability):r.hasWeather("Sun")&&a.hasAbility(v?"Flower Gift":"Solar Power")?(k=Math.floor(1.5*k),s.attackerAbility=a.ability,s.weather=r.weather):v&&(a.hasAbility("Hustle")||a.hasAbility("Guts")&&a.status)||!v&&a.abilityOn&&a.hasAbility("Plus","Minus")?(k=Math.floor(1.5*k),s.attackerAbility=a.ability):v&&a.hasAbility("Slow Start")&&a.abilityOn&&(k=Math.floor(k/2),s.attackerAbility=a.ability),(v?a.hasItem("Choice Band"):a.hasItem("Choice Specs"))||!v&&a.hasItem("Soul Dew")&&a.named("Latios","Latias")?(k=Math.floor(1.5*k),s.attackerItem=a.item):(a.hasItem("Light Ball")&&a.named("Pikachu")||a.hasItem("Thick Club")&&a.named("Cubone","Marowak")&&v||a.hasItem("Deep Sea Tooth")&&a.named("Clamperl")&&!v)&&(k*=2,s.attackerItem=a.item);var T,w=v?"def":"spd";s.defenseEVs=n.getEVDescriptionText(e,t,w,t.nature);var B=t.boosts[w],x=t.rawStats[w];0===B||l&&B>0?T=x:a.hasAbility("Unaware")?(T=x,s.attackerAbility=a.ability):t.hasAbility("Simple")?(T=le(x,B),s.defenderAbility=t.ability,s.defenseBoost=B):(T=n.getModifiedStat(x,B),s.defenseBoost=B),t.hasAbility("Marvel Scale")&&t.status&&v?(T=Math.floor(1.5*T),s.defenderAbility=t.ability):t.hasAbility("Flower Gift")&&r.hasWeather("Sun")&&!v&&(T=Math.floor(1.5*T),s.defenderAbility=t.ability,s.weather=r.weather),t.hasItem("Soul Dew")&&t.named("Latios","Latias")&&!v?(T=Math.floor(1.5*T),s.defenderItem=t.item):(t.hasItem("Deep Sea Scale")&&t.named("Clamperl")&&!v||t.hasItem("Metal Powder")&&t.named("Ditto")&&v)&&(T*=2,s.defenderItem=t.item),r.hasWeather("Sand")&&t.hasType("Rock")&&!v&&(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 F=Math.floor(Math.floor(Math.floor(2*a.level/5+2)*h*k/50)/T);if(a.hasStatus("brn")&&v&&!a.hasAbility("Guts")&&(F=Math.floor(.5*F),s.isBurned=!0),!l){var G="Singles"!==r.gameType?2/3:.5;v&&r.defenderSide.isReflect?(F=Math.floor(F*G),s.isReflect=!0):!v&&r.defenderSide.isLightScreen&&(F=Math.floor(F*G),s.isLightScreen=!0)}"Singles"!==r.gameType&&["allAdjacent","allAdjacentFoes"].includes(i.target)&&(F=Math.floor(3*F/4)),r.hasWeather("Sun")&&i.hasType("Fire")||r.hasWeather("Rain")&&i.hasType("Water")?(F=Math.floor(1.5*F),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"))&&(F=Math.floor(.5*F),s.weather=r.weather),a.hasAbility("Flash Fire")&&a.abilityOn&&i.hasType("Fire")&&(F=Math.floor(1.5*F),s.attackerAbility="Flash Fire"),F+=2,l&&(a.hasAbility("Sniper")?(F*=3,s.attackerAbility=a.ability):F*=2,s.isCritical=l),a.hasItem("Life Orb")&&(F=Math.floor(1.3*F),s.attackerItem=a.item),i.named("Pursuit")&&"out"===r.defenderSide.isSwitching&&(a.hasAbility("Technician")?F=Math.floor(1*F):(F=Math.floor(2*F),s.isSwitching="out"));var R=1;i.hasType.apply(i,V(a.types))&&(a.hasAbility("Adaptability")?(R=2,s.attackerAbility=a.ability):R=1.5);var I=1;t.hasAbility("Filter","Solid Rock")&&m>1&&(I=.75,s.defenderAbility=t.ability);var H=1;a.hasItem("Expert Belt")&&m>1&&(H=1.2,s.attackerItem=a.item);var D=1;a.hasAbility("Tinted Lens")&&m<1&&(D=2,s.attackerAbility=a.ability);var W=1;i.hasType(ne.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(F*(85+O)/100),C[O]=Math.floor(C[O]*R),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]*H),C[O]=Math.floor(C[O]*D),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){Q.checkAirLock(a,r),Q.checkAirLock(t,r),Q.checkForecast(a,r.weather),Q.checkForecast(t,r.weather),Q.checkIntimidate(e,a,t),Q.checkIntimidate(e,t,a),a.stats.spe=Q.getFinalSpeed(e,a,r,r.attackerSide),t.stats.spe=Q.getFinalSpeed(e,t,r,r.defenderSide);var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new J.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=Q.getMoveEffectiveness(e,i,t.types[0],r.defenderSide.isForesight)*(t.types[1]?Q.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=t.evs.hp+" HP";var l,h=Q.handleFixedDamageMoves(a,i);if(h)return o.damage=h,o;switch(i.hits>1&&(s.hits=i.hits),i.name){case"Flail":case"Reversal":var c=Math.floor(48*a.curHP()/a.maxHP());l=c<=1?200:c<=4?150:c<=9?100:c<=16?80:c<=32?40:20,s.moveBP=l;break;case"Eruption":case"Water Spout":l=Math.max(1,Math.floor(150*a.curHP()/a.maxHP())),s.moveBP=l;break;case"Low Kick":var d=t.weightkg;l=d>=200?120:d>=100?100:d>=50?80:d>=25?60:d>=10?40:20,s.moveBP=l;break;default:l=i.bp}if(0===l)return o;var u="Physical"===i.category,y=u?"atk":"spa";s.attackEVs=Q.getEVDescriptionText(e,a,y,a.nature);var m=u?"def":"spd";s.defenseEVs=Q.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(ne.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"))&&(l=Math.floor(1.5*l),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=Q.getModifiedStat(p,g),s.attackBoost=g),(S<0||!b&&S>0)&&(f=Q.getModifiedStat(f,S),s.defenseBoost=S);var v=a.level,k=Math.floor(Math.floor(Math.floor(2*v/5+2)*p*l/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*l),r.attackerSide.isHelpingHand&&(k=Math.floor(1.5*k),s.isHelpingHand=!0),i.hasType.apply(i,V(a.types))&&(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){Q.computeFinalStats(e,a,t,r,"atk","def","spa","spd","spe");var s={attackerName:a.name,moveName:i.name,defenderName:t.name},o=new J.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=Q.handleFixedDamageMoves(a,i)))return o.damage=n,o;var n,l=Q.getMoveEffectiveness(e,i,t.types[0],r.defenderSide.isForesight)*(t.types[1]?Q.getMoveEffectiveness(e,i,t.types[1],r.defenderSide.isForesight):1);if(0===l)return o;if(2===e.num&&(n=Q.handleFixedDamageMoves(a,i)))return o.damage=n,o;if(i.hits>1&&(s.hits=i.hits),i.named("Flail","Reversal")){i.isCrit=!1;var h=Math.floor(48*a.curHP()/a.maxHP());i.bp=h<=1?200:h<=4?150:h<=9?100:h<=16?80:h<=32?40:20,s.moveBP=i.bp}else i.named("Present")&&!i.bp&&(i.bp=40);if(0===i.bp)return o;var c="Physical"===i.category,d=c?"atk":"spa",u=c?"def":"spd",y=a.stats[d],m=t.stats[u],p=i.isCrit&&(1===e.num||2===e.num&&a.boosts[d]<=t.boosts[u]),f=a.level;if(p?(y=a.rawStats[d],m=t.rawStats[u],1===e.num&&(f*=2,s.isCritical=!0)):(0!==a.boosts[d]&&(s.attackBoost=a.boosts[d]),0!==t.boosts[u]&&(s.defenseBoost=t.boosts[u]),c&&a.hasStatus("brn")&&(y=Math.floor(y/2),s.isBurned=!0)),i.named("Explosion","Self-Destruct")&&(m=Math.floor(m/2)),p||(c&&r.defenderSide.isReflect?(m*=2,s.isReflect=!0):!c&&r.defenderSide.isLightScreen&&(m*=2,s.isLightScreen=!0)),(a.named("Pikachu")&&a.hasItem("Light Ball")&&!c||a.named("Cubone","Marowak")&&a.hasItem("Thick Club")&&c)&&(y*=2,s.attackerItem=a.item),(y>255||m>255)&&(y=Math.floor(y/4)%256,m=Math.floor(m/4)%256),i.named("Present")){var b={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};y=10,m=Math.max(b[a.types[1]?a.types[1]:a.types[0]],1),f=Math.max(b[t.types[1]?t.types[1]:t.types[0]],1)}t.named("Ditto")&&t.hasItem("Metal Powder")&&(m=Math.floor(1.5*m),s.defenderItem=t.item);var g=Math.floor(Math.floor(Math.floor(2*f/5+2)*Math.max(1,y)*i.bp/Math.max(1,m))/50);2===e.num&&i.isCrit&&(g*=2,s.isCritical=!0),i.named("Pursuit")&&"out"===r.defenderSide.isSwitching&&(g=Math.floor(2*g),s.isSwitching="out");var S=a.hasItem("Dragon Fang")?void 0:ne.getItemBoostType(a.hasItem("Dragon Scale")?"Dragon Fang":a.item);if(i.hasType(S)&&(g=Math.floor(1.1*g),s.attackerItem=a.item),g=Math.min(997,g)+2,r.hasWeather("Sun")&&i.hasType("Fire")||r.hasWeather("Rain")&&i.hasType("Water")?(g=Math.floor(1.5*g),s.weather=r.weather):(r.hasWeather("Sun")&&i.hasType("Water")||r.hasWeather("Rain")&&(i.hasType("Fire")||i.named("Solar Beam")))&&(g=Math.floor(g/2),s.weather=r.weather),i.hasType.apply(i,V(a.types))&&(g=Math.floor(1.5*g)),g=Math.floor(g*l),i.named("Flail","Reversal"))return o.damage=g,o;o.damage=[];for(var v=217;v<=255;v++)o.damage[v-217]=Math.floor(g*v/255);return o};var he=e,ce=e,de=e,ue=e,ye=e,me=e,pe=[function(){},ce.calculateRBYGSC,ce.calculateRBYGSC,de.calculateADV,ue.calculateDPP,ye.calculateBWXY,ye.calculateBWXY,me.calculateSMSS,me.calculateSMSS];e.calculate=function(e,a,t,i,r){return pe[e.num](e,a.clone(),t.clone(),i.clone(),r?r.clone():new he.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})}();