Make right the front.
This commit is contained in:
@@ -8,10 +8,11 @@ interface Props {
|
||||
send: (msg: ClientMessage) => void
|
||||
}
|
||||
|
||||
// ArrangePhase lets the player order their deck for battle. Leftmost card
|
||||
// fights first; food cards buff the next pet to their right... i.e. foods
|
||||
// apply "down" to the next pet later in the order. Drag cards or use the
|
||||
// arrow buttons to reorder, then lock in.
|
||||
// ArrangePhase lets the player order their deck for battle. Rightmost card
|
||||
// fights first; food cards buff the next pet to their left... i.e. foods
|
||||
// apply to the next pet later in the play order. Internally `order` stays in
|
||||
// play order (index 0 fights first) to match the backend; we only reverse for
|
||||
// display. Drag cards or use the arrow buttons to reorder, then lock in.
|
||||
export function ArrangePhase({ view, you, send }: Props) {
|
||||
const [order, setOrder] = useState<Card[]>(you.deck ?? [])
|
||||
const dragIndex = useRef<number | null>(null)
|
||||
@@ -79,55 +80,58 @@ export function ArrangePhase({ view, you, send }: Props) {
|
||||
<span className="status-hot">Arrange your battle line</span>
|
||||
</div>
|
||||
<p className="hint">
|
||||
The <strong>leftmost</strong> card fights first. Food cards power up the
|
||||
next pet to their <strong>right</strong>.
|
||||
The <strong>rightmost</strong> card fights first. Food cards power up the
|
||||
next pet to their <strong>left</strong>.
|
||||
{trailingFoods > 0 && (
|
||||
<span className="warn-text">
|
||||
{' '}
|
||||
⚠️ {trailingFoods} food card{trailingFoods > 1 ? 's' : ''} at the end
|
||||
will be wasted!
|
||||
⚠️ {trailingFoods} food card{trailingFoods > 1 ? 's' : ''} on the far
|
||||
left will be wasted!
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
|
||||
<div className="arrange-row">
|
||||
<div className="arrange-marker">⚔️ first</div>
|
||||
{order.map((c, i) => (
|
||||
<div
|
||||
key={c.id}
|
||||
className="arrange-card"
|
||||
draggable
|
||||
onDragStart={() => (dragIndex.current = i)}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault()
|
||||
if (dragIndex.current !== null && dragIndex.current !== i) {
|
||||
move(dragIndex.current, i)
|
||||
dragIndex.current = i
|
||||
}
|
||||
}}
|
||||
onDragEnd={() => (dragIndex.current = null)}
|
||||
>
|
||||
<CardView card={c} bonus={bonuses.get(c.id) ?? 0} />
|
||||
<div className="arrange-arrows">
|
||||
<button
|
||||
className="btn btn-ghost btn-sm"
|
||||
disabled={i === 0}
|
||||
onClick={() => move(i, i - 1)}
|
||||
aria-label="move earlier"
|
||||
>
|
||||
◀
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-ghost btn-sm"
|
||||
disabled={i === order.length - 1}
|
||||
onClick={() => move(i, i + 1)}
|
||||
aria-label="move later"
|
||||
>
|
||||
▶
|
||||
</button>
|
||||
{order
|
||||
.map((c, i) => ({ c, i }))
|
||||
.reverse()
|
||||
.map(({ c, i }) => (
|
||||
<div
|
||||
key={c.id}
|
||||
className="arrange-card"
|
||||
draggable
|
||||
onDragStart={() => (dragIndex.current = i)}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault()
|
||||
if (dragIndex.current !== null && dragIndex.current !== i) {
|
||||
move(dragIndex.current, i)
|
||||
dragIndex.current = i
|
||||
}
|
||||
}}
|
||||
onDragEnd={() => (dragIndex.current = null)}
|
||||
>
|
||||
<CardView card={c} bonus={bonuses.get(c.id) ?? 0} />
|
||||
<div className="arrange-arrows">
|
||||
<button
|
||||
className="btn btn-ghost btn-sm"
|
||||
disabled={i === order.length - 1}
|
||||
onClick={() => move(i, i + 1)}
|
||||
aria-label="move left"
|
||||
>
|
||||
◀
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-ghost btn-sm"
|
||||
disabled={i === 0}
|
||||
onClick={() => move(i, i - 1)}
|
||||
aria-label="move right"
|
||||
>
|
||||
▶
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
))}
|
||||
<div className="arrange-marker">⚔️ first</div>
|
||||
</div>
|
||||
|
||||
<div className="actions">
|
||||
|
||||
Reference in New Issue
Block a user