This commit is contained in:
Tao Tien 2026-02-14 20:05:04 -08:00
parent 042975e561
commit 3143e5964b
3 changed files with 13 additions and 12 deletions

8
Cargo.lock generated
View file

@ -1229,7 +1229,6 @@ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"color-eyre", "color-eyre",
"ratatui", "ratatui",
"smol_str",
"tracing", "tracing",
] ]
@ -3338,6 +3337,12 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "hashbag"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7040a10f52cba493ddb09926e15d10a9d8a28043708a405931fe4c6f19fac064"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.12.3"
@ -3715,6 +3720,7 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
name = "jiang" name = "jiang"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"hashbag",
"jong-types", "jong-types",
] ]

View file

@ -4,4 +4,5 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
hashbag = "0.1.13"
jong-types.workspace = true jong-types.workspace = true

View file

@ -1,11 +1,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use hashbag::HashBag;
use jong_types::*; use jong_types::*;
// pub fn check_valid() {} // pub fn check_valid() {}
pub enum Meldable { pub enum Meldable {
Ron,
Chii(Tile, Tile), Chii(Tile, Tile),
Pon, Pon,
Kan, Kan,
@ -52,17 +52,11 @@ pub fn find_meldables(hand: &[Tile], dealt: Tile) -> Vec<Meldable> {
calls.push(Meldable::Chii(prev_outer, prev_inner)); calls.push(Meldable::Chii(prev_outer, prev_inner));
} }
// find ron
calls calls
} }
fn count_shapes(hand: &[Tile]) { pub fn check_ron(hand: &[Tile], melds: &[&[Tile]]) {
let hand = if !hand.is_sorted() { let bag: HashBag<Tile> = HashBag::from_iter(hand.iter().cloned());
let mut hand = hand.to_vec();
hand.sort();
&hand
} else {
hand
};
} }