{ "version": 3, "sources": ["../../../sim/battle-queue.ts"], "sourcesContent": ["/**\r\n * Simulator Battle Action Queue\r\n * Pokemon Showdown - http://pokemonshowdown.com/\r\n *\r\n * The action queue is the core of the battle simulation. A rough overview of\r\n * the core battle loop:\r\n *\r\n * - chosen moves/switches are added to the action queue\r\n * - the action queue is sorted in speed/priority order\r\n * - we go through the action queue\r\n * - repeat\r\n *\r\n * @license MIT\r\n */\r\n\r\nimport type {Battle} from './battle';\r\n\r\n/** A move action */\r\nexport interface MoveAction {\r\n\t/** action type */\r\n\tchoice: 'move' | 'beforeTurnMove' | 'priorityChargeMove';\r\n\torder: 3 | 5 | 200 | 201 | 199 | 106;\r\n\t/** priority of the action (lower first) */\r\n\tpriority: number;\r\n\t/** fractional priority of the action (lower first) */\r\n\tfractionalPriority: number;\r\n\t/** speed of pokemon using move (higher first if priority tie) */\r\n\tspeed: number;\r\n\t/** the pokemon doing the move */\r\n\tpokemon: Pokemon;\r\n\t/** location of the target, relative to pokemon's side */\r\n\ttargetLoc: number;\r\n\t/** original target pokemon, for target-tracking moves */\r\n\toriginalTarget: Pokemon;\r\n\t/** a move to use (move action only) */\r\n\tmoveid: ID;\r\n\t/** a move to use (move action only) */\r\n\tmove: Move;\r\n\t/** true if megaing or ultra bursting */\r\n\tmega: boolean | 'done';\r\n\t/** if zmoving, the name of the zmove */\r\n\tzmove?: string;\r\n\t/** if dynamaxed, the name of the max move */\r\n\tmaxMove?: string;\r\n\t/** effect that called the move (eg Instruct) if any */\r\n\tsourceEffect?: Effect | null;\r\n}\r\n\r\n/** A switch action */\r\nexport interface SwitchAction {\r\n\t/** action type */\r\n\tchoice: 'switch' | 'instaswitch' | 'revivalblessing';\r\n\torder: 3 | 6 | 103;\r\n\t/** priority of the action (lower first) */\r\n\tpriority: number;\r\n\t/** speed of pokemon switching (higher first if priority tie) */\r\n\tspeed: number;\r\n\t/** the pokemon doing the switch */\r\n\tpokemon: Pokemon;\r\n\t/** pokemon to switch to */\r\n\ttarget: Pokemon;\r\n\t/** effect that called the switch (eg U */\r\n\tsourceEffect: Effect | null;\r\n}\r\n\r\n/** A Team Preview choice action */\r\nexport interface TeamAction {\r\n\t/** action type */\r\n\tchoice: 'team';\r\n\t/** priority of the action (lower first) */\r\n\tpriority: number;\r\n\t/** unused for this action type */\r\n\tspeed: 1;\r\n\t/** the pokemon switching */\r\n\tpokemon: Pokemon;\r\n\t/** new index */\r\n\tindex: number;\r\n}\r\n\r\n/** A generic action not done by a pokemon */\r\nexport interface FieldAction {\r\n\t/** action type */\r\n\tchoice: 'start' | 'residual' | 'pass' | 'beforeTurn';\r\n\t/** priority of the action (lower first) */\r\n\tpriority: number;\r\n\t/** unused for this action type */\r\n\tspeed: 1;\r\n\t/** unused for this action type */\r\n\tpokemon: null;\r\n}\r\n\r\n/** A generic action done by a single pokemon */\r\nexport interface PokemonAction {\r\n\t/** action type */\r\n\tchoice: 'megaEvo' | 'shift' | 'runPrimal' | 'runSwitch' | 'event' | 'runUnnerve' | 'runDynamax' | 'terastallize';\r\n\t/** priority of the action (lower first) */\r\n\tpriority: number;\r\n\t/** speed of pokemon doing action (higher first if priority tie) */\r\n\tspeed: number;\r\n\t/** the pokemon doing action */\r\n\tpokemon: Pokemon;\r\n\t/** `runSwitch` only: the pokemon forcing this pokemon to switch in */\r\n\tdragger?: Pokemon;\r\n\t/** `event` only: the event to run */\r\n\tevent?: string;\r\n}\r\n\r\nexport type Action = MoveAction | SwitchAction | TeamAction | FieldAction | PokemonAction;\r\n\r\n/**\r\n * An ActionChoice is like an Action and has the same structure, but it doesn't need to be fully filled out.\r\n *\r\n * Any Action or ChosenAction qualifies as an ActionChoice.\r\n *\r\n * The `[k: string]: any` part is required so TypeScript won't warn about unnecessary properties.\r\n */\r\nexport interface ActionChoice {\r\n\tchoice: string;\r\n\t[k: string]: any;\r\n}\r\n\r\n/**\r\n * Kind of like a priority queue, although not sorted mid-turn in Gen 1-7.\r\n *\r\n * Sort order is documented in `BattleQueue.comparePriority`.\r\n */\r\nexport class BattleQueue {\r\n\tbattle: Battle;\r\n\tlist: Action[];\r\n\tconstructor(battle: Battle) {\r\n\t\tthis.battle = battle;\r\n\t\tthis.list = [];\r\n\t\tconst queueScripts = battle.format.queue || battle.dex.data.Scripts.queue;\r\n\t\tif (queueScripts) Object.assign(this, queueScripts);\r\n\t}\r\n\r\n\tshift() {\r\n\t\treturn this.list.shift();\r\n\t}\r\n\tpeek(end?: boolean): Action | undefined {\r\n\t\treturn this.list[end ? this.list.length - 1 : 0];\r\n\t}\r\n\tpush(action: Action) {\r\n\t\treturn this.list.push(action);\r\n\t}\r\n\tunshift(action: Action) {\r\n\t\treturn this.list.unshift(action);\r\n\t}\r\n\t// eslint-disable-next-line no-restricted-globals\r\n\t[Symbol.iterator]() { return this.list[Symbol.iterator](); }\r\n\tentries() {\r\n\t\treturn this.list.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Takes an ActionChoice, and fills it out into a full Action object.\r\n\t *\r\n\t * Returns an array of Actions because some ActionChoices (like mega moves)\r\n\t * resolve to two Actions (mega evolution + use move)\r\n\t */\r\n\tresolveAction(action: ActionChoice, midTurn = false): Action[] {\r\n\t\tif (!action) throw new Error(`Action not passed to resolveAction`);\r\n\t\tif (action.choice === 'pass') return [];\r\n\t\tconst actions = [action];\r\n\r\n\t\tif (!action.side && action.pokemon) action.side = action.pokemon.side;\r\n\t\tif (!action.move && action.moveid) action.move = this.battle.dex.getActiveMove(action.moveid);\r\n\t\tif (!action.order) {\r\n\t\t\tconst orders: {[choice: string]: number} = {\r\n\t\t\t\tteam: 1,\r\n\t\t\t\tstart: 2,\r\n\t\t\t\tinstaswitch: 3,\r\n\t\t\t\tbeforeTurn: 4,\r\n\t\t\t\tbeforeTurnMove: 5,\r\n\t\t\t\trevivalblessing: 6,\r\n\r\n\t\t\t\trunUnnerve: 100,\r\n\t\t\t\trunSwitch: 101,\r\n\t\t\t\trunPrimal: 102,\r\n\t\t\t\tswitch: 103,\r\n\t\t\t\tmegaEvo: 104,\r\n\t\t\t\trunDynamax: 105,\r\n\t\t\t\tterastallize: 106,\r\n\t\t\t\tpriorityChargeMove: 107,\r\n\r\n\t\t\t\tshift: 200,\r\n\t\t\t\t// default is 200 (for moves)\r\n\r\n\t\t\t\tresidual: 300,\r\n\t\t\t};\r\n\t\t\tif (action.choice in orders) {\r\n\t\t\t\taction.order = orders[action.choice];\r\n\t\t\t} else {\r\n\t\t\t\taction.order = 200;\r\n\t\t\t\tif (!['move', 'event'].includes(action.choice)) {\r\n\t\t\t\t\tthrow new Error(`Unexpected orderless action ${action.choice}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (!midTurn) {\r\n\t\t\tif (action.choice === 'move') {\r\n\t\t\t\tif (!action.maxMove && !action.zmove && action.move.beforeTurnCallback) {\r\n\t\t\t\t\tactions.unshift(...this.resolveAction({\r\n\t\t\t\t\t\tchoice: 'beforeTurnMove', pokemon: action.pokemon, move: action.move, targetLoc: action.targetLoc,\r\n\t\t\t\t\t}));\r\n\t\t\t\t}\r\n\t\t\t\tif (action.mega && !action.pokemon.isSkyDropped()) {\r\n\t\t\t\t\tactions.unshift(...this.resolveAction({\r\n\t\t\t\t\t\tchoice: 'megaEvo',\r\n\t\t\t\t\t\tpokemon: action.pokemon,\r\n\t\t\t\t\t}));\r\n\t\t\t\t}\r\n\t\t\t\tif (action.terastallize && !action.pokemon.terastallized) {\r\n\t\t\t\t\tactions.unshift(...this.resolveAction({\r\n\t\t\t\t\t\tchoice: 'terastallize',\r\n\t\t\t\t\t\tpokemon: action.pokemon,\r\n\t\t\t\t\t}));\r\n\t\t\t\t}\r\n\t\t\t\tif (action.maxMove && !action.pokemon.volatiles['dynamax']) {\r\n\t\t\t\t\tactions.unshift(...this.resolveAction({\r\n\t\t\t\t\t\tchoice: 'runDynamax',\r\n\t\t\t\t\t\tpokemon: action.pokemon,\r\n\t\t\t\t\t}));\r\n\t\t\t\t}\r\n\t\t\t\tif (!action.maxMove && !action.zmove && action.move.priorityChargeCallback) {\r\n\t\t\t\t\tactions.unshift(...this.resolveAction({\r\n\t\t\t\t\t\tchoice: 'priorityChargeMove',\r\n\t\t\t\t\t\tpokemon: action.pokemon,\r\n\t\t\t\t\t\tmove: action.move,\r\n\t\t\t\t\t}));\r\n\t\t\t\t}\r\n\t\t\t\taction.fractionalPriority = this.battle.runEvent('FractionalPriority', action.pokemon, null, action.move, 0);\r\n\t\t\t} else if (['switch', 'instaswitch'].includes(action.choice)) {\r\n\t\t\t\tif (typeof action.pokemon.switchFlag === 'string') {\r\n\t\t\t\t\taction.sourceEffect = this.battle.dex.moves.get(action.pokemon.switchFlag as ID) as any;\r\n\t\t\t\t}\r\n\t\t\t\taction.pokemon.switchFlag = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst deferPriority = this.battle.gen === 7 && action.mega && action.mega !== 'done';\r\n\t\tif (action.move) {\r\n\t\t\tlet target = null;\r\n\t\t\taction.move = this.battle.dex.getActiveMove(action.move);\r\n\r\n\t\t\tif (!action.targetLoc) {\r\n\t\t\t\ttarget = this.battle.getRandomTarget(action.pokemon, action.move);\r\n\t\t\t\t// TODO: what actually happens here?\r\n\t\t\t\tif (target) action.targetLoc = action.pokemon.getLocOf(target);\r\n\t\t\t}\r\n\t\t\taction.originalTarget = action.pokemon.getAtLoc(action.targetLoc);\r\n\t\t}\r\n\t\tif (!deferPriority) this.battle.getActionSpeed(action);\r\n\t\treturn actions as any;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the passed action happen next (skipping speed order).\r\n\t */\r\n\tprioritizeAction(action: MoveAction | SwitchAction, sourceEffect?: Effect) {\r\n\t\tfor (const [i, curAction] of this.list.entries()) {\r\n\t\t\tif (curAction === action) {\r\n\t\t\t\tthis.list.splice(i, 1);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\taction.sourceEffect = sourceEffect;\r\n\t\taction.order = 3;\r\n\t\tthis.list.unshift(action);\r\n\t}\r\n\r\n\t/**\r\n\t * Changes a pokemon's action, and inserts its new action\r\n\t * in priority order.\r\n\t *\r\n\t * You'd normally want the OverrideAction event (which doesn't\r\n\t * change priority order).\r\n\t */\r\n\tchangeAction(pokemon: Pokemon, action: ActionChoice) {\r\n\t\tthis.cancelAction(pokemon);\r\n\t\tif (!action.pokemon) action.pokemon = pokemon;\r\n\t\tthis.insertChoice(action);\r\n\t}\r\n\r\n\taddChoice(choices: ActionChoice | ActionChoice[]) {\r\n\t\tif (!Array.isArray(choices)) choices = [choices];\r\n\t\tfor (const choice of choices) {\r\n\t\t\tconst resolvedChoices = this.resolveAction(choice);\r\n\t\t\tthis.list.push(...resolvedChoices);\r\n\t\t\tfor (const resolvedChoice of resolvedChoices) {\r\n\t\t\t\tif (resolvedChoice && resolvedChoice.choice === 'move' && resolvedChoice.move.id !== 'recharge') {\r\n\t\t\t\t\tresolvedChoice.pokemon.side.lastSelectedMove = resolvedChoice.move.id;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\twillAct() {\r\n\t\tfor (const action of this.list) {\r\n\t\t\tif (['move', 'switch', 'instaswitch', 'shift'].includes(action.choice)) {\r\n\t\t\t\treturn action;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\twillMove(pokemon: Pokemon) {\r\n\t\tif (pokemon.fainted) return null;\r\n\t\tfor (const action of this.list) {\r\n\t\t\tif (action.choice === 'move' && action.pokemon === pokemon) {\r\n\t\t\t\treturn action;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\tcancelAction(pokemon: Pokemon) {\r\n\t\tconst oldLength = this.list.length;\r\n\t\tfor (let i = 0; i < this.list.length; i++) {\r\n\t\t\tif (this.list[i].pokemon === pokemon) {\r\n\t\t\t\tthis.list.splice(i, 1);\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this.list.length !== oldLength;\r\n\t}\r\n\r\n\tcancelMove(pokemon: Pokemon) {\r\n\t\tfor (const [i, action] of this.list.entries()) {\r\n\t\t\tif (action.choice === 'move' && action.pokemon === pokemon) {\r\n\t\t\t\tthis.list.splice(i, 1);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\twillSwitch(pokemon: Pokemon) {\r\n\t\tfor (const action of this.list) {\r\n\t\t\tif (['switch', 'instaswitch'].includes(action.choice) && action.pokemon === pokemon) {\r\n\t\t\t\treturn action;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\t/**\r\n\t * Inserts the passed action into the action queue when it normally\r\n\t * would have happened (sorting by priority/speed), without\r\n\t * re-sorting the existing actions.\r\n\t */\r\n\tinsertChoice(choices: ActionChoice | ActionChoice[], midTurn = false) {\r\n\t\tif (Array.isArray(choices)) {\r\n\t\t\tfor (const choice of choices) {\r\n\t\t\t\tthis.insertChoice(choice);\r\n\t\t\t}\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst choice = choices;\r\n\r\n\t\tif (choice.pokemon) {\r\n\t\t\tchoice.pokemon.updateSpeed();\r\n\t\t}\r\n\t\tconst actions = this.resolveAction(choice, midTurn);\r\n\r\n\t\tlet firstIndex = null;\r\n\t\tlet lastIndex = null;\r\n\t\tfor (const [i, curAction] of this.list.entries()) {\r\n\t\t\tconst compared = this.battle.comparePriority(actions[0], curAction);\r\n\t\t\tif (compared <= 0 && firstIndex === null) {\r\n\t\t\t\tfirstIndex = i;\r\n\t\t\t}\r\n\t\t\tif (compared < 0) {\r\n\t\t\t\tlastIndex = i;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (firstIndex === null) {\r\n\t\t\tthis.list.push(...actions);\r\n\t\t} else {\r\n\t\t\tif (lastIndex === null) lastIndex = this.list.length;\r\n\t\t\tconst index = firstIndex === lastIndex ? firstIndex : this.battle.random(firstIndex, lastIndex + 1);\r\n\t\t\tthis.list.splice(index, 0, ...actions);\r\n\t\t}\r\n\t}\r\n\r\n\tclear() {\r\n\t\tthis.list = [];\r\n\t}\r\n\r\n\tdebug(action?: any): string {\r\n\t\tif (action) {\r\n\t\t\treturn `${action.order || ''}:${action.priority || ''}:${action.speed || ''}:${action.subOrder || ''} - ${action.choice}${action.pokemon ? ' ' + action.pokemon : ''}${action.move ? ' ' + action.move : ''}`;\r\n\t\t}\r\n\t\treturn this.list.map(\r\n\t\t\tqueueAction => this.debug(queueAction)\r\n\t\t).join('\\n') + '\\n';\r\n\t}\r\n\r\n\tsort() {\r\n\t\t// this.log.push('SORT ' + this.debugQueue());\r\n\t\tthis.battle.speedSort(this.list);\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nexport default BattleQueue;\r\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8HO,MAAM,YAAY;AAAA,EAGxB,YAAY,QAAgB;AAC3B,SAAK,SAAS;AACd,SAAK,OAAO,CAAC;AACb,UAAM,eAAe,OAAO,OAAO,SAAS,OAAO,IAAI,KAAK,QAAQ;AACpE,QAAI;AAAc,aAAO,OAAO,MAAM,YAAY;AAAA,EACnD;AAAA,EAEA,QAAQ;AACP,WAAO,KAAK,KAAK,MAAM;AAAA,EACxB;AAAA,EACA,KAAK,KAAmC;AACvC,WAAO,KAAK,KAAK,MAAM,KAAK,KAAK,SAAS,IAAI,CAAC;AAAA,EAChD;AAAA,EACA,KAAK,QAAgB;AACpB,WAAO,KAAK,KAAK,KAAK,MAAM;AAAA,EAC7B;AAAA,EACA,QAAQ,QAAgB;AACvB,WAAO,KAAK,KAAK,QAAQ,MAAM;AAAA,EAChC;AAAA;AAAA,EAEA,CAAC,OAAO,QAAQ,IAAI;AAAE,WAAO,KAAK,KAAK,OAAO,QAAQ,EAAE;AAAA,EAAG;A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