Skip to content

Commit

Permalink
Разбиение проекта на подпроекты
Browse files Browse the repository at this point in the history
  • Loading branch information
syrtcevvi committed Jan 4, 2024
1 parent 4c288f8 commit 08e5911
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 176 deletions.
245 changes: 117 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 10 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
[package]
name = "checkers"
[workspace]
members = [
# Исполняемая программа
"crates/checkers-app",
# Библиотека логики поведения шашек
"crates/checkers-lib"
]
resolver = "2"

[workspace.package]
authors = ["Сырцев Вадим Игоревич <syrtcevvi@gmail.com>"]
description = "Игра Шашки"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bincode = "1.3.3"
derive_more = "0.99.17"
iced = { version = "0.10.0", features = ["canvas"] }
itertools = "0.12.0"
once_cell = "1.18.0"
serde = { version = "1.0.193", features = ["derive"] }

[profile.release]
panic = "abort"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ cargo run --release
## Дальнейшие планы?
На момент написания этого файла, планируется сделать следующие улучшения:
- Покрыть игровую логику автотестами
- Мигрировать к использованию библиотеки [tauri](https://github.com/tauri-apps/tauri) для создания интерфейса
- Оптимизировать использование программой оперативной памяти
- Расширить доступный инструментарий программы
- Внедрить возможность добавления переводов текстовых сообщений
- Добавить возможность собственной стилизации элементов интерфейса

### Маловероятно, но вдруг?)
- Добавить возможность игры по сети?
20 changes: 20 additions & 0 deletions crates/checkers-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "checkers-app"
authors.workspace = true
description.workspace = true
version = "0.1.0"
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
checkers-lib = { path = "../checkers-lib" }

serde = { version = "1.0.193", features = ["derive"] }
bincode = "1.3.3"
once_cell = "1.18.0"
itertools = "0.12.0"
iced = { version = "0.10.0", features = ["canvas"] }

[profile.release]
panic = "abort"
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions crates/checkers-app/src/application/enums/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod message;

pub use message::Message;
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ use iced::{
};
use once_cell::sync::Lazy;

use crate::application::{
use checkers_lib::{
enums::{Piece, Route, Side},
structs::{GameData, Position},
structs::Position,
};

use super::{Message, State};
use crate::application::structs::{
board::{Message, State},
GameData,
};

// Преднастроенная конфигурация текстового элемента, отображаемого в overlay
static OVERLAY_TEXT_PRESET: Lazy<Text> = Lazy::new(|| Text {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use crate::application::{enums::Side, structs::Position};
use checkers_lib::{enums::Side, structs::Position};

#[derive(Debug, Clone)]
pub enum Message {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

use crate::application::{enums::Piece, structs::Position};
use checkers_lib::{enums::Piece, structs::Position};

#[derive(Default)]
pub enum State {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use serde::{Deserialize, Serialize};
use std::{collections::HashMap, ops::RangeInclusive};

use crate::application::{
use serde::{Deserialize, Serialize};

use checkers_lib::{
enums::{Direction, Piece, Route, Side},
structs::Position,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub mod board;
mod game_data;
mod position;

pub use self::{
board::{Board, Message as BoardMessage},
game_data::GameData,
position::Position,
};
2 changes: 1 addition & 1 deletion src/main.rs → crates/checkers-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#![windows_subsystem = "windows"]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod application;
use iced::{window, Application, Result, Settings};

Expand Down
12 changes: 12 additions & 0 deletions crates/checkers-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "checkers-lib"
authors.workspace = true
description.workspace = true
version = "0.1.0"
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.193", features = ["derive"] }
derive_more = "0.99.17"
File renamed without changes.
6 changes: 6 additions & 0 deletions crates/checkers-lib/src/enums/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod direction;
mod piece;
mod route;
mod side;

pub use self::{direction::Direction, piece::Piece, route::Route, side::Side};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum Piece {
King,
}

// TODO заменить на enum-as-inner?
impl Piece {
pub fn is_man(&self) -> bool {
matches!(self, Piece::Man)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use crate::application::structs::Position;
use crate::structs::Position;

/// Маршрут перемещения фигуры
#[derive(Debug, Clone)]
Expand All @@ -23,7 +23,7 @@ pub enum Route {
Movement(Position),
/// Взятие фигур противника
///
/// Конечная позиция и позиция вражеских фигур, которые были "съедены" во время взятия
/// Конечная позиция и позиции вражеских фигур, которые были "съедены" во время взятия
Taking(Position, Vec<Position>),
}

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions crates/checkers-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod enums;
pub mod structs;
3 changes: 3 additions & 0 deletions crates/checkers-lib/src/structs/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod position;

pub use self::position::Position;
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use derive_more::Display;
use derive_more::{Display, From};
use serde::{Deserialize, Serialize};

use crate::application::enums::Direction;
use crate::enums::Direction;

/// Положение фигуры на игральной доске
#[derive(Debug, Display, Hash, PartialEq, Eq, Clone, Copy, Deserialize, Serialize)]
#[derive(Debug, Display, From, Hash, PartialEq, Eq, Clone, Copy, Deserialize, Serialize)]
#[display(fmt = "({}, {})", row, column)]
pub struct Position {
pub row: i8,
Expand Down Expand Up @@ -84,11 +84,11 @@ impl Position {
}
}

impl From<(i8, i8)> for Position {
fn from(value: (i8, i8)) -> Self {
Self {
row: value.0,
column: value.1,
}
}
}
// impl From<(i8, i8)> for Position {
// fn from(value: (i8, i8)) -> Self {
// Self {
// row: value.0,
// column: value.1,
// }
// }
// }
7 changes: 0 additions & 7 deletions src/application/enums/mod.rs

This file was deleted.

0 comments on commit 08e5911

Please sign in to comment.