Commit graph

111 commits

Author SHA1 Message Date
Kurt
02420d3e93
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases

Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization

* Handle bits more obviously without null

* Make SaveFile.BAK explicitly readonly again

* merge constructor methods to have readonly fields

* Inline some properties

* More nullable handling

* Rearrange box actions

define straightforward classes to not have any null properties

* Make extrabyte reference array immutable

* Move tooltip creation to designer

* Rearrange some logic to reduce nesting

* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum

* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case

* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable

* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator

* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever

* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)

* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-16 18:47:31 -07:00
Kurt
4baf745af8 Use some c#8 sugar
static local functions
switch expressions
using usings :)

nullable next?
2019-10-07 18:40:09 -07:00
Kurt
8d8adde2b1 sealed
sealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealed
2019-10-03 19:09:02 -07:00
Kurt
21e7f4317e Minor updates
increase readability, simplifly some expressions
relocate hot path for legality report string creation
2019-05-11 10:12:14 -07:00
Kurt
d975081a86 Add short/long name property differentiation 2019-03-17 22:19:37 -07:00
Kurt
78ff441e8b Update iencounterable api with new criteria arg
rearrange some logic for clearer function (extract some methods)
2018-12-29 22:24:34 -08:00
Kurt
f358c0e4cf Handle all deviating met location string versions 2018-11-22 10:11:51 -08:00
Kurt
6495dc41af Add move/enc/loc references 2018-11-11 22:49:17 -08:00
Kurt
f38c46f5ec Misc updates 2018-11-10 21:07:31 -08:00
Kurt
8f9cc6cd7e Fix xmldoc ampersands 2018-10-31 13:52:09 -07:00
Kurt
d02b87a7b2 Expose checkresult properties
can now check individual strings / identifiers in a LegalityAnalysis
object by:

var la = new LegalityAnalysis(pkm);
var parse = la.Info.Parse;
if (parse.Any(z => ReferenceEquals(z.Comment, LegalityCheckStrings.X))
...
should be faster than doing string.Contains
2018-09-05 21:27:52 -07:00
Kurt
91c37ab573 Update legality check message string style
V### names weren't enjoyable to work with; use similar verbose style as
the program message strings.

updating the translation files with the remapped variable names shortly

remap list: https://pastebin.com/jybkVDAK
2018-09-01 14:11:12 -07:00
Kurt
4656909d98 Misc reorg
use shared class for pk1/2 setnotnicknamed
fix extendedeurope values (copypaste from extendedAmericas)
move ball out of verifiers, move nature/movetype with ball
2018-08-26 16:29:52 -07:00
Kurt
1486b7f14a Misc style & minor tweaks
Remove move combobox flicker hack (no longer necessary)
Add more Array.Empty usages
cache mysterygift sizes
seal some classes

no functionality changes
2018-08-02 20:11:42 -07:00
Kurt
f4bfdb8311 Remove unnecessary empty array allocations
yay net 4.6
read more: http://justinvp.com/2015/07/20/array-empty/
2018-08-01 18:30:51 -07:00
Kurt
711157f3ea Refactoring
Extract trainer pkm origin check to interface extension
2018-07-25 20:40:57 -07:00
Kurt
625a77589b Extract geolocation logic to interface
mixins would be nice but I guess extensions cover this
2018-07-14 10:34:34 -07:00
Kurt
d11a89d52d Move relearn required flag to checkmoveresult
reduce usage for non gen6+ relearn move cases
save contains result for later usage instead of recomputing the inverse
2018-07-01 21:34:17 -07:00
Kurt
021ac7c54f Refactoring
where!contains -> except
relocate special tutor
2018-06-09 16:04:06 -07:00
Kurt
99005d8fc0 Refactoring
more discards & simplifications
2018-05-12 12:28:48 -07:00
Kurt
5a3c8f4147 Remove trailing whitespace 2018-05-12 08:41:29 -07:00
Kurt
ab71ea2d8b More generator updates
Graveler (SM Trade) -> Force applying handling trainer details for
ingame trades
Ponyta (Ranch Trade) Apply correct ability for encountertradePID

Up to 98 : Wild Gen2 Krabby (safari zone impossible location needs to
get filtered from possible encounters)
2018-04-29 21:29:34 -07:00
Kurt
b2c54b7a43 Apply trade memory when changing handlers for pk6 2018-04-28 15:58:53 -07:00
Kurt
71faaee31c Refactor savefile tid/sid to int
can now use TrainerID editor control on a savefile... soon?
2018-04-28 11:06:58 -07:00
Kurt
0b62ab85a1 Nature -> byte instead of int 2018-04-21 09:18:53 -07:00
Kurt
ba4c911566 Refactoring & finish eevee test case
generates a legal pk* for every possible encounter; there's likely other
scenarios and more roughness to smooth out, but seems legit for now
2018-03-31 20:37:36 -07:00
Kurt
a89c0c3312 Rename egg game->version
add more gameversions (soon)
2018-03-30 21:37:01 -07:00
Kurt
b38abc22e2 Refactoring
add IVersion interface with common interactions
2018-03-30 16:31:40 -07:00
Kurt
2ea1fea5f5 Refactoring
add GameVersion to generation
fix generating pk2 eggs
relocate some logic
2018-03-29 21:00:38 -07:00
Kurt
1e13220e6e Add IEncounterable -> pkm interface method
egg,slot,static,link,trade need to be implemented later

remove IEncounterable from PL6
2018-03-28 20:38:07 -07:00
Kurt
314a92b67b Extend core api
add copy/fetch new
2018-03-28 20:34:58 -07:00
Kurt
e026a8ab49 Add default trainer info
use in pkmeditor and utilize
2018-03-28 18:52:50 -07:00
Kurt
a0eb658ef2 Extract minimum trainer information requirements
If one wanted to extend ConvertToPKM to other IEncounterables, this
would be the provided obj containing the receiver's info

allows pkm gen without a savefile, which is nice?
2018-03-28 15:55:19 -07:00
Kurt
f55028c1a0 Fix KChart errors
gen1 & gen2 types aren't laid out contiguously (yay bird type and extra
types)
fix gen2 type accessors looking at the wrong byte

type sprites now load correctly, and 3rd ability no longer throws an
error (forced to None).
2018-03-18 11:22:20 -07:00
Kurt
e9a3b4acf1 Merge PIDType and bool? shiny property
Gen5 does not follow the same convention, 0 = non, 1 = rnd, 2 = always;
not gonna bother updating for just that one

bool? occupies 2 bytes; enum:byte is 1 byte.

should probably move validity checking logic into the IEncounterable
objects instead...
2018-03-16 19:35:55 -07:00
Kurt
21cdf4f642 Reorganization
wonder if it's possible to provide a more lightweight core by pulling
out legality stuff to a separate project?
2018-03-05 20:49:45 -08:00
Kurt
999427f484 Update gen2 egg generator
Level = Level is equivalent to Level = 0

update EggInfoSource to use Level instead of LevelMin (LevelMin returns
Level, just be clear on usage)
update VerifyCurrentMoves so that only gen1/2 do the gen1/2 move update
methods. Recently extended all encounters to have a generation property;
we only care about gen1/2 here.

https://projectpokemon.org/home/forums/topic/43655-pokemon-crystal-egg-mark-as-not-legit/
2018-01-30 20:36:22 -08:00
Kurt
836566004f Use CXD met location string on verbose output
was previously using RSEFRLG locations for CXD encounters
2018-01-30 20:24:45 -08:00
Kurt
735ff26486 Rework GetEncounterMoves to match games
Closes #1787

Noticed that the search-backwards approach for GetMoves yields Sludge
for muk even though it shouldn't be allowed
im fine with this for now because gen2 never had online checks and any
current-gen checks allow relearning.
2018-01-28 00:09:11 -08:00
Kurt
fb6738f18b Add unown 2->7+ shiny check
closes #1755

also:
fix vc transfer checks not being called (EncounterOriginalGB is no
longer GBEncounterData).
remove usages of GBEncounterData -- class is (as of a ~~month ago) now
never leaked out of the EncounterGenerator -- always returns the actual
encounter data as the wrapper is not needed.
simplify logic flow / references
2018-01-10 16:16:35 -08:00
Kurt
0f21fc2217 add location interface for verbose analysis output
indicates met location for transferred mons
most gen1/2 encounters won't show values due to the location not being
stored respective to the string tables (anyone wanna do a location remap
after initial load?)
2018-01-02 12:00:41 -08:00
Kurt
5e59e20ea1 Store matched encounter generation
previously was only defined for gen1/2, why not all gens
can now query encounters in Core for encounters per generation via
reflection; can help group encounters for data vis or be faster than
getting individual gen numbers
2017-12-18 16:17:21 -08:00
Kurt
80baaea3b7 add b2w2 n's pokemon PIDs
add b2w2 fixed PID encounters (N's Pokemon), move nsparkle to this class
redo static encounter cloning
2017-12-18 15:25:40 -08:00
Kurt
816ebf6b0e Refactoring
no functional change
2017-12-11 16:01:24 -08:00
Kurt
5bc2e6da88 Refactoring
de-linq some areas where direct accessing is possible (list/array)
2017-12-04 20:16:54 -08:00
Kurt
6773a2801d update static/magnet slot permutations
using certain slot modifiers (swarm/game pak) causes different
arrangements of slots for different static/magnet pull groups to pull
from

store a list of permuted/different slots and add them to the table at
the end with the rest

move static/magnet pull marking into gen4 methods (only leave for gen3)
move trophy slot generation into gen4dppt area fetch (necessary for
static/magnet permuting)
fix electric off-by-one (yay for curse ??? type shifting everything)
2017-12-03 12:20:53 -08:00
Kurt
15ab0d5aff Add origin seed for frame output
looks like for gen4 I have to yield twice as many frames (for FixedLevel
and non) as level call usage is dependent on encounter
2017-12-01 16:33:03 -08:00
Kurt
9930e8765a Add frame level checking
still WIP but should be working fairly well
2017-11-29 23:20:49 -08:00
Kurt
187726b4af Use static/magnet pull values
reorganize a little for lead use cases
2017-11-26 16:09:24 -08:00
Kurt
0f3529e764 Add gen3 swarm encounter slot call
via pret/pokeemerald (and pokeruby); rate is set at 50%
swarm pokemon have the ability to have 4 fixed moves, so derive from
EncounterSlot to have moves, and remove special handling from
VerifyCurrentMoves (now picked up by IMoveset pattern
2017-11-26 11:00:54 -08:00