-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement gadgets in the backend #33
base: main
Are you sure you want to change the base?
Conversation
3dc1405
to
a1adb3d
Compare
Determine gadgets based on team Add `Gadget` element
Check if gadget has already been used Use more functions More warnings
pub enum MrXGadget { | ||
AlternativeFacts { stop_id: String }, | ||
Midjourney { image: Vec<u8> }, | ||
NotFound, | ||
Teleport, | ||
Shifter, | ||
} | ||
|
||
#[derive(specta::Type, Clone, Serialize, Deserialize, Debug)] | ||
pub enum DetectiveGadget { | ||
Stop { stop_id: String }, | ||
OutOfOrder, | ||
Shackles, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would speak against using just one enum? You could add a function is_usable_by(team: Team) -> bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main advantage is that it's harder for the frontend to accidentally send a gadget from the wrong team. Using a single enum might be cleaner though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another advantage is that there are separate countdowns for Mr. X and Detective gadgets.
#[derive(Debug)] | ||
pub struct GadgetState<T> { | ||
can_be_used: bool, | ||
cooldown: Option<f32>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to use chrono::DateTime<Utc>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cooldown is the number of seconds remaining, using a DateTime<Utc>
requires more work to get the remaining time each iteration.
MrXGadget(MrXGadget), | ||
DetectiveGadget(DetectiveGadget), | ||
MrXPosition(MrXPosition), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add more gadget this might become cluttered, thus you might want to wrap this in a UseGadget(Gadget)
Part of #31.