Commit graph

51 commits

Author SHA1 Message Date
Kurt
fd4034272b Update WC8.cs 2021-01-31 10:36:33 -08:00
Kurt
33b671c636 Allow home gifts with T7SID > 0 2021-01-30 18:39:40 -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
b1c3526618 Update WC8.cs 2021-01-23 11:43:56 -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
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
09089da14e Use more expression return style
Reduces indentation & bracketing, a bit more concise
2021-01-01 17:08:49 -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
ee5349ff98 moar is or 2020-12-25 12:30:26 -08:00
Kurt
95e3337f2c More switch expressions 2020-12-24 17:12:08 -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
51c872f4e1 Move more logic closer to where it's used 2020-11-02 14:46:26 -08:00
Kurt
a6b704b887 Update WC8.cs 2020-11-01 23:29:53 -08:00
Kurt
d2fed0d66c Set party stats on pkm create
Party stats are stored in box format
2020-10-05 09:04:32 -07:00
Kurt
eb6c570695 Add TSV=0 checks for WC8 home gifts
Don't match if TSV == 0
Don't assign at TSV of 0, randomize TID7 if it happens to be so.

Closes #3007
2020-09-29 23:10:48 -07:00
Kurt
6243135f28 Minor clean
Move Home8 location to Locations.cs for documentation
Move FestaFacility to correct folder
Remove unnecessary public modifier on interface method
Pass the program's Version to any loaded plugins, if they wanted to check compatibility...?
2020-09-25 23:55:31 -07:00
Kurt
af99e0b37c Revise fixed PID checks
Closes #3000
Thanks @CScorpion-h & @SciresM !
2020-09-24 19:29:01 -07:00
Kurt
e125424423 Refine zygarde encounter form checking logic
Closes #2984
ty atrius & matt via discord

Co-Authored-By: Atrius97 <39707481+Atrius97@users.noreply.github.com>
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2020-09-13 15:45:15 -07:00
Kurt
0a6d53dc0d
Make IsHomeGift a public get property 2020-09-10 11:25:29 -07:00
Kurt
a62324a5a1
Refactoring some IEncounterable-type'd object initialization and original-generation evo chain (#2974) 2020-08-21 16:35:49 -07:00
Kurt
adb55c9e7b Make CanToggleGigantamax have a form argument
no more meowth-1/2 and or perrserker
Closes #2973
2020-08-16 23:06:49 -07:00
Kurt
8fae396b76 Inject matching dexlevel for form comparison 2020-07-18 13:29:16 -05:00
Kurt
5128825e78 Update WC8.cs 2020-07-18 10:46:22 -05:00
Kurt
035bac1ed3 Update WC8.cs 2020-07-18 10:27:44 -05:00
Kurt
9b14235a6c Add zeraora wc from event gallery 2020-07-17 20:40:11 -05:00
Kurt
ea609d43a5 Move soup to gmax class (extension methods), fix home gmax starters
Directly accessing CanEatMaxSoup is now forbidden :)

Fixes home galar starters being flagged when gmax-final evos
2020-07-16 21:04:27 -05:00
Kurt
5d8a5ba045 Revise "Is HOME" gift check, add height/weight scalar condition 2020-07-02 17:18:36 -05:00
Kurt
a2d9f06350 Differentiate AbilityType from AbilityNumber
invert ability index favoring so that the first ability index is most favored

ability num:
-1=>0/1/2
0=>0/1,
1=>0
2 =>1
4=>2

Ability Type:
0,1,2=>0,1,2
3=>0/1
4=>0/1/2

Should probably get rid of AbilityNumber definition usage but it's so entwined in the trade/static definitions...
2020-06-22 22:01:42 -05:00
Kurt
93308ca4ae Account for losing/gaining gmax for comparison
Don't defer for static, and don't skip for WC8

skip home gifts with player OT when SID7 not 0 (all home OTs have 6digit TID and 0 SID)
2020-06-22 21:29:21 -05:00
Kurt
2cdb5d26db Clean up some method signatures
rename things to be a little more consistent in naming conventions
2020-06-16 21:46:22 -05:00
Kurt
afa368823e Minor clean
handle some compiler messages
2020-05-26 16:59:47 -07:00
Kurt
913d2773bf Pass form when form doesn't match encounter
This is still a horrible hack, needs to be done similar to encounter slots

handle the galar NFE formchange cases
2020-04-23 20:53:57 -07:00
Kurt
3aaf318035 Update event database, handle HOME gifts horribly 2020-03-14 14:22:45 -07:00
Kurt
03c58dbe89 Use selected language instead of sav lang 2020-02-19 21:32:01 -08:00
Kurt
a3e9649f09 Update 20.01.26
Update with latest events from EventsGallery
2020-01-26 00:35:31 -08:00
Kurt
c301ce88ab Update Random to be a bit more thread safe
Random isn't thread safe; users of PKHeX.Core.dll might run multithreaded operations (see PKSM + ALM), so we need to have a thread-specific RNG available.

Thread Local get; to improve performance, save the random object locally whenever it is used more than once in the method.

https://docs.microsoft.com/en-us/dotnet/api/system.threading.threadlocal-1?redirectedfrom=MSDN&view=netframework-4.8
https://stackoverflow.com/questions/18333885/threadstatic-v-s-threadlocalt-is-generic-better-than-attribute/18337158#18337158
2020-01-25 21:49:52 -08:00
Kurt
467045e95c Swap rand call order, rename as overload 2020-01-22 19:04:20 -08:00
Kurt
8312c52cc1 Make Move[] readonly list
contract: don't modify the template movesets
mystery gift now exposes IRelearn, remove unnecessary type checks
2020-01-18 16:46:38 -08:00
Kurt
bfd9bf6b53 Simplify formchange calls
Don't use the dex chain for certain checks, it's unnecessary.
2019-12-28 19:00:01 -08:00
Kurt
bc3e84d30e Check high bound of language when generating wb7/8
Closes #2599 ty @slp32
2019-12-23 11:27:36 -08:00
Kurt
802b93bb16 Fix xor order
oops, upper half gets the star/square xor
no real difference since PID is random
2019-12-10 22:05:47 -08:00
Kurt
8acb336d51 Use enum for species comparisons
slightly easier to read with named values
2019-12-08 17:39:19 -08:00
Kurt
5ba396db6e Update shiny comparisons for (traded)eggs
PID rerolls happen on trade to ensure star/square state is kept
2019-11-28 12:40:33 -08:00
Kurt
7a51e48747 Add wc8 star/square pid types 2019-11-28 09:46:48 -08:00
Kurt
445fdee2ba Add shared memory interface (encounter) 2019-11-26 10:46:16 -08:00
Kurt
a368b81519 Minor clean 2019-11-18 22:48:03 -08:00
Kurt
21c3b4e1b1 Add Ribbon interfaces to WC8
pretty silly but gets the job done
Closes #2446 by fully implementing all ribbon checks possible
2019-11-18 17:37:38 -08:00
Kurt
502adc6d74 Don't throw exception on setting giftused
needed in mystery gift db to clear flags (why idk)
2019-11-16 08:24:46 -08:00