-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user interface option to Notify by Pokemon Level #2399
Changes from 6 commits
ab964b3
5d44772
62d9912
317f365
ac92978
0f3cb05
5e7a62f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var $selectExclude | |
var $selectPokemonNotify | ||
var $selectRarityNotify | ||
var $textPerfectionNotify | ||
var $textLevelNotify | ||
var $selectStyle | ||
var $selectIconSize | ||
var $switchOpenGymsOnly | ||
|
@@ -37,6 +38,7 @@ var excludedRarity | |
var notifiedPokemon = [] | ||
var notifiedRarity = [] | ||
var notifiedMinPerfection = null | ||
var notifiedMinLevel = null | ||
|
||
var buffer = [] | ||
var reincludedPokemon = [] | ||
|
@@ -1046,13 +1048,23 @@ function playPokemonSound(pokemonID, cryFileTypes) { | |
|
||
function isNotifyPerfectionPoke(poke) { | ||
var hasHighIV = false | ||
var hasHighLevel = false | ||
var hasHighAttributes = false | ||
|
||
if (poke['individual_attack'] != null) { | ||
if (poke['individual_attack'] != null && poke['cp_multiplier'] !== null) { | ||
const perfection = getIv(poke['individual_attack'], poke['individual_defense'], poke['individual_stamina']) | ||
const level = getPokemonLevel(poke['cp_multiplier']) | ||
|
||
hasHighIV = notifiedMinPerfection > 0 && perfection >= notifiedMinPerfection | ||
hasHighLevel = notifiedMinLevel > 0 && level >= notifiedMinLevel | ||
|
||
const shouldNotifyForIV = (hasHighIV && notifiedMinLevel <= 0) | ||
const shouldNotifyForLevel = (hasHighLevel && (hasHighIV || notifiedMinPerfection <= 0)) | ||
|
||
hasHighAttributes = shouldNotifyForIV || shouldNotifyForLevel | ||
} | ||
|
||
return hasHighIV | ||
return hasHighAttributes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current code will cause a problem when "Notify by IV" is enabled and "Notify by level" is disabled, and the Pokémon has IV data but no The problem lies in your condition:
|
||
} | ||
|
||
function isNotifyPoke(poke) { | ||
|
@@ -2687,6 +2699,7 @@ $(function () { | |
$selectPokemonNotify = $('#notify-pokemon') | ||
$selectRarityNotify = $('#notify-rarity') | ||
$textPerfectionNotify = $('#notify-perfection') | ||
$textLevelNotify = $('#notify-level') | ||
var numberOfPokemon = 493 | ||
|
||
// Load pokemon names and populate lists | ||
|
@@ -2768,13 +2781,25 @@ $(function () { | |
$textPerfectionNotify.val(notifiedMinPerfection) | ||
Store.set('remember_text_perfection_notify', notifiedMinPerfection) | ||
}) | ||
$textLevelNotify.on('change', function (e) { | ||
notifiedMinLevel = parseInt($textLevelNotify.val(), 10) | ||
if (isNaN(notifiedMinLevel) || notifiedMinLevel <= 0) { | ||
notifiedMinLevel = '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree but note that I copied the exact '' assignment also used for |
||
} | ||
if (notifiedMinLevel > 35) { | ||
notifiedMinLevel = 35 | ||
} | ||
$textLevelNotify.val(notifiedMinLevel) | ||
Store.set('remember_text_level_notify', notifiedMinLevel) | ||
}) | ||
|
||
// recall saved lists | ||
$selectExclude.val(Store.get('remember_select_exclude')).trigger('change') | ||
$selectExcludeRarity.val(Store.get('excludedRarity')).trigger('change') | ||
$selectPokemonNotify.val(Store.get('remember_select_notify')).trigger('change') | ||
$selectRarityNotify.val(Store.get('remember_select_rarity_notify')).trigger('change') | ||
$textPerfectionNotify.val(Store.get('remember_text_perfection_notify')).trigger('change') | ||
$textLevelNotify.val(Store.get('remember_text_level_notify')).trigger('change') | ||
|
||
if (isTouchDevice() && isMobileDevice()) { | ||
$('.select2-search input').prop('readonly', true) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js object literal syntax error,
npm run build
will failThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, fixed. Was introduced during rebase.