better module structure, and added prelude
This commit is contained in:
parent
0639869590
commit
63d8fe2470
2 changed files with 14 additions and 8 deletions
|
@ -7,3 +7,13 @@ pub mod grid_displayer;
|
||||||
pub fn clear_term() {
|
pub fn clear_term() {
|
||||||
print!("\x1B[2J\x1B[1;1H");
|
print!("\x1B[2J\x1B[1;1H");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use super::controller::{
|
||||||
|
Controller, PlayerController, RandomController, SimulatedController,
|
||||||
|
};
|
||||||
|
pub use super::game::GameError;
|
||||||
|
pub use super::game::Rules as GameRules;
|
||||||
|
pub use super::game_manager::GameManager;
|
||||||
|
pub use super::game_manager::Rules as ManagerRules;
|
||||||
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,14 +1,10 @@
|
||||||
use lib::{
|
|
||||||
controller::{player::PlayerController, random::RandomController, Controller},
|
|
||||||
game::{self, GameError},
|
|
||||||
game_manager::{self, GameManager},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod lib;
|
pub mod lib;
|
||||||
|
|
||||||
|
use lib::prelude::*;
|
||||||
|
|
||||||
fn main() -> Result<(), GameError> {
|
fn main() -> Result<(), GameError> {
|
||||||
let game_rules = game::Rules::default().size(8).spawn_per_turn(1);
|
let game_rules = GameRules::default().size(8).spawn_per_turn(1);
|
||||||
let manager_rules = game_manager::Rules::default();
|
let manager_rules = ManagerRules::default();
|
||||||
let controller = PlayerController::new().into_box();
|
let controller = PlayerController::new().into_box();
|
||||||
let mut managed = GameManager::new(game_rules, manager_rules, controller);
|
let mut managed = GameManager::new(game_rules, manager_rules, controller);
|
||||||
managed.play_all()
|
managed.play_all()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue