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

Implement basic battle arena functionality #32

This commit is contained in:
NG (Graham)
2025-08-30 21:36:01 -04:00
parent 1403a6e3d0
commit 7f9ed8bf35
41 changed files with 1836 additions and 327 deletions

View File

@@ -0,0 +1,44 @@
use polariton::operation::Typed;
use base64::{Engine, engine::general_purpose::STANDARD};
pub struct BattleArenaData {
pub protonium_health: i64,
pub respawn_time_seconds: i64,
pub heal_over_time_per_tower: Vec<u64>,
pub base_machine_map: Vec<u8>, // aka team base model, converted into base64
pub equalizer_model: Vec<u8>, // converted into base64
pub equalizer_health: i64,
pub equalizer_trigger_time_seconds: Vec<u64>,
pub equalizer_warning_seconds: i64,
pub equalizer_duration_seconds: Vec<u64>,
pub capture_time_seconds_per_player: Vec<i64>,
pub num_segments: i32,
pub heal_escalation_time_seconds: i64,
}
fn to_obj_arr_u<C>(slice: &[u64]) -> Typed<C> {
Typed::<C>::ObjArr(slice.iter().map(|x| Typed::<C>::Long(*x as i64)).collect::<Vec<Typed<C>>>().into())
}
fn to_obj_arr_i<C>(slice: &[i64]) -> Typed<C> {
Typed::<C>::ObjArr(slice.iter().map(|x| Typed::<C>::Long(*x)).collect::<Vec<Typed<C>>>().into())
}
impl BattleArenaData {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("protoniumHealth".into()), Typed::Long(self.protonium_health)),
(Typed::Str("respawnTimeSeconds".into()), Typed::Long(self.respawn_time_seconds)),
(Typed::Str("healOverTimePerTower".into()), to_obj_arr_u(&self.heal_over_time_per_tower)),
(Typed::Str("baseMachineMap".into()), Typed::Str(STANDARD.encode(&self.base_machine_map).into())),
(Typed::Str("equalizerModel".into()), Typed::Str(STANDARD.encode(&self.equalizer_model).into())),
(Typed::Str("equalizerHealth".into()), Typed::Long(self.equalizer_health)),
(Typed::Str("equalizerTriggerTimeSeconds".into()), to_obj_arr_u(&self.equalizer_trigger_time_seconds)),
(Typed::Str("equalizerWarningSeconds".into()), Typed::Long(self.equalizer_warning_seconds)),
(Typed::Str("equalizerDurationSeconds".into()), to_obj_arr_u(&self.equalizer_duration_seconds)),
(Typed::Str("captureTimeSecondsPerPlayer".into()), to_obj_arr_i(&self.capture_time_seconds_per_player)),
(Typed::Str("numSegments".into()), Typed::Int(self.num_segments)),
(Typed::Str("healEscalationTimeSeconds".into()), Typed::Long(self.heal_escalation_time_seconds)),
].into())
}
}

View File

@@ -15,6 +15,7 @@ pub mod channel;
pub mod sanction;
pub mod robot_data;
pub mod lobby;
pub mod battle_arena_config;
pub mod error_codes;