Skip to content

Commit

Permalink
Merge pull request #2 from horita-yuya/feature/update
Browse files Browse the repository at this point in the history
Feature/update
  • Loading branch information
horita-yuya authored Nov 21, 2024
2 parents 0a41f9e + 7e443f5 commit 43704c9
Show file tree
Hide file tree
Showing 33 changed files with 1,261 additions and 876 deletions.
33 changes: 33 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noUselessElse": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
20 changes: 14 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Calculate, Hand, HuAll, WinningStyle, YakuAll, YakuChitoitsu, YakuPinhu } from "./types";
import { Position } from "./types/field";
import type {
Calculate,
Hand,
HuAll,
WinningStyle,
YakuAll,
YakuChitoitsu,
YakuPinhu,
} from "./types";
import type { Position } from "./types/field";

export type MahjongKun<
HAND extends Hand,
WINNING extends HAND[number],
NAKI extends HAND[number][],
STYLE extends WinningStyle,
POSITION extends Position
POSITION extends Position,
> = Calculate<
YakuAll<HAND, WINNING, NAKI>,
HuAll<HAND, WINNING, NAKI, STYLE>,
Expand All @@ -15,8 +23,8 @@ export type MahjongKun<
YakuChitoitsu<HAND, WINNING> extends [1, 1]
? "chitoitsu"
: STYLE extends "tumo"
? YakuPinhu<HAND, WINNING, NAKI> extends [1]
? "pin-tumo"
? YakuPinhu<HAND, WINNING, NAKI> extends [1]
? "pin-tumo"
: null
: null
: null
>;
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
"license": "MIT",
"scripts": {
"test": "tsc --noEmit",
"build": "tsc --noEmit && esbuild index.ts --bundle --minify --outfile=dist/index.js"
"build": "tsc ./index.ts --declaration --outDir ./dist --emitDeclarationOnly"
},
"devDependencies": {
"esbuild": "^0.14.11",
"eslint": "^8.10.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4"
},
"prettier": {
"printWidth": 120
"@biomejs/biome": "^1.9.4",
"esbuild": "^0.24.0",
"typescript": "^5.6.3"
}
}
110 changes: 105 additions & 5 deletions tests/huAll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,132 @@ import { Equal, HuAll } from "../types";
// 20 + 4 + 4
type Case1_1 = ExpectTrue<
Equal<
HuAll<["o2", "o3", "o4", "I2", "I2", "I2", "C4", "C5", "C6", "I6", "I6", "I6", "o4", "o4"], "o2", [], "ron">,
HuAll<
[
"o2",
"o3",
"o4",
"I2",
"I2",
"I2",
"C4",
"C5",
"C6",
"I6",
"I6",
"I6",
"o4",
"o4",
],
"o2",
[],
"ron"
>,
40
>
>;
// 20
type Case2_1 = ExpectTrue<
Equal<
HuAll<["o2", "o3", "o4", "I2", "I3", "I4", "C4", "C5", "C6", "I2", "I3", "I4", "o4", "o4"], "o2", [], "ron">,
HuAll<
[
"o2",
"o3",
"o4",
"I2",
"I3",
"I4",
"C4",
"C5",
"C6",
"I2",
"I3",
"I4",
"o4",
"o4",
],
"o2",
[],
"ron"
>,
30
>
>;
type Case2_2 = ExpectTrue<
Equal<
HuAll<["o2", "o3", "o4", "I2", "I3", "I4", "C4", "C5", "C6", "I2", "I3", "I4", "o4", "o4"], "o2", [], "tumo">,
HuAll<
[
"o2",
"o3",
"o4",
"I2",
"I3",
"I4",
"C4",
"C5",
"C6",
"I2",
"I3",
"I4",
"o4",
"o4",
],
"o2",
[],
"tumo"
>,
30
>
>;
type Case2_3 = ExpectTrue<
Equal<
HuAll<["o2", "o3", "o4", "I2", "I3", "I4", "C4", "C5", "C6", "I2", "I3", "I4", "o4", "o4"], "o2", ["I2"], "ron">,
HuAll<
[
"o2",
"o3",
"o4",
"I2",
"I3",
"I4",
"C4",
"C5",
"C6",
"I2",
"I3",
"I4",
"o4",
"o4",
],
"o2",
["I2"],
"ron"
>,
20
>
>;
type Case2_4 = ExpectTrue<
Equal<
HuAll<["o2", "o3", "o4", "I2", "I3", "I4", "C4", "C5", "C6", "I2", "I3", "I4", "o4", "o4"], "o2", ["I2"], "tumo">,
HuAll<
[
"o2",
"o3",
"o4",
"I2",
"I3",
"I4",
"C4",
"C5",
"C6",
"I2",
"I3",
"I4",
"o4",
"o4",
],
"o2",
["I2"],
"tumo"
>,
30
>
>;
Loading

0 comments on commit 43704c9

Please sign in to comment.