From 0796613a721ecb83b8c7c9b7cd1a3c411377b240 Mon Sep 17 00:00:00 2001 From: SuddenlyQ <8680017+SuddenlyQ@users.noreply.github.com> Date: Sat, 9 Feb 2019 09:25:45 -0800 Subject: [PATCH] Add in-battle mod detection to /weak and /coverage (#5144) --- server/chat-plugins/info.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/server/chat-plugins/info.js b/server/chat-plugins/info.js index e85f4b00fb123..7d0a578d2bff2 100644 --- a/server/chat-plugins/info.js +++ b/server/chat-plugins/info.js @@ -682,7 +682,15 @@ const commands = { if (!this.runBroadcast()) return; target = target.trim(); let modName = target.split(','); - let mod = Dex.mod(toId(modName[modName.length - 1])) || Dex; + let mod = Dex; + /** @type {Format?} */ + let format = null; + if (modName[modName.length - 1] && toId(modName[modName.length - 1]) in Dex.dexes) { + mod = Dex.mod(toId(modName[modName.length - 1])); + } else if (room && room.battle) { + format = Dex.getFormat(room.battle.format); + mod = Dex.mod(format.mod); + } let targets = target.split(/ ?[,/] ?/); /** @type {{types: string[], [k: string]: any}} */ let pokemon = mod.getTemplate(targets[0]); @@ -831,8 +839,14 @@ const commands = { let targets = target.split(/[,+]/); let sources = []; - let mod = Dex.mod(toId(targets[targets.length - 1])) || Dex; - + let mod = Dex; + if (room && room.battle) { + let format = Dex.getFormat(room.battle.format); + mod = Dex.mod(format.mod); + } + if (targets[targets.length - 1] && toId(targets[targets.length - 1]) in Dex.dexes) { + mod = Dex.mod(toId(targets[targets.length - 1])); + } let dispTable = false; let bestCoverage = {}; let hasThousandArrows = false;