trucses
This commit is contained in:
parent
1ae2336180
commit
d698793e95
3 changed files with 13 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -292,6 +292,7 @@ dependencies = [
|
||||||
name = "rs48-telnet"
|
name = "rs48-telnet"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"rand",
|
||||||
"rs48_lib",
|
"rs48_lib",
|
||||||
"termion 2.0.1",
|
"termion 2.0.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
||||||
# 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]
|
||||||
|
rand = "0.8.5"
|
||||||
rs48_lib = "1.3.1"
|
rs48_lib = "1.3.1"
|
||||||
termion = "2.0.1"
|
termion = "2.0.1"
|
||||||
tokio = { version = "1.21.2", features = ["full"] }
|
tokio = { version = "1.21.2", features = ["full"] }
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -43,9 +43,17 @@ async fn game(mut write: OwnedWriteHalf, config: Config) {
|
||||||
let rules = GameRules::default();
|
let rules = GameRules::default();
|
||||||
let mut game = Game::new(rules);
|
let mut game = Game::new(rules);
|
||||||
let mut controller = SimulatedController::new(50, 20);
|
let mut controller = SimulatedController::new(50, 20);
|
||||||
|
let color_seed: u16 = rand::random();
|
||||||
|
|
||||||
'_game: loop {
|
'_game: loop {
|
||||||
let result = turn(&mut game, &mut controller, &mut write, config.delay).await;
|
let result = turn(
|
||||||
|
&mut game,
|
||||||
|
&mut controller,
|
||||||
|
&mut write,
|
||||||
|
config.delay,
|
||||||
|
color_seed,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
match result {
|
match result {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(Error::GameEnd) => continue 'session,
|
Err(Error::GameEnd) => continue 'session,
|
||||||
|
@ -60,8 +68,9 @@ async fn turn(
|
||||||
controller: &mut SimulatedController,
|
controller: &mut SimulatedController,
|
||||||
write: &mut OwnedWriteHalf,
|
write: &mut OwnedWriteHalf,
|
||||||
delay: Duration,
|
delay: Duration,
|
||||||
|
color_seed: u16,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let displayer = GridDisplayer::new(1234);
|
let displayer = GridDisplayer::new(color_seed);
|
||||||
let display = displayer.display(game.get_board());
|
let display = displayer.display(game.get_board());
|
||||||
let clear = clear::All;
|
let clear = clear::All;
|
||||||
let goto = cursor::Goto(1, 1);
|
let goto = cursor::Goto(1, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue