-
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
Add user interface option to Notify by Pokemon Level #2399
Conversation
593ec2c
to
3268554
Compare
static/js/map.js
Outdated
hasHighIV = notifiedMinPerfection > 0 && perfection >= notifiedMinPerfection | ||
hasHighLevel = notifiedMinLevel > 0 && level >= notifiedMinLevel | ||
|
||
hasHighAttributes = (hasHighIV && notifiedMinLevel === 0) || (hasHighLevel && notifiedMinPerfection === 0) || hasHighLevel && hasHighIV |
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.
Change this to
hasHighAttributes = (hasHighIV && !(notifiedMinLevel > 0)) || (hasHighLevel && !(notifiedMinPerfection > 0)) || hasHighLevel && hasHighIV
...to make it always work.
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.
Fixed...
FYI sloppydrive's users found the needed code improvement earlier but otherwise this is working well. |
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.
No problems, also works good in combination with minimum IV level.
Is it also possible for you to build in 'Exclude/hide pokemon by iv/level'? I would love that. |
@darkelement1987 Yes there is another PR that allows you to hide pokemon that are not being notified. So you could set the minimum level and IV to what you want and then 'hide unnotified pokemon' and it will only show the high level ones (excluding the others) #2377 |
Awesome!
2018-01-15 19:02 GMT+01:00 tomballgithub <notifications@github.com>:
… @darkelement1987 <https://github.com/darkelement1987> Yes there is
another PR that allows you to hide pokemon that are not being notified. So
you could set the minimum level and IV to what you want and then 'hide
unnotified pokemon' and it will only show the high level ones (excluding
the others) #2377 <#2377>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2399 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AUJj-7ng-qMinFhCu4iiIN_ifziV4xxQks5tK5KygaJpZM4REZSf>
.
|
e758135
to
4d683fb
Compare
Rebased... |
static/js/map.js
Outdated
if (isNaN(notifiedMinLevel) || notifiedMinLevel <= 0) { | ||
notifiedMinLevel = '' | ||
} | ||
if (notifiedMinLevel > 40) { |
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.
Wild pokemon can be max lvl 30 and 35 with weather boost, just a tiny notice.
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.
Using level 40 allows this code to be future proof.
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.
I would remove this check and set the upper limit to 35
in the input in the HTML template. If anyone tampers with it to allow values above 35, the code is right to assume that they only want to be notified of levels at or above whichever level they've set.
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.
There doesn't seem to be a simple way to do this in the template. Min/Max values are only applicable if input type is number not text. Changing to number causes a behavior change in that there are now scroll bars up/down and the input box gets resized. I'll leave it as-is but change to 35 maximum even though I'd prefer 40 to be future proof.
static/js/map.common.js
Outdated
@@ -869,6 +869,9 @@ var StoreOptions = { | |||
'excludedRarity': { | |||
default: 0, // 0: none, 1: <=Common, 2: <=Uncommon, 3: <=Rare, 4: <=Very Rare, 5: <=Ultra Rare | |||
type: StoreTypes.Number | |||
'remember_text_level_notify': { |
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 fail
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.
Thank you, fixed. Was introduced during rebase.
static/js/map.js
Outdated
hasHighIV = notifiedMinPerfection > 0 && perfection >= notifiedMinPerfection | ||
hasHighLevel = notifiedMinLevel > 0 && level >= notifiedMinLevel | ||
|
||
hasHighAttributes = (hasHighIV && !(notifiedMinLevel > 0)) || (hasHighLevel && !(notifiedMinPerfection > 0)) || hasHighLevel && hasHighIV |
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.
You can simplify
hasHighAttributes = (hasHighIV && !(notifiedMinLevel > 0)) || (hasHighLevel && !(notifiedMinPerfection > 0)) || hasHighLevel && hasHighIV
to
const shouldNotifyForIV = (hasHighIV && notifiedMinLevel <= 0)
const shouldNotifyForLevel = (hasHighLevel && (hasHighIV || notifiedMinPerfection <= 0))
hasHighAttributes = shouldNotifyForIV || shouldNotifyForLevel
Note that I used <= 0
because it's the reverse of >
. If <
is unnecessary, change it to ==
.
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.
This was due to a bug caused by the '' assignment as default
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
The default should be 0
rather than an empty string and the <= 0
should be changed with < 0
. 0
can be a valid option, to disable it. Make sure to keep the behavior consistent with "Notify by IV".
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.
I agree but note that I copied the exact '' assignment also used for remember_text_perfection_notify
static/js/map.js
Outdated
if (isNaN(notifiedMinLevel) || notifiedMinLevel <= 0) { | ||
notifiedMinLevel = '' | ||
} | ||
if (notifiedMinLevel > 40) { |
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.
I would remove this check and set the upper limit to 35
in the input in the HTML template. If anyone tampers with it to allow values above 35, the code is right to assume that they only want to be notified of levels at or above whichever level they've set.
Fixed travis Change code to handled undefined notification parameters
a1f19ee
to
5d44772
Compare
Should be all rebased and fixed |
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.
Tested with some IV accounts and it works.
Thanks for the feature!
static/js/map.js
Outdated
} | ||
|
||
return hasHighIV | ||
return hasHighAttributes |
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.
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 cp_multiplier
(technically not possible since they're both inserted during scan, but logically they're unrelated so they should be separated).
The problem lies in your condition:
var hasHighAttributes = false
if (poke['individual_attack'] != null && poke['cp_multiplier'] !== null) {
...
}
return hasHighAttributes
Approved via code review only, not testing of latest changes |
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.
Fixed it! ty.
Description
This adds a user interface option to notify by pokemon level. This is virtually the same coding as the notify by pokemon perfection.
If the user enters a pokemon level between 1 and 40, the map will notify them if a pokemon meeting that level is found. If both a level and perfection notification are configured, a pokemon will only be notified if it meets both criteria.
Motivation and Context
This was request in the PR channel and I have had multiple users request this feature. It is especially interesting now with weather-boosting causing pokemon with level 35 to be found in the wild
How Has This Been Tested?
I tested the code on my Rocketmap server user interface under Ubuntu 16.04.
I tweaked it until it worked as desired.
Screenshots (if appropriate):
Types of changes
Checklist: