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

Implement gadgets in the backend #33

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Implement gadgets in the backend #33

wants to merge 15 commits into from

Conversation

konsumlamm
Copy link
Contributor

@konsumlamm konsumlamm commented May 21, 2024

Part of #31.

@konsumlamm konsumlamm mentioned this pull request May 23, 2024
@konsumlamm konsumlamm force-pushed the gadgets branch 2 times, most recently from 3dc1405 to a1adb3d Compare May 24, 2024 13:37
@konsumlamm konsumlamm changed the title Implement gadgets Implement gadgets in the backend May 24, 2024
@konsumlamm konsumlamm requested review from Comeza and TrueDoctor and removed request for Comeza May 24, 2024 13:48
@konsumlamm konsumlamm marked this pull request as ready for review May 24, 2024 15:19
@konsumlamm konsumlamm added enhancement New feature or request Backend About the Backend (robusta) labels May 24, 2024
Comment on lines +7 to +20
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,
}
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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>,
Copy link
Member

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>.

Copy link
Contributor Author

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.

Comment on lines +20 to +22
MrXGadget(MrXGadget),
DetectiveGadget(DetectiveGadget),
MrXPosition(MrXPosition),
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend About the Backend (robusta) enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants