@pai-forge/riichi-mahjong 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,9 @@
1
+ import { Result } from 'neverthrow';
2
+
1
3
  declare const __tehai13Brand: unique symbol;
2
4
 
3
5
  declare const __tehai14Brand: unique symbol;
4
6
 
5
- /**
6
- * 手牌がTehai13(有効枚数13枚)であることを表明します。
7
- * バリデーション成功後、引数を Tehai13 型にナローイングします。
8
- * @throws {ShoushaiError} 枚数が不足している場合
9
- * @throws {TahaiError} 枚数が超過している場合
10
- */
11
- export declare function assertTehai13<T extends HaiKindId | HaiId>(tehai: Tehai<T>): asserts tehai is Tehai13<T>;
12
-
13
- /**
14
- * 手牌がTehai14(有効枚数14枚)であることを表明します。
15
- * バリデーション成功後、引数を Tehai14 型にナローイングします。
16
- * @throws {ShoushaiError} 枚数が不足している場合
17
- * @throws {TahaiError} 枚数が超過している場合
18
- * @throws {InvalidHaiQuantityError} 同一種の牌が5枚以上ある場合
19
- * @throws {DuplicatedHaiIdError} 物理牌モードでIDが重複している場合
20
- */
21
- export declare function assertTehai14<T extends HaiKindId | HaiId>(tehai: Tehai<T>): asserts tehai is Tehai14<T>;
22
-
23
7
  /**
24
8
  * 基本的な面子構造 (ジェネリック)
25
9
  *
@@ -62,7 +46,7 @@ export declare function calculateScoreForTehai(tehai: Tehai14, config: Readonly<
62
46
  * @param tehai 手牌
63
47
  * @returns シャンテン数
64
48
  */
65
- export declare function calculateShanten(tehai: Tehai13, useChiitoitsu?: boolean, useKokushi?: boolean): number;
49
+ export declare function calculateShanten(tehai: Tehai13, useChiitoitsu?: boolean, useKokushi?: boolean): Result<number, TehaiError>;
66
50
 
67
51
  /**
68
52
  * 七対子の和了構造 (ChiitoitsuHouraStructure)
@@ -664,7 +648,7 @@ export declare interface OyaTsumo {
664
648
  * @param input 拡張MSPZ形式の文字列
665
649
  * @returns 手牌オブジェクト
666
650
  */
667
- export declare function parseExtendedMspz(input: string): Tehai;
651
+ export declare function parseExtendedMspz(input: string): Result<Tehai, MspzParseError>;
668
652
 
669
653
  /**
670
654
  * 標準的なMSPZ文字列(例: "123m456p...")を解析して手牌オブジェクトを生成します。
@@ -673,7 +657,7 @@ export declare function parseExtendedMspz(input: string): Tehai;
673
657
  * @param input MSPZ形式の文字列
674
658
  * @returns 手牌オブジェクト
675
659
  */
676
- export declare function parseMspz(input: string): Tehai;
660
+ export declare function parseMspz(input: string): Result<Tehai, MspzParseError>;
677
661
 
678
662
  /** 支払い情報 */
679
663
  export declare type Payment = Ron | KoTsumo | OyaTsumo;
@@ -868,6 +852,8 @@ export declare interface Tehai14<T extends HaiKindId | HaiId = HaiKindId> extend
868
852
  readonly [__tehai14Brand]: never;
869
853
  }
870
854
 
855
+ declare type TehaiError = ShoushaiError | TahaiError | InvalidHaiQuantityError | DuplicatedHaiIdError;
856
+
871
857
  /**
872
858
  * 手牌役 (TehaiYaku)
873
859
  *
@@ -886,15 +872,21 @@ declare type Toitsu<T extends HaiKindId | HaiId = HaiKindId> = BaseMentsu<T> & {
886
872
  };
887
873
 
888
874
  /**
889
- * 手牌がTehai13またはTehai14(有効枚数が13または14枚)であるか検証します。
890
- * シャンテン計算や待ち判定など、13枚/14枚の区別なく手牌として扱いたい場合に使用します。
891
875
  *
892
- * @throws {ShoushaiError} 枚数が不足している場合 (< 13)
893
- * @throws {TahaiError} 枚数が超過している場合 (> 14)
894
- * @throws {InvalidHaiQuantityError} 同一種の牌が5枚以上ある場合
895
- * @throws {DuplicatedHaiIdError} 物理牌モードでIDが重複している場合
896
876
  */
897
- export declare function validateTehai<T extends HaiKindId | HaiId>(tehai: Tehai<T>): void;
877
+ export declare function validateTehai<T extends HaiKindId | HaiId>(tehai: Tehai<T>): Result<Tehai<T>, TehaiError>;
878
+
879
+ /**
880
+ * 手牌がTehai13(有効枚数13枚)であるか検証し、スマートコンストラクタとして機能します。
881
+ * バリデーション成功後、Tehai13 型にナローイングされたオブジェクトをResultで返します。
882
+ */
883
+ export declare function validateTehai13<T extends HaiKindId | HaiId>(tehai: Tehai<T>): Result<Tehai13<T>, TehaiError>;
884
+
885
+ /**
886
+ * 手牌がTehai14(有効枚数14枚)であるか検証し、スマートコンストラクタとして機能します。
887
+ * バリデーション成功後、Tehai14 型にナローイングされたオブジェクトをResultで返します。
888
+ */
889
+ export declare function validateTehai14<T extends HaiKindId | HaiId>(tehai: Tehai<T>): Result<Tehai14<T>, TehaiError>;
898
890
 
899
891
  /**
900
892
  * 役牌 (Yakuhai)