diff --git a/rocketmad/models.py b/rocketmad/models.py index 35516013e..3183f9446 100644 --- a/rocketmad/models.py +++ b/rocketmad/models.py @@ -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'), @@ -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: diff --git a/static/js/map/map.js b/static/js/map/map.js index 4b1414587..58cf912d6 100644 --- a/static/js/map/map.js +++ b/static/js/map/map.js @@ -150,7 +150,9 @@ const settings = { startLocationMarkerStyle: null, userLocationMarkerStyle: null, darkMode: null, - clusterZoomLevel: null + clusterZoomLevel: null, + filterPokemonBySize: null, + filterPokemonBySizeOptions: null } const notifiedPokemonData = {} diff --git a/static/js/map/map.pokemon.js b/static/js/map/map.pokemon.js index 2d0918039..448e63200 100644 --- a/static/js/map/map.pokemon.js +++ b/static/js/map/map.pokemon.js @@ -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 */ @@ -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 } @@ -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) @@ -202,6 +207,7 @@ function pokemonLabel(item) { var verifiedDisplay = '' var typesDisplay = '' var statsDisplay = '' + var sizeDisplay = '' var nearbyStopWarning = '' if (id === 29 || id === 32) { @@ -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) { @@ -268,6 +272,14 @@ function pokemonLabel(item) { ` } + if (size) { + sizeDisplay = ` +
+ ${i18n('Size')}: ${size} +
+ ` + } + statsDisplay = `
@@ -282,10 +294,8 @@ function pokemonLabel(item) {
${i18n('Charge')}: ${move2Name}
-
- ${i18n('Weight')}: ${weight}kg | ${i18n('Height')}: ${height}m -
${catchRatesDisplay} + ${sizeDisplay}
` let rarityDisplay = '' diff --git a/static/js/map/map.settings.js b/static/js/map/map.settings.js index e87e0e826..499203e32 100644 --- a/static/js/map/map.settings.js +++ b/static/js/map/map.settings.js @@ -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') @@ -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) { @@ -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) diff --git a/static/js/utils/utils.pokemon.js b/static/js/utils/utils.pokemon.js index 426c52daa..c078d72f7 100644 --- a/static/js/utils/utils.pokemon.js +++ b/static/js/utils/utils.pokemon.js @@ -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 = [] @@ -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 diff --git a/static/js/utils/utils.store.js b/static/js/utils/utils.store.js index 4fc3450f3..af35eace1 100644 --- a/static/js/utils/utils.store.js +++ b/static/js/utils/utils.store.js @@ -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 diff --git a/templates/map.html b/templates/map.html index f449c7947..f33b73f34 100644 --- a/templates/map.html +++ b/templates/map.html @@ -694,6 +694,27 @@

{{ i18n('Export Pokémon lists') }}

+
+
+ +
+
+
+
+
{{ i18n('Pokemon Size') }}
+ +
+
{% if settings.highlightPokemon %}