mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add pit win conditions #34
This commit is contained in:
@@ -514,6 +514,7 @@ fn default_multiplayer() -> super::MultiplayerConfig {
|
||||
network: super::multiplayer::default_net_conf(),
|
||||
fakes: super::multiplayer::default_fake_users(),
|
||||
battle_arena: super::multiplayer::default_ba_conf(),
|
||||
pit_config: super::multiplayer::default_pit_conf(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -462,4 +462,8 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
data: self.battle.multiplayer.battle_arena.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn pit_settings(&self) -> super::PitSettings {
|
||||
self.battle.multiplayer.pit_config.clone().into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver};
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition};
|
||||
|
||||
pub type ConfigImpl = CubeConfig;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn fake_players(&self) -> Vec<FakePlayer>;
|
||||
fn energy(&self) -> EnergyConfig;
|
||||
fn ba_settings(&self) -> BattleArenaResolver;
|
||||
fn pit_settings(&self) -> PitSettings;
|
||||
}
|
||||
|
||||
pub struct CompleteCampaignProvider {
|
||||
@@ -428,3 +429,18 @@ impl BattleArenaResolver {
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PitSettings {
|
||||
pub wins: Vec<PitWinCondition>,
|
||||
pub respawn_time_seconds: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PitWinCondition {
|
||||
StreakKills(u32),
|
||||
TotalKills(u32),
|
||||
Score(u32),
|
||||
Damage(u32),
|
||||
Time,
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ pub struct MultiplayerConfig {
|
||||
pub fakes: Vec<FakePlayerConf>,
|
||||
#[serde(default = "default_ba_conf")]
|
||||
pub battle_arena: BattleArenaConfig,
|
||||
#[serde(default = "default_pit_conf")]
|
||||
pub pit_config: PitConfig,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
@@ -169,3 +171,67 @@ fn default_equalizer_duration() -> u64 {
|
||||
fn default_segments() -> u16 {
|
||||
3
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum PitWinCondition {
|
||||
StreakKills {
|
||||
streak: u32,
|
||||
},
|
||||
TotalKills {
|
||||
kills: u32,
|
||||
},
|
||||
TotalScore {
|
||||
score: u32,
|
||||
},
|
||||
TotalDamage {
|
||||
damage: u32,
|
||||
},
|
||||
Time,
|
||||
}
|
||||
|
||||
impl std::convert::From<PitWinCondition> for crate::persist::config::PitWinCondition {
|
||||
fn from(value: PitWinCondition) -> Self {
|
||||
match value {
|
||||
PitWinCondition::StreakKills { streak } => crate::persist::config::PitWinCondition::StreakKills(streak),
|
||||
PitWinCondition::TotalKills { kills } => crate::persist::config::PitWinCondition::TotalKills(kills),
|
||||
PitWinCondition::TotalScore { score } => crate::persist::config::PitWinCondition::Score(score),
|
||||
PitWinCondition::TotalDamage { damage } => crate::persist::config::PitWinCondition::Damage(damage),
|
||||
PitWinCondition::Time => crate::persist::config::PitWinCondition::Time,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct PitConfig {
|
||||
pub wins: Vec<PitWinCondition>,
|
||||
pub respawn_time_s: u64,
|
||||
}
|
||||
|
||||
impl std::convert::From<PitConfig> for crate::persist::config::PitSettings {
|
||||
fn from(value: PitConfig) -> Self {
|
||||
Self {
|
||||
wins: value.wins.into_iter().map(|x| x.into()).collect(),
|
||||
respawn_time_seconds: value.respawn_time_s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn default_pit_conf() -> PitConfig {
|
||||
PitConfig {
|
||||
wins: default_pit_win_conditions(),
|
||||
respawn_time_s: default_respawn_time(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_pit_win_conditions() -> Vec<PitWinCondition> {
|
||||
vec![
|
||||
PitWinCondition::StreakKills {
|
||||
streak: 2,
|
||||
},
|
||||
PitWinCondition::TotalKills {
|
||||
kills: 5,
|
||||
},
|
||||
PitWinCondition::Time,
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user