-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d3f02bf
commit 5893427
Showing
5 changed files
with
376 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[workspace] | ||
|
||
members = ["core", "pylatro"] | ||
members = ["core", "pylatro", "cli"] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "balatro-cli" | ||
version = "0.0.1" | ||
edition = "2021" | ||
description = "Balatro on the command line (basic)" | ||
license = "MIT" | ||
repository ="https://github.com/evanofslack/balatro-rs" | ||
|
||
[dependencies] | ||
text_io = "0.1.9" | ||
balatro-rs = {path = "../core/", version = "0.0.1"} |
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,43 @@ | ||
use balatro_rs::action::Action; | ||
use balatro_rs::game::Game; | ||
use text_io::read; | ||
|
||
fn input_loop(max: usize) -> usize { | ||
loop { | ||
let i: usize = read!(); | ||
if i <= max { | ||
return i; | ||
} else { | ||
println!("Input must be between 0 and {}", max) | ||
} | ||
} | ||
} | ||
|
||
fn game_loop(game: &mut Game) { | ||
loop { | ||
if game.is_over() { | ||
return; | ||
} | ||
let actions: Vec<Action> = game.gen_actions().collect(); | ||
println!("Select action:"); | ||
println!("[0] Show game state"); | ||
for (i, action) in actions.clone().iter().enumerate() { | ||
println!("[{}] {:}", i + 1, action); | ||
} | ||
let index = input_loop(actions.len()); | ||
if index == 0 { | ||
println!("\n{}", game); | ||
continue; | ||
} | ||
let action = actions[index - 1].clone(); | ||
game.handle_action(action).expect("handle action"); | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut game = Game::default(); | ||
game.start(); | ||
println!("Starting game..."); | ||
game_loop(&mut game); | ||
println!("Game over!"); | ||
} |