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

Make power bar configurable

This commit is contained in:
NG (Graham)
2025-08-17 15:03:30 -04:00
parent 2674ab4035
commit 1403a6e3d0
6 changed files with 39 additions and 9 deletions

View File

@@ -123,7 +123,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.add(crf_config::crf_config_provider())
.add(weapon_stats::weapon_config_provider(&init_ctx.cubes))
.add(movement_stats::movement_config_provider(&init_ctx.cubes))
.add(power_bar_stats::power_bar_provider())
.add(power_bar_stats::power_bar_provider(&init_ctx.cubes))
.add(damage_boost_stats::damage_boost_provider())
.add(battle_arena_config::battle_arena_config_provider())
.add(cpu_limits_config::cpu_config_provider())

View File

@@ -1,16 +1,17 @@
use polariton_server::operations::SimpleFunc;
use polariton_server::operations::Immediate;
use polariton::operation::{ParameterTable, Typed};
const PARAM_KEY: u8 = 61;
pub(super) fn power_bar_provider() -> SimpleFunc<51, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
pub(super) fn power_bar_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<51, crate::UserTy> {
let energy_conf = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::energy(conf);
Immediate::new(|| {
let mut params = ParameterTable::with_capacity(2);
params.insert(PARAM_KEY, Typed::HashMap(vec![
(Typed::Str("refillRatePerSecond".into()), Typed::Float(0.10)), // should take 10s to refill
(Typed::Str("powerForAllRobots".into()), Typed::Int(12_550 /* converted to u32 */)),
(Typed::Str("refillRatePerSecond".into()), Typed::Float(energy_conf.refill_rate)),
(Typed::Str("powerForAllRobots".into()), Typed::Int(energy_conf.total as _)),
].into()
));
Ok(params.into())
params
})
}