Commit graph

126 commits

Author SHA1 Message Date
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
9ff01bccc6 Add ToString override for debugging 2020-05-31 12:12:20 -07:00
Kurt
6970c3a5fb Remove IVersion.set property, as separate interface
I don't want people to mutate IEncounterable.Version; it's only intended to be set on-load
2020-05-19 21:46:05 -07:00
Kurt
301350d32b Make IEncounterable expose IVersion get 2020-05-19 21:07:30 -07:00
Kurt
6164884700 Merge IGeneration into IEncounterable
all but egg exposed it; now, just make egg expose it and remove the unnecessary interface

we still need to Set generation for non-eggs/mgift, so have a separate Settable interface for internal purposes.
2020-05-17 12:32:28 -07: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
ffa70e7626 Move files
no functional change, just putting stuff in a more appropriate folder
2020-01-25 17:22:20 -08:00
Kurt
5be9c6bcc8 Remove unnecessary null handling
objects are no longer null
2020-01-20 23:32:05 -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
Archit Date
897b97ceed comment typo fix (#2535)
lul
2019-11-28 10:35:18 -08:00
Kurt
7a51e48747 Add wc8 star/square pid types 2019-11-28 09:46:48 -08:00
Kurt
08e293dadc Add SimpleTrainerInfo constructor
zeroes out console region data if not present in game
2019-11-26 16:55:28 -08:00
Kurt
7960f2d748 Don't set console region data for pb7/pk8+ 2019-11-26 10:46:32 -08:00
Kurt
f88388cb70 Add Form (AltForm) to IEncounterable interface
All of the encounterable templates have Form anyway; funny that I was
consistent naming them all differently than pkm.AltForm :)

Closes #2452
2019-11-18 22:20:55 -08:00
Kurt
4bcf60746b Add egg move sharing checks
Was referencing wild caught mons that are given a single egg move; this
logic handles shared egg moves too via daycare.

Probably need to rework SplitBreed into a dictionary; this might not
catch Mime/etc split breeds if they have different tables.
2019-11-17 17:14:21 -08:00
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