Skip to content

Commit 56fb3ad

Browse files
tknkaaCopilot
andcommitted
Scale agari scoring
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 353e732 commit 56fb3ad

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

app/lib/components/LocalRule.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function LocalRule() {
55

66
<ul className="list-disc ml-6 mb-8 space-y-4">
77
<li className="leading-relaxed text-sm">
8-
牌を18巡ツモって、流局までにアガれたら+8000点、アガれなくても流局時にテンパイしていたら+3000点、イーシャンテンでも+1000点となっています。実戦では流局時にイーシャンテンでも点数はもらえないのですが、
8+
牌を18巡ツモって、流局までにアガれたら1-6巡目は+8000点、7-12巡目は+6400点、13-18巡目は+5200点となっています。アガれなくても流局時にテンパイしていたら+3000点、イーシャンテンでも+1000点となっています。実戦では流局時にイーシャンテンでも点数はもらえないのですが、
99
<u>一人麻雀はパズルとして楽しんでほしい</u>
1010
ので、シャンテン数を進めたということで、点数がもらえます。
1111
</li>

app/lib/score.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function getAgariScoreDelta(junme: number): number {
2+
if (junme <= 6) return 8000;
3+
if (junme <= 12) return 6400;
4+
return 5200;
5+
}

app/routes/api.agari.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getDB } from "~/lib/db";
44
import { getGameState, recordKyoku, restartGame } from "~/lib/game-service";
55
import judgeAgari from "~/lib/hai/agari";
66
import { sortTehai } from "~/lib/hai/types";
7+
import { getAgariScoreDelta } from "~/lib/score";
78
import type { Route } from "./+types/api.agari";
89

910
export async function action({ context, request }: Route.ActionArgs) {
@@ -32,12 +33,14 @@ export async function action({ context, request }: Route.ActionArgs) {
3233
});
3334
}
3435

35-
// Record win with +8000 points
36+
const scoreDelta = getAgariScoreDelta(gameStateRecord.junme);
37+
38+
// Record win with score based on junme
3639
await recordKyoku(db, userId, {
3740
didAgari: true,
3841
agariJunme: gameStateRecord.junme,
3942
shanten: 0,
40-
scoreDelta: 8000,
43+
scoreDelta,
4144
});
4245

4346
const { isGameOver } = await restartGame(db, userId);

app/routes/play.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import judgeAgari from "~/lib/hai/agari";
1515
import { calculateShanten } from "~/lib/hai/shanten";
1616
import type { Hai } from "~/lib/hai/types";
1717
import { haiToIndex, indexToHai, sortTehai } from "~/lib/hai/types";
18+
import { getAgariScoreDelta } from "~/lib/score";
1819
import type { GameState } from "~/lib/types";
1920
import type { Route } from "./+types/play";
2021

@@ -35,7 +36,6 @@ const TILE_IMAGE_PATHS = [
3536
...JIHAI_VALUES.map((value) => `/hai/jihai_${value}.png`),
3637
];
3738
const TOTAL_TSUMO_PER_KYOKU = 18;
38-
const AGARI_SCORE_DELTA = 8000;
3939

4040
type ShantenAdvanceDiscard = {
4141
hai: Hai;
@@ -306,6 +306,7 @@ export default function Page({ loaderData }: Route.ComponentProps) {
306306
const shantenResult = optimisticTehai
307307
? calculateShanten(optimisticTehai)
308308
: { shanten: 8, isTenpai: false };
309+
const agariScoreDelta = getAgariScoreDelta(optimisticJunme);
309310
const isRyukyoku = optimisticRemainTsumo <= 0;
310311
const ryukyokuShanten = shantenResult.shanten;
311312
const ryukyokuScoreDelta =
@@ -430,7 +431,7 @@ export default function Page({ loaderData }: Route.ComponentProps) {
430431
<dialog id="agari_modal" className="modal" open>
431432
<div className="modal-box bg-[#0F2918] border border-yellow-700 text-white">
432433
<h3 className="font-bold text-2xl text-yellow-400">和了</h3>
433-
<p className="mt-2">獲得スコア: +{AGARI_SCORE_DELTA}</p>
434+
<p className="mt-2">獲得スコア: +{agariScoreDelta}</p>
434435
{optimisticTsumohai && (
435436
<div className="mt-2">
436437
<p className="text-sm mb-1">ツモ牌</p>

0 commit comments

Comments
 (0)