import React, { CSSProperties } from 'react'; import { NpcType, Quest } from '../domain'; const container_style: CSSProperties = { width: 280, padding: 10, display: 'flex', flexDirection: 'column' }; const table_style: CSSProperties = { borderCollapse: 'collapse', width: '100%' }; const table_header_style: CSSProperties = { textAlign: 'right', paddingRight: 5 }; const description_style: CSSProperties = { whiteSpace: 'pre-wrap', margin: '3px 0 3px 0' }; const npc_counts_container_style: CSSProperties = { overflow: 'auto' }; export function QuestInfoComponent({ quest }: { quest?: Quest }) { if (quest) { const episode = quest.episode === 4 ? 'IV' : (quest.episode === 2 ? 'II' : 'I'); const npc_counts = new Map(); for (const npc of quest.npcs) { const val = npc_counts.get(npc.type) || 0; npc_counts.set(npc.type, val + 1); } const extra_canadines = (npc_counts.get(NpcType.Canane) || 0) * 8; // Sort by type ID. const sorted_npc_counts = [...npc_counts].sort((a, b) => a[0].id - b[0].id); const npc_count_rows = sorted_npc_counts.map(([npc_type, count]) => { const extra = npc_type === NpcType.Canadine ? extra_canadines : 0; return ( {npc_type.name}: {count + extra} ); }); return (
Name:{quest.name}
Episode:{episode}
{quest.shortDescription}
{quest.longDescription}
{npc_count_rows}
NPC Counts
); } else { return
; } }