Commit graph

52 commits

Author SHA1 Message Date
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
a481757b45 Relocate CheckEncrypted to PKX
PKX references within the method; no dependence on anything in
PKMConverter
2019-04-16 22:51:01 -07:00
Kurt
bbe56a3318 Simplify trade trainer parameters
Bank was always false, don't try to minimalize gets by fetching before
call (be simple)

remove unreachable branches now that dust has settled
2019-03-30 22:05:28 -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
d792c0d3a0 use u/L
use 'u' to denote uint values, so that less IL ops are required
~(21->17) in the case of IVs
no functional change, just a fun exercise looking at generated IL and
finding ways to use less ops
2019-02-23 15:36:26 -08:00
Kurt
383d4b7700 "" -> string.Empty
be explicit that the string is empty rather than possibly missing
disallow encrypted export for BK4 (they're not encrypted), removes type
check
simplify replaceall in showdownset (don't call ReplaceAll 4x, just get
valid chars and rebuild)
simplify get ribbon sprite name (precompute ToLower and appended values
2019-02-07 21:40:20 -08: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
d85bb76208 Mirror order of operations from pb7
see prior commit; this doesn't make any difference since
CurrentFriendship isn't being called; but we're just matching the flow.
Closes #2235
2019-01-08 18:35:26 -08:00
Kurt
9db771c0d5 Split out common 6+ pkm format to abstract class
Didn't really feel like pulling out the shared structure get/set
operations, only the derived properties & overall fixer methods. Should
be easier to maintain if any handling updates.

Clean up pb7 unused stuff; removes ribbon logic since none are used.

c# 8.0 interface defaults can maybe pull out more logic (ex making
FixRelearn and relearn moves into an interface); multiple inheritance
can be useful as features are added/dropped between generations.
2018-12-25 22:56:32 -08:00
Kurt
2d774ac7cc Allow dynamic default savefile type load
Make extrabytes a pkm property (don't mutate array pls)
reconfigure startup loading to only initialize after initial load of sav
& pkm (using blanks if not provided)
2018-12-19 22:10:32 -08:00
Kurt
3d7f3caef8 Add status condition prop to all mainline formats
Closes #2160 , use Batch Editor to modify slots; it's not worth GUI
presence as it's only saved for party format mons and is undocumented
for anything besides affliction flags
2018-12-02 21:23:10 -08:00
Kurt
cfbdb7c26c Add parameter-less constructors
Removes null check for hot path where data is actually provided
2018-11-21 14:15:48 -08:00
Kurt
b280ffcfef style updates
should be pretty much it
2018-09-14 22:37:47 -07:00
Kurt
4dc04cb4b9 Add pelago status value check + etc
0, [9,19] are set (didn't see 15), but there's also a switch case which
references all values 0-19.

these values are used by a 80 sbyte array (4*20) in the Resort.cro

remove usages of "goto case"
2018-08-27 20:44:26 -07:00
Kurt
f27f11bfc8 Clean up pk7/sav6/sav7 simple methods
extract GetFormDuration to method, remove unused GetIsCompatible
specialized variant (there's a generalized version in SAVUtil.cs,
IsPKMCompatible -- might do another round of WinForms->Core absorption
2018-07-20 20:25:28 -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
450d40535d Relocate hypertraining properties to interface
lessen temp array creation, speed++
2018-06-05 21:31:42 -07:00
Kurt
6cff642ff1 Skip format check on pk* init
also remove ck3/xk3 no-op call (no encryption for those formats, like
bk4).
2018-06-04 20:25:54 -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
ca14b43b62 Relocate memory specific data to own file
allows easier handling for memory interactions
2018-05-19 10:04:07 -07:00
Kurt
5a3c8f4147 Remove trailing whitespace 2018-05-12 08:41:29 -07:00
Kurt
ea357cd57a Add GetRandomFeeling
fixes tests & transfers where an explicit range is not legal
2018-04-28 12:59:11 -07:00
Kurt
2f57630b4a Clamp abilitynumber value
keep to 3 bitflags
1/2/H
2018-04-04 21:42:02 -07:00
Kurt
d794e71175 Extend contest-affection check to pre-gen6 transfer
Closes #1881
Thanks @ijuintekka !
Thanks @sora10pls !
2018-03-28 16:07:03 -07:00
Kurt
a24e5aa742 Update personalinfo usages
less temp array usages, add methods for cleaner understanding
2018-03-25 13:54:30 -07:00
Kurt
0d69e803e1 Add gen4/5 synthetic trade logic
was previously present for gen6 and gen7 only, resulting in eggs in
gen4/5 not getting link trade values applied. that's really all.

https://projectpokemon.org/home/forums/topic/44437-bug-eggs-transfer-for-gen-4-dppt-and-hgss/
2018-03-21 21:10:23 -07: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
Kurt
3445b46526 Remove unnecessary array cloning
new objects would always clone the input array; only clone on object
cloning (keep the original array reference on initial creation from
bytes)
2017-12-26 21:38:19 -08:00
Kurt
18796d6f92 Misc tweaks
fix bk4 ribbon checks (lacked interface inheritance)
change MN -> UM for get blank save (unused in PKHeX solution)
prevent inheriting from derived pkm classes
2017-12-16 14:11:41 -08:00
Kurt
e5aa39a6bb Refactoring
get language list now doesn't return new objects (or re-enumerate)
update rand usage to be inclusive for top bound, extend shuffle to
collections
remove unnecessary location overrides (already overriden in legal fetch)
2017-12-14 20:58:55 -08:00
wwwwwwzx
6c4a4ff4ec Fix chinese language ID check
Some species have the same unicode name in CHS and in CHT, so it will lose language info after converting from a in-game string to textbox (The game will use different fonts to distinguish them, bad GF)
This change will give CHT encoding a higher priorty if the pkm is in CHT, although it's possible to get CHS encoding default species name with CHT language ID.
Also fixed previous editing error
2017-12-14 19:30:59 -08:00
Kurt
a9ff74059a Misc perf tweaks
checking untraded should just check for the first character (rather than
creating string object)
hashset for wild6 balls
2017-12-13 16:12:53 -08:00
Michael Scire
e8d1d1f521 Add "IsSMCompatible" helper method to PK7.
Translated from official game code (PokeRegulation::CheckNijiCompatible).
Potentially for future use in USUM -> SM transfers?
2017-11-16 12:23:35 -08:00
Kurt
ece66e1a02 Misc tweaks
allows loading of species > 720 lol
still nowhere near done (large task is resource acquisition)
2017-11-08 00:51:08 -08:00
Kurt
60e719a65a Misc refactoring
more usum prep
don't allocate empty array on every savefile creation (use linq All
comparison)
add percent seen/caught savefile properties for data analysis purposes
2017-10-31 09:24:54 -07:00
Kurt
69cf1eaa9c add more pkhex.core xml documentation
adds a bunch of documentation useful for those unfamiliar with the core
library
2017-10-23 23:12:58 -07:00
Kurt
02c06d154b Split item cap for usum prep 2017-10-10 19:30:55 -07:00
Kurt
059451d66e misc tweaks
dictionary species check, max deviation beginnings for USUM
simplification for gen1/2 pokemonlists
2017-10-05 22:37:45 -07:00
Kurt
b5e3b616de nickname edge case
evolved on a foreign language can't rely on stored language ID, have to
detect it
2017-10-03 19:21:17 -07:00
Kurt
ea751e26b1 Convert chinese string only if species name
Resolves charmap duplications in the chinese char tables:
多边兽Z (Porygon-Z)
属性:空 (Type Null)
谜拟Q (Mimikyu)
卡璞・鸣鸣 (Tapu-Koko)

Games cannot have a nickname/OT in chinese as of current date... I
assume this will be fixed down the road
2017-10-03 18:15:15 -07:00
Kurt
6611e874c3 more usum prep
species added requires the 'latest personal table' reference to be
USUM's; the other referencs for .SM are fine as there's no possibility
to have a species ID high enough for it to matter.
2017-09-18 22:36:06 -07:00
Kurt
47ca69f92b Legality edge case fixes
Some incorrect IDs, some additions (unbreedable hidden abilities in
genV)

https://projectpokemon.org/forums/forums/topic/41407-pkhex-legality-errors-on-gen-6-updated/?tab=comments#comment-219459
2017-09-05 18:28:38 -07:00
Kurt
80196f75ef Refactoring
split Core.PKX into smaller classes, only StringConverter is exposed for
outside namespaces
2017-07-31 23:03:51 -07:00
Kurt
a91764b283 Add hot springs as valid egg location for gen6
split table references, remove per-format calculations as they all
behaved the same as the main method
2017-07-10 18:56:13 -07:00
Kurt
4b1e91677e Fix misc legality issues
Closes #1273
not noted anywhere was encounterstatic pikachu on gen6 (pokewalker->6)
would get flagged.
2017-06-24 17:24:37 -07:00
Kurt
9b76d9b214 Next round of ribbon checking
Returned messages are slightly misleading since missing/invalid are
mixed together with the static method.

#1250
~322 lines to check ribbons, on top of the interface abstraction... so
much required... kinda understandable as there's over 100 ribbons to
check.
2017-06-20 21:57:03 -07:00
Kurt
6921a2ebee Initial ribbon refactor
remove legality check's use of reflection which checked individual
properties; add interfaces to interact with the ribbons of each PKM
type. With this, every ribbon attribute is accessible via its
corresponding interface (cast)

will have to add checks for individual interfaces as per #1250

I didn't feel like adding much documentation, is pretty straightforward.
Cast a pkm object to the desired ribbon set; if not null, can access
ribbons regardless of pkm format.
2017-06-19 21:43:44 -07:00
Kurt
3f38b123a3 Refactoring
mostly renaming things, includes a little bit of added sugar and
splitting methods to simplify the codebase.

all methods are now PascalCase
2017-06-17 18:37:19 -07:00
Kurt
0ae907e4d0 Update unused byte usage knowledge
DistByte is actually 16bits; no point changing the name.
The 32bits afterwards are form duration (Hoopa/Furfrou only), and only
exist while the PKM is in the player's party.

The game sets an initial value with days to exist in the form before
reverting (probably on game restart), checking the delta between days
saved. Either way, just set a base value when writing it to the party,
else clear the value if it is not supposed to be used.

Thanks @SciresM !
2017-06-06 22:13:12 -07:00
Kurt
11b2dc35d7 Refactor main form into smaller pieces
pkm editor, sav editor, menus, and a manager to glue the storage slots
together
decouples the pkm/sav editors from a static savefile reference.

improves dragdrop/click view/set/delete indication, hides unavailable
contextmenuitems, and fixes a few incorrect references. Box Subviewer
slots now have all the indication/events that the main save editor slots
have.

pls report behavior bugs 👍
2017-05-22 21:55:12 -07:00