Implement non-multiplayer parts of custom games

This commit is contained in:
NG (Graham) committed 2026-03-12 22:44:04 -04:00
1 parent 6ce456a739
commit af04c4093c
34 files changed
+1751 -78

No files matched your search

@@ -0,0 +1,25 @@
use polariton::operation::Typed;
#[derive(Clone)]
pub struct CustomGameConfigRefresh {
pub field: String,
pub value: String,
}
impl <C: Send + Sync + 'static> polariton_server::events::IntoEvent<C> for CustomGameConfigRefresh {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
let mut params = polariton::operation::ParameterTable::with_capacity(1);
params.insert(181, polariton::operation::Typed::HashMap(vec![
(Typed::Str("Field".into()), Typed::Str(self.field.into())),
(Typed::Str("Value".into()), Typed::Str(self.value.into())),
].into()));
polariton::operation::Event {
code: 9,
params,
}
}
}
@@ -0,0 +1,30 @@
//#[derive(Clone)]
pub struct CustomGameInvite {
pub inviter_public_id: String,
pub inviter_display_name: String,
pub session: String,
pub avatar_id: Option<i32>,
pub invited_to_team_a: bool,
}
impl <C: Send + Sync + 'static> polariton_server::events::IntoEvent<C> for CustomGameInvite {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
let mut params = polariton::operation::ParameterTable::with_capacity(1);
params.insert(172, polariton::operation::Typed::HashMap(vec![
(polariton::operation::Typed::Str("Inviter".into()), polariton::operation::Typed::Str(self.inviter_public_id.into())),
(polariton::operation::Typed::Str("DisplayName".into()), polariton::operation::Typed::Str(self.inviter_display_name.into())),
(polariton::operation::Typed::Str("SessionID".into()), polariton::operation::Typed::Str(self.session.into())),
(polariton::operation::Typed::Str("UseCustomAvatar".into()), polariton::operation::Typed::Bool(self.avatar_id.is_none())),
(polariton::operation::Typed::Str("AvatarID".into()), polariton::operation::Typed::Int(self.avatar_id.unwrap_or(0))),
(polariton::operation::Typed::Str("InvitedToTeamA".into()), polariton::operation::Typed::Bool(self.invited_to_team_a)),
].into()));
polariton::operation::Event {
code: 7,
params,
}
}
}
@@ -0,0 +1,23 @@
use polariton::operation::Typed;
#[derive(Clone)]
pub struct CustomGameInviteDecline {
pub public_id: String,
}
impl <C: Send + Sync + 'static> polariton_server::events::IntoEvent<C> for CustomGameInviteDecline {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
let mut params = polariton::operation::ParameterTable::with_capacity(1);
params.insert(190, polariton::operation::Typed::HashMap(vec![
(Typed::Str("UserName".into()), Typed::Str(self.public_id.into()))
].into()));
polariton::operation::Event {
code: 12,
params,
}
}
}
@@ -0,0 +1,25 @@
use polariton::operation::Typed;
//#[derive(Clone)]
pub struct CustomGameKick {
pub session: String,
pub was_invited: bool,
}
impl <C: Send + Sync + 'static> polariton_server::events::IntoEvent<C> for CustomGameKick {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
let mut params = polariton::operation::ParameterTable::with_capacity(2);
params.insert(184, polariton::operation::Typed::HashMap(vec![
(Typed::Str("Session".into()), Typed::Str(self.session.into())),
(Typed::Str("WasInvited".into()), Typed::Bool(self.was_invited)),
].into()));
polariton::operation::Event {
code: 11,
params,
}
}
}
@@ -0,0 +1,19 @@
#[derive(Clone)]
pub struct CustomGameRefresh {
pub session: String,
}
impl <C: Send + Sync + 'static> polariton_server::events::IntoEvent<C> for CustomGameRefresh {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
let mut params = polariton::operation::ParameterTable::with_capacity(1);
params.insert(172, polariton::operation::Typed::Str(self.session.into()));
polariton::operation::Event {
code: 8,
params,
}
}
}
+3 -3
View File
@@ -4,7 +4,7 @@ use oj_rc_core::persist::user::intercom::IntercomWebServiceUserMessage;
pub struct IntercomHandler {
listener: IntercomListener<IntercomWebServiceUserMessage>,
user: std::sync::Weak<Box<dyn oj_rc_core::persist::user::User<()> + Send + Sync>>,
emitter: polariton_server::events::EventEmitter<()>,
emitter: polariton_server::events::WeakEventEmitter<()>,
}
impl IntercomHandler {
@@ -16,14 +16,14 @@ impl IntercomHandler {
Self {
listener,
user: std::sync::Arc::downgrade(user),
emitter: emitter.to_owned(),
emitter: emitter.to_owned().downgrade(),
}
}
async fn run_loop(
listener: IntercomListener<IntercomWebServiceUserMessage>,
user: std::sync::Weak<Box<dyn oj_rc_core::persist::user::User<()> + Send + Sync>>,
emitter: polariton_server::events::EventEmitter<()>
emitter: polariton_server::events::WeakEventEmitter<()>
) {
use futures::StreamExt;
let mut listener = listener.listen().await;
+15
View File
@@ -6,3 +6,18 @@ pub use dev_message::DevMessage;
mod maintenance_mode;
pub use maintenance_mode::MaintenanceMode;
mod custom_game_invite;
pub use custom_game_invite::CustomGameInvite;
mod custom_game_refresh;
pub use custom_game_refresh::CustomGameRefresh;
mod custom_game_config;
pub use custom_game_config::CustomGameConfigRefresh;
mod custom_game_invite_decline;
pub use custom_game_invite_decline::CustomGameInviteDecline;
mod custom_game_kick;
pub use custom_game_kick::CustomGameKick;