mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add minimal robot factory functionality and arc archive support for #6
This commit is contained in:
@@ -5,7 +5,7 @@ use serde::{Serialize, Deserialize};
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::serdes::TypePrefix;
|
||||
|
||||
use super::super::{MovementCategoryData, MovementData, Cube, ItemCategory, ItemTier, BattleConfig, Settings, ChatConfig};
|
||||
use super::super::{MovementCategoryData, MovementData, Cube, ItemCategory, ItemTier, BattleConfig, Settings, ChatConfig, FactoryConfig};
|
||||
|
||||
const CUBE_CONFIG_FILENAME: &str = "config.json";
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct CubeConfig {
|
||||
lerp_value: f32,
|
||||
battle: BattleConfig,
|
||||
chat: ChatConfig,
|
||||
factory: FactoryConfig,
|
||||
settings: Settings,
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@ impl CubeConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl <C: Clone> super::ConfigProvider<C> for CubeConfig {
|
||||
fn cube_list(&self) -> Typed<C> {
|
||||
Typed::Dict(Dict {
|
||||
@@ -271,4 +273,8 @@ impl <C: Clone> super::ConfigProvider<C> for CubeConfig {
|
||||
}).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn factory(&self) -> Result<crate::factory::Factory, Box<dyn std::error::Error + 'static>> {
|
||||
crate::factory::Factory::from_config(&self.factory).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use polariton::operation::Typed;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait ConfigProvider<C: Clone> {
|
||||
fn cube_list(&self) -> Typed<C>;
|
||||
fn movement_list(&self) -> Typed<C>;
|
||||
@@ -20,6 +21,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn public_channels(&self) -> Typed<C>;
|
||||
fn server_config(&self) -> ServerConfig;
|
||||
fn garage_upgrades(&self) -> GarageUpgrades;
|
||||
async fn factory(&self) -> Result<crate::factory::Factory, Box<dyn std::error::Error + 'static>>;
|
||||
}
|
||||
|
||||
pub struct CompleteCampaignProvider {
|
||||
|
||||
@@ -32,6 +32,9 @@ pub use settings::Settings;
|
||||
mod chat;
|
||||
pub use chat::ChatConfig;
|
||||
|
||||
mod vehicle_factory;
|
||||
pub use vehicle_factory::{FactoryConfig, AdapterSettings, ArcFactorySettings};
|
||||
|
||||
pub(self) const VALID_ROBOT: &[u8] = &[64,
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -387,6 +387,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
slot: polariton::operation::Typed::Int(model.slot as _),
|
||||
bay_cpu: polariton::operation::Typed::Int(model.bay_cpu as _),
|
||||
mastery_level: polariton::operation::Typed::Int(model.mastery_level as _),
|
||||
slot_i: model.slot as _,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ pub struct NewSlotData<C> {
|
||||
pub slot: polariton::operation::Typed<C>,
|
||||
pub bay_cpu: polariton::operation::Typed<C>,
|
||||
pub mastery_level: polariton::operation::Typed<C>,
|
||||
pub slot_i: i32,
|
||||
}
|
||||
|
||||
pub struct VehicleData {
|
||||
|
||||
30
rc_core/src/persist/vehicle_factory.rs
Normal file
30
rc_core/src/persist/vehicle_factory.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct FactoryConfig {
|
||||
#[serde(default = "default_variant")]
|
||||
pub adapter: AdapterSettings,
|
||||
}
|
||||
|
||||
fn default_variant() -> AdapterSettings {
|
||||
AdapterSettings::None
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(tag = "variant")]
|
||||
pub enum AdapterSettings {
|
||||
#[serde(alias = "sqlite")]
|
||||
Arc(ArcFactorySettings),
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ArcFactorySettings {
|
||||
pub uri: String,
|
||||
#[serde(default = "default_true")]
|
||||
pub show_expired: bool,
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
Reference in New Issue
Block a user