Skip to content

Commit

Permalink
Adds Wildcards (#616)
Browse files Browse the repository at this point in the history
- Gyms
- Raids
- Eggs
- Code borrowed from #606, to merge in faster

Co-Authored-By: James Berry <[email protected]>

Co-authored-by: James Berry <[email protected]>
  • Loading branch information
TurtIeSocks and jfberry authored Nov 19, 2021
1 parent fc79fb6 commit b559d1a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/controllers/gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Gym extends Controller {
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, gym.template, gym.distance, gym.clean, gym.ping from gym
join humans on (humans.id = gym.id and humans.current_profile_no = gym.profile_no)
where humans.enabled = 1 and humans.admin_disable = false and
gym.team = ${data.teamId}
(gym.team = ${data.teamId} or gym.team = 4)
${changeQuery}
${strictareastring}
and
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/raid.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Raid extends Controller {
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, raid.template, raid.distance, raid.clean, raid.ping from raid
join humans on (humans.id = raid.id and humans.current_profile_no = raid.profile_no)
where humans.enabled = 1 and humans.admin_disable = false and (humans.blocked_alerts IS NULL OR humans.blocked_alerts NOT LIKE '%raid%') and
(pokemon_id=${data.pokemon_id} or (pokemon_id=9000 and raid.level=${data.level})) and
(pokemon_id=${data.pokemon_id} or (pokemon_id=9000 and (raid.level=${data.level} or raid.level=90))) and
(raid.team = ${data.team_id} or raid.team = 4) and
(raid.exclusive = ${data.ex} or raid.exclusive = 0) and
(raid.form = ${data.form} or raid.form = 0) and
Expand Down Expand Up @@ -73,7 +73,7 @@ class Raid extends Controller {
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, egg.template, egg.distance, egg.clean, egg.ping from egg
join humans on (humans.id = egg.id and humans.current_profile_no = egg.profile_no)
where humans.enabled = 1 and humans.admin_disable = false and (humans.blocked_alerts IS NULL OR humans.blocked_alerts NOT LIKE '%egg%') and
egg.level = ${data.level} and
(egg.level = ${data.level} or egg.level = 90) and
(egg.team = ${data.team_id} or egg.team = 4) and
(egg.exclusive = ${data.ex} or egg.exclusive = 0)
${strictareastring}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/poracleMessage/commands/tracked.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ async function raidRowText(config, translator, GameData, raid, scannerQuery) {
const moveName = raid.move !== 9000 && GameData.moves[raid.move] ? `${translator.translate(GameData.moves[raid.move].name)}/${translator.translate(GameData.moves[raid.move].type)}` : ''

if (+raid.pokemon_id === 9000) {
return `**${translator.translate('level').charAt(0).toUpperCase() + translator.translate('level').slice(1)} ${raid.level} ${translator.translate('raids')}** ${raid.distance ? ` | ${translator.translate('distance')}: ${raid.distance}m` : ''}${moveName ? ` | ${translator.translate('with move')} ${moveName}` : ''}${raid.team === 4 ? '' : ` | ${translator.translate('controlled by')} ${raidTeam}`}${raid.exclusive ? ` | ${translator.translate('must be an EX Gym')}` : ''} ${standardText(config, translator, raid)}${raid.gym_id ? ` ${translator.translate('at gym ')} ${gymNameText}` : ''}`
return `**${raid.level === 90 ? translator.translate('All level') : `${translator.translate('level').charAt(0).toUpperCase() + translator.translate('level').slice(1)} ${raid.level}`} ${translator.translate('raids')}** ${raid.distance ? ` | ${translator.translate('distance')}: ${raid.distance}m` : ''}${moveName ? ` | ${translator.translate('with move')} ${moveName}` : ''}${raid.team === 4 ? '' : ` | ${translator.translate('controlled by')} ${raidTeam}`}${raid.exclusive ? ` | ${translator.translate('must be an EX Gym')}` : ''} ${standardText(config, translator, raid)}${raid.gym_id ? ` ${translator.translate('at gym ')} ${gymNameText}` : ''}`
}

return `**${monsterName}**${formName ? ` ${translator.translate('form')}: ${formName}` : ''}${raid.distance ? ` | ${translator.translate('distance')}: ${raid.distance}m` : ''}${moveName ? ` | ${translator.translate('with move')} ${moveName}` : ''}${raid.team === 4 ? '' : ` | ${translator.translate('controlled by')} ${raidTeam}`}${raid.exclusive ? ` | ${translator.translate('must be an EX Gym')}` : ''} ${standardText(config, translator, raid)}${raid.gym_id ? ` ${translator.translate('at gym ')} ${gymNameText}` : ''}`
}

async function gymRowText(config, translator, GameData, gym, scannerQuery) {
const raidTeam = translator.translate(GameData.utilData.teams[gym.team].name)
const raidTeam = (gym.team === 4) ? translator.translate('All team\'s') : translator.translate(GameData.utilData.teams[gym.team].name)

let gymNameText = null
if (gym.gym_id) gymNameText = scannerQuery ? await scannerQuery.getGymName(gym.gym_id) || gym.gym_id : gym.gym_id
Expand Down Expand Up @@ -106,7 +106,7 @@ async function eggRowText(config, translator, GameData, egg, scannerQuery) {
let gymNameText = null
if (egg.gym_id) gymNameText = scannerQuery ? await scannerQuery.getGymName(egg.gym_id) || egg.gym_id : egg.gym_id

return `**${translator.translate('level').charAt(0).toUpperCase() + translator.translate('level').slice(1)} ${egg.level} ${translator.translate('eggs')}** ${egg.distance ? ` | ${translator.translate('distance')}: ${egg.distance}m` : ''} ${egg.team === 4 ? '' : ` | ${translator.translate('controlled by')} ${raidTeam}`}${egg.exclusive ? ` | ${translator.translate('must be an EX Gym')}` : ''} ${standardText(config, translator, egg)}${egg.gym_id ? ` ${translator.translate('at gym ')} ${gymNameText}` : ''}`
return `**${egg.level === 90 ? translator.translate('All level') : `${translator.translate('level').charAt(0).toUpperCase() + translator.translate('level').slice(1)} ${egg.level}`} ${translator.translate('eggs')}** ${egg.distance ? ` | ${translator.translate('distance')}: ${egg.distance}m` : ''} ${egg.team === 4 ? '' : ` | ${translator.translate('controlled by')} ${raidTeam}`}${egg.exclusive ? ` | ${translator.translate('must be an EX Gym')}` : ''} ${standardText(config, translator, egg)}${egg.gym_id ? ` ${translator.translate('at gym ')} ${gymNameText}` : ''}`
}

function questRowText(config, translator, GameData, quest) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/apiTrackingEgg.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = async (fastify, options, next) => {

const insert = insertReq.map((row) => {
const level = +row.level
if (row.level === undefined || level < 1 || level > 6) {
if (row.level === undefined || level < 1 || (level > 6 && level !== 90)) {
throw new Error('Invalid level')
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/apiTrackingGym.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = async (fastify, options, next) => {

const insert = insertReq.map((row) => {
const team = +row.team
if (row.team === undefined || team < 0 || team > 3) {
if (row.team === undefined || team < 0 || team > 4) {
throw new Error('Invalid team')
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/apiTrackingRaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = async (fastify, options, next) => {
let level = 9000
if (row.pokemon_id === 9000) {
level = +row.level
if (row.level === undefined || level < 1 || level > 6) {
if (row.level === undefined || level < 1 || (level > 6 && level !== 90)) {
throw new Error('Invalid level (must be specified if no pokemon_id')
}
}
Expand Down

0 comments on commit b559d1a

Please sign in to comment.