import { observer } from "mobx-react"; import React, { Component, ReactNode } from "react"; import { NpcType } from "../../domain"; import { quest_editor_store } from "../../stores/QuestEditorStore"; import "./QuestInfoComponent.css"; import { DisabledTextComponent } from "../DisabledTextComponent"; @observer export class QuestInfoComponent extends Component { render(): ReactNode { const quest = quest_editor_store.current_quest; let body: ReactNode; 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} ); }); body = ( <>
Name: {quest.name}
Episode: {episode}
{quest.short_description}
{quest.long_description}
{npc_count_rows}
NPC Counts
); } else { body = No quest loaded.; } return (
{body}
); } }