Live location tracking and playback for the game "manhunt"
1use clap::{Parser, Subcommand, ValueEnum};
2use interprocess::local_socket::{tokio::Stream, traits::tokio::Stream as _};
3use manhunt_logic::PowerUpType;
4use manhunt_test_shared::{get_socket_name, prelude::*};
5
6#[derive(Parser)]
7struct Cli {
8 /// Path to the UNIX domain socket the test daemon is listening on
9 socket: String,
10
11 #[command(subcommand)]
12 command: Commands,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
16enum Role {
17 Seeker,
18 Hider,
19}
20
21#[derive(Subcommand)]
22enum LobbyCommand {
23 /// Switch teams between seekers and hiders
24 SwitchTeams {
25 /// The role you want to become
26 #[arg(value_enum)]
27 role: Role,
28 },
29 /// (Host) Sync game settings to players
30 SyncSettings,
31 /// (Host) Start the game for everyone
32 StartGame,
33 /// Quit to the main menu
34 Quit,
35}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
38enum PowerUpTypeValue {
39 PingSeeker,
40 PingAllSeekers,
41 ForcePingOther,
42}
43
44impl From<PowerUpTypeValue> for PowerUpType {
45 fn from(value: PowerUpTypeValue) -> Self {
46 match value {
47 PowerUpTypeValue::PingSeeker => PowerUpType::PingSeeker,
48 PowerUpTypeValue::PingAllSeekers => PowerUpType::PingAllSeekers,
49 PowerUpTypeValue::ForcePingOther => PowerUpType::ForcePingOther,
50 }
51 }
52}
53
54#[derive(Subcommand)]
55enum GameCommand {
56 /// Mark the local player as caught for everyone
57 MarkCaught,
58 /// Get a currently available powerup
59 GetPowerup,
60 /// Use the held powerup of the local player
61 UsePowerup,
62 /// Force set the held powerup to the given type
63 ForcePowerup {
64 #[arg(value_enum)]
65 ptype: PowerUpTypeValue,
66 },
67 /// Quit the game
68 Quit,
69}
70
71#[derive(Subcommand)]
72enum Commands {
73 /// Create a lobby
74 Create,
75 /// Join a lobby
76 Join {
77 /// The join code for the lobby
78 join_code: String,
79 },
80 /// Execute a command in an active lobby
81 #[command(subcommand)]
82 Lobby(LobbyCommand),
83 /// Execute a command in an active game
84 #[command(subcommand)]
85 Game(GameCommand),
86}
87
88#[tokio::main]
89async fn main() -> Result {
90 let cli = Cli::parse();
91
92 let socket_name = get_socket_name(cli.socket.clone()).context("Failed to get socket name")?;
93
94 let _stream = Stream::connect(socket_name)
95 .await
96 .context("Failed to connect to socket")?;
97
98 Ok(())
99}