mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 11:25:56 +00:00
Companions: clear error when no template characters exist; requests made while stopped are created after the next start
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4b1260099
commit
efacd4946e
8 files changed
+56
-6
No files matched your search
@@ -24,6 +24,8 @@ pub enum Error {
|
||||
PackageNotPublished(String),
|
||||
#[error("download server unreachable: {0}")]
|
||||
NetworkUnreachable(String),
|
||||
#[error("the bot module found no level 80 template characters")]
|
||||
CompanionTemplatesMissing,
|
||||
#[error("invalid values: {}", .0.iter().map(|f| format!("{}: {}", f.key, f.message)).collect::<Vec<_>>().join("; "))]
|
||||
Validation(Vec<FieldError>),
|
||||
}
|
||||
@@ -52,6 +54,7 @@ pub enum ErrorCode {
|
||||
PathRejected,
|
||||
PackageNotPublished,
|
||||
NetworkUnreachable,
|
||||
CompanionTemplatesMissing,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
@@ -142,6 +145,11 @@ impl ErrorCode {
|
||||
"Check your internet connection and try again.",
|
||||
&[Retry, ShowDetails],
|
||||
),
|
||||
ErrorCode::CompanionTemplatesMissing => (
|
||||
"Companions have nothing to be copied from yet",
|
||||
"New companions are copied from level 80 characters of each class. Create one level 80 character per class on any account except the console account, then try again.",
|
||||
&[ShowDetails],
|
||||
),
|
||||
ErrorCode::Unknown => ("Something went wrong", "See the technical details.", &[ShowDetails]),
|
||||
};
|
||||
Human { code: self, title, message, actions }
|
||||
@@ -157,6 +165,7 @@ impl Error {
|
||||
Error::Validation(_) => ErrorCode::InvalidConfigValue,
|
||||
Error::PackageNotPublished(_) => ErrorCode::PackageNotPublished,
|
||||
Error::NetworkUnreachable(_) => ErrorCode::NetworkUnreachable,
|
||||
Error::CompanionTemplatesMissing => ErrorCode::CompanionTemplatesMissing,
|
||||
_ => ErrorCode::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,18 +91,21 @@ impl Ra {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ask the bot module to create `count` leveling bots (throttled by the module itself). Only a number is sent.
|
||||
/// World update timing from the server's own `server info` report (mean/median/percentiles of the last 500 updates).
|
||||
pub fn performance(&mut self) -> Result<Option<Performance>> {
|
||||
let out = self.command("server info")?;
|
||||
Ok(parse_server_info(&out))
|
||||
}
|
||||
|
||||
/// Ask the bot module to create `count` leveling bots (throttled by the module itself). Only a number is sent.
|
||||
pub fn spawn_bots(&mut self, count: u32) -> Result<String> {
|
||||
if !(1..=2000).contains(&count) {
|
||||
return Err(Error::Invalid("Choose between 1 and 2000 companions.".into()));
|
||||
}
|
||||
let out = self.command(&format!("botcmd spawnleveled {count}"))?;
|
||||
if out.to_lowercase().contains("no usable template characters") {
|
||||
return Err(Error::CompanionTemplatesMissing);
|
||||
}
|
||||
Ok(out.lines().last().unwrap_or("").to_string())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user