Skip to content

Commit d9b8062

Browse files
committed
tmp
1 parent f7fa4bf commit d9b8062

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed
File renamed without changes.
File renamed without changes.

app/lib/redis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createClient } from "redis";
2-
import type { Hai } from "./hai";
3-
import { sortTehai } from "./hai";
2+
import type { Hai } from "./hai/utils";
3+
import { sortTehai } from "./hai/utils";
44

55
export function getRedisClient(env: Env) {
66
const client = createClient({

app/routes/play.agari.ts

Whitespace-only changes.

app/routes/play.ryukyoku.ts

Whitespace-only changes.

app/routes/play.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Form } from "react-router";
33
import { getAuth } from "~/lib/auth";
44
import { getDB } from "~/lib/db";
55
import { hai, haiyama } from "~/lib/db/schema";
6-
import { dbHaiToHai, sortTehai } from "~/lib/hai";
6+
import judgeAgari from "~/lib/hai/judgeAgari";
7+
import { dbHaiToHai, sortTehai } from "~/lib/hai/utils";
78
import { type GameState, getRedisClient, init } from "~/lib/redis";
89
import type { Route } from "./+types/play";
910

@@ -73,6 +74,9 @@ export async function loader({
7374
export default function Page({ loaderData }: Route.ComponentProps) {
7475
let { haiyama, sutehai, tsumohai, junme, kyoku, tehai } = loaderData;
7576
tehai = sortTehai(tehai);
77+
const isAgari =
78+
tehai && tsumohai ? judgeAgari(sortTehai([...tehai, tsumohai])) : false;
79+
const isRyukyoku = junme === 19;
7680
const indexedSutehai = sutehai.map((hai, index) => ({
7781
...hai,
7882
index: index,
@@ -84,6 +88,36 @@ export default function Page({ loaderData }: Route.ComponentProps) {
8488

8589
return (
8690
<div className="p-4">
91+
{isAgari && (
92+
<dialog id="my_modal_1" className="modal">
93+
<div className="modal-box">
94+
<h3 className="font-bold text-lg">ツモ!</h3>
95+
<div className="modal-action">
96+
<form method="post" action="/play/agari">
97+
<input type="hidden" value={junme} name="junme" />
98+
<button className="btn" type="submit">
99+
確認
100+
</button>
101+
</form>
102+
</div>
103+
</div>
104+
</dialog>
105+
)}
106+
{isRyukyoku && (
107+
<dialog id="my_modal_1" className="modal">
108+
<div className="modal-box">
109+
<h3 className="font-bold text-lg">流局</h3>
110+
<div className="modal-action">
111+
<form method="post" action="/play/ryukyoku">
112+
<button className="btn" type="submit">
113+
確認
114+
</button>
115+
</form>
116+
</div>
117+
</div>
118+
</dialog>
119+
)}
120+
87121
<p className="text-xl mb-4">
88122
Play Page - 局 {kyoku} 巡目 {junme}
89123
</p>

0 commit comments

Comments
 (0)