refactor: split board logic into logic module

This commit is contained in:
2026-08-13 22:44:10 +02:00
parent 3b854b9b2f
commit 11ae3d9760
5 changed files with 10 additions and 11 deletions

42
src/logic/board/pawn.rs Normal file
View File

@@ -0,0 +1,42 @@
use core::fmt;
use uuid::Uuid;
use crate::logic::{math::position::Position, player::Player};
#[derive(PartialEq, Eq, Debug)]
pub enum PawnState {
Man,
Dame,
Captured,
}
/// Basic pawn
#[derive(Debug, PartialEq, Eq)]
pub struct Pawn {
pub state: PawnState,
pub owner: Uuid,
}
impl Pawn {
pub fn new(owner: &Player) -> Self {
Self {
state: PawnState::Man,
owner: owner.id,
}
}
}
pub struct CapturePath {
pub from: Position,
pub steps: Vec<Position>,
pub captured_enemies: Vec<Position>,
}
impl CapturePath {
pub fn iter(
&self,
) -> std::iter::Zip<std::slice::Iter<'_, Position>, std::slice::Iter<'_, Position>> {
self.steps.iter().zip(self.captured_enemies.iter())
}
}