more refactor, start using stdb for everything???
4.5th rewrite for tui
This commit is contained in:
parent
034e543d40
commit
c3686221aa
29 changed files with 478 additions and 744 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue