Comments (4)
(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 themodels
sub module, same as the other object model data classes.- This means that
Event
must inherit frompydantic.BaseModel
(orPs2Data
, 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 acceptEvent
sub classes in place ofEventType
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.
Gonna try my hand at implementing the above; I don't want to have to write the event handler docs twice. :D
from auraxium.
Added in a24a7f0
from auraxium.
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)
- Move data classes to pydantic
- player.events_grouped() error. HOT 4
- Example of obtaining a player's overall kills and deaths. HOT 9
- Create outfit member join/leave event HOT 4
- Cannot pass conditions with @client.trigger() HOT 2
- Fix unit test workflow for forks HOT 1
- weapon datasheet 'max' and 'min' damage are meaningless due to API quirks HOT 2
- Reconsider object model getter helpers
- Note GainExperience quirks in documentation HOT 1
- Faction image_path missing HOT 1
- outfit.leader() -> Character or OutfitMember HOT 2
- ('experience_bonus',), 'msg': 'value is not a valid integer', 'type': 'type_error.integer'}])> HOT 2
- Improve error message when pydantic validation fails
- RTD broken link HOT 1
- Allow unsecured connections for expired API certs HOT 3
- WebSocket version migration HOT 1
- Support third-party fallback endpoints HOT 1
- Uncaught exception on await Character.items(): KeyError HOT 5
- README example is raising RuntimeError HOT 2
- Client.get_by_name not using name.first_lower HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auraxium.