Compare commits
5 Commits
cf1d77f445
...
0.1.0
Author | SHA1 | Date | |
---|---|---|---|
be454cce03 | |||
a91a4c5ef6 | |||
02477e6728 | |||
e389b59ab9 | |||
dfaa5ce30b |
14
README.md
14
README.md
@@ -1,5 +1,17 @@
|
|||||||
# SeaBattle
|
# SeaBattle
|
||||||
|
[](https://drone.communiquons.org/pierre/SeaBattle)
|
||||||
|
|
||||||
|
|
||||||
Full stack sea battle game.
|
Full stack sea battle game.
|
||||||
|
|
||||||
Current status: working on backend, and then building web ui...
|
|
||||||
|
## Implementations
|
||||||
|
Current implementations:
|
||||||
|
- [x] Rust shell implementations ([server](rust/sea_battle_backend) and [client](rust/sea_battle_cli_player))
|
||||||
|
- [ ] web implementation
|
||||||
|
- [ ] mobile implementation
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
### Shell implementation
|
||||||
|

|
||||||
|
50
rust/Cargo.lock
generated
50
rust/Cargo.lock
generated
@@ -456,31 +456,6 @@ dependencies = [
|
|||||||
"os_str_bytes",
|
"os_str_bytes",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cli_player"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
"crossterm",
|
|
||||||
"env_logger",
|
|
||||||
"futures",
|
|
||||||
"hostname",
|
|
||||||
"hyper-rustls",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"num",
|
|
||||||
"num-derive",
|
|
||||||
"num-traits",
|
|
||||||
"rustls",
|
|
||||||
"sea_battle_backend",
|
|
||||||
"serde_json",
|
|
||||||
"serde_urlencoded",
|
|
||||||
"textwrap",
|
|
||||||
"tokio",
|
|
||||||
"tokio-tungstenite",
|
|
||||||
"tui",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
@@ -1564,6 +1539,31 @@ dependencies = [
|
|||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sea_battle_cli_player"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"crossterm",
|
||||||
|
"env_logger",
|
||||||
|
"futures",
|
||||||
|
"hostname",
|
||||||
|
"hyper-rustls",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"num",
|
||||||
|
"num-derive",
|
||||||
|
"num-traits",
|
||||||
|
"rustls",
|
||||||
|
"sea_battle_backend",
|
||||||
|
"serde_json",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"textwrap",
|
||||||
|
"tokio",
|
||||||
|
"tokio-tungstenite",
|
||||||
|
"tui",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
|
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
members = [
|
members = [
|
||||||
"sea_battle_backend",
|
"sea_battle_backend",
|
||||||
"cli_player"
|
"sea_battle_cli_player"
|
||||||
]
|
]
|
||||||
|
@@ -2,6 +2,12 @@
|
|||||||
name = "sea_battle_backend"
|
name = "sea_battle_backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
license = "GPL-2.0-or-later"
|
||||||
|
description = "A Sea Battle game backend server"
|
||||||
|
repository = "https://gitea.communiquons.org/pierre/SeaBattle"
|
||||||
|
readme = "README.md"
|
||||||
|
authors = ["Pierre Hubert <pierre.git@communiquons.org>"]
|
||||||
|
categories = [ "games" ]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
30
rust/sea_battle_backend/README.md
Normal file
30
rust/sea_battle_backend/README.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Sea battle backend
|
||||||
|
[](https://drone.communiquons.org/pierre/SeaBattle)
|
||||||
|
[](https://crates.io/crates/sea_battle_backend)
|
||||||
|
[](https://docs.rs/sea_battle_backend/)
|
||||||
|
|
||||||
|
A backend HTTP server for the Sea Battle game. The binary included in
|
||||||
|
this crate can be used to deploy a server that will allow players to
|
||||||
|
connect to play together.
|
||||||
|
|
||||||
|
The `actix-web` library is used to spawn HTTP server. The games are encapsulated
|
||||||
|
inside websockets.
|
||||||
|
|
||||||
|
An official server is running at https://seabattleapi.communiquons.org/
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
You can install the backend using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo install sea_battle_backend
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```bash
|
||||||
|
sea_battle_backend -l 0.0.0.0:7000
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: a reverse-proxy must be used to protect
|
||||||
|
|
||||||
|
## Client
|
||||||
|
A command-line client is available in the [sea_battle_cli_player](https://crates.io/crates/sea_battle_cli_player) crate.
|
@@ -1,12 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cli_player"
|
name = "sea_battle_cli_player"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
license = "GPL-2.0-or-later"
|
||||||
|
description = "A Sea Battle game shell client"
|
||||||
|
repository = "https://gitea.communiquons.org/pierre/SeaBattle"
|
||||||
|
readme = "README.md"
|
||||||
|
authors = ["Pierre Hubert <pierre.git@communiquons.org>"]
|
||||||
|
categories = [ "games" ]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sea_battle_backend = { path = "../sea_battle_backend" }
|
sea_battle_backend = { path = "../sea_battle_backend", version = "0.1.0" }
|
||||||
clap = { version = "4.0.15", features = ["derive"] }
|
clap = { version = "4.0.15", features = ["derive"] }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
@@ -24,4 +30,4 @@ futures = "0.3.23"
|
|||||||
serde_json = "1.0.85"
|
serde_json = "1.0.85"
|
||||||
hostname = "0.3.1"
|
hostname = "0.3.1"
|
||||||
rustls = "0.20.6"
|
rustls = "0.20.6"
|
||||||
hyper-rustls = { version = "0.23.0", features = ["rustls-native-certs"] }
|
hyper-rustls = { version = "0.23.0", features = ["rustls-native-certs"] }
|
41
rust/sea_battle_cli_player/README.md
Normal file
41
rust/sea_battle_cli_player/README.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Sea battle cli player
|
||||||
|
[](https://drone.communiquons.org/pierre/SeaBattle)
|
||||||
|
[](https://crates.io/crates/sea_battle_cli_player)
|
||||||
|
[](https://docs.rs/sea_battle_cli_player/)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
A sea battle shell client player for the [sea_battle_backend](https://crates.io/crates/sea_battle_backend) crate, based on the [tui](https://crates.io/crates/tui) library.
|
||||||
|
|
||||||
|
## Available play modes
|
||||||
|
* 🤖 Play against bot (this mode does not require any Internet connection, a local server is automatically spawn)
|
||||||
|
* 🎲 Play against a random player
|
||||||
|
* ➕ Create play invite (online). In this mode, the server returns an invitation code to give to the opponent
|
||||||
|
* 🎫 Accept play invite (online)
|
||||||
|
|
||||||
|
For the 🤖 bot and ➕ create invite modes, game rules can be customized before starting the game.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
You can install the backend using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo install sea_battle_cli_player
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Simply launch using:
|
||||||
|
```bash
|
||||||
|
sea_battle_cli_player
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Offline LAN
|
||||||
|
If you want to run a local server to play offline LAN games, the cli player can also act as the server:
|
||||||
|
```bash
|
||||||
|
RUST_LOG=info sea_battle_cli_player -s -l 0.0.0.0:7000
|
||||||
|
```
|
||||||
|
|
||||||
|
Then all the players must specify the address of this server to use it instead of the default official one:
|
||||||
|
```bash
|
||||||
|
sea_battle_cli_player -r http://IP_OF_TARGET:7000
|
||||||
|
```
|
BIN
rust/sea_battle_cli_player/img/SeaBattleCli.png
Normal file
BIN
rust/sea_battle_cli_player/img/SeaBattleCli.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
@@ -12,20 +12,22 @@ use env_logger::Env;
|
|||||||
use tui::backend::{Backend, CrosstermBackend};
|
use tui::backend::{Backend, CrosstermBackend};
|
||||||
use tui::Terminal;
|
use tui::Terminal;
|
||||||
|
|
||||||
use cli_player::cli_args::{cli_args, TestDevScreen};
|
|
||||||
use cli_player::client::Client;
|
|
||||||
use cli_player::server::run_server;
|
|
||||||
use cli_player::ui_screens::configure_game_rules::GameRulesConfigurationScreen;
|
|
||||||
use cli_player::ui_screens::game_screen::GameScreen;
|
|
||||||
use cli_player::ui_screens::input_screen::InputScreen;
|
|
||||||
use cli_player::ui_screens::popup_screen::PopupScreen;
|
|
||||||
use cli_player::ui_screens::select_play_mode_screen::{SelectPlayModeResult, SelectPlayModeScreen};
|
|
||||||
use cli_player::ui_screens::*;
|
|
||||||
use sea_battle_backend::consts::{
|
use sea_battle_backend::consts::{
|
||||||
INVITE_CODE_LENGTH, MAX_PLAYER_NAME_LENGTH, MIN_PLAYER_NAME_LENGTH,
|
INVITE_CODE_LENGTH, MAX_PLAYER_NAME_LENGTH, MIN_PLAYER_NAME_LENGTH,
|
||||||
};
|
};
|
||||||
use sea_battle_backend::data::GameRules;
|
use sea_battle_backend::data::GameRules;
|
||||||
use sea_battle_backend::utils::res_utils::Res;
|
use sea_battle_backend::utils::res_utils::Res;
|
||||||
|
use sea_battle_cli_player::cli_args::{cli_args, TestDevScreen};
|
||||||
|
use sea_battle_cli_player::client::Client;
|
||||||
|
use sea_battle_cli_player::server::run_server;
|
||||||
|
use sea_battle_cli_player::ui_screens::configure_game_rules::GameRulesConfigurationScreen;
|
||||||
|
use sea_battle_cli_player::ui_screens::game_screen::GameScreen;
|
||||||
|
use sea_battle_cli_player::ui_screens::input_screen::InputScreen;
|
||||||
|
use sea_battle_cli_player::ui_screens::popup_screen::PopupScreen;
|
||||||
|
use sea_battle_cli_player::ui_screens::select_play_mode_screen::{
|
||||||
|
SelectPlayModeResult, SelectPlayModeScreen,
|
||||||
|
};
|
||||||
|
use sea_battle_cli_player::ui_screens::*;
|
||||||
|
|
||||||
/// Test code screens
|
/// Test code screens
|
||||||
async fn run_dev<B: Backend>(
|
async fn run_dev<B: Backend>(
|
Reference in New Issue
Block a user