Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Global Min IV/Level Filter and Image Based Pokemon Filters #54

Merged
merged 50 commits into from
Jan 22, 2018

Conversation

hammydown4325
Copy link
Contributor

@hammydown4325 hammydown4325 commented Jan 6, 2018

Global Min IV
The basic structure i went with was adding two fields. The first field was for minIV and the second field was exclude from minIV. I found people wanted to be able to see all tyrans, and drags and such even when miniv was on.

I have tested this with both Rocketmaps and Monkey Monocle and both work as intended. When the minIV is triggered all mons below the reported IV will not come into new raw_data request. I tried to reload the mons off the IV on the Javascript side but kept crashing tabs in chrome because its a lot more processing than just excluding a mon.

The min IV field is a number field with a minimum number of 0 and a maximum of 100. If the min IV is set to 0 or "" all mons on the map will be displayed regardless of whether they have an IV.

I also found the lots of my members wanted to see rare mons still even if the IV was lower than the global filter. So for this I added the exclude from min iv field. Any mon in this field will display on the map regardless of IV.

My users have enjoyed this feature for a couple weeks now while I was working the kinks out so please give it a try and if someone can test on Base Monocle that would be wonderful.

Image Based Pokemon Filtering
Select2 is not what it used to be in the internet world and does not make it easy to quickly filter various pokemon. So I created a simple element that encapsulates all pokemon images into a scrollable easy to deselect filter. This is implemented for exclude_min_iv, hide_pokemon and notify_pokemon.

In the config file I added two variables for this one. The first is $noImageSelect. This allows you to turn on and off the image based filtering and fallback to select 2 if you want. The second is $pathToImages which allows you to define a custom path to where the pokemon images are located. Default path is to the icons-safe directory.

This has been tested on Chrome, Firefox, Safari, and Edge.

…ify_pokemon

Added Config Setting to turn it on or off.
@hammydown4325 hammydown4325 changed the title Global Min IV Filter Global Min IV Filter / Image Based Pokemon Filters Jan 6, 2018
@hammydown4325
Copy link
Contributor Author

Still needs a little work to load in local storage. Should have finished up soon.

$excludeMinIV = '[131, 143, 147, 148, 149, 248]'; // [] for empty

$noMinIV = false; // true/false
$MinIV = '0'; // "0" for empty or a number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minIV not MinIV

$excludeMinIV = '[131, 143, 147, 148, 149, 248]'; // [] for empty

$noMinIV = false; // true/false
$MinIV = '0'; // "0" for empty or a number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@hammydown4325
Copy link
Contributor Author

I'll change that when I get home. Thanks for or pointing that out.

@123FLO321
Copy link
Contributor

123FLO321 commented Jan 7, 2018

A few thoughts:

  • Maybe a red transparent background in addition to the red border would be nice
  • Maybe change the border color based on what it does (e.g. exclude red, notify blue, include green)
  • Maybe add the same selector used for min iv to notify iv and notify level

And a minor bug:

  • In Safari it still opens the picker view

Otherwise really awsome work.

@hammydown4325
Copy link
Contributor Author

Good ideas on the transparency and changing of the colors. I'll today that up tonight thank!!

@hammydown4325
Copy link
Contributor Author

Ok i need to redo some data structuring and stuff to fix the safari bug as its not an easy one to fix. I have the other changes done and will keep you updated of my progress. I hope to have a solution early today.

@hammydown4325
Copy link
Contributor Author

In order to fix this dilema we need to convert the select lists on those three options into input[type="text"] fields. This will stop the select bar from popping up. My question is I originally left falllbacks in place in the code to allow people to continue using select 2 if they didn't want to use Image select.

Because of how input fields in select2 work each time the data is access and re put in we have to use .join and .split in order to make it compatible. We would need to add a conditional in each of the places where this exists to check if select2 or the other select is used. Do we want to do this or just convert all of PMSF into the new image based select menus? I'll have the polished PR in the morning but wanted to pry some minds overnight. Thanks!

@Falaris01
Copy link
Contributor

Falaris01 commented Jan 7, 2018

The change in how the pokemon are selected for notification / excluding is HUGE.

It has to be the number one complain by users.

I'm all for getting rid of the old way it's done, it was only functional with FireFox anyway.

Moved Hide Pokemon Up under the pokemon Toggle
Hide Pokemon now has transparent red background
Exclude Min IV now has green border with transparent green background
Notify Pokemon now has blue border with transparent blue background
Changed Notify of Perfection and Notify of Level to use number input fields for validation of the inputs.
Select 2 Pokemon Dropdowns have now been removed after consultations with several individuals.
Removed Config Parameters for fallback to old select2 method.
All/None Options Added to Image Based Pokemon Navigation
Min IV now refreshes mons within view range.
Removed padding 0 for buttons on mobile.
Upgraded Select 2 to latest version
@hammydown4325
Copy link
Contributor Author

I have made all requested updates to this point.

@123FLO321
Copy link
Contributor

There is a new bug:
Every time a pokemon gets added to the map it plays a sound (it sounds are enabled)

@hammydown4325
Copy link
Contributor Author

Let me take a look at that.

@hammydown4325
Copy link
Contributor Author

hammydown4325 commented Jan 7, 2018

@123FLO321 I am not getting this bug when mons are added to the map? Can you export your settings file your using and upload it here so i can have the exact settings. thanks!

UPDATE: I tried with notify off on all mons and sounds on and nothing played. Tried adding in weedle and each time a weedle spawned it made the weedle noise. Plenty of other mons were spawning that weren't making noises.

@123FLO321
Copy link
Contributor

123FLO321 commented Jan 7, 2018

It sends notifications again and again for a pokemon in the notify list.

@hammydown4325
Copy link
Contributor Author

@123FLO321 Provided me his setting file and found the bug. This is now fixed with this latest commit.

Copy link
Owner

@Glennmen Glennmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the spritesheet

Copy link
Collaborator

@CalamityJames CalamityJames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a vast PR, and from what I've tested in a real-world environment very well executed.

I just have a few minor niggles (and a PHP warning) that need changing.

Caveat: I've mainly been looking at the PHP, and I think it definitely needs another set of eyes or two to look over it, but it's been running in production on my server for a few days with no issues.

$this->set_cp_multiplier();
}

public function get_active($eids, $miniv, $minlevel, $exminiv, $swLat, $swLng, $neLat, $neLng, $tstamp = 0, $oSwLat = 0, $oSwLng = 0, $oNeLat = 0, $oNeLng = 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As RocketMap_Sloppy has not been updated, this throws the following warning:

PHP Warning:  Declaration of Scanner\RocketMap_Sloppy::get_active($eids, $swLat, $swLng, $neLat, $neLng, $tstamp = 0, $oSwLat = 0, $oSwLng = 0, $oNeLat = 0, $oNeLng = 0) should be compatible with Scanner\RocketMap::get_active($eids, $miniv, $minlevel, $exminiv, $swLat, $swLng, $neLat, $neLng, $tstamp = 0, $oSwLat = 0, $oSwLng = 0, $oNeLat = 0, $oNeLng = 0) 

I'd also request swapping to camelCase to keep in the styling of the other vars (change $minlevel to $minLevel for example). I understand they aren't all in camelCase but going forward we should be doing this, it also makes reading the variables a little easier :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot get the rocketmaps sloppy error to appear. I dont use rocketmaps sloppy nor do i have a database for it. I have display_errors on and and Display all errors and still nothing appear with either Monocle or Rocketmaps. My guess is it's missing the constructor but thats just a guess from the code and no testing. I'll take care of the camel casing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's strange, because all libraries are loaded by default. The reason it throws the error is because get_active() for RocketMap_Sloppy has a different list of arguments when compared to RocketMap (because you've added $miniv, $minlevel, $exminiv,).

I'll take another look in the morning and see if this is not just something exclusive to my test build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats weird because rocketmap_sloppy is basically an empty object in all sense other than it inherits rocketmaps. I had one other guy on rocketmaps get the same error but other than that other rocketmaps instances were running fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entirely my fault @iroken222. My sincere apologies, it was an error on my end. I'll approve these changes now!

raw_data.php Outdated
$prevminiv = !empty($_POST['prevminiv']) ? $_POST['prevminiv'] : false;
$minlevel = !empty($_POST['minlevel']) ? $_POST['minlevel'] : false;
$prevminlevel = !empty($_POST['prevminlevel']) ? $_POST['prevminlevel'] : false;
$exminiv = !empty($_POST['exminiv']) ? $_POST['exminiv'] : '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about camelCase here :)

package.json Outdated
"push.js": "^1.0.4"
},
"devDependencies": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done an in depth code review yet, just a quick question.
Why did you move these dependencies to devDependencies?

Will probably be my small npm knowledge that is failing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was on accident though we shjould definitely look through these. dependencies are required to run the application where as develop dependencies are only needed to develop. Things like phplint and other things that dont need to be in the build process shouldn't be in there. I'll move them back for now and we can discuss at a later time.

pre-index.php Outdated
</div>
<div id="tabs-2">
<?php
if (!$noExcludeMinIV) {
Copy link
Contributor

@123FLO321 123FLO321 Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove the tabs completely instead of only removing their content (for noHidePokemon and noExcludeMinIV)

Converted Functions to camel case.
Fixed package.json errors.
@hammydown4325
Copy link
Contributor Author

I have patched all issues mentioned above except the one @CalamityJames is going to look at. Please double check and make sure I got all the internationalizations as there are a lot of them. I also found some additional strings like Disable and such and converted them too. @CalamityJames @Glennmen @123FLO321

Copy link
Owner

@Glennmen Glennmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look into these issues.
I only did a code review, not tested it.

@@ -78,12 +78,23 @@

/* Marker Settings */

$pathToImages = '/static/icons-safe/'; // Path to images. Images must not contain 0s
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this to example.config.php and better alignment of the comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is removed. now. Must of missed during cleanup

lib/Monocle.php Outdated
if (empty($exminiv)) {
$conds[] = '((atk_iv + def_iv + sta_iv)' . $float . ' / 45) * 100 >= ' . $miniv;
} else {
$conds[] = '(((atk_iv + def_iv + sta_iv) / 45)' . $db->info()['driver'] == 'pgsql' ? "::float" : "" . ' * 100 >= ' . $miniv . ' OR pokemon_id IN(' . $exminiv . ') )';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use $float here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed update. Fixed now

} else {
$conds[] = '(level >= ' . $minlevel . ' OR pokemon_id IN(' . $exminiv . ') )';
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monocle/Alternate fork now also has get_active_by_id()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated this function into alternate

return $this->query_active($select, $conds, $params);
}

public function get_active_by_id($ids, $swLat, $swLng, $neLat, $neLng)
public function get_active_by_id($miniv, $minlevel, $exminiv, $ids, $swLat, $swLng, $neLat, $neLng)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be in the wrong order, $ids should be the first parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch updated this

lib/Monocle.php Outdated
}
if (!empty($minlevel) && !is_nan((float)$minlevel) && $minlevel != 0) {
if (empty($exminiv)) {
$conds[] = '(level >= ' . $minlevel;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZeChrales fork doesn't have level in DB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the level portion of ZeChrales

Include extra get_active_by_ids in Alternate Branch
Removed extra config parameter.
Fixed missing float variable in Monocle.php
Removed level from stock Monocle
$conds = array();
$params = array();

$select = "pokemon_id, expire_timestamp AS disappear_time, encounter_id, lat AS latitude, lon AS longitude, gender, form";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where you copied this from but this line has weight on develop branch

@@ -54,6 +70,7 @@ public function get_active_by_id($ids, $swLat, $swLng, $neLat, $neLng)
$params = array();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something went wrong when solving the merge conflicts, $miniv, $minlevel, $exminiv are removed from function params.

Copy link
Collaborator

@CalamityJames CalamityJames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Glennmen Glennmen merged commit d08665b into Glennmen:develop Jan 22, 2018
@hammydown4325 hammydown4325 deleted the develop branch April 21, 2018 13:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants