Skip to content

Commit

Permalink
Dynamically get grunt IDs from invasions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gattaca1 committed Jun 20, 2024
1 parent ec35b14 commit 8f851ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
24 changes: 2 additions & 22 deletions server/src/models/Pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ class Pokestop extends Model {
const midnight = getUserMidnight(args)
const ts = Math.floor(Date.now() / 1000)

const rocketGruntIDs = [
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 47, 48,
49, 50,
]
const rocketLeaderIDs = [41, 42, 43, 44]

const {
lures: lurePerms,
quests: questPerms,
Expand Down Expand Up @@ -585,14 +578,14 @@ class Pokestop extends Model {
if (onlyExcludeGrunts) {
invasion.whereNotIn(
isMad ? 'character_display' : 'character',
rocketGruntIDs,
Event.rocketGruntIDs,
)
}

if (onlyExcludeLeaders) {
invasion.whereNotIn(
isMad ? 'character_display' : 'character',
rocketLeaderIDs,
Event.rocketLeaderIDs,
)
}
})
Expand All @@ -614,19 +607,6 @@ class Pokestop extends Model {
if (hasConfirmed) {
invasion.andWhere('confirmed', onlyConfirmed)
}
if (onlyExcludeGrunts) {
invasion.whereNotIn(
isMad ? 'character_display' : 'character',
rocketGruntIDs,
)
}

if (onlyExcludeLeaders) {
invasion.whereNotIn(
isMad ? 'character_display' : 'character',
rocketLeaderIDs,
)
}
})
}
}
Expand Down
17 changes: 17 additions & 0 deletions server/src/services/EventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,23 @@ class EventManager {
try {
const newInvasions = await fetch(endpoint).then((res) => res.json())
if (newInvasions) {
this.rocketGruntIDs = Object.keys(newInvasions)
.filter(
(key) =>
newInvasions[key].grunt &&
newInvasions[key].grunt.includes('Grunt'),
)
.map(Number)

this.rocketLeaderIDs = Object.keys(newInvasions)
.filter(
(key) =>
newInvasions[key].grunt &&
(newInvasions[key].grunt.includes('Executive') ||
newInvasions[key].grunt.includes('Giovanni')),
)
.map(Number)

this.invasions = newInvasions
}
} catch (e) {
Expand Down

0 comments on commit 8f851ba

Please sign in to comment.