Commit graph

181 commits

Author SHA1 Message Date
Kurt
c3117994cc Allow GO7 handler 0
New current handler verifier settings flag GO => LGPE transfers. Unlike GO => HOME, these transfers use your LGPE OT info, so it's legal to have no HT and have the current handler be OT

Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2022-06-08 00:27:24 -07:00
Kurt
ab723af640 Expose Context for SaveFile/ITrainerInfo 2022-06-03 19:08:46 -07:00
Kurt
5bcccc6d92
HOME 2.0.0: Handle conversion behavior & restrictions (#3506)
* Revises legality checks to account for traveling between the three game islands (PLA/BDSP/SWSH)
* Adds conversion mechanisms between the three formats, as well as flexible conversion options to backfill missing data (thanks GameFreak/ILCA for opting for lossy conversion instead of updating the games).
* Adds API abstractions for HOME data storage format (EKH/PKH format 1, aka EH1/PH1).
* Revises some APIs for better usage:
  - `PKM` now exposes a `Context` to indicate the isolation context for legality purposes.
  - Some method signatures have changed to accept `Context` or `GameVersion` instead of a vague `int` for Generation.
  - Evolution History is now tracked in the Legality parse for specific contexts, rather than only per generation.
2022-05-30 21:43:52 -07:00
Kurt
ecee948107 Add gender sprites for main GUI
Might trickle this out to the other editors that have gender toggles.
2022-04-24 20:28:56 -07:00
Kurt
ef3cb34387
Refactor EvoCriteria to be a struct, reduce allocation (#3483)
* Make EvolutionCriteria struct

8 bytes per object instead of 26
Unify LevelMin/LevelMax to match EncounterTemplate
bubble up precise array type for better iteration

* Inline queue operations, less allocation

* Inline some logic

* Update EvolutionChain.cs

* Improve clarity on duplicate move check

* Search reverse

For a dual stage chain, finds it first iteration rather than second.
2022-04-23 21:33:17 -07:00
Kurt
4841a01b4e Update GO pickles, move Shiny.Never before Always 2022-03-12 17:39:01 -08:00
Kurt
69fafcab83 Performance: Slightly reduce allocations in moveset validation (#3460)
* Reuses move parse result objects for each encounter parsed in a LegalityCheck attempt, instead of creating a new object.
* Ensures the objects are never-null, and makes cleanup easier.

Slightly adjusts some other parts of the moveset validation to reduce allocations.
2022-03-12 17:39:00 -08:00
Kurt
93255efcb8 Disassociate Shiny enum from WC6 PIDType (#3461)
Have `Shiny.Random` be `0`, so we can skip init on this field for EncounterStatic. Plus makes it a little less brittle for future expansion if shiny qualities change.
2022-03-12 17:38:59 -08:00
Kurt
2991f62052 Reduce allocation for eggmove loading 2022-02-28 18:24:11 -08:00
Kurt
0b32cbf132 Update PKHeX.Core abstractions with latest logic
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2022-02-04 17:35:15 -08:00
Kurt
9cde291595
Enumerate ability permissions in encounter templates, misc updates (#3368) 2022-01-08 22:34:04 -08:00
Kurt
f83a9bf833 Expose shiny potential value
Not really digging it currently as it doesn't cover multi-state like AlwaysStar-Or-Never, but that single edge case can be handled elsewhere
2022-01-07 17:48:12 -08:00
Kurt
36bf73818e Source trainers for encounter database
Closes #3364
Related: #3358
2022-01-03 19:33:10 -08:00
Kurt
47071b41f3
Refactoring: Span-based value writes and method signatures (#3361)
Existing `get`/`set` logic is flawed in that it doesn't work on Big Endian operating systems, and it allocates heap objects when it doesn't need to.

`System.Buffers.Binary.BinaryPrimitives` in the `System.Memory` NuGet package provides both Little Endian and Big Endian methods to read and write data; all the `get`/`set` operations have been reworked to use this new API. This removes the need for PKHeX's manual `BigEndian` class, as all functions are already covered by the BinaryPrimitives API.

The `StringConverter` has now been rewritten to accept a Span to read from & write to, no longer requiring a temporary StringBuilder.

Other Fixes included:
- The Super Training UI for Gen6 has been reworked according to the latest block structure additions.
- Cloning a Stadium2 Save File now works correctly (opening from the Folder browser list).
- Checksum & Sanity properties removed from parent PKM class, and is now implemented via interface.
2022-01-02 21:35:59 -08:00
Kurt
507eef43e7 Move enum to separate file 2021-10-09 16:25:36 -07:00
Kurt
dd9b31dbbe Remove unnecessary property
template stores the version; no need to refer to store it separate from the object
Generation being separate is fine for now
2021-10-08 23:30:03 -07:00
Kurt
2575d73144 Add IFixedAbilityNumber, hide vivillon region flags
tfw can't using static a private class in the file, gotta be explicit.
2021-09-06 18:11:32 -07:00
Kurt
92d15bdd03 Rename SetTradeMemoryHT, add SetTradeMemoryHT8
Gen6 behaves differently from Gen8.
Fix broken test case [Arrived via link trade, it had fun! (2) -> (3)]
2021-08-29 13:15:45 -07:00
Kurt
6e3bcd5b66 Encounter visualization: Show ball and differentiate visually 2021-08-24 14:03:20 -07:00
Kurt
bedc52943e Trailing commas
No functional change
2021-08-20 13:49:20 -07:00
Kurt
b8e203bdef Remove invalidmatch tracking
The Encounter verifier method rarely rejects as our inner encounter matching methods are all-or-nothing. Don't bother keeping references for this bloat.
Ran the unit tests and nothing hit this logic.
2021-08-06 15:38:39 -07:00
Kurt
9f8642f7d2 Hide Generation/Game setters behind mutation method 2021-08-06 15:35:49 -07:00
Kurt
4e669468c3 Pass parse result list to encounter info fetch ctor
Old: when an encounter is found, we copied the contents of the list into our analysis list.
Since we stop when we find a suitable encounter, the old list is useless. By sharing the same list, there's no consequence. Reduces allocation by ~56B each analysis object!

Simplification reduces the amount of method calls by 1
2021-08-05 17:16:13 -07:00
Kurt
1efebe51d3 Simplify Country/Region/ConsoleRegion to byte from int
Only exists in gen6/7 games.
2021-08-02 19:43:57 -07:00
Kurt
565f161226 Show shiny state of encounter in db
Force shiny state for GO encounters

For encounters, this interface property is mainly just for exposing metadata for sprites.
2021-05-18 10:36:45 -07:00
Kurt
0e2f070510 Clean up know-move-evolution checks
Looks like Mr. Rime case wasn't being handled, so I rewrote it. Better performance, less complexity. No need to double-reference the moves.

Cache a single Valid evolution result; every parse can reuse that object.
2021-05-15 21:41:04 -07:00
Kurt
2f078e6565 Minor tweaks
Make HP IV set use single array fetch, less memory required
add some xmldoc
2021-04-20 01:02:32 -07:00
Kurt
fd8da81b4a Remove unnecessary setter 2021-04-18 11:00:40 -07:00
Kurt
0d45075d4b
Rewrite settings handling; enhance some user experiences (#3193)
- Settings now stored as json next to exe
- Settings now exposes all legality checking setttings that can be changed
- Slot hovering now can play cries in MGDB/PKMDB/etc, not just the main boxes.
- Enhanced hover text for mystery gifts and encounters that have movesets
- Show recently loaded save files in ctrl-f browser
- Toggle auto-load savefile setting to be none/detect-latest/last-loaded
- Custom extensions & extra backup paths can now be configured directly in the json settings
- Settings editor now uses propertygrid & tabs.
2021-04-11 18:09:54 -07:00
Kurt
75fb704658 Use already allocated result array
All operations overwrite all 4 entries of the result array, so no need to forcibly reallocate the array.
2021-03-30 20:27:40 -07:00
Kurt
a2d5d7d769 Show preview for encounter database slots on hover 2021-02-06 22:33:13 -08:00
Kurt
d2d20c13e0 Don't emit JP-BU as a random gameversion 2021-01-31 21:28:33 -08:00
Kurt
3a6bff11c9 Fix relearn move check for gen6+
Probably should rewrite some sections of the current move verifier; lots of old code with illogical paths
2021-01-28 18:08:13 -08:00
Kurt
3c42978afa Use IndexOf instead of FindIndex when possible 2021-01-16 12:47:02 -08:00
Kurt
730640decc Minor clean 2021-01-03 16:53:13 -08:00
Kurt
97be69bca1 Use EncounterMatch when EncounterOriginal doesn't matter 2021-01-02 14:47:39 -08:00
Kurt
09089da14e Use more expression return style
Reduces indentation & bracketing, a bit more concise
2021-01-01 17:08:49 -08:00
Kurt
2689e72252 Hide field that shouldnt be used by external users
Not to be confused with LegalityAnalysis.Parse
2020-12-31 17:14:39 -08:00
Kurt
c14f2a1dd1 Minor initialization tweaks
GameStrings: 10% of strings are unique; just mark everything. Stop a little early so we don't process the empty & (trade) string.
LearnsetReader: All empty entries are length==0; malformed should throw an exception (never).
EggMoves: Compute ptr inside the array fetch loop; don't use linq.

EggMoves & string shaves off 80ms of startup time according to profiling; some could be attributed to warm-up but yay more efficient.
2020-12-28 10:22:13 -08:00
Kurt
749fef0ac6 Minor clean 2020-12-24 15:23:38 -08:00
Kurt
afdd2bd57e Mark EncounterSlot/Static types as immutable record types 2020-12-23 20:40:59 -08:00
Kurt
98be0f6739 Target type'd new 2020-12-21 17:17:56 -08:00
Kurt
0303eada32 this is not that
clearer than before, yay
2020-12-21 17:12:39 -08:00
Kurt
62018cce1a Unify concepts with different names
AltForm & Form & Forme => Form
GenNumber & Generation => Generation

Extract out SpeciesForm interface, and re-add IGeneration

For those using PKHeX as a dependency, this should be a pretty straightforward manual replacement... GenNumber and AltForm should be quick find-replace`s.
2020-12-10 20:42:30 -08:00
Kurt
cb24c20a44 Remove relearn suggestion logic from relearn move verification
Sure it's nice to cache a valid array, but the amount of logic was small enough that it can be done with 10 lines of code rather than at the end of each verification method.

Reduces parameter passing & removes 1 field from the info object, as relearn suggestions are only done rarely after legality checking.

Allows for a simpler api surface (pkm, encounter) rather than a bigger object reference
2020-11-07 12:25:15 -08:00
Kurt
c09fb9a0ec Simplify "Flag" field in move source tracking 2020-10-17 13:40:12 -07:00
Kurt
6938d2f94d Split VivillonTables into two classes
Indicate that the content is for 3DS specific logic
Reduce restriction for parameters requiring IGeoTrack => IRegionOrigin
2020-10-04 14:15:13 -07:00
Kurt
9ce09c8b1b Minor clean 2020-08-30 16:16:22 -07:00
Kurt
13ee3745f2 Remove some unecessary setter requirements 2020-08-30 15:44:13 -07:00
Kurt
1bc7994137 Remove usage of linq for duplicate count
Check successive move slots after the current index rather than doing a count eq >= 2.

Flag all empty slots prior to a filled move slot, rather than flagging a full slot as invalid because "empty move".
2020-08-30 15:43:29 -07:00