Coder Social home page Coder Social logo

Add Event subclasses about auraxium HOT 4 CLOSED

leonhard-s avatar leonhard-s commented on June 11, 2024
Add Event subclasses

from auraxium.

Comments (4)

leonhard-s avatar leonhard-s commented on June 11, 2024

(Continuing here to keep it with the issue itself)

@LordFlashmeow Feel free to take this one, it has been bugging me for a while too. I originally pushed this back because I was already working on moving to pydantic for the rest of the object model at the time and wanted to figure that out first.

Here are some thoughts I've written down for myself, for inspiration:

  • events.py is already quite cluttered; the subclasses should therefore be part of the models sub module, same as the other object model data classes.
  • This means that Event must inherit from pydantic.BaseModel (or Ps2Data, that way we also keep the immutability), with all other events inheriting from it
  • These sub classes should have a type class attribute that points back to its enum equivalent (I want to keep the enums around for simplicity)
  • Reimporting the sub classes into the events module is fine imo
  • Should Trigger and related classes be extended to accept Event sub classes in place of EventType enums?

When implementing the MetagameEvent sub class, be wary of the zone_id field; it does not actually get sent with payloads anymore.
We can handle this in two ways: Either we don't include it at all and instead add a zone_id property that returns the appropriate value as per the reference in the Wiki, or we make it an optional field that defaults to -1, then add a pydantic validator that performs the same lookup and replacement if the value hasn't been changed. This also allows new alerts to just work in case the field ever gets fixed.

So yeah - if you want to help with this one, I'd appreciate it 👍

from auraxium.

leonhard-s avatar leonhard-s commented on June 11, 2024

Gonna try my hand at implementing the above; I don't want to have to write the event handler docs twice. :D

from auraxium.

leonhard-s avatar leonhard-s commented on June 11, 2024

Added in a24a7f0

from auraxium.

LordFlashmeow avatar LordFlashmeow commented on June 11, 2024

Nice, that's simpler than what I did. I'll make a draft pr so you can see what I was thinking.

from auraxium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.