[ui] Thorns: Touch her over her picture; Gently. I have thorns.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
careEvent, goodMoment, localDay, petalAt, pour, roseAt, ROSE, sentenceOpened,
|
||||
type Mood, type PetalNow, type Place, type RoseNow, type Stage
|
||||
careEvent, goodMoment, localDay, petalAt, pour, roseAt, ROSE, sentenceOpened, touch, TOUCH, UNTOUCHED,
|
||||
type Mood, type PetalNow, type Place, type RoseNow, type Stage, type TouchState
|
||||
} from '@rosea/engine';
|
||||
import type { CareEvent, SentenceOpened } from '@rosea/schema';
|
||||
import { en } from '../copy/en.js';
|
||||
@@ -126,11 +126,35 @@
|
||||
}
|
||||
$effect(() => () => clearInterval(pourTimer));
|
||||
|
||||
// --- Touching her (thorns.md): nothing is recorded ----------------------
|
||||
let touchState = $state.raw<TouchState>(UNTOUCHED);
|
||||
let touchLine = $state('');
|
||||
let touchBlush = $state(false);
|
||||
let fondSaid = 0;
|
||||
let touchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
function touchHer(): void {
|
||||
const { reply, state } = touch(touchState, wiring.now());
|
||||
touchState = state;
|
||||
if (reply.kind === 'nothing') return;
|
||||
const fond = en.rose.touch.fond;
|
||||
touchLine = reply.kind === 'thorns' ? en.rose.touch.thorns : (fond[fondSaid++ % fond.length] ?? '');
|
||||
if (reply.kind === 'fond' && reply.blush) touchBlush = true;
|
||||
clearTimeout(touchTimer);
|
||||
// Her words hold the bubble while she would rest, then her usual line returns (T6).
|
||||
touchTimer = setTimeout(() => {
|
||||
touchLine = '';
|
||||
touchBlush = false;
|
||||
}, TOUCH.restMs);
|
||||
}
|
||||
$effect(() => () => clearTimeout(touchTimer));
|
||||
|
||||
const isPourKey = (e: KeyboardEvent): boolean => e.key === ' ' || e.key === 'Enter';
|
||||
|
||||
// --- What she says: one line, or nothing --------------------------------
|
||||
const says = $derived.by(() => {
|
||||
if (!rose) return '';
|
||||
if (touchLine) return touchLine;
|
||||
const s = en.rose.says;
|
||||
if (rose.mood === 'blushing') return s.thanks;
|
||||
if (rose.mood === 'too-full') return s.tooFull;
|
||||
@@ -146,15 +170,30 @@
|
||||
return [rose.drift > 0 ? s.back : '', need || offer].filter(Boolean).join(' ');
|
||||
});
|
||||
|
||||
const picture = $derived(rose ? (rose.stage === 'full-bloom' ? MOOD_PICTURE[rose.mood] : STAGE_PICTURE[rose.stage]) : bud);
|
||||
const alt = $derived(rose ? en.rose.picture(en.rose.stageWords[rose.stage], en.rose.moodWords[rose.mood]) : '');
|
||||
// A touch's blush shows as her mood does: on her face in full bloom (thorns.md T4).
|
||||
const mood = $derived<Mood | null>(rose ? (touchBlush ? 'blushing' : rose.mood) : null);
|
||||
const picture = $derived(rose && mood ? (rose.stage === 'full-bloom' ? MOOD_PICTURE[mood] : STAGE_PICTURE[rose.stage]) : bud);
|
||||
const alt = $derived(rose && mood ? en.rose.picture(en.rose.stageWords[rose.stage], en.rose.moodWords[mood]) : '');
|
||||
const percent = (x: number): string => `${Math.round(Math.max(0, Math.min(1, x)) * 100)} %`;
|
||||
</script>
|
||||
|
||||
{#if rose}
|
||||
<section class="rose">
|
||||
<figure>
|
||||
<img src={picture} {alt} width="120" height="320" class:turned={rose.drift > 0} />
|
||||
<div class="picture">
|
||||
<img src={picture} {alt} width="120" height="320" class:turned={rose.drift > 0} />
|
||||
<!-- Her picture keeps its description; the touch is its own button over it (thorns.md T5). -->
|
||||
<button
|
||||
type="button"
|
||||
class="touch"
|
||||
aria-label={en.rose.touch.label}
|
||||
onclick={touchHer}
|
||||
onkeydown={(e) => {
|
||||
// A held key is one touch, not a rush.
|
||||
if (e.repeat) e.preventDefault();
|
||||
}}
|
||||
></button>
|
||||
</div>
|
||||
{#if says}
|
||||
<figcaption class="bubble" aria-live="polite">{says}</figcaption>
|
||||
{/if}
|
||||
@@ -246,6 +285,19 @@
|
||||
transition: transform 0.6s ease;
|
||||
}
|
||||
|
||||
.picture {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.touch {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: none;
|
||||
border-radius: 1rem;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Drift is drawn as waiting: turned a little away, never hurt (CLAUDE.md §8). */
|
||||
img.turned {
|
||||
transform: rotate(-4deg) scaleX(-1);
|
||||
|
||||
Reference in New Issue
Block a user