mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Make minimum multiplayer level configurable, (default 0); close #141
This commit is contained in:
@@ -637,6 +637,8 @@ fn default_multiplayer() -> super::MultiplayerConfig {
|
||||
pit_config: super::multiplayer::default_pit_conf(),
|
||||
team_death_match: super::multiplayer::default_tdm_conf(),
|
||||
vehicle_validator: super::multiplayer::default_validator(),
|
||||
minimum_level: 0,
|
||||
minimum_cpu: super::multiplayer::default_minimum_cpu(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -453,6 +453,8 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
is_enabled: self.battle.multiplayer.enabled,
|
||||
lobby_autostart_after: self.battle.multiplayer.autostart_after_s.map(std::time::Duration::from_secs),
|
||||
loading_autostart_after: self.battle.multiplayer.continue_loading_after_s.map(std::time::Duration::from_secs),
|
||||
min_level: self.battle.multiplayer.minimum_level as i32,
|
||||
min_cpu: self.battle.multiplayer.minimum_cpu as i32,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -553,6 +553,8 @@ pub struct MultiplayerSettings {
|
||||
pub is_enabled: bool,
|
||||
pub lobby_autostart_after: Option<std::time::Duration>,
|
||||
pub loading_autostart_after: Option<std::time::Duration>,
|
||||
pub min_level: i32,
|
||||
pub min_cpu: i32,
|
||||
}
|
||||
|
||||
pub struct VehicleValidators {
|
||||
|
||||
@@ -22,6 +22,10 @@ pub struct MultiplayerConfig {
|
||||
pub team_death_match: TeamDeathMatchConfig,
|
||||
#[serde(default = "default_validator")]
|
||||
pub vehicle_validator: super::VehicleValidator,
|
||||
#[serde(default)]
|
||||
pub minimum_level: u16,
|
||||
#[serde(default = "default_minimum_cpu")]
|
||||
pub minimum_cpu: u16,
|
||||
}
|
||||
|
||||
impl super::config::SelfValidator for MultiplayerConfig {
|
||||
@@ -130,6 +134,10 @@ pub(super) fn default_continue_loading_after_s() -> Option<u64> {
|
||||
Some(30)
|
||||
}
|
||||
|
||||
pub(super) fn default_minimum_cpu() -> u16 {
|
||||
100
|
||||
}
|
||||
|
||||
pub(super) fn default_net_conf() -> NetworkConf {
|
||||
NetworkConf {
|
||||
network_channel_ty: "3113".to_owned(),
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton_server::operations::Immediate;
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
pub(super) fn league_battle_parameters_provider() -> SimpleFunc<57, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
pub(super) fn league_battle_parameters_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<57, crate::UserTy> {
|
||||
let multiplayer_conf = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::multiplayer_settings(conf);
|
||||
let player_level = multiplayer_conf.min_level;
|
||||
let cpu = multiplayer_conf.min_cpu;
|
||||
Immediate::new(move || {
|
||||
let mut params = ParameterTable::with_capacity(3);
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: TypePrefix::Str, //str
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("playerLevelRequired".into()), Typed::Int(10)),
|
||||
(Typed::Str("minCpu".into()), Typed::Int(100)),
|
||||
(Typed::Str("playerLevelRequired".into()), Typed::Int(player_level)),
|
||||
(Typed::Str("minCpu".into()), Typed::Int(cpu)),
|
||||
],
|
||||
}));
|
||||
Ok(params.into())
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
|
||||
.add(player_rank::rank_provider())
|
||||
.add(player_rank::rank_static_provider())
|
||||
.add(ab_test_group::test_group_provider())
|
||||
.add(league_limits::league_battle_parameters_provider())
|
||||
.add(league_limits::league_battle_parameters_provider(&init_ctx.cubes))
|
||||
.add(crf_limits::robot_shop_submission_infos_provider(&init_ctx.cubes))
|
||||
.add(robot_mastery_settings::robot_mastery_settings_provider())
|
||||
.add(player_started_purchase::started_purchase_provider())
|
||||
|
||||
Reference in New Issue
Block a user