Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typechecker; typecheck data entries #357

Merged
merged 18 commits into from
Sep 12, 2021
Merged

Conversation

Ruin0x11
Copy link
Owner

@Ruin0x11 Ruin0x11 commented Sep 11, 2021

Purpose of this PR

  • Bug fix
  • Enhancement
  • New feature

Related issues

#61. Closes #110. Closes #305.

Description

  • Adds a runtime typechecker, and adds type annotations for every single data type in the codebase.
  • Validates all datatypes that are added on startup, and fails hard if any of them don't pass.
  • Implements the _ordering field, and makes data[...]:iter() sorted by default.
  • Adds some rudimentary typechecking for certain data types with custom parameter tables, like feats and activities.
  • Moves feat parameters into feat.params instead of placing them directly on the object.

Eventually I also want:

  • Typechecking for interface requirements. Also, it should be an error to define a default function implementation on an interface without specifying the function in the interface requirements.
  • Publicly exposed type definitions so mods can re-use them, and link between them when generating documentation.
  • Prettier type names/error output for data entries that fail validation.
  • A way of combining the new type annotations with LDoc comments in API modules, classes and interfaces to provide a proper mod API documentation site.

But this will do for now. I will have to start thinking about releasing something soon, or it's never going to get done...

Related to that thought, after this feature is implemented these are the things that I still want to implement before releasing the first alpha.

  1. Mod profile creation (Profile system #163).
  2. A config submenu for enabling/disabling themes and previewing the changes in-game.
  3. Improvements to serialization - modification of binser to be better aware of things like ILocation/pool and map object references, implementation of ISerializable using GUIDs for class type identification, fast failure if attempting to serialize a non-serializable class instance, fixing the known entity reference bugs (Serializing class instances can mutate their state in damaging ways #320, Rewrite the entire serialization code to be better suited to OpenNefia's design #135, Character references are unintentionally saved onto activity instances #348).
  4. A very rudimentary modding tutorial for simple things like adding in a new character. It needs to be as simple as possible so it won't become severely outdated by the upcoming changes to the API. Maybe adding a special quickstart scenario specifically for mod development would be helpful (the current quickstart scenario is kind of weird and mostly for my own personal use).
  5. Rudimentary log output to a file, so there will at least be some context for new bug reports (Output logs as files and rotate them #24).
  6. Minor changes to the in-game error handler to make it more friendly to non-programmers.
  7. English/Japanese language selection on the very first startup.
  8. Some basic issue templates for bug reports/feature requests.
  9. Bugfixes for anything major (Potion puddles from potions with an IItemPotionAspect don't work #338, Bugs with updating the screen in the middle of scrolling  #355).

That's it. After all of that is done, I will resign myself to shipping the first official alpha release, knowing full well that it will still be plainly broken and unfinished in various ways (no riding, for example).

The unimplemented features and refactorings for things like #179 at this point will have to follow after the first release happens. I don't think the code is in such a bad state that it would merit throwing away large parts of it, only improving on a couple of bad design decisions I made before aspects and base.data_ext were added and moving things around so they're better organized. A lot of the confusion with things like event parameter tables can be solved with more documentation, but given that there would be no consumers of such documentation at present, it's hard for me to be motivated enough to write it all... hence the need for a release of some kind.

I don't think I should feel shame in giving something back to the world that I've spent a lot of time on, even if it won't be fully completable and won't have save/mod API compatibility between alpha versions.

@Ruin0x11 Ruin0x11 added enhancement New feature or request data Concerns adding new content refactoring This requires refactoring existing code labels Sep 11, 2021
@Ruin0x11 Ruin0x11 merged commit 25ceb45 into develop Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Concerns adding new content enhancement New feature or request refactoring This requires refactoring existing code
Projects
None yet
1 participant