LasTres/js-src/components/talk-npcs.tsx

42 lines
1.3 KiB
TypeScript

import * as React from 'react'
import type { TalkNPCs } from '@lastres/talk-npc'
import type { StateGame, OnWordSelectCallback } from '@lastres/components/game'
import TalkNPCComponent from '@lastres/components/talk-npc'
export interface TalkNPCsComponentProps {
talkNPCs: TalkNPCs | null
websocket: WebSocket | null
setStateGame: (set: StateGame) => void
setOnWordSelect: (set: OnWordSelectCallback) => void
}
export default function TalkNPCsComponent (props: TalkNPCsComponentProps): JSX.Element {
const npcs = props.talkNPCs
if (npcs === null) {
return <></>
}
if (Object.keys(npcs).length < 1) {
return <>
<p>No hay nadie para hablar ahora.</p>
</>
}
return (
<>
<p>Disponible para hablar:</p>
{
Object.keys(npcs).map((identifier) => {
const npc = npcs[identifier]
return (
<TalkNPCComponent key={identifier}
npc={npc}
websocket={props.websocket}
setStateGame={props.setStateGame}
setOnWordSelect={props.setOnWordSelect}/>
)
})
}
</>
)
}