Skip to content
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

Check for hyper training legality #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions src/checks/hyper-training-31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
description: 'A maxed IV (31) cannot be hypertrained.',
field: 'iv',
test (pkmn) {
return !(
pkmn.ivHp === 31 && pkmn.hyperTrainedHp ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Rework the logic on this one as well, please. It's also really confusing to do.

Fitler on gen 7, and make it similar to how I did the other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So just to clarify - should it be done like the other test where it's split in their separate cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah

pkmn.ivAtk === 31 && pkmn.hyperTrainedAtk ||
pkmn.ivDef === 31 && pkmn.hyperTrainedDef ||
pkmn.ivSpAtk === 31 && pkmn.hyperTrainedSpAtk ||
pkmn.ivSpDef === 31 && pkmn.hyperTrainedSpDef ||
pkmn.ivSpe === 31 && pkmn.hyperTrainedSpe
);
}
};
12 changes: 12 additions & 0 deletions src/checks/hyper-training.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
description: 'A Pokémon from SuMo can only be hyper trained if level 100.',
filter (pkmn) {
return pkmn.level !== 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this filter and test. It's quite complicated to read. We don't want to play coding golf here.

Filter on the game, imo.

Then do something like

if (pokemon.level === 100) {
return true
}
if (pokemon.hyperTrained || .. ) {
return false
)

That makes it really clear what it's doing. As I read through this, it's really complicated to figure out what the logic is actually doing, it kinda feels unnecessary to make it so concise, and also we don't want to check non-gen 7 pokemon.

},
field: 'level',
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really level, is it? It's hypertrained that's the issue.

test (pkmn) {
return !(pkmn.hyperTrainedHp || pkmn.hyperTrainedAtk ||
pkmn.hyperTrainedDef || pkmn.hyperTrainedSpAtk ||
pkmn.hyperTrainedSpDef || pkmn.hyperTrainedSpe);
}
};
7 changes: 6 additions & 1 deletion src/helpers/gameId.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const genMap = {
1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 15: 3, /* S, R, E, FR, LG, XD/Colo */
7: 4, 8: 4, 10: 4, 11: 4, 12: 4, /* HG, SS, D, P, Pt */
20: 5, 21: 5, 22: 5, 23: 5, /* W, B, W2, B2 */
24: 6, 25: 6, 26: 6, 27: 6 /* X, Y, OR, AS */
24: 6, 25: 6, 26: 6, 27: 6, /* X, Y, OR, AS */
28: 7, 29: 7 /* Su, Mo */
};

exports.isFromXY = function (gameId) {
Expand All @@ -13,6 +14,10 @@ exports.isFromORAS = function (gameId) {
return [26, 27].indexOf(gameId) > -1;
};

exports.isFromSuMo = function (gameId) {
return [28, 29].indexOf(gameId) > -1;
};

exports.originGen = function (gameId) {
return genMap[gameId];
};
Binary file added test/pk7/illegal/6iv-hypertrained.pk7
Binary file not shown.
Binary file added test/pk7/illegal/underleveled-hypertrained.pk7
Binary file not shown.
Binary file added test/pk7/legal/sumo-hyper-trained.pk7
Binary file not shown.