advance_game stuff
This commit is contained in:
parent
151f7a3489
commit
a39ad4cf7c
6 changed files with 95 additions and 79 deletions
|
|
@ -4,19 +4,13 @@
|
|||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::game_timer_type::GameTimer;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub(super) struct AdvanceGameArgs {
|
||||
pub game_timer: GameTimer,
|
||||
}
|
||||
pub(super) struct AdvanceGameArgs {}
|
||||
|
||||
impl From<AdvanceGameArgs> for super::Reducer {
|
||||
fn from(args: AdvanceGameArgs) -> Self {
|
||||
Self::AdvanceGame {
|
||||
game_timer: args.game_timer,
|
||||
}
|
||||
Self::AdvanceGame
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,8 +29,8 @@ pub trait advance_game {
|
|||
/// The reducer will run asynchronously in the future,
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`advance_game:advance_game_then`] to run a callback after the reducer completes.
|
||||
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> {
|
||||
self.advance_game_then(game_timer, |_, _| {})
|
||||
fn advance_game(&self) -> __sdk::Result<()> {
|
||||
self.advance_game_then(|_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `advance_game` to run as soon as possible,
|
||||
|
|
@ -47,7 +41,6 @@ pub trait advance_game {
|
|||
/// and its status can be observed with the `callback`.
|
||||
fn advance_game_then(
|
||||
&self,
|
||||
game_timer: GameTimer,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
|
|
@ -58,13 +51,12 @@ pub trait advance_game {
|
|||
impl advance_game for super::RemoteReducers {
|
||||
fn advance_game_then(
|
||||
&self,
|
||||
game_timer: GameTimer,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AdvanceGameArgs { game_timer }, callback)
|
||||
.invoke_reducer_with_callback(AdvanceGameArgs {}, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ pub use wind_type::Wind;
|
|||
|
||||
pub enum Reducer {
|
||||
AddBot { lobby_id: u32 },
|
||||
AdvanceGame { game_timer: GameTimer },
|
||||
AdvanceGame,
|
||||
ClearAll,
|
||||
DiscardTile { tile_id: u32 },
|
||||
JoinOrCreateLobby { lobby_id: u32 },
|
||||
|
|
@ -92,7 +92,7 @@ impl __sdk::Reducer for Reducer {
|
|||
fn reducer_name(&self) -> &'static str {
|
||||
match self {
|
||||
Reducer::AddBot { .. } => "add_bot",
|
||||
Reducer::AdvanceGame { .. } => "advance_game",
|
||||
Reducer::AdvanceGame => "advance_game",
|
||||
Reducer::ClearAll => "clear_all",
|
||||
Reducer::DiscardTile { .. } => "discard_tile",
|
||||
Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby",
|
||||
|
|
@ -106,10 +106,8 @@ impl __sdk::Reducer for Reducer {
|
|||
Reducer::AddBot { lobby_id } => __sats::bsatn::to_vec(&add_bot_reducer::AddBotArgs {
|
||||
lobby_id: lobby_id.clone(),
|
||||
}),
|
||||
Reducer::AdvanceGame { game_timer } => {
|
||||
__sats::bsatn::to_vec(&advance_game_reducer::AdvanceGameArgs {
|
||||
game_timer: game_timer.clone(),
|
||||
})
|
||||
Reducer::AdvanceGame => {
|
||||
__sats::bsatn::to_vec(&advance_game_reducer::AdvanceGameArgs {})
|
||||
}
|
||||
Reducer::ClearAll => __sats::bsatn::to_vec(&clear_all_reducer::ClearAllArgs {}),
|
||||
Reducer::DiscardTile { tile_id } => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue