Skip to content

Commit

Permalink
Merge pull request #316 from wraythex/wraythex-patch-9
Browse files Browse the repository at this point in the history
Add detailed invasion stats in the sidebar (async)
  • Loading branch information
wraythex authored Sep 7, 2023
2 parents 1d1c910 + bf98196 commit 6c33450
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions static/js/map/map.stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function updateStatsTable() {
if (selectedTab === '#pokestop-stats-tab') {
let noStatusCount = 0
let questCount = 0
let invasionCount = 0
let invasionCounts = {}
let normalLureCount = 0
let glacialLureCount = 0
let magneticLureCount = 0
Expand All @@ -448,7 +448,15 @@ function updateStatsTable() {
hasStatus = true
}
if (isPokestopMeetsInvasionFilters(pokestop)) {
invasionCount++
if ( !(pokestop.incident_grunt_type in invasionCounts) ) {
let invDesc = 'Unknown Invasion'
if (pokestop.incident_grunt_type != 0) {
invDesc = `${getInvasionType(pokestop.incident_grunt_type)} ${getInvasionGrunt(pokestop.incident_grunt_type)}`
}
invasionCounts[pokestop.incident_grunt_type] = [1, getPokestopIconUrl(pokestop), invDesc]
} else {
invasionCounts[pokestop.incident_grunt_type][0] += 1
}
hasStatus = true
}
if (isPokestopMeetsLureFilters(pokestop)) {
Expand Down Expand Up @@ -501,13 +509,13 @@ function updateStatsTable() {
]
)
}
if (invasionCount > 0) {
for (let invNum in invasionCounts) {
pokestopRows.push(
[
'<img src="static/images/pokestop/stop_i.png" width=32 />',
i18n('Rocket Invasion'),
invasionCount,
(invasionCount * 100) / pokestopCount
`<img src="${invasionCounts[invNum][1]}" width=32 />`,
i18n(invasionCounts[invNum][2]),
invasionCounts[invNum][0],
(invasionCounts[invNum][0] * 100) / pokestopCount
]
)
}
Expand Down

0 comments on commit 6c33450

Please sign in to comment.