-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bytekeeper
committed
Mar 9, 2022
1 parent
7a6dd13
commit 916da74
Showing
5 changed files
with
245 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
bitsadmin.exe /transfer "Nitekat" "https://www.sscaitournament.com/bot_binary.php?bot=NiteKatT" blub.zip | ||
cargo build --release | ||
releng\7za a -pshotgun -- bwaishotgun.7z target/release/bwaishotgun.exe bots SNP_DirectIP.snp bwheadless.exe game.toml shotgun.toml | ||
releng\7za rn -pshotgun -- bwaishotgun.7z target/release/bwaishotgun.exe BWAIShotgun.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use crate::{BotConfig, GameConfig}; | ||
use clap::{ErrorKind, Parser, Subcommand}; | ||
|
||
#[derive(Subcommand, Debug)] | ||
enum GameType { | ||
/// Host a melee game | ||
Melee { | ||
/// Names of bots to play | ||
bots: Vec<String>, | ||
}, | ||
/// You will host a game the bots can join (make sure to select Local PC network) | ||
Human { | ||
/// Names of bots to play | ||
bots: Vec<String>, | ||
}, | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Cli { | ||
/// Absolute path of map to host | ||
#[clap(short, long)] | ||
map: Option<String>, | ||
#[clap(subcommand)] | ||
game_type: Option<GameType>, | ||
} | ||
|
||
pub enum Error { | ||
NoArguments, | ||
ClapError(clap::Error), | ||
} | ||
|
||
impl TryFrom<Cli> for GameConfig { | ||
type Error = Error; | ||
|
||
fn try_from(cli: Cli) -> Result<Self, Self::Error> { | ||
if cli.map.is_none() && cli.game_type.is_none() { | ||
Err(Error::NoArguments) | ||
} else if cli.map.is_some() != cli.game_type.is_some() { | ||
Err(Error::ClapError(clap::Error::raw( | ||
ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand, | ||
"Either no or all arguments are required. Use '-h' to get help.\n", | ||
))) | ||
} else { | ||
let game_type = match cli.game_type.as_ref().expect("Game Type not set") { | ||
GameType::Melee { bots } | GameType::Human { bots } => crate::GameType::Melee( | ||
bots.iter() | ||
.map(|name| BotConfig { | ||
name: name.to_string(), | ||
player_name: None, | ||
race: None, | ||
}) | ||
.collect(), | ||
), | ||
}; | ||
Ok(GameConfig { | ||
map: cli.map.unwrap(), | ||
game_name: None, | ||
game_type, | ||
human_host: matches!(cli.game_type.unwrap(), GameType::Human { .. }), | ||
}) | ||
} | ||
} | ||
} |
Oops, something went wrong.