Skip to content

Conversation

@Hanmac
Copy link
Contributor

@Hanmac Hanmac commented Nov 29, 2025

Other part of #9259

This should cause all Display Functions to be serializable

i added a new Interface because it was very ugly to mark a Type as both while extending a class

@Jetz72
Copy link
Contributor

Jetz72 commented Nov 29, 2025

Can you actually serialize and deserialize a function this easily without any issues?

@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 29, 2025

@Jetz72 it seems https://www.baeldung.com/java-serialize-lambda#bd-2-how-to-serialize-lambda

i was trying to do it without extra interface, it worked for the functions, but for some classes it doesn't like it.
That's why i added that interface.

@Jetz72
Copy link
Contributor

Jetz72 commented Nov 29, 2025

The fact that it's hard-coded to return a String suggests we should probably use a less general name than "Serializable Function". DisplayFunction? TextFunction? ListItemTextFunction?

Broadly speaking it feels a bit janky that we have to pass a function through such a long pipeline in the first place. Ideally the UI would be responsible for recognizing what kind of list it's been given and decide for itself how to display it, without explicit instructions from the game logic. We already do that with some object types like Cards. It'd be nice to just trim these function signatures down a bit. But that might be a lot of trouble for little practical benefit.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants