Commit graph

438 commits

Author SHA1 Message Date
Lusamine
ab33df2fc9
Enforce weather legality for SWSH (#3221)
* Add weather types by location

Creates a dictionary of possible weather types for each SWSH location.
Unlisted locations may only have Normal weather or do not have any
encounter slots.

* Prune unused weather from static encounters

Some encounters were too permissive with weather, e.g. Sandstorm in
Fields of Honor and Challenge Beach; Snowstorm at Dyna Tree Hill.

A few crossover areas that would have limited the possible weathers were
marked with a "(c)". An example is Nidorina from Giant's Bed crossing
to Frostpoint Field, where Raining and Thunderstorm do not occur.

This additionally organizes encounters by location.

* Move location-weather dictionary to EncounterArea8

* Verify weather marks on encounterslot/static encounters

* Adds some static encounters available through weather bleed

Weathers aren't normally available, but these static encounters are
close enough to the boundary that the weather in an adjacent area can be
used to spawn them.

- Frostpoint Field Snorlax with Raining/Thunderstorm from Giant's Bed
- Snowslide Slope Amaura with Raining/Thunderstorm from Giant's Bed
- Frigid Sea Carracosta with Intense_Sun from Three-Point Pass
- Frigid Sea Magmortar with Intense_Sun from Three-Point Pass
- Ballimere Lake Corviknight with Snowstorm from Giant's Bed
- Ballimere Lake Cryogonal with Snowstorm from Giant's Bed
- Ballimere Lake Tyrunt with all weather from Giant's Bed
- Lakeside Cave Ferrothorn with all weather from Ballimere Lake
- Tunnel to the Top Golbat with all weather from Path to the Peak

* Defer weather marks if incompatible, enforce encounterslot weather

This uses the area weather to check fishing slots and tentatively adds
some tables for weather bleed encounterslots.

* Warm-Up Tunnel gets weather bleed from Training Lowlands

* Update for base PKHeX

* Handle weather bleed for SWSH encounter slots

Co-authored-by: Skadiv <62726360+Skadiv@users.noreply.github.com>

* Minor clean

Having duplicate weather marks is illegal, so just auto-partial match them instead of checking the other marks.

* Rearrange slot weather check logic

* Claim reserved byte in SWSH pkl

* No need for two variable names now

* Valid weather marks on tree/fishing should return with main weather

* Fix tree/fishing deferral and add another surf slot weather bleed

* Disallow tree/fishing encounters from using bleed tables

None are currently known at this time, and only hidden grass encounters
have a weather bleed table

* Condense bleed expression, combine tree/fish flag check

* Move weather-bleed check into EncounterArea8

Makes the dictionaries private instead of internal.

Co-authored-by: Skadiv <62726360+Skadiv@users.noreply.github.com>
2021-07-26 14:28:05 -07:00
Kurt
e961694bdb Minor tweaks
Pass evo chain to memory learning machine move
Pass minimum level for GB encounters if present, rather than enc min level
2021-07-22 19:08:56 -07:00
Kurt
8e5e4487ba Change interface for method call to less restricted
Don't need "Name" or "LongName" for these methods.
2021-07-13 18:22:04 -07:00
sora10pls
34c401b7a0 Revise IsHOMEGift, check Card ID for gift date range
Currently, HOME gifts present in wc8.pkl will not be flagged for invalid dates due to them missing their respective Card IDs. This will be fixed with the next stable release, so this works for now.
2021-07-13 18:22:04 -07:00
Kurt
9e665034b7 Implement "Can Buy Item" memory check
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2021-07-03 13:12:46 -07:00
Kurt
f2183f985f Tighten up memory 71 permissions 2021-06-30 15:56:08 -07:00
Kurt
600f4a550a Allow urshifu for gen8 dynamax memory 2021-06-30 13:37:40 -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
401ab98f42 Fix inlined check 2021-06-22 23:30:40 -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
652e9eb6da Add Eon Flute to observable used key items
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-06-13 00:59:06 -07:00
Kurt
f984862f48 Extract catchrate check 2021-06-09 22:54:21 -07:00
Kurt
a07549f013 Extract sketch valid check
GetCanKnowMove should be checking for Smeargle knowing thousand arrows/waves.
GetNeededMoves should also return 1ka/1kw for needed moves, and then no encounters.

All uses of InvalidSketch are behind that method, so any future Smeargle modifications (like sketching a dummied move) will be checked (yay BDSP considerations).
2021-06-06 23:36:59 -07:00
Kurt
8ec25da194 Condense expression
single bool branch
2021-06-03 17:08:42 -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
9b4e085890 Clamp fullness-byte (Playfulness) at maximum 2021-05-23 22:06:40 -07:00
Kurt
c9499f95be Add sociability to Memory editor, add legality checks 2021-05-23 11:22:09 -07:00
Kurt
2c820bfbe9 Minor tweaks 2021-05-18 13:29:55 -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
f66662b8db More deferral tweaks for non-HA having HA 2021-04-22 13:47:33 -07:00
Kurt
8483dc241d Update MarkVerifier.cs 2021-04-21 19:12:50 -07:00
Kurt
7256ff0a7f Check if the Shedinja's encounter can have marks
Not all gen8 encounters can have marks (nest, go), so use the regular method.
2021-04-21 18:52:24 -07:00
Kurt
2aed4c3118 Add shedinja dropped ribbons/marking considerations
Nice bug ya got there, gamefreak.

Coulda cleared the AffixedRibbon value instead of copying it on Shedinja creation, and it would have made this unnecessary.

Please ditch the Affixed Ribbon gimmick for future games, thanks!
2021-04-21 15:20:16 -07:00
Kurt
25565e6f07 More pattern matching expressions
Shapes are fancy; nested pattern checks
2021-04-20 02:17:28 -07:00
Kurt
45f12bd924 Update FormVerifier.cs 2021-04-18 21:22:58 -07:00
Kurt
f61108ac4e Check gen1/2 female OTs a little more thoroughly
https://github.com/kwsch/PKHeX/issues/2687#issuecomment-822072999

celebi is a es2e, so just filter on specified TID

Co-Authored-By: FeralFalcon <33670476+FeralFalcon@users.noreply.github.com>
2021-04-18 19:31:22 -07:00
Kurt
f35a3ce03c Add overload for Totem check, simplify some flow 2021-04-17 13:24:57 -07:00
Kurt
16406d7bba Allow Strongest Trainer memory on gen6-visitors banned from Maison
https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/?do=findComment&comment=265898

End result is only gen7-origin-in-gen7 are disallowed.

Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2021-04-16 08:53:50 -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
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
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
0626b0c29b
Add Breeding move ordering logic, and use in legality analysis (#3183)
* Initial bred moveset validation logic

Unpeel the inheritance via recursion and permitted moves

* Volt tackle considerations

* Optimize out empty slot skips

* Add tests, fix off-by-one's

* Require all base moves if empty slot in moveset

* Add test to prove failure per Anubis' provided test

* Tweak enum labels for easier debugging

When two enums share the same underlying value, the ToString/name of the value may be either of the two (or the last defined one, in my debugging). Just give it a separate magic value.

* Fix recursion oopsie

Also check for scenario where no-base-moves but not enough moves to push base moves out

* Add Crystal tutor checks

* Add specialized gen2 verification method

Game loops through father's moves and pushes in one iteration, rather than checking by type.

* Add another case with returning base move

* Add push-out requirement for re-added base moves

* Minor tweaks

Condense tests, fix another off-by-one noticed when creating tests

* Disallow inherited parent levelup moves

Disallow volt tackle on Gen2/R/S

* Split MoveBreed into generation specific classes

Gen2 behaves slightly different from Gen3/4, which behaves slightly different from Gen5... and Gen6 behaves differently too.

Add some xmldoc as the api is starting to solidify

* Add method overload that returns the parse

Verify that the parse order is as expected

* Add reordering suggestion logic

Try sorting first, then go nuclear with rebuilding.

* Return base moves if complete fail

* Set base moves when generating eggs, only.

* Use breed logic to check for egg ordering legality

Don't bother helping for split-breed species
2021-04-04 18:30:01 -07:00
Kurt
5ce3d64996 Disallow lang=2 for dp trades
DP English origin are Japanese language; since we 1=>2, we still needed to disallow 2.
2021-03-21 10:34:00 -07:00
Kurt
012f6678ba Check for dual ability =>evo w/single ability capsule 2021-03-20 17:49:16 -07:00
Kurt
a71d7d1950 Handle gen3 mismatched ability
ty Breil --
https://projectpokemon.org/home/forums/topic/58665-makuhita-in-game-trade-bug-sapphire/
2021-03-20 11:22:56 -07:00
Kurt
1acefbcf93 Remove sigilyph from g5 breed HA banlist
https://projectpokemon.org/home/forums/topic/58657-sigilyph/?do=findComment&comment=265330
2021-03-17 20:20:54 -07:00
Kurt
c27697c919 Flag contest stats if sheen is present on gen5+ origin 2021-02-27 20:02:18 -08:00
Kurt
aaa1fd1b4f Remove obsolete legality checks for safari
Hard matches for encounter slot result in these never being executable.
2021-02-21 15:22:10 -08:00
Kurt
31245d0e37 Add mythical table, allow non-mythical legends in latest ruleset (master ribbon) 2021-02-16 21:42:36 -08:00
Kurt
0121028a6b Furfrou Bank edge cases
lmao nice meme
2021-02-16 21:22:20 -08:00
Kurt
b82b0da7d9 Add checks for fishing mark 2021-02-14 22:25:59 -08:00
Kurt
ebb4e2a56a Defer curry mark static encounters, flag as invalid
Closes #3001 as all marks that can be checked are checked.

Promote trades above static encounters, as it's just met location.
2021-02-14 21:24:31 -08:00
Kurt
927c83d660 Show seed in output, flag correlations that shouldn't 2021-02-14 16:00:43 -08:00
Kurt
5949c3b57e Minor clean 2021-02-14 15:14:45 -08:00
Kurt
1af27516e6 pid encounter type mismatch: returns
Keeping the cryptic message for now :)
2021-02-14 10:20:35 -08:00
Kurt
2ee88ee010 Update FormVerifier.cs 2021-02-08 23:18:45 -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
5bb4c9e7fe Update FormVerifier.cs 2021-02-05 17:25:13 -08:00
Kurt
a7f65554ad Update formarg handling 2021-02-05 16:52:46 -08:00