Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/configs/default.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -257,5 +257,8 @@
407,416,424,429,430,433,438,439,440,442,446,447,448,458,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,532,533,534,559,
560,599,600,601,627,628
]
}
},
"shinyRates": {
"129-f253": 512
}
}
1 change: 0 additions & 1 deletion src/data/default.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,5 @@ data.default_show_submission_cells = config.map.filters.submissionCells;
data.default_show_nests = config.map.filters.nests;
data.default_show_scan_areas = config.map.filters.scanAreas;
data.default_show_devices = config.map.filters.devices;
data.pokemon_rarity_json = JSON.stringify(config.rarity);

module.exports = data;
3 changes: 3 additions & 0 deletions src/routes/ui.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -193,6 +193,9 @@ const handlePage = async (req, res) => {
data.min_zoom = config.map.minZoom || 10;
data.max_zoom = config.map.maxZoom || 18;

data.pokemon_rarity_json = JSON.stringify(config.rarity);
data.pokemon_shiny_rates_json = JSON.stringify(config.shinyRates);

data.locale_last_modified = (await fs.promises.stat(path.resolve(__dirname, `../../static/locales/${data.locale}.json`))).mtimeMs;
data.css_last_modified = (await fs.promises.stat(path.resolve(__dirname, '../../static/css/index.css'))).mtimeMs;
data.js_last_modified = (await fs.promises.stat(path.resolve(__dirname, '../../static/js/index.js'))).mtimeMs;
Expand Down
2 changes: 2 additions & 0 deletions src/views/index.mustache
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
{{> navbar}}

<script type="text/javascript">
const myUsername = '{{{username}}}';
const defaultStartLocation = ['{{lat}}', '{{lon}}'];
const defaultStartZoom = '{{zoom}}';
let clusterPokemon = '{{cluster_pokemon}}' === 'true';
Expand DownExpand Up@@ -35,6 +36,7 @@
const defaultShowDevices = '{{default_show_devices}}' === 'true';

const pokemonRarity = JSON.parse('{{{pokemon_rarity_json}}}');
const pokemonShinyRates = JSON.parse('{{{pokemon_shiny_rates_json}}}');
const glow = JSON.parse('{{{glow_json}}}');

const locale = '{{{locale}}}';
Expand Down
37 changes: 32 additions & 5 deletions static/js/index.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -2607,7 +2607,7 @@ function getPokemonPopupContent (pokemon) {
}

// TODO: add evolution https://github.com/versx/DataParser/issues/9
const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume);
const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume, didIFindAShinyPokemon(pokemon.pokemon_id, pokemon.form, `wild-${pokemon.id}`));

content +=
'<div class="row">' + // START 1ST ROW
Expand DownExpand Up@@ -3052,7 +3052,7 @@ function getGymPopupContent (gym) {
} else {
pokemonName = 'Level ' + gym.raid_level + ' Egg';
}
const pokemonIcon = getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form, gym.raid_pokemon_evolution, gym.raid_pokemon_gender, gym.raid_pokemon_costume);
const pokemonIcon = getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form, gym.raid_pokemon_evolution, gym.raid_pokemon_gender, gym.raid_pokemon_costume, didIFindAShinyPokemon(gym.raid_pokemon_id, gym.raid_pokemon_form, `raid-${gym.id}-${gym.raid_battle_timestamp}`));
content +=
'<div class="row" style="margin:auto;">' + // START 1ST ROW
'<div class="col-4">' + // START 1ST COL
Expand DownExpand Up@@ -3656,7 +3656,8 @@ function calcIV(atk, def, sta) {

function getPokemonMarkerIcon (pokemon, ts) {
const size = getPokemonSize(pokemon.pokemon_id, pokemon.form);
const pokemonIdString = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume);
const pokemonIdString = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume, didIFindAShinyPokemon(pokemon.pokemon_id, pokemon.form, `wild-${pokemon.id}`));
const color = glowColor; // TODO: settings['pokemon-glow'].color;
const iv = calcIV(pokemon.atk_iv, pokemon.def_iv, pokemon.sta_iv);
const bestRank = getPokemonBestRank(pokemon.pvp_rankings_great_league, pokemon.pvp_rankings_ultra_league);
const bestRankIcon = bestRank === 3
Expand DownExpand Up@@ -3784,7 +3785,7 @@ function getPokestopMarkerIcon (pokestop, ts) {
// Pokemon
rewardString = 'p' + info.pokemon_id;
// TODO: evolution https://github.com/versx/DataParser/issues/10
iconUrl = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(info.pokemon_id, info.form_id, 0, info.gender_id, info.costume_id, info.shiny)}.png`;
iconUrl = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(info.pokemon_id, info.form_id, 0, info.gender_id, info.costume_id, info.shiny || info.form_id && didIFindAShinyPokemon(info.pokemon_id, info.form_id, `quest-${pokestop.id}-${pokestop.quest_timestamp}`))}.png`;
} else if (id === 8) {
// Pokecoin
rewardString = 'i-6';
Expand DownExpand Up@@ -3914,7 +3915,7 @@ function getGymMarkerIcon (gym, ts) {
if (gym.raid_pokemon_id !== 0 && gym.raid_pokemon_id !== null) {
// Raid Boss
raidSize = getRaidSize('p' + gym.raid_pokemon_id);
raidIcon = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form, gym.raid_pokemon_evolution, gym.raid_pokemon_gender, gym.raid_pokemon_costume)}.png`;
raidIcon = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form, gym.raid_pokemon_evolution, gym.raid_pokemon_gender, gym.raid_pokemon_costume, didIFindAShinyPokemon(gym.raid_pokemon_id, gym.raid_pokemon_form, `raid-${gym.id}-${gym.raid_battle_timestamp}`))}.png`;
} else {
// Egg
raidSize = getRaidSize('l' + raidLevel);
Expand DownExpand Up@@ -7321,3 +7322,29 @@ function setPokemonFilters(type, show) {

$('#table-filter-pokemon').DataTable().rows().invalidate('data').draw(false);
}

// MARK: minigames that nobody asks for

function didIFindAShinyPokemon(pokemonId, form, description) {
let rate = pokemonShinyRates[form ? `${pokemonId}-f${form}` : `${pokemonId}`];
if (rate === undefined) {
rate = pokemonShinyRates['default'];
}
if (!rate) {
return false;
}
// https://stackoverflow.com/a/52171480/2245107
const cyrb53 = function(str, seed = 0) {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1>>>16), 2246822507) ^ Math.imul(h2 ^ (h2>>>13), 3266489909);
h2 = Math.imul(h2 ^ (h2>>>16), 2246822507) ^ Math.imul(h1 ^ (h1>>>13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1>>>0);
};
const lottery = `${myUsername}-${description}`;
return cyrb53(lottery) % rate === 0;
}