@@ -3,7 +3,8 @@ import { Form } from "react-router";
33import { getAuth } from "~/lib/auth" ;
44import { getDB } from "~/lib/db" ;
55import { 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" ;
78import { type GameState , getRedisClient , init } from "~/lib/redis" ;
89import type { Route } from "./+types/play" ;
910
@@ -73,6 +74,9 @@ export async function loader({
7374export 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