Commit graph

85 commits

Author SHA1 Message Date
Kurt
41096fb56e Minor xmldoc / usage updates 2021-02-21 15:01:28 -08:00
Kurt
107d9a71d5 Fix transfer for Gen1 in-game trades 2021-02-02 16:27:31 -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
ee5349ff98 moar is or 2020-12-25 12:30:26 -08:00
Kurt
98be0f6739 Target type'd new 2020-12-21 17:17:56 -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
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
e984f71d82 Fix PID mutation for VC shiny transfers 2020-10-13 22:43:43 -07:00
Kurt
f4f25da986 Add IsEgg for SK2
Stored at 0x1E
2020-10-04 14:15:29 -07:00
Kurt
52a67f2425 Add Stadium2 Support
Introducing a new PKM format: SK2
Split ICaughtData2 off of PK2 so it can be shared with SK2 when type-checks occur
Add conversion for PK2<->SK2
Split the split-buffer handling for GBPKM to GBPKML (what a name), so that I can reuse shared accessor logic for SK2.
2020-10-02 18:08:40 -07:00
Kurt
a34434f7cb Make pkm.Data a readonly field rather than property 2020-09-26 12:09:02 -07:00
Kurt
cb0bbe889e Make pk1/2 => pk7 PID transfer mimic official mechanism
Hardcode 0 xors to indicate SID and end result ShinyXor=0.

#3002
2020-09-25 18:00:10 -07:00
Kurt
0b8989e4ce Make EV_SPC a shared property for GBPKM derived classes
seal up some properties that aren't overriden in the derived classes; could do more but meh
2020-09-07 10:55:15 -07:00
Kurt
c1adab9703 Refactoring
Move logic closer to where it is used rather than in larger static classes

EncounterStatic(7): move VC transfer template creation to class, simplify some sanity checks
EvoChain: g==2 case is never hit as the generation check at the top of the loop already skips
2020-09-05 12:11:43 -07:00
Kurt
e84ce77008 Split memories from main pkm class to interface
pk6/7/8, not pb7
2020-07-31 17:25:14 -07:00
Kurt
eb7ed44b29 Finish splitting gen1/2 encounter types from parent class
Results in a little more code, but each path is less tangled
simplify some expressions
remove RBDragonair content in favor of a strict filter for catch rate

Move gen1 trade trainer names to stringconverter, since pk1/pk2 shouldn't refer to legality classes
2020-07-19 13:32:40 -05:00
Kurt
e04b96a9b3 Fix dizzy punch egg recognition & gen2 hatch conter verification
Closes #2939
Fixes #2938

Inline some logic where appropriate for egg levels
2020-07-12 20:58:07 -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
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
1906a1040f Relocate console-location data setting to PKMConverter
When adding data, check if the current Trainer has valid console data; if not, use a default value.
2020-01-05 21:41:32 -08:00
Kurt
e21d108fb2 Split PokeCrypto from PKX
All logic in PokeCrypto is separate from the rest of the PKHeX.Core
library; makes it easy to just rip this portion out and reuse in other
projects without needing the entirety of PKHeX.Core logic

optimize out the CheckEncrypted to the actual path, separate methods.
Only usages of this method were with hardcoded Format values, so no
impact
2020-01-04 14:48:39 -08:00
Kurt
d736f24bb7 Heal PP on transfer
force everything to their current pp count
2019-12-26 15:28:04 -08:00
Kurt
fcc993784b Rename abstract pkm inherited class names
leading underscore for a class name = pls no
2019-10-26 12:42:33 -07:00
Kurt
b41f2a3062 Extract logic from PKX
Extract Species Name logic to SpeciesName
Extract Language logic to Language
Remove FormConverter wrapper for string[] fetch
Rearrange some logic to more appropriate locations, update access
modifiers / types
Move some pkm array methods to arrayutil, make generic

PKX.GetVCLanguage was a dupe of _K12.GuessedLanguage() so just expose
the method

PKX is now back to pkm data manip only
2019-09-18 19:58:23 -07:00
Kurt
7424cf6fb0 Remove GSC/C differentiation in PK2
Allows for no adjusting the game group
2019-07-28 13:26:39 -07:00
Kurt
33a07a6fcd Try and force destination language on transfer
Closes #2314
2019-05-27 11:23:47 -07:00
Kurt
b1ead9e630 Split StringConverter into smaller pieces
reduces loading time (don't have to allocate conversion arrays when
launching a gen7 game), and separates things to easier to manage
locations

reworks gen3 string encode/decode, no longer does 3->4->5 and 5->4->3;
instead goes straight to the end result without an intermediary format.

String sanitization should probably be broken up rather than reused, oh
well.
2019-03-20 21:50:44 -07:00
Kurt
99baca5f5e Use min parameter count
PK2 doesn't like getting passed null for the byte[] parameter (rightly
so); don't depend on the src code order having the first constructor
being the one with the least arguments

fix it in pk1/2 so that the first constructor has the least args, anyway
2019-03-16 20:04:44 -07:00
Kurt
8a08d32dff Simplify pkm constructors
remove Identifier param. 99% of the time, identifier is not provided,
resulting in a useless call

end result:
provide 'create new' and 'create from' constructors
2019-03-16 18:41:56 -07:00
Kurt
fb76032a39 Remove unnecessary null checks on constructors 2019-03-16 18:23:50 -07:00
Kurt
ca0e012c5c Add Heal, make status_condition a pkm property
also split out battle box slot offset fetch
if anyone finds where colo&xd store their status bits, lmk 👍
2019-01-11 22:25:48 -08:00
Kurt
359a529870 Misc updates
Move some logic around, fix style warnings
2018-10-27 08:53:09 -07:00
Kurt
c0b5d3eef7 Abstract away pk1/pk2 properties to shared class
some inefficiencies with pk1 altform/iskorean but is much easier to
manage
2018-08-19 15:50:15 -07:00
Kurt
fc73eee570 Extract PokemonList* to inherited class
Logic is essentially identical; implement a base class and have the
generation specific structures implment the differences.

Reduce the verbosity a little
2018-08-05 17:28:54 -07:00
Kurt
4c96efb9b7 Update pk2->pk1 party stat transfer logic
pk1 boxdata stores current level & current hp, which is only present in
pk2 party data.
if the user drops in pk2(boxdata), the transfer leaves 0 for both
values, which isn't correct.
detect stat_level to determine if values should be regenerated or not.

Thanks HaxAras for finding this :)
2018-07-31 14:29:47 -07:00
Kurt
f35712fcf2 Extract experience logic to separate file
add exp bar logic, unused.
2018-07-29 17:43:30 -07:00
Kurt
279f44a645 Simplify GB stat calc, fix pk2->pk1 xfer fainting
Remove unnecessary floor operation, don't fetch stat arrays for each
stat

Current HP is a box stat in pk1 format (offset 0x1), which isn't stored
in box pk2's. If the hp is zero, set it to the current HP.

Thanks HaxAras for the conversion tip!
2018-07-24 16:41:18 -07:00
Kurt
f8c43d4a06 Rework gen1 trade OT handling
convert all dictionaries to char-byte instead of string (saves 50KB on
compressed dll, lul)
update OT string comparison for pre/post transfer specimens

Showing "TRAINER" for all languages isn't correct, just show a mapped
character

Closes #2049 , thanks @egzonqj & @WEERSOQUEER !
2018-07-10 16:45:24 -07:00
Kurt
397de97f3c Remove excessive references to Util.Rand32()
all usages besides fetching a 32bit random value should use rand.next
remove unnecessary do-while loop for calculating random EVs (always
returns 510 in total)
2018-07-04 11:30:43 -07:00
Kurt
3674a11cfe Misc simplifications
absorb verifier calls into the parsing methods
2018-07-01 17:07:29 -07:00
Kurt
dc3cdd4491 Fix gen1/2 gender detect
gender: take top 4 bits of gr:
31 = 0x1F = 1
63 = 0x3F = 3
127 = 0x7F = 7
191 = 0xBF = 11

See the pattern? If we change the compares from >= to >, we -1. All
numbers match except for the 25/75 ratio pkm... which unveils the
problem.

Simplify the calc for these using the logic above, which fixes the error
and makes the code easier to read!

Thanks SystemError for assisting :)
2018-06-27 18:31:24 -07:00
Kurt
9faba26e90 Add egg base move branch
Closes #1991
Thanks @iiippppk  !

Improve pk2 version detect to better provide gs vs c egg base moves
2018-06-11 07:23:48 -07:00
Kurt
59b4b8f755 Simplify pkm conversion
just loop instead of goto, let the jit handle optimization
src looks quite pretty now!
some tradeoffs made but much more maintainable now
2018-06-04 21:28:14 -07:00
Kurt
ae3b6a7fa1 Simplify IContestStats usage
remove new[] creating for checking if any contest stats exist
(HasContestStats)
2018-06-02 21:19:03 -07:00
Kurt
5a3c8f4147 Remove trailing whitespace 2018-05-12 08:41:29 -07:00
Kurt
f5c9873348 Update showdownset handling for gen2/3
Closes #1913 by detecting any required pkm format related to the item.
2018-04-25 18:45:31 -07:00
Kurt
e6a74b0145 Only skip nickname set if currently same
Closes #1842
2018-02-17 17:42:00 -08:00
Kurt
802105d22d Allow pay day mewtwo, disallow dizzy punch
#1772
transfer pk1->pk2->pk7 for mewtwo knowing dizzy punch, just so we can
keep Pay Day
2018-01-25 19:17:42 -08:00
Kurt
e79a35d387 Fix long OT name length setting
StringLength is the raw buffer size, needs to be offset by 1 as the
string length enforced does not consider the terminator

12char OT name in sav7 loaded to tabs -> load gen1/2 save = exception
(now fixed)
2018-01-01 11:27:45 -08:00
Kurt
a1f2f8708a Refactoring
pass identifier on cloning pkm
remove unnecessary ref for passing Data (not modifying array reference)
const some magic numbers
2017-12-27 16:36:24 -08:00