Let players dismiss completed duel feedback
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { apiRequest } from '../../lib/api';
|
||||
import { getCardDisplay, isJoker, displayName, playerName as lookupName, cardTooltipHtml, obstacleTable } from '../../lib/cards';
|
||||
import { tooltip } from '../../lib/tooltip';
|
||||
import ObstacleItem from './ObstacleItem.svelte';
|
||||
|
||||
export let state;
|
||||
export let completedDuels = [];
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let error = '';
|
||||
let taxTargetId = '';
|
||||
@@ -17,7 +20,6 @@
|
||||
|
||||
$: hand = state.player.hand_cards ? JSON.parse(state.player.hand_cards) : [];
|
||||
$: openChallenges = (state.challenges || []).filter(c => c.status === 'open');
|
||||
$: completedDuels = (state.challenges || []).filter(c => c.challenge_type === 'pvp' && ['succeeded', 'failed'].includes(c.status));
|
||||
$: challengedObstacleIds = new Set(openChallenges.flatMap(c => JSON.parse(c.obstacle_ids || '[]')));
|
||||
$: myTaxRequest = openChallenges.find(c => c.tax_state === 'requested' && c.tax_target_id === state.player.id) || null;
|
||||
$: myPvpDefense = openChallenges.find(c => c.challenge_type === 'pvp' && c.acting_player_id === state.player.id) || null;
|
||||
@@ -185,10 +187,13 @@
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<!-- Results remain available until the next scene, including after a reload. -->
|
||||
<!-- Each player clears their own result feedback after reading it. -->
|
||||
{#each completedDuels as ch (ch.id)}
|
||||
<div class="challenge-item duel-result">
|
||||
<h4>⚔️ Duel: {playerName(ch.challenger_player_id)} vs {playerName(ch.target_player_id)}</h4>
|
||||
<div class="challenge-head">
|
||||
<h4>⚔️ Duel: {playerName(ch.challenger_player_id)} vs {playerName(ch.target_player_id)}</h4>
|
||||
<button class="btn btn-secondary btn-small" title="Dismiss this result for you" on:click={() => dispatch('dismissDuel', ch.id)}>Dismiss</button>
|
||||
</div>
|
||||
<p class="duel-outcome">
|
||||
{ch.status === 'succeeded' ? '✓' : '✕'}
|
||||
<strong>{playerName(ch.acting_player_id)} {ch.status === 'succeeded' ? 'won the defense' : 'lost the defense'}.</strong>
|
||||
|
||||
Reference in New Issue
Block a user