Skip to content

[FEAT] [DRAFT] Polished Crystal integration - #1174

Draft
merlinnerd922 wants to merge 4 commits into
mainfrom
impl-poCr-attempt2
Draft

merlinnerd922 wants to merge 4 commits into
mainfrom
impl-poCr-attempt2

Conversation

@merlinnerd922

Copy link
Copy Markdown
Collaborator

Description

Preliminary changes to start integrated Polished Crystal as well as all games based in that engine.

Issue

This PR exists merely for others to provide feedback.

Comment thread pkm_rs_types/src/structures.rs Resolved
Comment thread pkm_rs_types/src/structures.rs Resolved

@andrewbenington andrewbenington left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is still a work in progress, so I'm sure some of the things I mention were planned to be changed anyways. Overall it looks good! Thanks for your work on this!

Comment on lines +32 to +33
personality_value: 0,
encryption_constant: 0,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personality value should be generated using pkm_rs::convert_strategy::personality_value::generate_pid_matching_fields(). I would set the encryption constant to the same value, that's what Poké Transporter does.

right now I imagine this code will result in all mons of the same evolution family from Polished Crystal being treated as clones of each other

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, oops...didn't realize this would be a thing. Will fix.

let met_data = converter.met_data(ohpkm);

let mut mon = Self {
encryption_constant: 0,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you havent gotten to implementing this yet. is there a reason you wouldn't just use the encryption constant from the ohpkm?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could definitely do that! I just wasn't sure if encryption constants are even used in Polished Crystal.

let mut mon = Self {
encryption_constant: 0,
sanity: 0,
checksum: 0,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also assuming this is a todo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Apologies; should highlight that.

I do think some of these values aren't necessarily used in Polished Crystal though, so some may be placeholders.

Comment thread pkm_rs_types/src/stats.rs Resolved
Comment thread pkm_rs_types/src/structures.rs Resolved
type WasmPkmInterface<P> = PKMInterface & { inner: P }

type WasmSaveClass<S> = {
export type WasmSaveClass<S> = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you need to export this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe because it was being used elsewhere and it wouldn't work without an exportation.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I'm wondering why you are using it elsewhere. The other Wasm save types didn't require this to be used elsewhere

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try removing and see if there are errors.

case 'PK2': {
case 'PK2':
case 'PK2PolishedCrystal': {
const gen12Identifier = getMonGen12Identifier(mon)

@andrewbenington andrewbenington Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does polished crystal have an encryption constant or personality value? I thought I saw an encryption constant in your struct

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the code is now, the fields are mandatory if we implement certain traits in Rust, but I don't believe they're actually being used.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields are mandatory to derive the IsShiny trait automatically (via #[derive(IsShiny8192)] or #[derive(IsShiny4096)]), because those macros use either the personality value (8192) or encryption constant (4096) in tandem with the trainer/secret ids to calculate shininess. They should probably be renamed to #[derive(PersonalityValueShiny)] and #[derive(EncryptionConstantShiny)] respectively, sorry about the ambiguity.

Regardless, you should only be using those derives if Polished Crystal calculates shininess via personality value or encryption constant. Otherwise, you should implement the IsShiny trait manually.

@merlinnerd922 merlinnerd922 Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll determine how Polished Crystal calculates shininess. But I have a gut instinct that because they decoupled determination of shininess from the way the original Crystal does it that it will need to be different.

@merlinnerd922

Copy link
Copy Markdown
Collaborator Author

Andrew, thanks again for checking all this and verifying I'm on the right track! I know your schedule is busy so I appreciate it.

@andrewbenington andrewbenington changed the title WARNING! NOT ready to be merged; just for review. - Polished Crystal integration [FEAT] [DRAFT] Polished Crystal integration Dec 3, 2026
@FlitPix
FlitPix marked this pull request as draft December 3, 2026 21:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants