Commit graph

971 commits

Author SHA1 Message Date
Kurt
5942a74147 Expose SpeciesID3 for CK3/XK3
Closes #3463
Not going to add unobtainable species IDs to the GUI.
2022-03-13 19:53:46 -07:00
Kurt
d95ba482f3 Reduce allocation in methodfinder IV set 2022-03-13 19:39:38 -07:00
Kurt
d5ae6764aa Stackalloc IVs for template->pkm fill 2022-03-13 19:24:08 -07: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
2e6364dceb Fix pk2->pk1 nickname copy
nobody noticed until I did
2022-03-10 18:00:45 -08:00
Kurt
e1414a0bea Move some interfaces to different folder
No code changes
2022-03-06 12:06:50 -08:00
Kurt
c51d51d381 More specific primitives for Memories/others 2022-03-06 12:01:47 -08:00
Kurt
e17483fe46 some linq reduction 2022-03-05 20:03:52 -08:00
Kurt
1b266c1e4b Handle PLA MMO formarg deferral
Can capture formarg evolved stuff directly in wild
2022-03-05 18:54:50 -08:00
Kurt
3d9c7dc750 Reduce IAwakened from int->byte 2022-03-05 18:46:03 -08:00
Kurt
b20566eb59 Use actual primitive instead of int
Some interfaces aren't needed to be exposed as int
2022-03-05 18:30:35 -08:00
Kurt
6ae59c509f IGanbaru int->byte fields 2022-03-04 22:34:11 -08:00
Kurt
7443db3564 Update some xmldoc 2022-03-04 22:34:11 -08:00
Kurt
e5e2a3427f Rename Silver SV->SI
SV will likely be the lump for SCarlet and VIolet
2022-02-27 11:16:12 -08:00
Kurt
2753927942 Ignore empty slots in pre-filter
Add Palma property to PK8 per bdsp disassembly
2022-02-22 07:34:43 -08:00
Kurt
75bd26d056 Add new Illegal (clone/glitch abuse) flag + check 2022-02-21 20:13:27 -08:00
Kurt
f2637168ab Fix kor string writes
Was writing kor string, then writing en after (all terminators).
Make method signature match other SetString, with write buffer as first arg

Closes #3440
2022-02-17 23:11:13 -08:00
Kurt
51975e4bdd Only push move if doesn't already have
Closes #3439
2022-02-17 20:53:21 -08:00
Kurt
dc3d8e7cec Minor clean 2022-02-14 21:32:52 -08:00
Kurt
0eece2711a Set the calc h/w float regardless of epsilon
epsilon no longer required per #3417
closes #3434
2022-02-12 18:48:33 -08:00
Kurt
cedf13c343 PK4: Fix DP met location write
Closes #3431
2022-02-11 16:28:51 -08:00
Kurt
a5d1bf7900 Fix cxd pouch write, bk4 pid reads
Closes #3429
2022-02-10 10:57:59 -08:00
Kurt
a287efe3a1 Inline pk2/pk3 form setter, only SetGender if different
Helps out ALM generate unown
2022-02-09 20:20:32 -08:00
Kurt
6da235f0e8 Set 3 flawless IVs if randomizing alpha IVs
Closes #3428
2022-02-09 19:26:18 -08:00
Kurt
d17639f956 Add alpha move for encounter slots
oops
Closes #3427
2022-02-09 19:21:45 -08:00
Kurt
9c5955c104
Emulate Height & Weight float calculations matching the game (#3417)
* Accurately implement height/weight calc

* Handle GUI reads

Having Auto off will read and write the values correctly

F6 will handle all the decimal points possible

* Remove no longer needed tolerance check
2022-02-08 18:56:11 -08:00
Kurt
e12f3004ad Post-check defer if catchrate disallows tradeback
Closes #3412
2022-02-07 18:44:29 -08:00
Kurt
e8903505df Min move count: ignore purchased moves 2022-02-05 16:47:19 -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
429c80e9f5 Add new abstractions for pkm/personal/mysterygift
Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
2022-02-04 17:26:15 -08:00
Kurt
659fc9978b Stackalloc marking set & raid IV gen 2022-01-08 22:48:33 -08:00
Kurt
b96e2cacd7 Add xmldoc 2022-01-08 09:54:32 -08:00
Kurt
9bddc89c07 Use span if possible instead of new arrays 2022-01-07 20:56:44 -08:00
Kurt
01f1be6f89 Fix incorrect g1 trade trainer char reference 2022-01-07 20:52:26 -08:00
Kurt
8f5f80b391 Only remove space in gen1/2
prior version removed all spaces if < 3, this just early returns before span trimming.
2022-01-07 20:34:35 -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
cc8ac7a4f1 Remove unnecessary warning suppression
fixed dat .editorconfig in vs22
Catching general exceptions is okay because this program handles user modified data that can potentially be corrupt.
2021-12-27 12:09:15 -08:00
Kurt
5f7caf9ca2 Tweak PB8.FixMemories for importing eggs & handler quirk 2021-12-27 01:53:28 -08:00
Kurt
24e1898410 Update gen4 Shedinja handling
PK4->PK5 fixes gendered Shedinja -> genderless.
Clean up PK4 ball value setters and expose those 2 properties separately.
Add edge case permission for HG/SS Sport Ball Shedinja being legal if evolved on DP (DP doesn't change 0x86, lol)
Copy PokéathlonStat and ball values individually for BK4<->PK4 conversion

Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-12-26 20:13:36 -08:00
Kurt
76ab09f024 Inline constant value 2021-12-26 01:06:30 -08:00
Kurt
1d0993f852 Remove EvoBase, relocate functions to call sites
Utilize FormInfo to remap battle forms into hatch forms so the encounter matches something valid, and is flagged later in FormVerifier
2021-12-26 00:57:40 -08:00
Kurt
543359fff6 Add contest stat sheen checking
Closes #3324
2021-12-07 00:54:39 -08:00
Kurt
f55c5bea66 Minor clean
no functional change
2021-12-04 17:56:56 -08:00
Kurt
4046ea0840 Handle encrypted pb8 file detection as pb8 2021-11-30 22:08:15 -08:00
sora10pls
5b04a10fa3 Swap Pioneer and TwinklingStar indexes
silly me
2021-11-25 19:27:02 -05:00
Kurt
cd5c220ddc Show correct HatchCounter value for BDSP traded eggs
Yay abstractions to hide away the quirks.

BDSP traded eggs set HT_Friendship and the CurrentHandler flag, but the HatchCounter is always the OT_Friendship value.

Trades always receive BaseFriendship, instead of a hardcoded 50. Necessary to not hardcode because it's immutable for eggs.

Clicking the hatch counter label now sets it to the legal minimum hatch counter (best), and control clicking sets it to the max (worst). Check the encounter template for the true maximum.
2021-11-21 19:53:13 -08:00
Kurt
1ca1b838c1 Handle traded BDSP eggs & flag HatchCounter=0 2021-11-21 19:29:07 -08:00
Kurt
baa7bd52a8 Manually hardcode incompatible conversion cases for P*8 2021-11-20 09:40:38 -08:00
Kurt
b26f4db6ab Enforce AffixedRibbon -1
All your hacks are still hacks

Re-expose affixed ribbon in the ribbon editor for PB8
Since there's no way to change it in BDSP, flag anything non-neg1
2021-11-20 09:04:09 -08:00
Kurt
723514e89c
Update 21.11.19 - Brilliant Diamond & Shining Pearl (#3289)
Big thanks to @SciresM @sora10pls @Lusamine @architdate @ReignOfComputer for testing and contributing code / test cases. Can't add co-authors from the PR menu :(

Builds will fail because azure pipelines not yet updated with net6.
2021-11-19 18:23:49 -08:00
Kurt
4b263bf9bb Fix pattern matching comparison
Wish I had an analyzer to catch this (missing parens) similar to boolean logic

#3271 - resolves the traded egg recognition issue
2021-10-13 20:05:19 -07:00
Kurt
aa5b8c217b Don't update catch rate if it's already zero 2021-10-04 22:55:18 -07:00
Kurt
113cd9be4f Clamp pk5->pk6 feeling set for HT
bank transfers limited to first 10 feelings
2021-10-02 10:42:39 -07:00
Kurt
51a01a6df5 Update G3PKM.cs 2021-09-30 21:46:13 -07:00
Kurt
25316fbaef Add IV ceiling for GBL GO encounters 2021-09-17 17:56:15 -07:00
Kurt
80d1712b72 Mark stuff with enums, remove unused arrays
Fix shuffled comments for FormInfo
Remove unnecessary Reset on ctor, all fields are already the default
2021-09-07 20:57:19 -07:00
Kurt
1d00e17217 Add properties for cleaner interaction 2021-09-07 15:31:54 -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
20d0fcfab4 More performant trashbyte clearing 2021-08-29 12:02:07 -07:00
Kurt
c65fda5e7d Allow HM moves in gen2-4 eggs
Yay silly inheritance
ty atrius
2021-08-28 13:54:58 -07:00
Kurt
0e2dac3ff6 Minor tweaks
Empty return for invalid species encountertemplate fetch
Expose property for ck3 @ 0xD7
show legal memory context items rather than gen8 always
2021-08-25 19:23:15 -07:00
Kurt
c1a7d04c5c Fix ck3 fateful read
Hope 555e81205d was actually incorrect and that this is finally correct
2021-08-24 22:23:45 -07:00
Kurt
a631e5cb4e Rearrange how some memory info is checked
Split into different game contexts
2021-08-22 16:41:57 -07:00
Kurt
5b42dc8ae4 Minor clean 2021-08-22 00:05:41 -07:00
Kurt
8f0fb902d1 ArgumentException -> ArgumentOutOfRangeException 2021-08-21 16:51:50 -07:00
Kurt
cd12962a50 Remove Tradeback state caching in PKM data
Since we have more metadata with move learn sourcing, we can check if it was traded to gen2 to get new moves / deleted.

Adjust call sites appropriately
might have some issues, to be ironed out maybe
2021-08-20 15:59:54 -07:00
Kurt
bedc52943e Trailing commas
No functional change
2021-08-20 13:49:20 -07:00
Kurt
a926923a6b Remove Fullness/Enjoyment from ExtraBytes
They show up in the memory editor
2021-08-15 19:32:50 -07:00
Kurt
05d745afe5 Fix inverted format search 2021-08-15 19:32:33 -07:00
Kurt
e1c8ab8d96 Fix remapped glyph
Future updates to glyph remapping to come later
2021-08-13 17:25:20 -07:00
sora10pls
803fe84f04 Add form strings for Eiscue, Morpeko, and Zacian/Zamazenta
Ice Face, Full Belly Mode, and Hero of Many Battles (strings trimmed where appropriate)
2021-08-07 13:22:14 -04:00
Kurt
0f3e5095c5 Replace more linq usage 2021-08-05 22:39:38 -07:00
Kurt
5c472a400d Expand shorthand parameters
int i => int index, or whatever the value is representing.
2021-08-05 20:33:25 -07:00
Kurt
9f4ff5f070 Update SearchSettings.cs 2021-08-05 12:07:40 -07:00
Kurt
277b1b658d Un-nest 3ds console region bitflags
Insert 3DS into the name to indicate that it's for the 3DS
2021-08-02 20:59:40 -07:00
Kurt
c1e6693b9c Change GeoTrack props to byte too
if u say so, archit
2021-08-02 20:03:11 -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
0d3cb1f6ad Shorten string get/set to valid range
Implicit terminator set
2021-07-31 19:46:14 -07:00
Kurt
de94876822 Minor tweaks
no functional change
2021-07-30 16:22:10 -07:00
Kurt
a10d1df9ca Extract pkm filename'ing logic to allow behavior replacing
injecting dependencies

replace the virtual inheritance with a type check
2021-07-28 19:28:56 -07:00
Kurt
97683932a1 Lowercase method paremeters 2021-07-26 15:31:46 -07:00
Kurt
c9640f8561 Comments: forme->form 2021-07-26 14:14:39 -07:00
Kurt
46f50a3a56 Use named consts for magic gender values
More personal magic value comparisons
2021-07-13 18:22:04 -07:00
Kurt
3fa311f6ed Misc tweaks
more annotations - all bool->out ? are annotated now
fix gender symbol inversion (forgot to set text)
extract some methods to reduce nesting
2021-07-06 08:42:15 -07:00
Kurt
5a769312fd Finish renaming EncounterType->GroundTile
Update the localization for GroundTile for english (and Italian, which is untranslated)
2021-07-03 23:25:09 -07:00
Kurt
103aa9aa4b
Revise EncounterArea and EncounterType for clarity (#3228)
EncounterArea now stores a more specific type'd array for encounter slots. Better iteration and less casting, as the nonspecific `Slots` fetch is rarely referenced.

EncounterType renamed to GroundTile to reflect how it actually works in Gen4. Was previously an ambiguous field that was clarified a little; we can describe it a little better now. Keep the GUI the same to not scare the end users.

Change Trash Byte properties to get/set a Span. Trash Byte legality checking easier on the garbage collector?
2021-06-29 20:58:06 -07:00
Kurt
49488bb503 Use invariant culture for ToUpper/ToLower
Turkish is quite the language; let's try to prevent any errors down the road for internal/game string case changes.
2021-06-24 09:16:36 -07:00
Kurt
a10b35190c Minor tweaks
off by 1 max range for gen2 slot -> pk2
SetRandomIVs already sets IVs inside the method, retval is for knowing what the new value sare
show WC8 restricted version rather than defaulting to SH
pass the rand object rather than fetching for the current thread every loop for Unown & random IV shuffling
Use ToLowerInvariant for resource fetching, should resolve the turkish issue
Check typeof(T) first, not that we check for ToolStripItem or ContextMenuStrip with this function.
2021-06-24 00:36:04 -07:00
Kurt
3e7775fc44
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately

Don't store within the object, track the slot origin data separately.

Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.

- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code

* Remove WasLink virtual in PKM

Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.

* Use Fateful to directly check gen5 mysterygift origins

No other encounter types in gen5 apply Fateful

* Simplify double ball comparison

Used to be separate for deferral cases, now no longer needed to be separate.

* Grab move/relearn reference and update locally

Fix relearn move identifier

* Inline defog HM transfer preference check

HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.

* Extract more met location metadata checks: WasBredEgg

* Replace Console.Write* with Debug.Write*

There's no console output UI, so don't include them in release builds.

* Inline WasGiftEgg, WasEvent, and WasEventEgg logic

Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-22 20:23:48 -07:00
Kurt
390cf518b8 Revise 4->5 encode table (Half-width symbols)
Manually transferred from English Pt to English B

All revised indexes were the result in Black.

Differences that were not incorporated:
0EE=09794 ♂, not 09325 ⑭
0EF=09792 ♀, not 09326 ⑮
0F2=00215 ×, not 09319 ⑧
0F3=00247 ÷, not 09320 ⑨

Full-width and half-width symbols I think are related to full-width games, which English isn't. Probably has different handling for other language, plus it'd result in other duplicates of the half-width symbols.

Revise not-found char glyph to return ? instead of {terminator}, to match the game's behavior. Again, this might be language specific, but whatever.

Make the Convert char methods public, add a few unit tests.

Closes #3172

Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-06-11 19:38:34 -07:00
Kurt
f77a8ecfbd Fix comment
wasn't sync'd :(
2021-06-10 23:29:03 -07:00
Kurt
24d6c0d713 Change "Some" EV train rating from [0,127] to (0,127] 2021-06-10 19:18:58 -07:00
Kurt
8c970ec991 Minor tweaks
no functional change, readability++
add more xmldoc
2021-06-03 12:04:19 -07:00
Kurt
138501da2f Minor clean
Condense some expressions
Use less linq
Rename some fields
2021-05-29 15:31:47 -07:00
Kurt
c9499f95be Add sociability to Memory editor, add legality checks 2021-05-23 11:22:09 -07:00
Kurt
d41fc571d0 Keep original trashbytes if string isn't changed
Similar to nickname setter
2021-05-20 16:54:53 -07:00
Kurt
53e9d31545 Allow searching encounter db for shiny state
random shinies behave like not-shinies
so it only really filters for "always shiny" or "can be nonshiny".
2021-05-18 16:17:57 -07:00
Kurt
2c820bfbe9 Minor tweaks 2021-05-18 13:29:55 -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
acdbda4e12 Split DateUtil from Util class 2021-05-14 16:46:48 -07:00
Kurt
50b15cd740 Use range/index
More in line with modernizing the codebase with latest c# syntax

improve web-qr decode speed slightly (no linq skiptake)
get money/coin mask without a temporary string (lol performance)
2021-05-14 15:30:55 -07:00
Kurt
013aac602f Don't clone string resources on fetch
Hardcode egg names, don't rely on string resource loading order for SpeciesNames to get an un-mutated copy.

fixes the infrequent race condition for legality unit tests
2021-05-10 18:41:01 -07:00
Kurt
3597eb14ad Improve gen1-4 species name fetch
reduce nesting (separated methods)
handle gen2 french egg name (all caps)
use stringbuilder to replace chars
2021-05-10 16:09:28 -07:00
Kurt
ceede68861 Minor tweaks 2021-05-07 22:11:10 -07:00
Kurt
31142ee297 Replace some linq usage with direct logic 2021-05-06 23:26:38 -07:00
Kurt
d9c22b1d74 Move pk1/2 EV maxing to class 2021-04-20 01:50:27 -07:00
Kurt
b64edb751d More xmldoc 2021-04-20 01:50: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
c67e01849a Extract 3ds chinese glyph remapping, only do on 3DS games
Optimize some functions within gen7zh for perf (no linq, no allocation)
2021-04-18 18:29:02 -07:00
Kurt
f35a3ce03c Add overload for Totem check, simplify some flow 2021-04-17 13:24:57 -07:00
Kurt
c56ba76601 Expand jp table too
6754645a5f
2021-04-12 19:14:23 -07:00
Kurt
6754645a5f Minor optimization
Similar to the index hack done for array shuffling modulo 24 & 1f.
2021-04-12 17:08:57 -07:00
Kurt
758b6e6770 Remove '<->’ aliasing
Farfetch’d uses the non-vertical apostrophe, still.

Showdown is consistent with their usage (in/outputting ’), but we'll keep the '->’ for that sanitization just in case other services/users enter the wrong char.

Closes #3185
2021-04-12 17:04:02 -07:00
Kurt
7bc733c900 Update SK2 language coercion
Closes #3194
Exports are fine, imports with an ambiguous language (can be either JPN or INT) while illegal don't result in the above branches passing it.

Inputs with <=6 chars for OT&Nick will be ambiguous; PKM editor.
2021-04-11 20:50:34 -07:00
Kurt
aaa69eac15 Rename Gen3 Champ ribbon to be more accurate
been like this since mid 2016

this ribbon can be obtained in either Hoenn or Kanto within Gen3
https://bulbapedia.bulbagarden.net/wiki/List_of_Ribbons_in_the_games#League_Ribbons
2021-04-10 12:09:43 -07:00
Kurt
c7b997865c Minor clean 2021-04-09 14:52:49 -07:00
Kurt
645f2b4db5 Revert implicit casting
Looks like netstandard2.0 wasn't meant to receive that new c#9 goodie
2021-03-29 00:14:44 -07:00
Kurt
7c926dc09e More xmldoc 2021-03-23 21:20:02 -07:00
Kurt
3822981590
Rework EncounterCriteria to be ability indexed rather than direct ability (#3179)
* Exploration: rework ability criteria to ability numbers desired

* Sync remaining changes

* Update EncounterCriteria.cs

* Add xmldoc

* Improve speed of IsDualGender check

* More xmldoc updates

Should be doing this on main but meh, this branch is gonna get merged later

* Fix typo

* Update WC7.cs

* Update PersonalInfo.cs
2021-03-23 17:05:15 -07:00
Kurt
6bce4eea14 Minor clean
Annotations (nullable), some switch cases for readability
2021-03-14 16:16:55 -07:00
Kurt
155e0283ce Inline some string logic, extract magic values, xmldoc 2021-03-09 21:31:53 -08:00
Kurt
4c45aa99af Add missing uint cast 2021-03-08 15:33:52 -08:00
Kurt
41096fb56e Minor xmldoc / usage updates 2021-02-21 15:01:28 -08:00
Kurt
0d05715582 Fix reflective convert
Adding setters for Hidden Power caused the IVs to get mutated, same for some other values. The DateTime could return null if undefined.

Used to be Declared only (properties in destination class), but GBPKM has shared Nick/Lang/IV logic.
513648638f

Just do the GBPKM fixup at the end to copy the remaining properties manually. Set HP type if the conversion was from future 31IV games.
2021-02-15 13:52:49 -08:00
Kurt
4cabbc49a2 Add affixed ribbon drop-down
Closes #3146
2021-02-10 13:34:49 -08:00
Kurt
1405f2b9ba Add optional original species parameter 2021-02-09 08:41:34 -08:00
Kurt
666a1805ba Relocate formargument logic 2021-02-08 20:42:19 -08:00
Kurt
ff7817a749 Create FormArgument extension logic 2021-02-08 20:39:46 -08:00
Kurt
37cb15749e Update FormArgument handling for gen6/7
Disassociate pk4/pk6 backing byte[] when converting to pk5|pk7, as we no longer make a copy of the byte[] in the pkm's constructor.

Change UpdatePKM to include isParty, as we want it optional to update FormArgument too.

Change FormArgument saving to be handled by FormConverter; kinda not really good to have it there, but nothing else is handling FormArgument values.

Expand IFormArgument to have all FormArgument values exposed. "Maximum" is furfrou only.
PK6: Max is in the "FormArgument" u32, and the remain/elapsed is in party stats (hence the reverting when boxed)
PK7: u8 remain, u8 elapsed, u8 max, u8 unused.
PK8: assumedly the same as PK7, given the disassembly hints that it's the same as past games (even though Furfrou and Hoopa are not in SWSH).
2021-02-08 20:26:53 -08:00
Kurt
61266e3d49 Use popcount when appropriate 2021-02-07 21:47:43 -08:00
Kurt
a7f65554ad Update formarg handling 2021-02-05 16:52:46 -08:00
Kurt
335ba2447e Default parsesettings tradeback to true 2021-02-03 15:39:30 -08:00
Kurt
862403858b Refactoring
no functional change
2021-02-03 11:33:09 -08:00
Kurt
33fc33a165 Add more nickname logic checks
Variant nicklang OT can nickname if it's the handler
2021-02-02 22:12:36 -08:00
Kurt
107d9a71d5 Fix transfer for Gen1 in-game trades 2021-02-02 16:27:31 -08:00
Kurt
9124a3c62b Improve handling of multi-nicknamed mystery gifts 2021-02-01 18:35:37 -08:00
Kurt
fa3fe0a380 Invert check, fix xmldoc descriptions 2021-01-31 20:12:46 -08:00
Kurt
7d6249853d Add gen8 case
This method is only used by BulkStorage, which is unused. Just keeping this up to date.
2021-01-31 13:10:03 -08:00
Kurt
d8e75ee85a Force Japanese language for JP-BU safe language fetch 2021-01-31 10:19:12 -08:00
Kurt
1e86fdcea8
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue

We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.

## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots. 
* We have a Silcoon that we've leveled up a few times.

Was our Silcoon originally a Wurmple, or was it caught as a Silcoon? 
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.

---

Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).

The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.

---

The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.

---

## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.

## Conclusion

This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-29 17:55:27 -08:00
Kurt
e5943e3c92 Clamp generation fetch for battleversion 2021-01-29 09:56:31 -08:00
Kurt
acfbef6cfa Disallow raids matching if has mark
Closes #3133
not an ideal solution, but the encounter matching API is kinda limited in deferred-invalid vs deferred-notIdeal.

probably need to unify the match logic and generators so they can cache one secondary-check invalid
2021-01-22 20:28:54 -08:00
Kurt
680e8b711d Add some code analysis for try-return with nullable out 2021-01-17 00:05:07 -08:00
Kurt
b5c30193fa Set initial capacity for stringbuilder to reduce reallocation
Default capacity is 16 so it's rarely an issue, but sometimes we don't need that much.

Update xmldoc for more clarity
2021-01-16 17:31:05 -08:00
Kurt
03ae3d470c Simplify value passing
buffers are fixed size matching the StringLength anyways; don't bother with confusing max length passing when the buffer is obvious
2021-01-16 13:56:37 -08:00
Kurt
de418e8db2 Simplify string termination handling
If 0x50,00.. terminated, treat differently than 0x50.. terminated buffer
2021-01-16 12:43:17 -08:00
Kurt
bb1d23e112 Minor clean
Use some enums, save a few virtual/static fetches
2021-01-16 12:01:40 -08:00
Kurt
613e6db744 Use StringConverter api consistently; use stringbuilder when possible
Retain a stringbuilder to mutate the string rather than finalizing temporary strings

yields some speed improvements (less gen0 string objects allocated)
2021-01-14 22:50:13 -08:00
Kurt
e62ea685c3 Make SpeciesConverter methods visible (class)
4 public methods; shouldn't need these except for fringe scenarios.
2021-01-11 17:52:02 -08:00
Kurt
4a3a8dd090 Add japanese blue encounter tables (unique to jp_blue)
When creating a new pk1 for the slot->pkm, get it as a pk1-japanese.
Export the gameversion when in pk1/2 format (same as VC).
2021-01-08 11:29:00 -08:00
Kurt
cc43550357 Simplify more expressions 2021-01-04 17:31:43 -08:00
Kurt
1f3d3112d3 Move some future-evolution tables to separate class 2021-01-02 19:11:46 -08:00
Kurt
4a52b349ff Minor clean 2021-01-02 19:11:34 -08:00
Kurt
c432a15a20 Relocate some tables to a location closer to where they're used 2021-01-02 00:46:09 -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
813180453e Delete duplicate HT bit fetch method
Make expression methods
2021-01-01 16:39:33 -08:00
Kurt
7523e0e200 Make ContestStat fields byte (from int) 2021-01-01 13:39:08 -08:00
Kurt
f6d4d93613 Inline some logic for contest stats 2021-01-01 12:21:46 -08:00
Kurt
f631cbbecd Generate gen2 eggs via gen2 method, ignore gen1 versions
For searching, only return versions compatible with the save file
Don't bother filtering out BU for Japanese-only.
2020-12-31 15:51:06 -08:00
Kurt
aaad127b99 Condense things a little more 2020-12-31 10:41:55 -08:00
Kurt
38e02a53b2 Condense switch cases to switch expressions 2020-12-31 10:33:13 -08:00
Kurt
24332b6979 Minor tweaks 2020-12-30 13:08:15 -08:00
Kurt
de840f40d4 Invert some "!is" to "is not" 2020-12-29 00:58:08 -08:00
Kurt
e8c23f6644 Simplify some repeated comparisons with expressions
Less prone for bugs since it uses the same value for all comparisons without re-specifying
2020-12-29 00:37:59 -08:00
Kurt
a124168e87 Make FormArg editing a complex control
Shows a dropdown for alcremie only, and a number entry for everything else.

See 771086a222 for initial implementation; I don't want the lag anymore lol
2020-12-28 11:51:25 -08:00
Kurt
ee5349ff98 moar is or 2020-12-25 12:30:26 -08:00
Kurt
4a8a495d04 Condense some switch expressions
Should be it for now; exhaustively searched for all that made sense to change
2020-12-25 10:58:33 -08:00
Kurt
95e3337f2c More switch expressions 2020-12-24 17:12:08 -08:00
Kurt
43dd390f21 Split IContestStats, mark trades as records 2020-12-24 00:06:40 -08:00
Kurt
93910df2c6 Use new switch statements 2020-12-23 17:14:38 -08:00
Kurt
e34c8df044 Revise some method signatures 2020-12-22 20:50:33 -08:00
Kurt
997e0751f3 Minor clean
Handle remainder of c#9 sugar
Fix some spelling mistakes
2020-12-21 23:37:07 -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
5729718d68 Simplify ternary byte casts
No longer needed to explicitly cast, thanks c#9 !
2020-12-21 16:53:28 -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
6f7602f2ad Change signatures to use readonly if possible
Extract get/set team methods for battle video
2020-12-05 06:09:33 -08:00
Kurt
5bc5b611cb Make RefreshAbility virtual, add overrides for gen3&5
Gen5: set HA bit if hidden ability
Gen3: prevent setting AbilityBit if it doesn't have 2 distinct abilities

Failed test now passes; all tests are passing!
2020-11-29 15:02:57 -08:00
Kurt
67b7d44ced Fix accented-a/i for spanish in-game trade
I think this was a PKHeX issue that went unnoticed; originally, we didn't include the Á and Í chars in the dictionary.

I checked the transporter code:
The app maintains the international & japanese character tables, and depending on the ROM language, it may change a char to the language-specific entry. Refer to Bulbapedia's notes on the char tables for different languages:

https://bulbapedia.bulbagarden.net/wiki/Character_encoding_in_Generation_II

However, none of these char-changes are able to be reached with a legal char.

Á and Í (only accessible from the Spanish in-game trades) and the german 0xC0 && z <= 0xC6 chars are already in the international table. Every single difference in the VC1/VC2 table is an un-enterable char.

tl;dr -- all possible char codes are transferred fine with the VC2 table without extra language logic. We just keep out any inaccessible char (replaced with space).
2020-11-27 16:49:06 -08:00
Kurt
e9075436b7 Split off g7 transporter string handling
Add katakana / hiragana sensitive transferring

var check = CheckKata("ぐリお") == "ぐりお";
check should be true, dugtrio case !
2020-11-27 15:37:55 -08:00
Kurt
9b178fefe2 Xmldoc, minor tweaks
Move form-info logic from FormConverter to AltFormInfo; now FormConverter is entirely form=>string[]
Add a bunch of xmldoc
Make pogo no-end-date cmp agaisnt UTCnow rather than local now.
2020-11-27 11:51:02 -08:00
sora10pls
a437cbb9ca Update FormConverter.cs
Display 0-9999 for Galarian Yamask formarg values.
2020-11-26 18:41:45 -05:00
Kurt
771086a222 Show all valid yamask-1 formarg values
from 319 (max HP-1) to 9999 (max saved value).

Causes a little bit of GUI lag when loading 10k items to the combobox; could be a number entry but meh. Lazily allocate the 10k strings; wait until it's requested.
2020-11-24 12:40:56 -08:00
Kurt
0af0c05bac Update go slot list yield and move fetch 2020-11-18 21:34:40 -08:00
Kurt
26e0f31c95 Include date legality parameters for LGPE
Extract common abstract class for GO transferred encounters
Clamp minlevel instead of met level
Add optional parameter for GO IV randomization
Update go legality binaries with latest
2020-11-16 15:32:22 -08:00
Kurt
b6da6c1207 Add raticate form list for gen8+ 2020-11-15 08:31:58 -08:00
Kurt
72e209a156 Split some methods, handle flow for go enc 2020-11-11 21:22:13 -08:00
Kurt
5b313210ed Handle SWSH gender strings same as LGPE
See 6a0a6aa82a for more context
2020-10-27 09:24:06 -07:00
Kurt
0aa95c42c0 Remove 0x42 from extrabytes
all values can be modified via the GUI, no need to expose as raw value.
2020-10-25 18:08:36 -07:00
Kurt
9264150b2b Add shiny1 batch editor, add ctrl-shiny (1)
GUI: Ctrl click star to get shiny1, shift click for shiny0, any-click to get random

make Alt click modify the SID instead of PID

add SetShinySID shiny type
2020-10-25 10:42:48 -07:00
Kurt
3b5bcc9dad Update comments with context/clarification
No functional change, the order of switch case won't matter
2020-10-24 23:08:39 -07:00
Kurt
5326067c8d Return old Chinese species name for Gen7 fetch
Add documentation comments, because changing species names is so weird.

ty anubis for confirming the game resets the old-nickname to new-nickname even without transferring to HOME.

Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2020-10-24 22:28:39 -07:00
Kurt
5fa4ddd4a2 Update internal data sources for Crown Tundra
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
Co-Authored-By: ReignOfComputer <2667537+ReignOfComputer@users.noreply.github.com>
2020-10-24 11:11:05 -07:00
Kurt
7a01b1249c Minor clean
Handle more messages, add more xmldoc
2020-10-18 09:43:41 -07:00
Kurt
6239f59b9d Inline checksum logic for gen3, simplify else case 2020-10-18 09:16:52 -07:00
Kurt
e984f71d82 Fix PID mutation for VC shiny transfers 2020-10-13 22:43:43 -07:00
Kurt
ea81bb2c1e Add swsh items based on DLC1 metadata 2020-10-10 14:14:02 -07:00
Kurt
7132750c9b Placeholder crown tundra logic
To be updated:
- Tables8: magic numbers for maximums
- IGigantamax: any new gigantamax forms?
- FormConverter: any new forms? (calyrex)
2020-10-10 13:14:32 -07:00