kjdskjdsk
This commit is contained in:
@@ -6,8 +6,10 @@ import {
|
||||
deleteDeck,
|
||||
exportDeckText,
|
||||
loadDecks,
|
||||
loadSharedDeck,
|
||||
newDeckId,
|
||||
saveDeck,
|
||||
shareDeck,
|
||||
type ApiCard,
|
||||
type DeckCard,
|
||||
type SavedDeck,
|
||||
@@ -26,6 +28,8 @@ interface DraftDeck {
|
||||
definePageMeta({ middleware: 'auth' })
|
||||
|
||||
const { public: { apiBase } } = useRuntimeConfig()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const BASIC_NAMES = ['Plains', 'Island', 'Swamp', 'Mountain', 'Forest']
|
||||
|
||||
const decks = ref<SavedDeck[]>([])
|
||||
@@ -43,6 +47,8 @@ const importErrors = ref<string[]>([])
|
||||
const importing = ref(false)
|
||||
const basics = ref<Record<string, ApiCard>>({})
|
||||
const showExport = ref(false)
|
||||
const shareLink = ref('')
|
||||
const shareCopied = ref(false)
|
||||
|
||||
const count = computed(() => 1 + (draft.value?.cards.length ?? 0))
|
||||
const grouped = computed(() => {
|
||||
@@ -115,6 +121,30 @@ async function reloadDecks() {
|
||||
decks.value = (await loadDecks(apiBase)).sort((a, b) => b.updatedAt - a.updatedAt)
|
||||
}
|
||||
|
||||
async function share(deck: SavedDeck) {
|
||||
error.value = ''
|
||||
try {
|
||||
const token = await shareDeck(apiBase, deck.id)
|
||||
shareLink.value = `${window.location.origin}/decks?share=${token}`
|
||||
shareCopied.value = false
|
||||
} catch (caught) {
|
||||
error.value = errorMessage(caught)
|
||||
}
|
||||
}
|
||||
|
||||
async function copyShareLink() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareLink.value)
|
||||
shareCopied.value = true
|
||||
} catch {
|
||||
shareCopied.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function closeShare() {
|
||||
shareLink.value = ''
|
||||
}
|
||||
|
||||
function selectDeck(deck: SavedDeck) {
|
||||
draft.value = {
|
||||
id: deck.id,
|
||||
@@ -314,6 +344,27 @@ function errorMessage(caught: unknown): string {
|
||||
onMounted(async () => {
|
||||
await reloadDecks()
|
||||
|
||||
const sharedToken = route.query.share
|
||||
if (typeof sharedToken === 'string' && sharedToken) {
|
||||
try {
|
||||
const deck = await loadSharedDeck(apiBase, sharedToken)
|
||||
draft.value = {
|
||||
id: newDeckId(),
|
||||
name: deck.name,
|
||||
commander: { ...deck.commander },
|
||||
cards: deck.cards.map(card => ({ ...card })),
|
||||
cardBack: deck.cardBack ?? undefined,
|
||||
}
|
||||
notice.value = 'Shared deck loaded. Save it to add it to your account.'
|
||||
} catch (caught) {
|
||||
error.value = errorMessage(caught)
|
||||
}
|
||||
// Drop the token from the URL so a reload does not import the deck again.
|
||||
const query = { ...route.query }
|
||||
delete query.share
|
||||
await router.replace({ query })
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await $fetch<{ cards: (ApiCard | null)[] }>(`${apiBase}/cards/resolve`, {
|
||||
method: 'POST',
|
||||
@@ -519,33 +570,50 @@ onMounted(async () => {
|
||||
</header>
|
||||
|
||||
<section class="decks-panel">
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="!decks.length" class="muted">No saved decks yet.</p>
|
||||
<div class="deck-grid">
|
||||
<button type="button" class="deck-tile import-tile" @click="openImport">
|
||||
<span class="plus" aria-hidden="true">+</span>
|
||||
<span class="deck-name">Import deck</span>
|
||||
</button>
|
||||
<button
|
||||
v-for="deck in decks"
|
||||
:key="deck.id"
|
||||
type="button"
|
||||
class="deck-tile"
|
||||
@click="selectDeck(deck)"
|
||||
>
|
||||
<span class="deck-stack">
|
||||
<img :src="commanderImage(deck)" :alt="`${deck.commander.name} card`" loading="lazy">
|
||||
</span>
|
||||
<span class="deck-name">{{ deck.name }}</span>
|
||||
<span class="deck-meta">
|
||||
<span class="tag" :class="deck.cards.length + 1 === 100 ? 'good' : 'bad'">
|
||||
{{ deck.cards.length + 1 }}/100
|
||||
<div v-for="deck in decks" :key="deck.id" class="deck-cell">
|
||||
<button type="button" class="deck-tile" @click="selectDeck(deck)">
|
||||
<span class="deck-stack">
|
||||
<img :src="commanderImage(deck)" :alt="`${deck.commander.name} card`" loading="lazy">
|
||||
</span>
|
||||
<span class="muted deck-commander">{{ deck.commander.name }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<span class="deck-name">{{ deck.name }}</span>
|
||||
<span class="deck-meta">
|
||||
<span class="tag" :class="deck.cards.length + 1 === 100 ? 'good' : 'bad'">
|
||||
{{ deck.cards.length + 1 }}/100
|
||||
</span>
|
||||
<span class="muted deck-commander">{{ deck.commander.name }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="mini share-button"
|
||||
:aria-label="`Share ${deck.name}`"
|
||||
@click="share(deck)"
|
||||
>Share</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div v-if="shareLink" class="modal-backdrop" @click.self="closeShare">
|
||||
<div class="modal">
|
||||
<h2>Share deck</h2>
|
||||
<p class="muted">Anyone with this link can view and import a copy of the deck.</p>
|
||||
<input :value="shareLink" readonly aria-label="Share link">
|
||||
<div class="row wrap modal-actions">
|
||||
<button type="button" @click="closeShare">Done</button>
|
||||
<button type="button" class="primary" @click="copyShareLink">
|
||||
{{ shareCopied ? 'Copied' : 'Copy link' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="importOpen" class="modal-backdrop" @click.self="closeImport">
|
||||
<form class="modal" @submit.prevent="importDeck">
|
||||
<h2>Import deck</h2>
|
||||
@@ -609,6 +677,21 @@ onMounted(async () => {
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.deck-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.deck-cell .deck-tile {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.share-button {
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.deck-tile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -34,6 +34,7 @@ interface CardView {
|
||||
attacking?: string
|
||||
blockedBy: string[]
|
||||
blocking?: string
|
||||
chosenType?: string
|
||||
abilities: AbilityView[]
|
||||
playable?: boolean
|
||||
}
|
||||
@@ -77,11 +78,19 @@ interface MatchView {
|
||||
log: string[]
|
||||
hand: CardView[]
|
||||
manaPool: Record<string, number>
|
||||
pendingChoice?: {
|
||||
player: string
|
||||
what: string
|
||||
sourceId: string
|
||||
sourceName: string
|
||||
options: string[]
|
||||
}
|
||||
pendingSearch?: {
|
||||
player: string
|
||||
remaining: number
|
||||
destination: string
|
||||
cards: CardView[]
|
||||
library?: CardView[]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,9 +135,10 @@ const connection = ref<'connecting' | 'live' | 'reconnecting' | 'offline'>('conn
|
||||
const castCardId = ref('')
|
||||
const selectedTarget = ref('')
|
||||
const castX = ref(0)
|
||||
const castOverload = ref(false)
|
||||
const selectedAttackers = ref<string[]>([])
|
||||
const attackTargets = reactive<Record<string, string>>({})
|
||||
const defenderId = ref('')
|
||||
const attackDropId = ref('')
|
||||
const blockSelection = reactive<Record<string, string>>({})
|
||||
const selectedCardId = ref('')
|
||||
const menu = ref<{ cardId: string; x: number; y: number } | null>(null)
|
||||
@@ -202,6 +212,7 @@ const opponents = computed(() => (state.value?.players ?? []).filter(player => p
|
||||
const canAct = computed(() => Boolean(state.value?.status === 'active'
|
||||
&& game.value
|
||||
&& !game.value.pendingSearch
|
||||
&& !game.value.pendingChoice
|
||||
&& game.value.priority === viewerId.value))
|
||||
const isActive = computed(() => game.value?.activePlayer === viewerId.value)
|
||||
const priorityName = computed(() => playerName(game.value?.priority))
|
||||
@@ -222,9 +233,15 @@ const attackWindow = computed(() => Boolean(state.value?.status === 'active'
|
||||
&& !game.value.stack.length
|
||||
&& (game.value.phase === 'precombat_main'
|
||||
|| (game.value.phase === 'combat' && game.value.step === 'declare_attackers'))))
|
||||
const draggingAttackerId = computed(() => {
|
||||
const cardId = dragPreview.value?.cardId
|
||||
if (!attackWindow.value || !cardId) return ''
|
||||
return myUntappedCreatures.value.some(card => card.id === cardId) ? cardId : ''
|
||||
})
|
||||
const blockWindow = computed(() => Boolean(state.value?.status === 'active'
|
||||
&& game.value
|
||||
&& !game.value.pendingSearch
|
||||
&& !game.value.pendingChoice
|
||||
&& game.value.step === 'declare_blockers'
|
||||
&& game.value.priority === viewerId.value))
|
||||
const castCard = computed(() => {
|
||||
@@ -232,7 +249,27 @@ const castCard = computed(() => {
|
||||
return state.value.game?.hand.find(card => card.id === castCardId.value)
|
||||
?? me.value?.command?.find(card => card.id === castCardId.value)
|
||||
})
|
||||
const overloadAbility = computed(() => castCard.value?.abilities.find(ability => ability.kind === 'overload'))
|
||||
const pendingSearch = computed(() => game.value?.pendingSearch)
|
||||
const searchFilter = ref('')
|
||||
const searchInput = ref<HTMLInputElement | null>(null)
|
||||
const searchLegalIds = computed(() => new Set(pendingSearch.value?.cards.map(card => card.id) ?? []))
|
||||
const searchLibrary = computed(() => pendingSearch.value?.library ?? pendingSearch.value?.cards ?? [])
|
||||
const filteredSearchLibrary = computed(() => {
|
||||
const query = searchFilter.value.trim().toLowerCase()
|
||||
return query
|
||||
? searchLibrary.value.filter(card => card.name.toLowerCase().includes(query))
|
||||
: searchLibrary.value
|
||||
})
|
||||
const pendingChoice = computed(() => game.value?.pendingChoice)
|
||||
const choiceFilter = ref('')
|
||||
const choiceInput = ref<HTMLInputElement | null>(null)
|
||||
const filteredChoiceOptions = computed(() => {
|
||||
const query = choiceFilter.value.trim().toLowerCase()
|
||||
return query
|
||||
? (pendingChoice.value?.options ?? []).filter(option => option.toLowerCase().includes(query))
|
||||
: (pendingChoice.value?.options ?? [])
|
||||
})
|
||||
const browseView = computed(() => {
|
||||
const zone = browsingZone.value
|
||||
const player = state.value?.players.find(entry => entry.id === zone?.playerId)
|
||||
@@ -243,13 +280,13 @@ const browseView = computed(() => {
|
||||
cards: (zone.zone === 'graveyard' ? player.graveyard : player.exile) ?? [],
|
||||
}
|
||||
})
|
||||
const sidebarOpen = computed(() => Boolean(pendingSearch.value
|
||||
const sidebarOpen = computed(() => Boolean((pendingSearch.value && pendingSearch.value.player !== viewerId.value)
|
||||
|| (pendingChoice.value && pendingChoice.value.player !== viewerId.value)
|
||||
|| castCard.value
|
||||
|| browseView.value
|
||||
|| playmatOpen.value
|
||||
|| attackWindow.value
|
||||
|| blockWindow.value
|
||||
|| game.value?.stack.length
|
||||
|| showLog.value))
|
||||
const searchDestination = computed(() => {
|
||||
switch (pendingSearch.value?.destination) {
|
||||
@@ -448,9 +485,6 @@ async function connect() {
|
||||
const next = JSON.parse(event.data) as MatchView
|
||||
applyState(next)
|
||||
connection.value = 'live'
|
||||
if (!defenderId.value || !next.players.some(player => player.id === defenderId.value)) {
|
||||
defenderId.value = next.players.find(player => player.id !== next.viewerId)?.id ?? ''
|
||||
}
|
||||
} catch {
|
||||
// Ignore malformed keepalive frames.
|
||||
}
|
||||
@@ -679,11 +713,26 @@ function moveCardPreview(event: PointerEvent) {
|
||||
const marginX = Math.min(0.49, drag.halfWidth / rect.width)
|
||||
const marginY = Math.min(0.49, drag.halfHeight / rect.height)
|
||||
const clamp = (value: number, margin: number) => Math.min(1 - margin, Math.max(margin, value))
|
||||
const x = (event.clientX - drag.grabX - rect.left) / rect.width
|
||||
const y = (event.clientY - drag.grabY - rect.top) / rect.height
|
||||
const attackDrag = Boolean(attackWindow.value && myUntappedCreatures.value.some(card => card.id === drag.cardId))
|
||||
dragPreview.value = {
|
||||
cardId: drag.cardId,
|
||||
x: clamp((event.clientX - drag.grabX - rect.left) / rect.width, marginX),
|
||||
y: clamp((event.clientY - drag.grabY - rect.top) / rect.height, marginY),
|
||||
x: attackDrag ? x : clamp(x, marginX),
|
||||
y: attackDrag ? y : clamp(y, marginY),
|
||||
}
|
||||
attackDropId.value = attackDropTargetAt(drag.cardId, event.clientX, event.clientY)
|
||||
}
|
||||
|
||||
/** Topmost opponent panel under the pointer, ignoring the card being dragged. */
|
||||
function attackDropTargetAt(cardId: string, x: number, y: number): string {
|
||||
if (!attackWindow.value || !myUntappedCreatures.value.some(card => card.id === cardId)) return ''
|
||||
for (const element of document.elementsFromPoint(x, y)) {
|
||||
const panel = element.closest<HTMLElement>('.player')
|
||||
const id = panel?.dataset.playerId
|
||||
if (id && opponents.value.some(player => player.id === id)) return id
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
async function endCardMove(event: PointerEvent) {
|
||||
@@ -692,16 +741,30 @@ async function endCardMove(event: PointerEvent) {
|
||||
cardDrag = null
|
||||
const preview = dragPreview.value
|
||||
dragPreview.value = null
|
||||
const attackTarget = attackDropTargetAt(drag.cardId, event.clientX, event.clientY)
|
||||
attackDropId.value = ''
|
||||
if (!drag.moved || !preview) return
|
||||
|
||||
// The click that follows a drag must not open the ability menu.
|
||||
suppressCardClick = drag.cardId
|
||||
setTimeout(() => { suppressCardClick = '' }, 0)
|
||||
|
||||
if (attackTarget) {
|
||||
if (!selectedAttackers.value.includes(drag.cardId)) selectedAttackers.value.push(drag.cardId)
|
||||
attackTargets[drag.cardId] = attackTarget
|
||||
return
|
||||
}
|
||||
|
||||
const target = myBattlefield.value.find(card => card.id === drag.cardId)
|
||||
if (!target) return
|
||||
const rect = drag.board.getBoundingClientRect()
|
||||
const marginX = Math.min(0.49, drag.halfWidth / rect.width)
|
||||
const marginY = Math.min(0.49, drag.halfHeight / rect.height)
|
||||
const previous = target.position
|
||||
target.position = { x: preview.x, y: preview.y }
|
||||
target.position = {
|
||||
x: Math.min(1 - marginX, Math.max(marginX, preview.x)),
|
||||
y: Math.min(1 - marginY, Math.max(marginY, preview.y)),
|
||||
}
|
||||
const ok = await act({
|
||||
type: 'move_permanent',
|
||||
cardId: drag.cardId,
|
||||
@@ -714,18 +777,21 @@ function cancelCardMove(event: PointerEvent) {
|
||||
if (cardDrag?.pointerId !== event.pointerId) return
|
||||
cardDrag = null
|
||||
dragPreview.value = null
|
||||
attackDropId.value = ''
|
||||
}
|
||||
|
||||
function openCast(card: CardView) {
|
||||
castCardId.value = card.id
|
||||
selectedTarget.value = ''
|
||||
castX.value = 0
|
||||
castOverload.value = false
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
function cancelCast() {
|
||||
castCardId.value = ''
|
||||
selectedTarget.value = ''
|
||||
castOverload.value = false
|
||||
}
|
||||
|
||||
async function confirmCast() {
|
||||
@@ -736,6 +802,7 @@ async function confirmCast() {
|
||||
cardId: castCard.value.id,
|
||||
targets: target ? [target] : [],
|
||||
x: castX.value,
|
||||
overload: castOverload.value,
|
||||
})
|
||||
if (ok) cancelCast()
|
||||
}
|
||||
@@ -750,19 +817,34 @@ async function activateFromMenu(card: CardView, ability: AbilityView) {
|
||||
}
|
||||
|
||||
async function chooseSearchCard(card: CardView) {
|
||||
if (busy.value || !searchLegalIds.value.has(card.id)) return
|
||||
await act({ type: 'choose_search', cardId: card.id })
|
||||
}
|
||||
|
||||
async function chooseCreatureType(type: string) {
|
||||
if (busy.value) return
|
||||
await act({ type: 'choose_type', choice: type })
|
||||
}
|
||||
|
||||
async function attack() {
|
||||
if (!selectedAttackers.value.length) return
|
||||
const ok = await act({
|
||||
type: 'attack',
|
||||
attackers: selectedAttackers.value.map(attackerId => ({
|
||||
attackerId,
|
||||
defenderId: attackTargets[attackerId] || defenderId.value,
|
||||
})),
|
||||
})
|
||||
if (ok) selectedAttackers.value = []
|
||||
const attackers = selectedAttackers.value
|
||||
.filter(attackerId => attackTargets[attackerId])
|
||||
.map(attackerId => ({ attackerId, defenderId: attackTargets[attackerId] }))
|
||||
if (!attackers.length) return
|
||||
const ok = await act({ type: 'attack', attackers })
|
||||
if (ok) {
|
||||
selectedAttackers.value = []
|
||||
for (const key of Object.keys(attackTargets)) delete attackTargets[key]
|
||||
}
|
||||
}
|
||||
|
||||
function removeAttacker(cardId: string) {
|
||||
selectedAttackers.value = selectedAttackers.value.filter(id => id !== cardId)
|
||||
delete attackTargets[cardId]
|
||||
}
|
||||
|
||||
function attackerName(cardId: string): string {
|
||||
return myUntappedCreatures.value.find(card => card.id === cardId)?.name ?? 'Creature'
|
||||
}
|
||||
|
||||
async function declareBlocks() {
|
||||
@@ -887,10 +969,25 @@ function resetAnimations() {
|
||||
|
||||
watch(() => game.value?.step, () => {
|
||||
selectedAttackers.value = []
|
||||
attackDropId.value = ''
|
||||
for (const key of Object.keys(attackTargets)) delete attackTargets[key]
|
||||
for (const key of Object.keys(blockSelection)) delete blockSelection[key]
|
||||
})
|
||||
|
||||
watch(() => Boolean(pendingSearch.value), async active => {
|
||||
if (!active) return
|
||||
searchFilter.value = ''
|
||||
await nextTick()
|
||||
searchInput.value?.focus()
|
||||
})
|
||||
|
||||
watch(() => pendingChoice.value?.sourceId, async sourceId => {
|
||||
if (!sourceId) return
|
||||
choiceFilter.value = ''
|
||||
await nextTick()
|
||||
choiceInput.value?.focus()
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
window.addEventListener('keydown', onKeydown)
|
||||
decks.value = (await loadDecks(apiBase)).sort((a, b) => b.updatedAt - a.updatedAt)
|
||||
@@ -1065,11 +1162,14 @@ onUnmounted(() => {
|
||||
v-for="(player, playerIndex) in state.players"
|
||||
:key="player.id"
|
||||
class="panel player"
|
||||
:data-player-id="player.id"
|
||||
:class="{
|
||||
current: game.activePlayer === player.id,
|
||||
dead: player.lost,
|
||||
'anim-hit': playerHitAnimations[player.id],
|
||||
'anim-heal': playerHealAnimations[player.id],
|
||||
'attack-ready': draggingAttackerId && player.id !== viewerId && !player.lost,
|
||||
'drop-hover': attackDropId === player.id,
|
||||
}"
|
||||
>
|
||||
<header class="player-head">
|
||||
@@ -1166,6 +1266,7 @@ onUnmounted(() => {
|
||||
positioned: isPositioned(card),
|
||||
dragging: dragPreview?.cardId === card.id,
|
||||
movable: card.controller === viewerId,
|
||||
'pending-attack': attackTargets[card.id],
|
||||
'anim-enter': cardEnterAnimations[card.id],
|
||||
'anim-damage': cardDamageAnimations[card.id],
|
||||
'anim-attack': cardAttackAnimations[card.id],
|
||||
@@ -1185,7 +1286,16 @@ onUnmounted(() => {
|
||||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||||
<GameCard :oracle-id="card.oracleId" :name="card.name" :tapped="card.tapped">
|
||||
<span v-if="card.isCommander" class="overlay-tag commander" title="Commander">♛</span>
|
||||
<span v-if="card.attacking" class="overlay-tag attacking" title="Attacking">⚔</span>
|
||||
<span
|
||||
v-if="card.chosenType"
|
||||
class="overlay-tag chosen"
|
||||
:title="`Chosen creature type: ${card.chosenType}`"
|
||||
>{{ card.chosenType }}</span>
|
||||
<span
|
||||
v-if="card.attacking || attackTargets[card.id]"
|
||||
class="overlay-tag attacking"
|
||||
:title="`Attacking ${playerName(card.attacking || attackTargets[card.id])}`"
|
||||
>⚔</span>
|
||||
<span v-if="card.damage" class="overlay-tag card-damage" title="Damage">−{{ card.damage }}</span>
|
||||
<span v-if="card.power !== undefined" class="stats">{{ card.power }}/{{ card.toughness }}</span>
|
||||
<div v-if="Object.keys(card.counters).length" class="overlay-counters">
|
||||
@@ -1228,6 +1338,28 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="stack-pile" :class="{ empty: !game.stack.length }" aria-live="polite" aria-label="Stack">
|
||||
<h2 v-if="game.stack.length" class="stack-heading">
|
||||
Stack <span class="muted">{{ game.stack.length }}</span>
|
||||
</h2>
|
||||
<TransitionGroup name="stack" tag="ol" class="stack-pile-list">
|
||||
<li
|
||||
v-for="(item, index) in [...game.stack].reverse()"
|
||||
:key="item.id"
|
||||
class="stack-card"
|
||||
:class="[`kind-${item.kind}`, { 'is-top': index === 0 }]"
|
||||
:style="{ zIndex: game.stack.length - index }"
|
||||
:title="item.label"
|
||||
>
|
||||
<span class="stack-glyph" aria-hidden="true">{{ item.kind === 'spell' ? '✦' : '⟳' }}</span>
|
||||
<span class="stack-copy">
|
||||
<strong><SymbolText :text="item.label" /></strong>
|
||||
<span class="muted">{{ playerName(item.controller) }}</span>
|
||||
</span>
|
||||
</li>
|
||||
</TransitionGroup>
|
||||
</section>
|
||||
|
||||
<section class="hand-panel">
|
||||
<div class="row wrap hand-head">
|
||||
<h2>Your hand</h2>
|
||||
@@ -1312,33 +1444,16 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="pendingSearch" class="panel side search-panel">
|
||||
<div class="row">
|
||||
<h2 class="grow">Search your library</h2>
|
||||
<span v-if="pendingSearch.remaining > 1" class="tag">{{ pendingSearch.remaining }} left</span>
|
||||
</div>
|
||||
<p v-if="pendingSearch.player === viewerId" class="muted">
|
||||
Choose a card to put {{ searchDestination }}.
|
||||
<section v-if="pendingSearch && pendingSearch.player !== viewerId" class="panel side search-panel">
|
||||
<h2>Search</h2>
|
||||
<p class="muted">{{ playerName(pendingSearch.player) }} is searching their library.</p>
|
||||
</section>
|
||||
|
||||
<section v-if="pendingChoice && pendingChoice.player !== viewerId" class="panel side search-panel">
|
||||
<h2>Choose a type</h2>
|
||||
<p class="muted">
|
||||
{{ playerName(pendingChoice.player) }} is choosing a creature type for {{ pendingChoice.sourceName }}.
|
||||
</p>
|
||||
<p v-else class="muted">
|
||||
{{ playerName(pendingSearch.player) }} is searching their library.
|
||||
</p>
|
||||
<div v-if="pendingSearch.cards.length" class="search-picks">
|
||||
<button
|
||||
v-for="card in pendingSearch.cards"
|
||||
:key="card.id"
|
||||
type="button"
|
||||
class="search-pick"
|
||||
:disabled="busy"
|
||||
:title="`Choose ${card.name}`"
|
||||
@click="chooseSearchCard(card)"
|
||||
>
|
||||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||||
<GameCard :oracle-id="card.oracleId" :name="card.name" />
|
||||
</CardHover>
|
||||
<span class="search-name">{{ card.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="castCard" class="panel side cast-panel">
|
||||
@@ -1351,6 +1466,10 @@ onUnmounted(() => {
|
||||
<ManaCost v-if="castCard.manaCost" :cost="castCard.manaCost" />
|
||||
</p>
|
||||
<p v-if="castCard.oracleText" class="oracle small"><SymbolText :text="castCard.oracleText" /></p>
|
||||
<label v-if="overloadAbility" class="row">
|
||||
<input v-model="castOverload" type="checkbox">
|
||||
<span>{{ overloadAbility.text ?? 'Overload' }}</span>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="muted">Target</span>
|
||||
<select v-model="selectedTarget">
|
||||
@@ -1368,26 +1487,21 @@ onUnmounted(() => {
|
||||
|
||||
<section v-if="attackWindow" class="panel side">
|
||||
<h2>Attack</h2>
|
||||
<p class="muted">Choose creatures and who each one attacks.</p>
|
||||
<div v-for="card in myUntappedCreatures" :key="card.id" class="check-row">
|
||||
<input v-model="selectedAttackers" type="checkbox" :value="card.id">
|
||||
<span class="grow">
|
||||
{{ card.name }} <span class="muted">{{ card.power }}/{{ card.toughness }}</span>
|
||||
</span>
|
||||
<select v-if="selectedAttackers.includes(card.id)" v-model="attackTargets[card.id]">
|
||||
<option v-for="player in opponents" :key="player.id" :value="player.id">
|
||||
{{ player.name }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="muted">Drag an untapped creature onto a player to attack them.</p>
|
||||
<div v-if="selectedAttackers.length" class="attack-list">
|
||||
<button
|
||||
v-for="attackerId in selectedAttackers"
|
||||
:key="attackerId"
|
||||
type="button"
|
||||
class="attack-pick"
|
||||
:title="`Remove ${attackerName(attackerId)} from the attack`"
|
||||
@click="removeAttacker(attackerId)"
|
||||
>
|
||||
<span>{{ attackerName(attackerId) }}</span>
|
||||
<span class="muted">⚔ {{ playerName(attackTargets[attackerId]) }} ✕</span>
|
||||
</button>
|
||||
</div>
|
||||
<label class="field">
|
||||
<span class="muted">Default defender</span>
|
||||
<select v-model="defenderId">
|
||||
<option v-for="player in opponents" :key="player.id" :value="player.id">
|
||||
{{ player.name }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<p v-else class="muted">No attackers chosen yet.</p>
|
||||
<button type="button" :disabled="busy || !selectedAttackers.length" @click="attack">
|
||||
Attack with {{ selectedAttackers.length }}
|
||||
</button>
|
||||
@@ -1410,15 +1524,6 @@ onUnmounted(() => {
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section v-if="game.stack.length" class="panel side"> <h2>Stack</h2>
|
||||
<ol class="stack-list">
|
||||
<li v-for="item in [...game.stack].reverse()" :key="item.id">
|
||||
<strong><SymbolText :text="item.label" /></strong>
|
||||
<span class="muted">{{ playerName(item.controller) }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section v-if="showLog" class="panel side log-panel">
|
||||
<h2>Log</h2>
|
||||
<ul class="log-list">
|
||||
@@ -1445,6 +1550,83 @@ onUnmounted(() => {
|
||||
>End turn</button>
|
||||
</div>
|
||||
|
||||
<Teleport to="body">
|
||||
<div v-if="pendingChoice?.player === viewerId" class="search-backdrop">
|
||||
<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>
|
||||
<p class="muted">{{ pendingChoice.sourceName }} enters.</p>
|
||||
</div>
|
||||
<span 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>
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
|
||||
<Teleport to="body">
|
||||
<div v-if="pendingSearch?.player === viewerId" class="search-backdrop">
|
||||
<section class="search-modal" role="dialog" aria-modal="true" aria-labelledby="search-title">
|
||||
<header class="search-head">
|
||||
<div class="grow">
|
||||
<h2 id="search-title">Search your library</h2>
|
||||
<p class="muted">
|
||||
Choose a card to put {{ searchDestination }}.
|
||||
<template v-if="pendingSearch.remaining > 1">({{ pendingSearch.remaining }} picks left)</template>
|
||||
</p>
|
||||
</div>
|
||||
<span class="tag">{{ searchLegalIds.size }} can be chosen</span>
|
||||
</header>
|
||||
<input
|
||||
ref="searchInput"
|
||||
v-model="searchFilter"
|
||||
class="search-filter"
|
||||
type="search"
|
||||
placeholder="Search by card name"
|
||||
autocomplete="off"
|
||||
>
|
||||
<p v-if="!filteredSearchLibrary.length" class="muted">No cards match “{{ searchFilter }}”.</p>
|
||||
<div v-else class="search-library">
|
||||
<button
|
||||
v-for="card in filteredSearchLibrary"
|
||||
:key="card.id"
|
||||
type="button"
|
||||
class="search-card"
|
||||
:class="{ legal: searchLegalIds.has(card.id) }"
|
||||
:disabled="!searchLegalIds.has(card.id) || busy"
|
||||
:title="searchLegalIds.has(card.id) ? `Choose ${card.name}` : `${card.name} does not match this search`"
|
||||
@click="chooseSearchCard(card)"
|
||||
>
|
||||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||||
<GameCard :oracle-id="card.oracleId" :name="card.name" />
|
||||
</CardHover>
|
||||
<span class="search-name">{{ card.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="muted small">Cards that do not match this search are dimmed.</p>
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
|
||||
<Teleport to="body">
|
||||
<template v-if="menuOpen">
|
||||
<div class="menu-backdrop" @pointerdown="menuOpen = false" />
|
||||
@@ -1735,6 +1917,16 @@ onUnmounted(() => {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.player.attack-ready {
|
||||
border-style: dashed;
|
||||
border-color: var(--bad);
|
||||
}
|
||||
|
||||
.player.drop-hover {
|
||||
border-color: var(--bad);
|
||||
box-shadow: inset 0 0 0 3px var(--bad), 0 0 24px rgb(224 122 122 / 35%);
|
||||
}
|
||||
|
||||
.player.dead {
|
||||
opacity: 0.6;
|
||||
}
|
||||
@@ -2077,6 +2269,12 @@ onUnmounted(() => {
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.perm.pending-attack .game-card {
|
||||
border-radius: 6px;
|
||||
outline: 2px solid var(--bad);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.perm:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
@@ -2114,6 +2312,16 @@ onUnmounted(() => {
|
||||
color: var(--warn);
|
||||
}
|
||||
|
||||
.overlay-tag.chosen {
|
||||
bottom: 0.2rem;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
max-width: 80%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.overlay-tag.attacking {
|
||||
top: 0.2rem;
|
||||
right: 0.2rem;
|
||||
@@ -2268,24 +2476,76 @@ onUnmounted(() => {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.search-picks {
|
||||
.search-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 70;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
|
||||
gap: 0.4rem;
|
||||
place-items: center;
|
||||
padding: 1rem;
|
||||
background: rgb(0 0 0 / 65%);
|
||||
}
|
||||
|
||||
.search-pick {
|
||||
.search-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
width: min(60rem, 100%);
|
||||
max-height: calc(100vh - 2rem);
|
||||
padding: 1rem;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.search-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.search-head h2,
|
||||
.search-head p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.search-filter {
|
||||
width: 100%;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.search-library {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(6.2rem, 1fr));
|
||||
gap: 0.5rem;
|
||||
min-height: 0;
|
||||
flex: 1 1 auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding: 0.25rem;
|
||||
border-color: transparent;
|
||||
opacity: 0.35;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.search-pick:hover:not(:disabled) {
|
||||
.search-card.legal {
|
||||
border-color: var(--line);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.search-card.legal:hover:not(:disabled) {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.search-card:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.search-name {
|
||||
overflow: hidden;
|
||||
font-size: 0.72rem;
|
||||
@@ -2293,18 +2553,37 @@ onUnmounted(() => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.check-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-size: 0.85rem;
|
||||
.choice-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
|
||||
gap: 0.35rem;
|
||||
min-height: 0;
|
||||
flex: 1 1 auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.check-row select {
|
||||
width: auto;
|
||||
flex: 0 0 auto;
|
||||
font-size: 0.75rem;
|
||||
padding: 0.15rem 0.3rem;
|
||||
.choice-option {
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.attack-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.attack-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
font-size: 0.8rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.attack-pick:hover {
|
||||
border-color: var(--bad);
|
||||
}
|
||||
|
||||
.block-row {
|
||||
@@ -2465,17 +2744,134 @@ onUnmounted(() => {
|
||||
transform: translateY(2.5em) scale(0.7);
|
||||
}
|
||||
|
||||
.stack-list {
|
||||
margin: 0;
|
||||
padding-left: 1.2rem;
|
||||
.stack-pile {
|
||||
position: absolute;
|
||||
top: 5rem;
|
||||
right: 24rem;
|
||||
z-index: 22;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
font-size: 0.85rem;
|
||||
gap: 0.35rem;
|
||||
width: min(15rem, calc(100% - 2rem));
|
||||
pointer-events: none;
|
||||
transition: opacity 160ms ease;
|
||||
}
|
||||
|
||||
.stack-list > li > span {
|
||||
display: block;
|
||||
.stack-pile.empty {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.stack-heading {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
align-items: baseline;
|
||||
margin: 0;
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.stack-pile-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.stack-pile-list > li + li {
|
||||
margin-top: -2.9rem;
|
||||
}
|
||||
|
||||
.stack-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
min-height: 4.4rem;
|
||||
padding: 0.5rem 0.65rem;
|
||||
border: 1px solid #3c4d64;
|
||||
border-left: 3px solid var(--accent);
|
||||
border-radius: 8px;
|
||||
background: #141a24;
|
||||
box-shadow: 0 8px 18px rgb(0 0 0 / 50%);
|
||||
transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 220ms ease;
|
||||
}
|
||||
|
||||
.stack-card.kind-ability {
|
||||
border-left-color: #c9a86a;
|
||||
}
|
||||
|
||||
.stack-card.is-top {
|
||||
border-color: rgb(122 162 247 / 65%);
|
||||
box-shadow:
|
||||
0 0 0 1px rgb(122 162 247 / 25%),
|
||||
0 0 20px rgb(122 162 247 / 25%),
|
||||
0 10px 24px rgb(0 0 0 / 55%);
|
||||
}
|
||||
|
||||
.stack-card.kind-ability.is-top {
|
||||
border-color: rgb(201 168 106 / 60%);
|
||||
box-shadow:
|
||||
0 0 0 1px rgb(201 168 106 / 22%),
|
||||
0 0 20px rgb(201 168 106 / 20%),
|
||||
0 10px 24px rgb(0 0 0 / 55%);
|
||||
}
|
||||
|
||||
.stack-glyph {
|
||||
flex: 0 0 auto;
|
||||
font-size: 1.05rem;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.kind-ability .stack-glyph {
|
||||
color: #c9a86a;
|
||||
}
|
||||
|
||||
.stack-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
min-width: 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.stack-copy strong {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
font-size: 0.8rem;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.stack-copy .muted {
|
||||
overflow: hidden;
|
||||
font-size: 0.68rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stack-enter-active {
|
||||
transition: transform 300ms cubic-bezier(0.2, 0.9, 0.25, 1.15), opacity 200ms ease, filter 300ms ease;
|
||||
}
|
||||
|
||||
.stack-leave-active {
|
||||
transition: transform 200ms ease-in, opacity 180ms ease-in;
|
||||
}
|
||||
|
||||
.stack-enter-from {
|
||||
opacity: 0;
|
||||
filter: brightness(1.9);
|
||||
transform: translate(4rem, -1.2rem) rotate(6deg) scale(0.82);
|
||||
}
|
||||
|
||||
.stack-leave-to {
|
||||
opacity: 0;
|
||||
transform: translate(3rem, -0.8rem) rotate(3deg) scale(0.9);
|
||||
}
|
||||
|
||||
.stack-move {
|
||||
transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
|
||||
.log-panel {
|
||||
@@ -2514,6 +2910,12 @@ onUnmounted(() => {
|
||||
.mana-burst {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.stack-enter-active,
|
||||
.stack-leave-active,
|
||||
.stack-move {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
@@ -2589,6 +2991,15 @@ onUnmounted(() => {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.stack-pile {
|
||||
position: static;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.stack-pile.empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hand-panel {
|
||||
position: static;
|
||||
width: auto;
|
||||
|
||||
@@ -83,6 +83,21 @@ export async function deleteDeck(apiBase: string, id: string): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
export async function shareDeck(apiBase: string, id: string): Promise<string> {
|
||||
const { token } = await $fetch<{ token: string }>(
|
||||
`${apiBase}/me/decks/${encodeURIComponent(id)}/share`,
|
||||
{ method: 'POST', headers: authHeaders() },
|
||||
)
|
||||
return token
|
||||
}
|
||||
|
||||
export async function loadSharedDeck(apiBase: string, token: string): Promise<SavedDeck> {
|
||||
const { deck } = await $fetch<{ deck: SavedDeck }>(
|
||||
`${apiBase}/decks/share/${encodeURIComponent(token)}`,
|
||||
)
|
||||
return deck
|
||||
}
|
||||
|
||||
export function isBasicLand(card: DeckCard): boolean {
|
||||
return /\bbasic\b/i.test(card.typeLine) && /\bland\b/i.test(card.typeLine)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user