Skip to content

Commit

Permalink
Merge pull request #318 from wraythex/wraythex-patch-10
Browse files Browse the repository at this point in the history
Add size display and filters to RM-async
  • Loading branch information
wraythex authored Sep 19, 2023
2 parents 4776548 + 4f507f0 commit cb3ec54
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 9 deletions.
4 changes: 3 additions & 1 deletion rocketmad/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Pokemon(db.Model):
last_modified = db.Column(db.DateTime)
seen_type = db.Column(db.String)
fort_id = db.Column(db.String)
size = db.Column(db.SmallInteger)

__table_args__ = (
Index('pokemon_spawnpoint_id', 'spawnpoint_id'),
Expand All @@ -77,7 +78,8 @@ def get_active(swLat, swLng, neLat, neLng, oSwLat=None, oSwLng=None,
Pokemon.cp, Pokemon.cp_multiplier, Pokemon.weight, Pokemon.height,
Pokemon.gender, Pokemon.form, Pokemon.costume,
Pokemon.catch_prob_1, Pokemon.catch_prob_2, Pokemon.catch_prob_3,
Pokemon.weather_boosted_condition, Pokemon.last_modified, Pokemon.seen_type
Pokemon.weather_boosted_condition, Pokemon.last_modified, Pokemon.seen_type,
Pokemon.size
]

if verified_despawn_time:
Expand Down
4 changes: 3 additions & 1 deletion static/js/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ const settings = {
startLocationMarkerStyle: null,
userLocationMarkerStyle: null,
darkMode: null,
clusterZoomLevel: null
clusterZoomLevel: null,
filterPokemonBySize: null,
filterPokemonBySizeOptions: null
}

const notifiedPokemonData = {}
Expand Down
22 changes: 16 additions & 6 deletions static/js/map/map.pokemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pokemonNotifiedZIndex, pokemonRareZIndex, pokemonUltraRareZIndex,
pokemonUncommonZIndex, pokemonVeryRareZIndex, pokemonZIndex, removeMarker,
removeRangeCircle, sendNotification, settings, setupRangeCircle,
updateRangeCircle, weatherClassesDay, weatherNames, updateMarkerLayer,
createPokemonMarker, filterManagers, serverSettings
createPokemonMarker, filterManagers, serverSettings, getSizeDisplay
*/
/* exported processPokemon, updatePokemons */

Expand Down Expand Up @@ -54,6 +54,10 @@ function isPokemonMeetsFilters(pokemon, isNotifPokemon) {
}
}

if (settings.filterPokemonBySize && settings.filterPokemonBySizeOptions && !settings.filterPokemonBySizeOptions.includes(pokemon.size)) {
return false
}

if (settings.excludeNearbyCells && pokemon.seen_type === 'nearby_cell') {
return false
}
Expand Down Expand Up @@ -191,6 +195,7 @@ function pokemonLabel(item) {
var cp = item.cp
var cpMultiplier = item.cp_multiplier
var weatherBoostedCondition = item.weather_boosted_condition
var size = getSizeDisplay(item.size)

var pokemonIcon = getPokemonRawIconUrl(item, serverSettings.generateImages)
var gen = getPokemonGen(id)
Expand All @@ -202,6 +207,7 @@ function pokemonLabel(item) {
var verifiedDisplay = ''
var typesDisplay = ''
var statsDisplay = ''
var sizeDisplay = ''
var nearbyStopWarning = ''

if (id === 29 || id === 32) {
Expand Down Expand Up @@ -255,8 +261,6 @@ function pokemonLabel(item) {
var move2Name = getMoveName(item.move_2)
var move1Type = getMoveTypeNoI8ln(item.move_1)
var move2Type = getMoveTypeNoI8ln(item.move_2)
var weight = item.weight.toFixed(2)
var height = item.height.toFixed(2)

var catchRatesDisplay = ''
if (serverSettings.catchRates && item.catch_prob_1) {
Expand All @@ -268,6 +272,14 @@ function pokemonLabel(item) {
</div>`
}

if (size) {
sizeDisplay = `
<div>
${i18n('Size')}: <strong>${size}</strong>
</div>
`
}

statsDisplay = `
<div class='info-container'>
<div>
Expand All @@ -282,10 +294,8 @@ function pokemonLabel(item) {
<div>
${i18n('Charge')}: <strong>${move2Name}</strong> <img class='move-type-icon' src='static/images/types/${move2Type.toLowerCase()}.png' title='${i18n(move2Type)}' width='15'>
</div>
<div>
${i18n('Weight')}: <strong>${weight}kg</strong> | ${i18n('Height')}: <strong>${height}m</strong>
</div>
${catchRatesDisplay}
${sizeDisplay}
</div>`

let rarityDisplay = ''
Expand Down
24 changes: 24 additions & 0 deletions static/js/map/map.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function initSettings() {
}
if (serverSettings.pokemonValues) {
settings.filterPokemonByValues = Store.get('filterPokemonByValues')
settings.filterPokemonBySize = Store.get('filterPokemonBySize')
settings.filterPokemonBySizeOptions = Store.get('filterPokemonBySizeOptions')
settings.noFilterValuesPokemon = Store.get('noFilterValuesPokemon')
settings.minIvs = Store.get('minIvs')
settings.maxIvs = Store.get('maxIvs')
Expand Down Expand Up @@ -237,6 +239,25 @@ function initSettingsSidebar() {
updatePokemons()
Store.set('pokemonIconSizeModifier', iconSize)
})

$('#filter-by-size-switch').on('change', function () {
settings.filterPokemonBySize = this.checked
const sizeFilterOptions = $('#filter-by-size-select').closest('.form-control')
if (this.checked) {
sizeFilterOptions.show()
} else {
sizeFilterOptions.hide()
updateMap({ loadAllPokemon: true })
}
updatePokemons()
Store.set('filterPokemonBySize', this.checked)
})

$('#filter-by-size-select').on('change', function () {
settings.filterPokemonBySizeOptions = $(this).val().map(Number)
updateMap({ loadAllPokemon: true })
Store.set('filterPokemonBySizeOptions', $(this).val().map(Number))
})
}

if (serverSettings.pokemonValues) {
Expand Down Expand Up @@ -1621,6 +1642,9 @@ function initSettingsSidebar() {
$('#hundo-ivs-pokemon-switch-wrapper').toggle(settings.maxIvs < 100)
$('#pokemon-level-slider-title').text(`${i18n('Levels')} (${settings.minLevel} - ${settings.maxLevel})`)
$('#pokemon-level-slider-wrapper').toggle(settings.filterPokemonByValues)
$('#filter-by-size-switch').prop('checked', settings.filterPokemonBySize)
$('#filter-by-size-select').val(settings.filterPokemonBySizeOptions)
$('#filter-by-size-select').closest('.form-control').toggle(settings.filterPokemonBySize)
if (serverSettings.highlightPokemon) {
$('#pokemon-highlight-switch').prop('checked', settings.highlightPokemon)
$('#highlight-pokemon-wrapper').toggle(settings.highlightPokemon)
Expand Down
8 changes: 7 additions & 1 deletion static/js/utils/utils.pokemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ getMoveName, getMoveType, getMoveTypeNoI8ln, getPokemonGen, getPokemonIds,
getPokemonLevel, getPokemonNameWithForm, getPokemonRarity,
getPokemonRarityName, getLocationNearStop, getLocationInCell,
getPokemonRawIconUrl, getPokemonTypes, initMoveData, initPokemonData,
searchPokemon, createPokemonMarker, updatePokemonRarities
searchPokemon, createPokemonMarker, updatePokemonRarities,
getSizeDisplay
*/

var pokemonData = {}
var moveData = {}
var pokemonRarities = {}
const rarityNames = ['Common', 'Uncommon', 'Rare', 'Very Rare', 'Ultra Rare', 'New Spawn']
const pokemonSizes = ['Unknown', 'XXS', 'XS', 'M', 'XL', 'XXL']
// FontAwesome gender classes.
const genderClasses = ['fa-mars', 'fa-venus', 'fa-neuter']
var pokemonSearchList = []
Expand Down Expand Up @@ -219,6 +221,10 @@ function getPokemonMapIconUrl(pokemon, generateImages) {
return `pkm_img?pkm=${pokemon.pokemon_id}${genderParam}${formParam}${costumeParam}${evolutionParam}${weatherParam}${perfectParam}`
}

function getSizeDisplay(size) {
return i18n(pokemonSizes[size]) ?? i18n('Unknown Size')
}

function getIvsPercentage(atk, def, sta) {
// Round to 1 decimal place.
return Math.round(1000 * (atk + def + sta) / 45) / 10
Expand Down
8 changes: 8 additions & 0 deletions static/js/utils/utils.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ const StoreOptions = {
default: false,
type: StoreTypes.Boolean
},
filterPokemonBySize: {
default: false,
type: StoreTypes.Boolean
},
filterPokemonBySizeOptions: {
default: [1, 2, 3, 4, 5],
type: StoreTypes.JSON
},
excludedPokemon: {
default: new Set(),
type: StoreTypes.Set
Expand Down
21 changes: 21 additions & 0 deletions templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,27 @@ <h4>{{ i18n('Export Pokémon lists') }}</h4>
</div>
</div>
</div>
<div class="form-control">
<div class="switch">
<label>
<input type="checkbox" id="filter-by-size-switch">
<span class="lever"></span>
{{ i18n('Filter by size') }}
</label>
</div>
</div>
<div class="form-control">
<div class="input-field">
<div class="select-title">{{ i18n('Pokemon Size') }}</div>
<select id="filter-by-size-select" multiple>
<option value="1">{{ i18n('XXS') }}</option>
<option value="2">{{ i18n('XS') }}</option>
<option value="3">{{ i18n('M') }}</option>
<option value="4">{{ i18n('XL') }}</option>
<option value="5">{{ i18n('XXL') }}</option>
</select>
</div>
</div>
{% if settings.highlightPokemon %}
<div class="form-control">
<div class="switch">
Expand Down

0 comments on commit cb3ec54

Please sign in to comment.