mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add self-validation framework for config
This commit is contained in:
1 parent
b3ad2c3758
commit
2cc467726f
11 files changed
+284
No files matched your search
@@ -27,6 +27,28 @@ impl SingleplayerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl super::config::SelfValidator for SingleplayerConfig {
|
||||
type Context = crate::ConfigImpl;
|
||||
fn validate(&self, info: &mut super::config::ValidationInfo, _ctx: &Self::Context) -> bool {
|
||||
//let mut is_ok = true;
|
||||
// TODO campaigns
|
||||
// TODO vehicles
|
||||
if self.max_teammates == 0 {
|
||||
info.warn(super::config::ValidationMessage {
|
||||
path: vec!["max_teammates".to_owned()],
|
||||
message: "Player's team may be lonely with zero teammates".to_owned(),
|
||||
});
|
||||
}
|
||||
if self.max_enemies == 0 {
|
||||
info.warn(super::config::ValidationMessage {
|
||||
path: vec!["max_enemies".to_owned()],
|
||||
message: "Singleplayer game may be boring with zero enemies".to_owned(),
|
||||
});
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Campaign {
|
||||
pub id: String,
|
||||
|
||||
Reference in new issue
Block a user