Commit graph

28 commits

Author SHA1 Message Date
Kurt
92a50264cc
Refactor RNG advance/reverse methods (#3579)
The new LCRNG/GCRNG/ARNG classes are static, rather than singletons. Allows them to be inlined much better.
2022-09-04 12:03:37 -07:00
Kurt
3c232505e5
Refactoring: Narrow some value types (Species, Move, Form) (#3575)
In this pull request I've changed a ton of method signatures to reflect the more-narrow types of Species, Move# and Form; additionally, I've narrowed other large collections that stored lists of species / permitted values, and reworked them to be more performant with the latest API spaghetti that PKHeX provides. Roamer met locations, usually in a range of [max-min]<64, can be quickly checked using a bitflag operation on a UInt64. Other collections (like "Is this from Colosseum or XD") were eliminated -- shadow state is not transferred COLO<->XD, so having a Shadow ID or matching the met location from a gift/wild encounter is a sufficient check for "originated in XD".
2022-08-26 23:43:36 -07:00
Kurt
6441bdadd8
Add specialized struct for Moveset and IV specs (#3572)
`Moveset` struct stores 4 moves, and exposes methods to interact with a moveset.
`IndividualValueSet` stores a 6 IV template (signed).

Performance impact:
* Less allocating on the heap: Moves - (8 bytes member ptr, 20 bytes heap->8 bytes member)
* Less allocating on the heap: IVs - (8 bytes member ptr, 28 bytes heap->8 bytes member)
* No heap pointers, no need to jump to grab data.
* Easy to inline logic for checking if moves are present (no linq usage with temporary collections).

End result is faster ctor times, less memory used, faster program.
2022-08-21 17:34:32 -07:00
Kurt
2cb2531288 Add more xmldoc 2022-08-21 01:39:16 -07:00
Kurt
fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00
Kurt
88ddc5822e c#10: readonly record structs
Reduces some boilerplate constructors/equality compares
2021-12-04 18:32:35 -08:00
Kurt
6071834d4f Fix gender ratio comparison for Colo starters
LockFinder:
https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/?do=findComment&comment=263736

CXDVerifier:
Use a switch expression for a more concise representation of logic
2020-12-29 20:25:05 -08:00
Kurt
5fc15dc9c8 Correctly prevent xd locked shinies
oops, 7fd7a86074 was not correct (only handled lockless) -- the verifier doesn't check the final shadow pokemon (not a lock).

https://projectpokemon.org/home/forums/topic/57014-shiny-shadow-pok%C3%A9mon-from-xd-shown-as-legal-pkhex-legality-check-error/
2020-05-08 10:07:21 -07:00
Kurt
7fd7a86074 Shiny check lockless XD shadow encounters 2020-04-09 14:14:48 -07:00
Kurt
1d5f929981 Fix shiny check behavior for XD nonshadows
XD compares the player TSV against the non-shadow members, which is unnecessary but does result in them being able to cause shiny skips.

Update the VerifyNPC method to remove tsv check, as it's just repeating the logic we've done in the lock generator.

Added a test method that can be stepped through; compare the team results manually since they aren't exposed for interaction.

Closes #2751 , big thanks to @ijuintekka for being so detailed in their investigation/report!

Co-Authored-By: ijuintekka <ijuintekka@users.noreply.github.com>
2020-03-11 19:18:58 -07:00
Kurt
8acb336d51 Use enum for species comparisons
slightly easier to read with named values
2019-12-08 17:39:19 -08:00
Kurt
9401b7a790 More readonly struct tweaks
help dat compiler
minor clean elsewhere
2019-10-26 23:18:25 -07:00
Kurt
2a8b43d9c7 Remove temporary test
Shadow lock checks were finished; teams with 5 locks are working.
Relocate member data to the full team verifier.
2019-01-06 20:58:17 -08:00
Kurt
908c98b876 Switch lock checks to newer more complete check obj
Now accounts for the shiny locks & associated restrictions, abusing the
recursion by setting & unsetting the required CPU Trainer's shiny value.

Repoint all test methods to use the new obj methods
2018-10-29 22:49:04 -07:00
Kurt
b124a6e70d Extract seedframe to separate file
soon tm
2018-10-29 21:03:29 -07:00
Kurt
1b57acc6a7 Check all locks for legality checking
Single->All
2018-10-28 20:28:56 -07:00
Kurt
7c0a74337e Update shadow lock checks
Passes all 3 lock3 cases in addition to some bulk checks
(VerifyPIDResults).
Lock4 has an issue on one; will have to investigate why.
2018-10-28 20:10:35 -07:00
Kurt
4268239c12 Continue work on shadow lock checks
Now gets count=2 tests working

yield return new SeedFrame { FrameID = ctr + (l.Seen ? 5 : 7), PID = pid
};
used to be ctr + 6, needs to alternate even-odd
all 2 lock cases pass, but didn't make lock3's pass. Something else is
still amiss :)

break out some classes for the solidified lock objects
2018-10-28 11:15:40 -07:00
Kurt
8c4a17335f Add first shadow lock test method
Everything should always pass the first lock check; will add shortly to
any cxd encounter checks
2018-10-21 20:55:02 -05:00
Kurt
c0aae6ab78 Add cxd lock check info & begin troubleshooting
commented out test calls = not working
will have to debug in more detail later; the first lock is always
working at least.

data sourced from
https://github.com/ijuintekka/Eligor/blob/master/Eligor/Spread.cs , not
sure if it's perfect.

can't cleanly condense deviating team appearances as double-shadow leads
can't be selectively encountered. didn't feel like modding lockfinder's
recursive algo to be smarter.
2018-10-20 21:03:04 -05:00
Kurt
b280ffcfef style updates
should be pretty much it
2018-09-14 22:37:47 -07:00
wwwwwwzx
a25c6a4e00 Fix Colo Starter PID Method Check (#1961)
If SIDf >> 16 != SID then temp won't be assigned.
2018-05-24 06:00:29 -07:00
Kurt
e2f11edc43 Refactoring
discards, Array.Find over FirstOrDefault
2018-05-12 08:41:29 -07:00
Kurt
420a18ea85 Rework shadow lock checking
tested for 2 locks, later commits with legality check implementation
will feature more lengthy lock checks (test case automation).

https://pastebin.com/VdbjWaqL
(species doesn't matter since most are 50/50 ratio)
2018-02-04 16:33:53 -08:00
Kurt
9a20734be2 Update lock checks
test case
https://pastebin.com/f4K7uc56
only checked for single locks
2018-02-04 00:06:07 -08:00
Kurt
495eb26740 Rework colo starter PIDIV detection
force colo starters to be male only
use some c# lang features for EncounterType flags

add edge case PIDIV detection for starter gender/shiny lock scenario

adds a little documentation for those unfamiliar with the NPC PKM
generation quirks.

Colosseum Starters will now be recognized with a different PIDIV type
which is specific to them & them only.
2017-11-01 21:12:44 -07:00
Kurt
3f38b123a3 Refactoring
mostly renaming things, includes a little bit of added sugar and
splitting methods to simplify the codebase.

all methods are now PascalCase
2017-06-17 18:37:19 -07:00
Kurt
72865bbfe9 Add recursive shadow lock check template
nowhere near complete/functional, just getting out of src control until
more effort is exerted on this topic
2017-05-18 17:36:43 -07:00