import * as React from 'react' import type { Action, ActionHash } from '@lastres/action' import type { TalkNPCs, TalkNPC } from '@lastres/talk-npc' import OutputPacketExecuteAction from '@lastres/output-packet/execute_action' import OutputPacketTalk from '@lastres/output-packet/talk'; import PresentationItem from '@lastres/components/presentation-item' import Presentation from '@lastres/components/presentation' export interface BottomPanelProps { websocket: WebSocket | null actionHash: ActionHash | null talkNPCs: TalkNPCs | null } export interface Style { background?: string } export default function BottomPanel (props: BottomPanelProps): JSX.Element { const actionHash = props.actionHash function printListActions(): JSX.Element { if (actionHash === null) { return <>> } const listOfActionKeys = Object.keys(actionHash).sort((a, b) => { const isDisabledComparisionValue: number = +actionHash[a].is_disabled - +actionHash[b].is_disabled if (isDisabledComparisionValue !== 0) { return isDisabledComparisionValue } if (actionHash[a].name < actionHash[b].name) { return -1 } if (actionHash[a].name > actionHash[b].name) { return 1 } return 0 }) function printDisabledReason (action: Action): JSX.Element { if (!action.is_disabled || action.disabled_reason === null) { return <>> } return (
{action.disabled_reason}
) } return <>Acciones disponibles.
{ listOfActionKeys.map((key) => { const style: Style = {} const action = actionHash[key] if (action.is_disabled) { style.background = 'lightgray' } function onClick (): void { if (action.is_disabled) { return } if (props.websocket !== null) { new OutputPacketExecuteAction(action.identifier) .send(props.websocket) } } return{action.name}
{ printDisabledReason(action) } }) } > } function printAvatar (npc: TalkNPC): JSX.Element { if (npc.icon === undefined) { return <>> } returnNo hay nadie para hablar ahora.
> } return ( <>Disponible para hablar:
{ Object.keys(npcs).map((identifier) => { const npc = npcs[identifier] return{npc.name}