mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement most of clans functionality; close #89
This commit is contained in:
1 parent
e120b945c8
commit
f0cca11d3c
43 files changed
+2605
-26
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#[derive(Clone)]
|
||||
pub struct ClanDataUpdated {
|
||||
pub description: Option<String>,
|
||||
pub ty: Option<crate::data::clan::ClanType>,
|
||||
}
|
||||
|
||||
impl ClanDataUpdated {
|
||||
pub const CODE: u8 = 27;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
if let Some(description) = &self.description {
|
||||
params.insert(32, polariton::operation::Typed::Str(description.into()));
|
||||
}
|
||||
if let Some(ty) = self.ty {
|
||||
params.insert(34, polariton::operation::Typed::Int(ty.to_u8() as _));
|
||||
}
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanDataUpdated {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
pub struct ClanInviteCancelled {
|
||||
pub clan_name: String,
|
||||
}
|
||||
|
||||
impl ClanInviteCancelled {
|
||||
pub const CODE: u8 = 25;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
params.insert(31, polariton::operation::Typed::Str(self.clan_name.clone().into()));
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanInviteCancelled {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
pub struct ClanInviteReceived {
|
||||
pub inviter_public_id: String,
|
||||
pub inviter_display_name: String,
|
||||
pub clan_size: i32,
|
||||
pub clan_name: String,
|
||||
pub avatar_id: Option<i32>,
|
||||
}
|
||||
|
||||
impl ClanInviteReceived {
|
||||
pub const CODE: u8 = 21;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(5);
|
||||
params.insert(1, polariton::operation::Typed::Str(self.inviter_public_id.clone().into()));
|
||||
params.insert(75, polariton::operation::Typed::Str(self.inviter_display_name.clone().into()));
|
||||
params.insert(31, polariton::operation::Typed::Str(self.clan_name.clone().into()));
|
||||
params.insert(35, polariton::operation::Typed::Int(self.clan_size));
|
||||
|
||||
params.insert(13, polariton::operation::Typed::Bool(self.avatar_id.is_none()));
|
||||
params.insert(14, polariton::operation::Typed::Int(self.avatar_id.unwrap_or_default()));
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanInviteReceived {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#[derive(Clone)]
|
||||
pub struct ClanMemberDataUpdated {
|
||||
pub member_public_id: String,
|
||||
pub member_display_name: String,
|
||||
pub avatar_id: Option<i32>,
|
||||
pub state: Option<crate::data::clan::ClanMemberState>,
|
||||
pub rank: Option<crate::data::clan::ClanMemberRank>,
|
||||
pub is_online: Option<bool>,
|
||||
}
|
||||
|
||||
impl ClanMemberDataUpdated {
|
||||
pub const CODE: u8 = 26;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(8);
|
||||
params.insert(1, polariton::operation::Typed::Str(self.member_public_id.clone().into()));
|
||||
params.insert(75, polariton::operation::Typed::Str(self.member_display_name.clone().into()));
|
||||
params.insert(13, polariton::operation::Typed::Bool(self.avatar_id.is_none()));
|
||||
params.insert(14, polariton::operation::Typed::Int(self.avatar_id.unwrap_or_default()));
|
||||
if let Some(state) = self.state {
|
||||
params.insert(37, polariton::operation::Typed::Int(state as _));
|
||||
}
|
||||
if let Some(rank) = self.rank {
|
||||
params.insert(38, polariton::operation::Typed::Int(rank as _));
|
||||
}
|
||||
if let Some(is_online) = self.is_online {
|
||||
params.insert(2, polariton::operation::Typed::Bool(is_online));
|
||||
}
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanMemberDataUpdated {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#[derive(Clone)]
|
||||
pub struct ClanMemberJoined {
|
||||
pub joiner_public_id: String,
|
||||
pub joiner_display_name: String,
|
||||
pub avatar_id: Option<i32>,
|
||||
pub state: crate::data::clan::ClanMemberState,
|
||||
pub season_xp: i32,
|
||||
}
|
||||
|
||||
impl ClanMemberJoined {
|
||||
pub const CODE: u8 = 22;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(6);
|
||||
params.insert(1, polariton::operation::Typed::Str(self.joiner_public_id.clone().into()));
|
||||
params.insert(75, polariton::operation::Typed::Str(self.joiner_display_name.clone().into()));
|
||||
params.insert(13, polariton::operation::Typed::Bool(self.avatar_id.is_none()));
|
||||
params.insert(14, polariton::operation::Typed::Int(self.avatar_id.unwrap_or_default()));
|
||||
params.insert(37, polariton::operation::Typed::Int(self.state as _));
|
||||
params.insert(48, polariton::operation::Typed::Int(self.season_xp));
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanMemberJoined {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#[derive(Clone)]
|
||||
pub struct ClanMemberLeft {
|
||||
pub leaver_public_id: String,
|
||||
pub new_leader_public_id: Option<String>,
|
||||
}
|
||||
|
||||
impl ClanMemberLeft {
|
||||
pub const CODE: u8 = 23;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(1, polariton::operation::Typed::Str(self.leaver_public_id.clone().into()));
|
||||
if let Some(new_leader) = &self.new_leader_public_id {
|
||||
params.insert(45, polariton::operation::Typed::Str(new_leader.into()));
|
||||
}
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanMemberLeft {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
pub struct ClanMemberRemoved;
|
||||
|
||||
impl ClanMemberRemoved {
|
||||
pub const CODE: u8 = 24;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
polariton::operation::ParameterTable::with_capacity(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanMemberRemoved {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
pub struct ClanRenamed {
|
||||
pub old_name: String,
|
||||
pub new_name: String,
|
||||
pub admin_public_id: String,
|
||||
}
|
||||
|
||||
impl ClanRenamed {
|
||||
pub const CODE: u8 = 28;
|
||||
|
||||
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
|
||||
let mut params = std::collections::HashMap::with_capacity(3);
|
||||
params.insert(31, polariton::operation::Typed::Str(self.old_name.clone().into()));
|
||||
params.insert(44, polariton::operation::Typed::Str(self.new_name.clone().into()));
|
||||
params.insert(1, polariton::operation::Typed::Str(self.admin_public_id.clone().into()));
|
||||
params.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for ClanRenamed {
|
||||
const CHANNEL: u8 = 0;
|
||||
const ENCRYPT: bool = true;
|
||||
const RELIABLE: bool = true;
|
||||
|
||||
fn into_event(self) -> polariton::operation::Event<C> {
|
||||
polariton::operation::Event {
|
||||
code: Self::CODE,
|
||||
params: self.as_event_params(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,3 +12,11 @@ pub mod platoon_removed;
|
||||
pub mod platoon_leader_changed;
|
||||
pub mod platoon_member_kick;
|
||||
pub mod platoon_member_avatar_update;
|
||||
pub mod clan_invite_received;
|
||||
pub mod clan_member_joined;
|
||||
pub mod clan_member_left;
|
||||
pub mod clan_member_removed;
|
||||
pub mod clan_invite_cancelled;
|
||||
pub mod clan_member_data_changed;
|
||||
pub mod clan_data_changed;
|
||||
//pub mod clan_renamed;
|
||||
Reference in new issue
Block a user