aboutsummaryrefslogtreecommitdiff
path: root/server/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands.rs')
-rw-r--r--server/src/commands.rs61
1 files changed, 38 insertions, 23 deletions
diff --git a/server/src/commands.rs b/server/src/commands.rs
index 4ba9fb60..1d260631 100644
--- a/server/src/commands.rs
+++ b/server/src/commands.rs
@@ -16,7 +16,7 @@
*/
use crate::{
- entity::{bot::BotDriver, tutorial::Tutorial},
+ entity::tutorial::Tutorial,
server::{AnnounceState, Server},
};
use anyhow::Result;
@@ -24,8 +24,7 @@ use clap::{Parser, ValueEnum};
use hurrycurry_bot::algos::ALGO_CONSTRUCTORS;
use hurrycurry_locale::{TrError, tre, trm};
use hurrycurry_protocol::{
- Character, GameConfig, Hand, ItemLocation, Menu, Message, PacketC, PacketS, PlayerClass,
- PlayerID, VoteSubject,
+ GameConfig, Hand, ItemLocation, Menu, Message, PacketC, PacketS, PlayerID, VoteSubject,
};
use std::{fmt::Write, str::FromStr};
@@ -35,7 +34,7 @@ enum Command {
/// Start a new game
#[clap(alias = "s")]
Start {
- /// Gamedata specification
+ /// Map name
#[arg(default_value = "junior")]
map: String,
@@ -44,8 +43,12 @@ enum Command {
hand_count: Option<usize>,
/// Duration in seconds
- #[arg(short = 't', long)]
+ #[arg(short, long)]
timer: Option<f32>,
+
+ /// Add bot by name
+ #[arg(short, long)]
+ bot: Vec<String>,
},
/// Shows the best entries of the scoreboard for this map.
#[clap(alias = "top", alias = "top5")]
@@ -80,8 +83,6 @@ enum Command {
#[arg(short, long)]
unready: bool,
},
- #[clap(alias = "summon", alias = "bot")]
- CreateBot { algo: String, name: Option<String> },
/// Reload the current map
#[clap(alias = "r")]
Reload,
@@ -98,6 +99,10 @@ enum Command {
message_id: String,
arguments: Vec<String>,
},
+ /// Add bots to the current game (CHEAT)
+ #[cfg(feature = "cheats")]
+ #[clap(alias = "summon", alias = "bot")]
+ CreateBot { algo: String, name: Option<String> },
/// Set your players hand item (CHEAT)
#[cfg(feature = "cheats")]
#[clap(alias = "give")]
@@ -146,7 +151,14 @@ impl Server {
map,
hand_count,
timer,
+ bot,
} => {
+ for b in &bot {
+ ALGO_CONSTRUCTORS
+ .iter()
+ .find(|(name, _)| *name == b)
+ .ok_or(tre!("s.error.algo_not_found", s = b.to_string()))?;
+ }
self.packet_in(
replies,
PacketS::InitiateVote {
@@ -156,6 +168,7 @@ impl Server {
hand_count,
map,
timer,
+ bots: bot,
},
},
},
@@ -243,22 +256,6 @@ impl Server {
},
)?;
}
- Command::CreateBot { algo, name } => {
- let (aname, cons) = ALGO_CONSTRUCTORS
- .iter()
- .find(|(name, _)| *name == algo.as_str())
- .ok_or(tre!("s.error.algo_not_found", s = algo))?;
- self.entities.push(Box::new(BotDriver::new(
- format!("{}-bot", name.unwrap_or((*aname).to_owned())),
- Character {
- color: 0,
- hairstyle: 0,
- headwear: 0,
- },
- PlayerClass::Bot,
- cons,
- )));
- }
Command::Scoreboard { map, text } => {
let mapname = map.as_ref().unwrap_or(&self.game.data.current_map);
let mapname_pretty = &self
@@ -380,6 +377,24 @@ impl Server {
});
}
#[cfg(feature = "cheats")]
+ Command::CreateBot { algo, name } => {
+ let (aname, cons) = ALGO_CONSTRUCTORS
+ .iter()
+ .find(|(name, _)| *name == algo.as_str())
+ .ok_or(tre!("s.error.algo_not_found", s = algo))?;
+ self.entities
+ .push(Box::new(crate::entity::bot::BotDriver::new(
+ format!("{}-bot", name.unwrap_or((*aname).to_owned())),
+ hurrycurry_protocol::Character {
+ color: 0,
+ hairstyle: 0,
+ headwear: 0,
+ },
+ hurrycurry_protocol::PlayerClass::Bot,
+ cons,
+ )));
+ }
+ #[cfg(feature = "cheats")]
Command::SetItem { name } => {
use hurrycurry_game_core::Item;
use hurrycurry_protocol::{Hand, ItemLocation};