1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Save current game event to database for use in the match

This commit is contained in:
NG (Graham)
2025-07-22 21:36:24 -04:00
parent 0683de965b
commit fd11b8746b
11 changed files with 240 additions and 23 deletions

View File

@@ -28,20 +28,33 @@ pub struct GameEventsParamsProvider {
impl Operation<()> for GameEventsParamsProvider {
type User = crate::UserTy;
async fn handle_async(&self, params: polariton::operation::ParameterTable<()>, _user: &Self::User) -> polariton::operation::OperationResponse<()> {
let mut params = params.to_dict();
let current_mode = self.sequence.lock().unwrap().now();
params.insert(MAP_NAMES_PARAM_KEY, current_mode.maps);
params.insert(VISIBILITY_PARAM_KEY, current_mode.visibilities);
params.insert(MODE_PARAM_KEY, current_mode.modes);
params.insert(AUTO_HEAL_PARAM_KEY, current_mode.auto_heals);
params.insert(REMAINING_TICKS_PARAM_KEY, current_mode.remaining_ticks);
polariton::operation::OperationResponse {
code: Self::op_code(),
return_code: 0,
message: polariton::operation::Typed::Null,
params: params.into(),
async fn handle_async(&self, params: polariton::operation::ParameterTable<()>, user: &Self::User) -> polariton::operation::OperationResponse<()> {
match user.user() {
Ok(user_info) => {
let mut params = params.to_dict();
let current_mode = self.sequence.lock().unwrap().now(user_info.current_game_event_setter());
params.insert(MAP_NAMES_PARAM_KEY, current_mode.maps);
params.insert(VISIBILITY_PARAM_KEY, current_mode.visibilities);
params.insert(MODE_PARAM_KEY, current_mode.modes);
params.insert(AUTO_HEAL_PARAM_KEY, current_mode.auto_heals);
params.insert(REMAINING_TICKS_PARAM_KEY, current_mode.remaining_ticks);
polariton::operation::OperationResponse {
code: Self::op_code(),
return_code: 0,
message: polariton::operation::Typed::Null,
params: params.into(),
}
},
Err(e) => {
polariton::operation::OperationResponse {
code: Self::op_code(),
return_code: e,
message: polariton::operation::Typed::Null,
params: params.into(),
}
}
}
}
}