Skip to content

Commit

Permalink
rename game to board
Browse files Browse the repository at this point in the history
  • Loading branch information
med1844 committed May 17, 2024
1 parent 2059a4a commit c80681c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/game/game.rs → src/game/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::screen::screen::ScreenTransition;
use crate::utils::print_by_queue::PrintFullByQueue;

#[derive(Clone, Hash, PartialEq, Eq)]
pub struct Game {
pub struct Board {
pub cells: Vec<Vec<Cell>>,
pub n: usize,
pub m: usize,
Expand All @@ -27,7 +27,7 @@ pub struct Game {

pub type Solution = Vec<GameCommand>;

impl Game {
impl Board {
pub fn new(cells: Vec<Vec<Cell>>) -> Self {
let n = cells.len();
let m = cells.first().unwrap_or(&vec![]).len();
Expand Down Expand Up @@ -180,7 +180,7 @@ impl Game {
}
}

impl From<&str> for Game {
impl From<&str> for Board {
fn from(value: &str) -> Self {
let rows = value.split('\n');
Self::new(
Expand All @@ -204,7 +204,7 @@ impl From<&str> for Game {
}
}

impl PrintFullByQueue for Game {
impl PrintFullByQueue for Board {
fn print_full(&self) -> Result<(), std::io::Error> {
queue!(
stdout(),
Expand Down
2 changes: 1 addition & 1 deletion src/game/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod board;
pub mod cell;
pub mod entity;
pub mod game;
pub mod game_command;
pub mod game_event;
pub mod grid;
4 changes: 2 additions & 2 deletions src/screen/computing_solution_screen.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::screen::{Screen, ScreenTransition};
use super::solver_screen::SolverScreen;
use crate::game::game::Game;

use crate::utils::print_by_queue::PrintFullByQueue;
use crossterm::cursor::{MoveTo, MoveToNextLine};
use crossterm::cursor::{MoveTo};
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::queue;
use crossterm::style::{PrintStyledContent, Stylize};
Expand Down
10 changes: 5 additions & 5 deletions src/screen/game_screen.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::computing_solution_screen::ComputingSolutionScreen;
use super::screen::{Screen, ScreenTransition};
use super::solver_screen::SolverScreen;
use crate::game::game::Game;
use crate::game::board::Board;
use crate::game::game_event::GameEvent;
use crate::utils::print_by_queue::PrintFullByQueue;
use crossterm::cursor::{MoveTo, MoveToNextLine};
use crossterm::cursor::MoveTo;
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::queue;
use crossterm::style::{Print, PrintStyledContent, Stylize};
use crossterm::style::Print;
use std::cell::RefCell;
use std::io::stdout;
use std::rc::Rc;
Expand All @@ -16,11 +16,11 @@ use std::thread;

#[derive(Clone)]
pub struct GameScreen {
pub g: Game,
pub g: Board,
}

impl GameScreen {
pub fn new(g: Game) -> Self {
pub fn new(g: Board) -> Self {
Self { g }
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/screen/solver_screen.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::game_screen::{self, GameScreen};
use super::game_screen::GameScreen;
use super::screen::{Screen, ScreenTransition};
use crate::{
game::{
game::{Game, Solution},
board::{Board, Solution},
game_command::GameCommand,
},
utils::print_by_queue::PrintFullByQueue,
Expand All @@ -16,7 +16,7 @@ use std::io::stdout;

#[derive(Clone)]
pub struct SolverScreen {
pub origin_game: Game,
pub origin_game: Board,
pub game_screen: GameScreen,
pub sol: Vec<GameCommand>,
pub cur: usize,
Expand All @@ -26,7 +26,7 @@ pub struct SolverScreen {
}

impl SolverScreen {
pub fn new(game: Game, sol: Solution) -> Self {
pub fn new(game: Board, sol: Solution) -> Self {
Self {
origin_game: game.clone(),
game_screen: GameScreen::new(game),
Expand Down

0 comments on commit c80681c

Please sign in to comment.