Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tracking of evolutions #722

Merged
merged 2 commits into from
Jun 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/lib/poracleMessage/commands/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,32 @@ exports.run = async (client, msg, args, options) => {
}
}
} else {
const monster = Object.values(client.GameData.monsters).find((mon) => (element === mon.name.toLowerCase()) || element === mon.id.toString())
if (monster) monsterList.add(monster.id)
else if (typeArray.includes(element)) typeList.push(element)
let monsterMatch = element
let addEvolutions = false
if (monsterMatch.endsWith('+')) {
monsterMatch = monsterMatch.slice(0, -1)
addEvolutions = true
}
const monster = Object.values(client.GameData.monsters).find((mon) => (monsterMatch === mon.name.toLowerCase()) || element === mon.id.toString())
if (monster) {
monsterList.add(monster.id)
if (addEvolutions) {
let count = 0
// eslint-disable-next-line no-loop-func
const evoAdd = (mon) => {
count++
if (count > 20) return
if (mon.evolutions) {
for (const evolution of mon.evolutions) {
monsterList.add(evolution.evoId)
const evoMonster = client.GameData.monsters[`${evolution.evoId}_${evolution.id}`]
evoAdd(evoMonster)
}
}
}
evoAdd(monster)
}
} else if (typeArray.includes(element)) typeList.push(element)
else {
await msg.react('🙅')
return msg.reply(translator.translateFormat('I do not understand this option: {0}', element))
Expand Down