more refactor, start using stdb for everything???

4.5th rewrite for tui
This commit is contained in:
Tao Tien 2026-02-16 00:05:57 -08:00
parent 034e543d40
commit c3686221aa
29 changed files with 478 additions and 744 deletions

View file

@ -1,54 +1,56 @@
pub mod db;
pub use db::*;
impl From<GameState> for jong_types::GameState {
fn from(value: GameState) -> Self {
Self::from_repr(value as usize).unwrap()
mod conversions {
impl From<crate::db::GameState> for jong_types::states::GameState {
fn from(value: crate::db::GameState) -> Self {
Self::from_repr(value as usize).unwrap()
}
}
}
impl From<TurnState> for jong_types::TurnState {
fn from(value: TurnState) -> Self {
Self::from_repr(value as usize).unwrap()
impl From<crate::db::TurnState> for jong_types::states::TurnState {
fn from(value: crate::db::TurnState) -> Self {
Self::from_repr(value as usize).unwrap()
}
}
}
impl From<&Tile> for jong_types::Tile {
fn from(value: &tile_type::Tile) -> Self {
Self {
suit: value.suit.clone().into(),
impl From<&crate::db::Tile> for jong_types::tiles::Tile {
fn from(value: &crate::db::Tile) -> Self {
Self {
suit: value.suit.clone().into(),
}
}
}
impl From<crate::db::Suit> for jong_types::tiles::Suit {
fn from(value: crate::db::Suit) -> Self {
match value {
crate::db::Suit::Man(rank) => Self::Man(rank.into()),
crate::db::Suit::Pin(rank) => Self::Pin(rank.into()),
crate::db::Suit::Sou(rank) => Self::Sou(rank.into()),
crate::db::Suit::Wind(wind) => Self::Wind(wind.into()),
crate::db::Suit::Dragon(dragon) => Self::Dragon(dragon.into()),
}
}
}
impl From<crate::db::Rank> for jong_types::tiles::Rank {
fn from(value: crate::db::Rank) -> Self {
Self {
number: value.number,
}
}
}
impl From<crate::db::Wind> for jong_types::tiles::Wind {
fn from(value: crate::db::Wind) -> Self {
Self::from_repr(value as usize).unwrap()
}
}
impl From<crate::db::Dragon> for jong_types::tiles::Dragon {
fn from(value: crate::db::Dragon) -> Self {
Self::from_repr(value as usize).unwrap()
}
}
}
impl From<Suit> for jong_types::Suit {
fn from(value: Suit) -> Self {
match value {
Suit::Man(rank) => Self::Man(rank.into()),
Suit::Pin(rank) => Self::Pin(rank.into()),
Suit::Sou(rank) => Self::Sou(rank.into()),
Suit::Wind(wind) => Self::Wind(wind.into()),
Suit::Dragon(dragon) => Self::Dragon(dragon.into()),
}
}
}
impl From<Rank> for jong_types::Rank {
fn from(value: Rank) -> Self {
Self {
number: value.number,
}
}
}
impl From<Wind> for jong_types::Wind {
fn from(value: Wind) -> Self {
Self::from_repr(value as usize).unwrap()
}
}
impl From<Dragon> for jong_types::Dragon {
fn from(value: Dragon) -> Self {
Self::from_repr(value as usize).unwrap()
}
}