refactor, add lobby
This commit is contained in:
23
lobby/lobby.rs
Normal file
23
lobby/lobby.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use crate::engine::Engine;
|
||||
use crate::player::PlayerConsole;
|
||||
|
||||
pub struct Lobby {}
|
||||
|
||||
impl Lobby {
|
||||
pub fn new() -> Lobby {
|
||||
Lobby {}
|
||||
}
|
||||
|
||||
pub fn run(self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
loop {
|
||||
let p1 = Box::new(PlayerConsole::new("Gopher"));
|
||||
let p2 = Box::new(PlayerConsole::new("Rustacean"));
|
||||
let mut engine = Engine::new(p1, p2);
|
||||
|
||||
match engine.run() {
|
||||
Ok(_) => continue,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
2
lobby/mod.rs
Normal file
2
lobby/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod lobby;
|
||||
pub use lobby::Lobby;
|
||||
Reference in New Issue
Block a user