@pai-forge/riichi-mahjong 0.1.0 → 0.3.0

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.
Files changed (44) hide show
  1. package/README.md +3 -0
  2. package/dist/core/tehai.d.ts +4 -0
  3. package/dist/core/tehai.js +70 -1
  4. package/dist/errors.d.ts +43 -0
  5. package/dist/errors.js +59 -0
  6. package/dist/features/machi/index.js +11 -0
  7. package/dist/features/points/constants.d.ts +5 -5
  8. package/dist/features/points/constants.js +7 -7
  9. package/dist/features/points/index.js +3 -3
  10. package/dist/features/score/constants.d.ts +27 -0
  11. package/dist/features/score/constants.js +30 -0
  12. package/dist/features/score/index.d.ts +45 -0
  13. package/dist/features/score/index.js +207 -0
  14. package/dist/features/score/lib/fu/constants.d.ts +37 -0
  15. package/dist/features/score/lib/fu/constants.js +45 -0
  16. package/dist/features/score/lib/fu/index.d.ts +11 -0
  17. package/dist/features/score/lib/fu/index.js +23 -0
  18. package/dist/features/score/lib/fu/lib/chiitoitsu.d.ts +5 -0
  19. package/dist/features/score/lib/fu/lib/chiitoitsu.js +17 -0
  20. package/dist/features/score/lib/fu/lib/kokushi.d.ts +6 -0
  21. package/dist/features/score/lib/fu/lib/kokushi.js +18 -0
  22. package/dist/features/score/lib/fu/lib/mentsu.d.ts +11 -0
  23. package/dist/features/score/lib/fu/lib/mentsu.js +136 -0
  24. package/dist/features/score/lib/fu/types.d.ts +56 -0
  25. package/dist/features/score/lib/fu/types.js +1 -0
  26. package/dist/features/score/types.d.ts +78 -0
  27. package/dist/features/score/types.js +22 -0
  28. package/dist/features/yaku/factory.d.ts +1 -1
  29. package/dist/features/yaku/factory.js +1 -1
  30. package/dist/features/yaku/index.d.ts +11 -2
  31. package/dist/features/yaku/index.js +30 -33
  32. package/dist/features/yaku/lib/definitions/daisuushii.js +1 -1
  33. package/dist/features/yaku/lib/definitions/iipeikou.d.ts +2 -0
  34. package/dist/features/yaku/lib/definitions/{iipeiko.js → iipeikou.js} +2 -2
  35. package/dist/features/yaku/lib/definitions/index.d.ts +2 -2
  36. package/dist/features/yaku/lib/definitions/index.js +5 -5
  37. package/dist/features/yaku/types.d.ts +6 -6
  38. package/dist/index.d.ts +12 -3
  39. package/dist/index.js +45 -1
  40. package/dist/types.d.ts +10 -0
  41. package/package.json +3 -2
  42. package/dist/features/yaku/lib/definitions/iipeiko.d.ts +0 -2
  43. /package/dist/features/yaku/lib/definitions/{ryanpeiko.d.ts → ryanpeikou.d.ts} +0 -0
  44. /package/dist/features/yaku/lib/definitions/{ryanpeiko.js → ryanpeikou.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { tanyaoDefinition } from "./tanyao";
2
2
  import { pinfuDefinition } from "./pinfu";
3
- import { iipeikoDefinition } from "./iipeiko";
4
- import { ryanpeikouDefinition } from "./ryanpeiko";
3
+ import { iipeikouDefinition } from "./iipeikou";
4
+ import { ryanpeikouDefinition } from "./ryanpeikou";
5
5
  import { sanankouDefinition } from "./sanankou";
6
6
  import { suuankouDefinition } from "./suuankou";
7
7
  import { sankantsuDefinition } from "./sankantsu";
@@ -29,8 +29,8 @@ import { hakuDefinition, hatsuDefinition, chunDefinition } from "./yakuhai";
29
29
  import { menzenTsumoDefinition } from "./menzen-tsumo";
30
30
  export * from "./tanyao";
31
31
  export * from "./pinfu";
32
- export * from "./iipeiko";
33
- export * from "./ryanpeiko";
32
+ export * from "./iipeikou";
33
+ export * from "./ryanpeikou";
34
34
  export * from "./sanankou";
35
35
  export * from "./suuankou";
36
36
  export * from "./sankantsu";
@@ -58,7 +58,7 @@ export * from "./yakuhai";
58
58
  export const ALL_YAKU_DEFINITIONS = [
59
59
  tanyaoDefinition,
60
60
  pinfuDefinition,
61
- iipeikoDefinition,
61
+ iipeikouDefinition,
62
62
  ryanpeikouDefinition,
63
63
  sanankouDefinition,
64
64
  suuankouDefinition,
@@ -15,7 +15,7 @@ export type Yakuhai = "Haku" | "Hatsu" | "Chun";
15
15
  */
16
16
  export type TehaiYaku = "Tanyao" | "Pinfu" | "Iipeikou" | Yakuhai | "SanshokuDoujun" | "Ikkitsuukan" | "Honchan" | "Chiitoitsu" | "Toitoi" | "Sanankou" | "Sankantsu" | "SanshokuDoukou" | "Honroutou" | "Shousangen" | "Honitsu" | "Junchan" | "Ryanpeikou" | "Chinitsu" | "KokushiMusou" | "Suuankou" | "Daisangen" | "Shousuushii" | "Daisuushii" | "Tsuuiisou" | "Chinroutou" | "Ryuuiisou" | "ChuurenPoutou" | "Suukantsu" | "MenzenTsumo";
17
17
  /**
18
- * 役の飜数 (Hansu)
18
+ * 役の翻数 (Hansu)
19
19
  *
20
20
  * 1, 2, 3, 5(流し満貫/清一色喰い下がり), 6(清一色), 13(役満), 26(ダブル役満)
21
21
  */
@@ -51,13 +51,13 @@ export interface KokushiHouraStructure {
51
51
  }
52
52
  export type HouraStructure = MentsuHouraStructure | ChiitoitsuHouraStructure | KokushiHouraStructure;
53
53
  /**
54
- * 役の飜数定義
54
+ * 役の翻数定義
55
55
  */
56
56
  export interface YakuHanConfig {
57
- /** 門前時の飜数 */
57
+ /** 門前時の翻数 */
58
58
  readonly closed: Hansu;
59
59
  /**
60
- * 鳴きあり時の飜数 (0なら不成立)
60
+ * 鳴きあり時の翻数 (0なら不成立)
61
61
  *
62
62
  * @remarks
63
63
  * この値が 0 の場合、その役は**門前限定(Menzen-only)**であることを意味します。
@@ -75,7 +75,7 @@ export type YakuName = TehaiYaku;
75
75
  /**
76
76
  * 役判定結果 (YakuResult)
77
77
  *
78
- * 成立した役と、その飜数のペアのリスト。
78
+ * 成立した役と、その翻数のペアのリスト。
79
79
  * 役が一つも成立しない場合は空配列となる。
80
80
  */
81
81
  export type YakuResult = readonly [YakuName, Hansu][];
@@ -101,7 +101,7 @@ export interface HouraContext {
101
101
  }
102
102
  export interface Yaku {
103
103
  readonly name: YakuName;
104
- /** 飜数 (喰い下がり考慮) */
104
+ /** 翻数 (喰い下がり考慮) */
105
105
  readonly han: {
106
106
  readonly open: Hansu | 0;
107
107
  readonly closed: Hansu;
package/dist/index.d.ts CHANGED
@@ -2,11 +2,20 @@
2
2
  * Riichi Mahjong Library
3
3
  */
4
4
  export { HaiKind, Tacha, FuroType, MentsuType, HaiType } from "./types";
5
- export type { HaiId, HaiKindId, Furo, Shuntsu, Koutsu, Kantsu, CompletedMentsu, Tehai, Tehai13, Tehai14, Mentsu, IncompletedMentsu, Kazehai, } from "./types";
5
+ export type { HaiId, HaiKindId, Furo, Shuntsu, Koutsu, Kantsu, CompletedMentsu, Tehai, Tehai13, Tehai14, Mentsu, IncompletedMentsu, Kazehai, Fu, } from "./types";
6
6
  export type { YakuResult, YakuName, Hansu } from "./features/yaku";
7
+ export type { ScoreResult, ScoreCalculationConfig, Payment, Ron, KoTsumo, OyaTsumo, } from "./features/score/types";
8
+ export { MahjongError, ShoushaiError, TahaiError, MahjongArgumentError, DuplicatedHaiIdError, InvalidHaiQuantityError, ChomboError, NoYakuError, } from "./errors";
9
+ export { haiIdToKindId, kindIdToHaiType, haiKindToNumber, isSuupai, isYaochu, YAOCHU_KIND_IDS, } from "./core/hai";
10
+ export { validateTehai, isTehai13, isTehai14 } from "./core/tehai";
11
+ export { isValidShuntsu, isValidKoutsu, isValidKantsu, isValidToitsu, isValidTatsu, } from "./core/mentsu";
12
+ export { getDoraNext, countDora } from "./core/dora";
13
+ export { classifyMachi } from "./core/machi";
14
+ export type { MachiType } from "./core/machi";
7
15
  export { calculateShanten } from "./features/shanten";
8
16
  export { getUkeire } from "./features/machi";
9
17
  export { detectYaku } from "./features/yaku";
18
+ export { isMenzen, isKazehai } from "./features/yaku/utils";
10
19
  export { parseMspz, parseExtendedMspz } from "./features/parser";
11
- export { calculateScore } from "./features/points";
12
- export type { ScoreResult, ScoreLevel, ScorePayment, ScoreCalculationConfig, } from "./features/points/types";
20
+ export { isMspz, isExtendedMspz } from "./features/parser/mspz";
21
+ export { calculateScoreForTehai, getPaymentTotal } from "./features/score";
package/dist/index.js CHANGED
@@ -1,9 +1,53 @@
1
1
  /**
2
2
  * Riichi Mahjong Library
3
3
  */
4
+ // =============================================================================
5
+ // Types & Constants
6
+ // =============================================================================
4
7
  export { HaiKind, Tacha, FuroType, MentsuType, HaiType } from "./types";
8
+ // =============================================================================
9
+ // Errors
10
+ // =============================================================================
11
+ export { MahjongError, ShoushaiError, TahaiError, MahjongArgumentError, DuplicatedHaiIdError, InvalidHaiQuantityError, ChomboError, NoYakuError, } from "./errors";
12
+ // =============================================================================
13
+ // Core - Hai (Tile) Utilities
14
+ // =============================================================================
15
+ export { haiIdToKindId, kindIdToHaiType, haiKindToNumber, isSuupai, isYaochu, YAOCHU_KIND_IDS, } from "./core/hai";
16
+ // =============================================================================
17
+ // Core - Tehai (Hand) Validation
18
+ // =============================================================================
19
+ export { validateTehai, isTehai13, isTehai14 } from "./core/tehai";
20
+ // =============================================================================
21
+ // Core - Mentsu (Meld) Validation
22
+ // =============================================================================
23
+ export { isValidShuntsu, isValidKoutsu, isValidKantsu, isValidToitsu, isValidTatsu, } from "./core/mentsu";
24
+ // =============================================================================
25
+ // Core - Dora
26
+ // =============================================================================
27
+ export { getDoraNext, countDora } from "./core/dora";
28
+ // =============================================================================
29
+ // Core - Machi (Wait) Classification
30
+ // =============================================================================
31
+ export { classifyMachi } from "./core/machi";
32
+ // =============================================================================
33
+ // Features - Shanten
34
+ // =============================================================================
5
35
  export { calculateShanten } from "./features/shanten";
36
+ // =============================================================================
37
+ // Features - Machi
38
+ // =============================================================================
6
39
  export { getUkeire } from "./features/machi";
40
+ // =============================================================================
41
+ // Features - Yaku
42
+ // =============================================================================
7
43
  export { detectYaku } from "./features/yaku";
44
+ export { isMenzen, isKazehai } from "./features/yaku/utils";
45
+ // =============================================================================
46
+ // Features - Parser
47
+ // =============================================================================
8
48
  export { parseMspz, parseExtendedMspz } from "./features/parser";
9
- export { calculateScore } from "./features/points";
49
+ export { isMspz, isExtendedMspz } from "./features/parser/mspz";
50
+ // =============================================================================
51
+ // Features - Score
52
+ // =============================================================================
53
+ export { calculateScoreForTehai, getPaymentTotal } from "./features/score";
package/dist/types.d.ts CHANGED
@@ -121,6 +121,16 @@ export type Jihai = typeof HaiType.Jihai;
121
121
  * 和了 (-1) はこの型には含めない。
122
122
  */
123
123
  export type ShantenNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
124
+ /**
125
+ * 符 (Fu)
126
+ *
127
+ * 和了時の手牌構成から算出される符の値。
128
+ *
129
+ * - 20: 副底(基本符)
130
+ * - 25: 七対子専用
131
+ * - 30〜110: 10符刻みの値
132
+ */
133
+ export type Fu = 20 | 25 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 110;
124
134
  /**
125
135
  * 他家 (Tacha)
126
136
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pai-forge/riichi-mahjong",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,7 +24,8 @@
24
24
  "lint": "eslint src --max-warnings=0",
25
25
  "lint:fix": "eslint src --fix",
26
26
  "format": "prettier --write src",
27
- "prepare": "husky"
27
+ "prepare": "husky",
28
+ "prepublishOnly": "npm run build"
28
29
  },
29
30
  "keywords": [
30
31
  "mahjong",
@@ -1,2 +0,0 @@
1
- import type { YakuDefinition } from "../../types";
2
- export declare const iipeikoDefinition: YakuDefinition;