Skip to content

Commit 94cb77f

Browse files
authored
Merge pull request #8 from ryblogs/fix/disable-riichi-open-hand
fix: disable riichi options for open hands, add live demo link
2 parents b25e3f4 + 0170e1e commit 94cb77f

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Agari is a comprehensive Riichi Mahjong scoring engine written in idiomatic, modern Rust. It transforms raw hand notations into detailed scoring results, handling the complex interplay between hand decomposition, wait patterns, situational yaku, and minipoint (fu) calculation.
44

5+
**[🎮 Live Demo](https://ryblogs.github.io/agari/)** — Try the web interface for agari-core
6+
57
---
68

79
## Installation

web/src/App.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@
899899
bind:isChankan
900900
bind:isTenhou
901901
bind:isChiihou
902+
hasOpenMelds={hasOpenMelds}
902903
onChange={handleContextChange}
903904
/>
904905
</div>

web/src/lib/components/ContextOptions.svelte

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
isTenhou: boolean;
2525
/** Whether chiihou */
2626
isChiihou: boolean;
27+
/** Whether hand has open melds (chi, pon, open kan) */
28+
hasOpenMelds?: boolean;
2729
/** Callback for any option change */
2830
onChange: () => void;
2931
}
@@ -40,9 +42,19 @@
4042
isChankan = $bindable(),
4143
isTenhou = $bindable(),
4244
isChiihou = $bindable(),
45+
hasOpenMelds = false,
4346
onChange,
4447
}: Props = $props();
4548
49+
// When hand becomes open, uncheck riichi-related options
50+
$effect(() => {
51+
if (hasOpenMelds) {
52+
if (isRiichi) isRiichi = false;
53+
if (isDoubleRiichi) isDoubleRiichi = false;
54+
if (isIppatsu) isIppatsu = false;
55+
}
56+
});
57+
4658
const winds = ['east', 'south', 'west', 'north'] as const;
4759
const windSymbols = { east: '', south: '', west: '西', north: '' };
4860
@@ -138,31 +150,37 @@
138150
<!-- Riichi Options -->
139151
<div class="option-section">
140152
<h3 class="section-title">Riichi</h3>
153+
{#if hasOpenMelds}
154+
<div class="open-hand-notice">
155+
🔓 Open hand — Riichi not available
156+
</div>
157+
{/if}
141158
<div class="checkbox-group">
142-
<label class="checkbox-item">
159+
<label class="checkbox-item" class:disabled={hasOpenMelds}>
143160
<input
144161
type="checkbox"
145162
bind:checked={isRiichi}
163+
disabled={hasOpenMelds}
146164
onchange={handleRiichiChange}
147165
/>
148166
<span class="checkbox-label">Riichi</span>
149167
<span class="han-indicator">+1 han</span>
150168
</label>
151-
<label class="checkbox-item" class:disabled={!isRiichi}>
169+
<label class="checkbox-item" class:disabled={hasOpenMelds || !isRiichi}>
152170
<input
153171
type="checkbox"
154172
bind:checked={isDoubleRiichi}
155-
disabled={!isRiichi}
173+
disabled={hasOpenMelds || !isRiichi}
156174
onchange={handleDoubleRiichiChange}
157175
/>
158176
<span class="checkbox-label">Double Riichi</span>
159177
<span class="han-indicator">+1 han</span>
160178
</label>
161-
<label class="checkbox-item" class:disabled={!isRiichi}>
179+
<label class="checkbox-item" class:disabled={hasOpenMelds || !isRiichi}>
162180
<input
163181
type="checkbox"
164182
bind:checked={isIppatsu}
165-
disabled={!isRiichi}
183+
disabled={hasOpenMelds || !isRiichi}
166184
onchange={onChange}
167185
/>
168186
<span class="checkbox-label">Ippatsu</span>
@@ -412,6 +430,16 @@
412430
color: var(--bg-primary);
413431
}
414432
433+
.open-hand-notice {
434+
font-size: 0.8rem;
435+
color: var(--text-secondary);
436+
background: rgba(255, 193, 7, 0.15);
437+
border: 1px solid rgba(255, 193, 7, 0.3);
438+
border-radius: 6px;
439+
padding: 0.5rem 0.75rem;
440+
margin-bottom: 0.5rem;
441+
}
442+
415443
@media (max-width: 768px) {
416444
.winds-grid {
417445
grid-template-columns: 1fr;

0 commit comments

Comments
 (0)