Add support for matchmaker sending clients off to game server

This commit is contained in:
NG (Graham) committed 2025-06-19 22:05:16 -04:00
1 parent 8cd63c3122
commit 9f74a2e76a
24 files changed
+543 -45

No files matched your search

+37
View File
@@ -1,5 +1,6 @@
use polariton::operation::Typed;
#[derive(Clone)]
pub struct PlayerData {
pub name: String,
pub display_name: String,
@@ -12,6 +13,7 @@ pub struct PlayerData {
pub has_premium: bool,
pub robot_uuid: String,
pub cpu: i32,
pub avatar_id: Option<i32>,
pub weapon_order: Vec<i32>,
pub colour_map: Vec<u8>,
pub is_ai: bool,
@@ -52,6 +54,41 @@ impl PlayerData {
}
Ok(42 + self.robot_map.len() + (self.weapon_order.len() * 4) + self.colour_map.len() + (self.weapon_rank.len() * 8) + total_len)
}
pub fn as_transmissible<C>(&self) -> Typed<C> {
let weapon_ranks = Typed::Dict(polariton::operation::Dict {
key_ty: polariton::serdes::TypePrefix::Int,
val_ty: polariton::serdes::TypePrefix::Int,
items: self.weapon_rank.clone().into_iter().map(|(k, v)| (Typed::Int(k), Typed::Int(v))).collect(),
});
Typed::HashMap(vec![
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
(Typed::Str("robotName".into()), Typed::Str(self.robot_name.clone().into())),
(Typed::Str("cubeMap".into()), Typed::Bytes(self.robot_map.clone().into())),
(Typed::Str("colourMap".into()), Typed::Bytes(self.colour_map.clone().into())),
(Typed::Str("spawnEffect".into()), Typed::Str(self.spawn_effect.clone().into())),
(Typed::Str("deathEffect".into()), Typed::Str(self.death_effect.clone().into())),
//(Typed::Str("groupId".into()), Typed::Int(self.group)), // FIXME
(Typed::Str("groupId".into()), Typed::Int(self.team)), // not strongly enforced in EnterBattleEventListener
(Typed::Str("team".into()), Typed::Int(self.team)), // not strongly enforced in EnterBattleEventListener (but has to be parsable into an i32)
(Typed::Str("hasPremium".into()), Typed::Bool(self.has_premium)),
(Typed::Str("weaponOrder".into()), Typed::IntArr(self.weapon_order.clone().into())),
(Typed::Str("robotUniqueID".into()), Typed::Str(self.robot_uuid.clone().into())),
(Typed::Str("cpu".into()), Typed::Int(self.cpu)), // not strongly enforced in EnterBattleEventListener
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.avatar_id.is_none())),
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id.unwrap_or(0))),
(Typed::Str("masteryLevel".into()), Typed::Int(self.mastery)),
(Typed::Str("tier".into()), Typed::Int(self.tier)),
(Typed::Str("playerRank".into()), Typed::Int(self.player_rank)),
(Typed::Str("weaponRanks".into()), weapon_ranks),
(Typed::Str("isAI".into()), Typed::Bool(self.is_ai)),
// only required if clanName exists
/*(Typed::Str("clanName".into()), Typed::Str(todo!())),
(Typed::Str("clanUseCustomAvatar".into()), Typed::Bool(todo!())),
(Typed::Str("clanDefaultAvatarID".into()), Typed::Int(todo!())),*/
].into())
}
}
pub struct PlayerDatas {