Kkdjskjd
This commit is contained in:
@@ -74,6 +74,7 @@ interface MatchView {
|
||||
priority: string
|
||||
status: string
|
||||
winner?: string
|
||||
mulligans?: { player: string; count: number; kept: boolean; bottom: number }[]
|
||||
stack: { id: string; kind: string; label: string; controller: string }[]
|
||||
log: string[]
|
||||
hand: CardView[]
|
||||
@@ -83,6 +84,7 @@ interface MatchView {
|
||||
what: string
|
||||
sourceId: string
|
||||
sourceName: string
|
||||
amount?: number
|
||||
options: string[]
|
||||
}
|
||||
pendingSearch?: {
|
||||
@@ -206,6 +208,15 @@ const myPlaymat = computed(() => {
|
||||
: { kind: 'upload' as const, url: `${apiBase}/playmats/${encodeURIComponent(playmat.id)}` }
|
||||
})
|
||||
const viewerId = computed(() => state.value?.viewerId ?? '')
|
||||
const mulligan = computed(() => game.value?.status === 'mulligan'
|
||||
? game.value.mulligans?.find(entry => entry.player === viewerId.value)
|
||||
: undefined)
|
||||
const mulliganBottom = computed(() => mulligan.value?.bottom ?? 0)
|
||||
const mulliganWaiting = computed(() => (game.value?.mulligans ?? [])
|
||||
.filter(entry => !entry.kept
|
||||
&& !state.value?.players.find(player => player.id === entry.player)?.lost)
|
||||
.map(entry => playerName(entry.player))
|
||||
.join(', '))
|
||||
const isHost = computed(() => state.value?.hostId === viewerId.value)
|
||||
const emptySeats = computed(() => state.value ? state.value.maxPlayers - state.value.players.length : 0)
|
||||
const opponents = computed(() => (state.value?.players ?? []).filter(player => player.id !== viewerId.value && !player.lost))
|
||||
@@ -262,6 +273,9 @@ const filteredSearchLibrary = computed(() => {
|
||||
: searchLibrary.value
|
||||
})
|
||||
const pendingChoice = computed(() => game.value?.pendingChoice)
|
||||
const pendingCostLabel = computed(() => pendingChoice.value?.amount === undefined
|
||||
? 'the cost'
|
||||
: `${pendingChoice.value.amount} life`)
|
||||
const choiceFilter = ref('')
|
||||
const choiceInput = ref<HTMLInputElement | null>(null)
|
||||
const filteredChoiceOptions = computed(() => {
|
||||
@@ -601,13 +615,26 @@ async function playLand(card: CardView) {
|
||||
await act({ type: 'play_land', cardId: card.id })
|
||||
}
|
||||
|
||||
async function keepHand() {
|
||||
await act({ type: 'keep_hand' })
|
||||
}
|
||||
|
||||
async function takeMulligan() {
|
||||
await act({ type: 'mulligan' })
|
||||
}
|
||||
|
||||
/** Cards with choices need the cast panel; everything else plays on click. */
|
||||
function needsCastOptions(card: CardView): boolean {
|
||||
return Boolean(card.manaCost?.includes('X') || /\btarget|choose (one|two|three)/i.test(card.oracleText ?? ''))
|
||||
}
|
||||
|
||||
async function playCard(card: CardView) {
|
||||
if (busy.value || !card.playable) return
|
||||
if (busy.value) return
|
||||
if (mulliganBottom.value > 0) {
|
||||
await act({ type: 'mulligan_bottom', cardId: card.id })
|
||||
return
|
||||
}
|
||||
if (!card.playable) return
|
||||
cancelCast()
|
||||
if (isLand(card)) {
|
||||
await playLand(card)
|
||||
@@ -826,6 +853,11 @@ async function chooseCreatureType(type: string) {
|
||||
await act({ type: 'choose_type', choice: type })
|
||||
}
|
||||
|
||||
async function chooseCost(pay: boolean) {
|
||||
if (busy.value) return
|
||||
await act({ type: 'choose_cost', pay })
|
||||
}
|
||||
|
||||
async function attack() {
|
||||
const attackers = selectedAttackers.value
|
||||
.filter(attackerId => attackTargets[attackerId])
|
||||
@@ -1026,7 +1058,8 @@ onUnmounted(() => {
|
||||
<header class="game-head">
|
||||
<div>
|
||||
<h1>{{ summary ? `${summary.hostName}'s game` : 'Commander game' }}</h1>
|
||||
<p v-if="game" class="muted">
|
||||
<p v-if="game?.status === 'mulligan'" class="muted">Opening hands · keep or mulligan</p>
|
||||
<p v-else-if="game" class="muted">
|
||||
Turn {{ game.turn }} · {{ phaseLabel }} · priority: {{ priorityName }}
|
||||
</p>
|
||||
<p v-else class="muted">{{ state?.status ?? summary?.status ?? 'Loading…' }}</p>
|
||||
@@ -1360,7 +1393,22 @@ onUnmounted(() => {
|
||||
</TransitionGroup>
|
||||
</section>
|
||||
|
||||
<section class="hand-panel">
|
||||
<div v-if="game.status === 'mulligan'" class="mulligan-backdrop" aria-hidden="true" />
|
||||
<section class="hand-panel" :class="{ 'mulligan-mode': game.status === 'mulligan' }">
|
||||
<div v-if="mulligan" class="mulligan-bar">
|
||||
<template v-if="mulligan.kept">
|
||||
<span class="muted">Hand kept. Waiting for {{ mulliganWaiting || 'the other players' }}.</span>
|
||||
</template>
|
||||
<template v-else-if="mulligan.bottom">
|
||||
<span>Click {{ mulligan.bottom }} card{{ mulligan.bottom === 1 ? '' : 's' }} in your hand to put
|
||||
{{ mulligan.bottom === 1 ? 'it' : 'them' }} on the bottom of your library.</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>Mulligans: {{ mulligan.count }}.</span>
|
||||
<button type="button" class="primary" :disabled="busy" @click="keepHand">Keep hand</button>
|
||||
<button type="button" :disabled="busy" @click="takeMulligan">Mulligan</button>
|
||||
</template>
|
||||
</div>
|
||||
<div class="row wrap hand-head">
|
||||
<h2>Your hand</h2>
|
||||
<span class="tag">{{ game.hand.length }}</span>
|
||||
@@ -1385,14 +1433,16 @@ onUnmounted(() => {
|
||||
v-for="(card, index) in game.hand"
|
||||
:key="card.id"
|
||||
class="hand-card"
|
||||
:class="{ playable: card.playable, unplayable: !card.playable }"
|
||||
:class="{ playable: card.playable || mulliganBottom > 0 }"
|
||||
:style="fanStyle(index, game.hand.length)"
|
||||
:title="card.playable
|
||||
? `Click to ${isLand(card) ? 'play' : 'cast'} ${card.name}`
|
||||
: card.oracleText"
|
||||
:title="mulliganBottom > 0
|
||||
? `Put ${card.name} on the bottom of your library`
|
||||
: card.playable
|
||||
? `Click to ${isLand(card) ? 'play' : 'cast'} ${card.name}`
|
||||
: card.oracleText"
|
||||
role="button"
|
||||
:tabindex="card.playable ? 0 : -1"
|
||||
:aria-disabled="!card.playable"
|
||||
:tabindex="card.playable || mulliganBottom > 0 ? 0 : -1"
|
||||
:aria-disabled="!card.playable && !mulliganBottom"
|
||||
@click="playCard(card)"
|
||||
@keydown.enter.prevent="playCard(card)"
|
||||
@keydown.space.prevent="playCard(card)"
|
||||
@@ -1450,9 +1500,12 @@ onUnmounted(() => {
|
||||
</section>
|
||||
|
||||
<section v-if="pendingChoice && pendingChoice.player !== viewerId" class="panel side search-panel">
|
||||
<h2>Choose a type</h2>
|
||||
<h2>{{ pendingChoice.what === 'pay_cost' ? 'Pay a cost' : 'Choose a type' }}</h2>
|
||||
<p class="muted">
|
||||
{{ playerName(pendingChoice.player) }} is choosing a creature type for {{ pendingChoice.sourceName }}.
|
||||
{{ playerName(pendingChoice.player) }}
|
||||
{{ pendingChoice.what === 'pay_cost'
|
||||
? `is deciding whether to pay ${pendingCostLabel} for ${pendingChoice.sourceName}.`
|
||||
: `is choosing a creature type for ${pendingChoice.sourceName}.` }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -1535,7 +1588,7 @@ onUnmounted(() => {
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<div v-if="state?.status === 'active' && game" class="turn-actions">
|
||||
<div v-if="state?.status === 'active' && game?.status === 'active'" class="turn-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="turn-button"
|
||||
@@ -1555,30 +1608,49 @@ onUnmounted(() => {
|
||||
<section class="search-modal" role="dialog" aria-modal="true" aria-labelledby="choice-title">
|
||||
<header class="search-head">
|
||||
<div class="grow">
|
||||
<h2 id="choice-title">Choose a creature type</h2>
|
||||
<h2 id="choice-title">{{ pendingChoice.what === 'pay_cost' ? `Pay ${pendingCostLabel}?` : 'Choose a creature type' }}</h2>
|
||||
<p class="muted">{{ pendingChoice.sourceName }} enters.</p>
|
||||
</div>
|
||||
<span class="tag">{{ filteredChoiceOptions.length }} types</span>
|
||||
<span v-if="pendingChoice.what !== 'pay_cost'" class="tag">{{ filteredChoiceOptions.length }} types</span>
|
||||
</header>
|
||||
<input
|
||||
ref="choiceInput"
|
||||
v-model="choiceFilter"
|
||||
class="search-filter"
|
||||
type="search"
|
||||
placeholder="Search creature types"
|
||||
autocomplete="off"
|
||||
>
|
||||
<p v-if="!filteredChoiceOptions.length" class="muted">No creature types match “{{ choiceFilter }}”.</p>
|
||||
<div v-else class="choice-grid">
|
||||
<button
|
||||
v-for="type in filteredChoiceOptions"
|
||||
:key="type"
|
||||
type="button"
|
||||
class="choice-option"
|
||||
:disabled="busy"
|
||||
@click="chooseCreatureType(type)"
|
||||
>{{ type }}</button>
|
||||
</div>
|
||||
<template v-if="pendingChoice.what === 'pay_cost'">
|
||||
<p class="muted">If you don't, it enters tapped.</p>
|
||||
<div class="choice-grid">
|
||||
<button
|
||||
type="button"
|
||||
class="choice-option"
|
||||
:disabled="busy || (pendingChoice.amount !== undefined && (me?.life ?? 0) < pendingChoice.amount)"
|
||||
@click="chooseCost(true)"
|
||||
>Pay {{ pendingCostLabel }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="choice-option"
|
||||
:disabled="busy"
|
||||
@click="chooseCost(false)"
|
||||
>Enter tapped</button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<input
|
||||
ref="choiceInput"
|
||||
v-model="choiceFilter"
|
||||
class="search-filter"
|
||||
type="search"
|
||||
placeholder="Search creature types"
|
||||
autocomplete="off"
|
||||
>
|
||||
<p v-if="!filteredChoiceOptions.length" class="muted">No creature types match “{{ choiceFilter }}”.</p>
|
||||
<div v-else class="choice-grid">
|
||||
<button
|
||||
v-for="type in filteredChoiceOptions"
|
||||
:key="type"
|
||||
type="button"
|
||||
class="choice-option"
|
||||
:disabled="busy"
|
||||
@click="chooseCreatureType(type)"
|
||||
>{{ type }}</button>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
@@ -2593,6 +2665,13 @@ onUnmounted(() => {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.mulligan-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 65;
|
||||
background: rgb(0 0 0 / 82%);
|
||||
}
|
||||
|
||||
.hand-panel {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
@@ -2608,12 +2687,37 @@ onUnmounted(() => {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.hand-panel.mulligan-mode {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
bottom: auto;
|
||||
z-index: 66;
|
||||
width: min(100%, 60rem);
|
||||
padding: 0 0.5rem;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.hand-head {
|
||||
justify-content: center;
|
||||
padding: 0 0.25rem;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.mulligan-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0 0.5rem;
|
||||
padding: 0.45rem 0.7rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 0.5rem;
|
||||
background: var(--panel);
|
||||
font-size: 0.9rem;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.hand-head h2 {
|
||||
font-size: 0.95rem;
|
||||
white-space: nowrap;
|
||||
@@ -2675,6 +2779,12 @@ onUnmounted(() => {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hand-card.playable .hand-lift {
|
||||
outline: 2px solid #58a6ff;
|
||||
outline-offset: 2px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.hand-card:hover,
|
||||
.hand-card:focus-within {
|
||||
z-index: 30;
|
||||
@@ -2694,18 +2804,6 @@ onUnmounted(() => {
|
||||
filter: drop-shadow(0 14px 22px rgb(0 0 0 / 55%));
|
||||
}
|
||||
|
||||
.hand-card.playable:hover .hand-lift,
|
||||
.hand-card.playable:focus-within .hand-lift {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.hand-card.unplayable {
|
||||
filter: grayscale(1);
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.hand-options {
|
||||
position: absolute;
|
||||
bottom: 0.4em;
|
||||
|
||||
Reference in New Issue
Block a user