diff --git a/Build.PL b/Build.PL index 5cdb5f6..0b32b6f 100755 --- a/Build.PL +++ b/Build.PL @@ -27,6 +27,7 @@ my $build = Module::Build->new( 'DateTime::Format::Pg' => 0, 'DateTime::Format::ISO8601::Format' => 0, 'Test::Most' => 0, + 'Carp::Always' => 0, }, ); $build->create_build_script; diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index f3f6247..482cc0c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,4 +12,4 @@ perl Build.PL && \ ./Build installdeps && \ npx webpack && \ bash build_styles.sh && \ -perl script/las_tres daemon +perl -MCarp::Always script/las_tres daemon diff --git a/js-src/components/bottom-panel.tsx b/js-src/components/bottom-panel.tsx index f6ae9d6..e791a79 100644 --- a/js-src/components/bottom-panel.tsx +++ b/js-src/components/bottom-panel.tsx @@ -1,8 +1,8 @@ import * as React from 'react' import type { Action, ActionHash } from '@lastres/action' -import type { TalkNPCs } from '@lastres/talk-npc' -import type { StateGame, OnWordSelectCallback } from '@lastres/components/game' +import type { TalkNPCs, TalkNPC } from '@lastres/talk-npc' +import type { StateGame } from '@lastres/components/game' import OutputPacketExecuteAction from '@lastres/output-packet/execute_action' @@ -15,7 +15,7 @@ export interface BottomPanelProps { actionHash: ActionHash | null talkNPCs: TalkNPCs | null setStateGame: (set: StateGame) => void - setOnWordSelect: (set: OnWordSelectCallback) => void + setNPCToSayWord: (set: TalkNPC | null) => void } export interface Style { @@ -88,7 +88,7 @@ export default function BottomPanel (props: BottomPanelProps): JSX.Element { + setNPCToSayWord={props.setNPCToSayWord}/> diff --git a/js-src/components/game.tsx b/js-src/components/game.tsx index 55847bf..a7838df 100644 --- a/js-src/components/game.tsx +++ b/js-src/components/game.tsx @@ -32,8 +32,6 @@ export enum StateGame { SelectingWord, } -export type OnWordSelectCallback = (npc: TalkNPC, word: string) => void - export default function Game (props: GameProps): JSX.Element { const selectedPJ = props.selectedPJ if (selectedPJ === null) { @@ -60,8 +58,8 @@ export default function Game (props: GameProps): JSX.Element { const [remainingFrames, setRemainingFrames] = React.useState(null) const [actionHash, setActionHash] = React.useState(null) const [talkNPCs, setTalkNPCs] = React.useState(null) - const [onWordSelect, setOnWordSelect] = React.useState(null) const [stateGame, setStateGame] = React.useState(StateGame.MainScreen) + const [NPCToSayWord, setNPCToSayWord] = React.useState(null) const [words, setWords] = React.useState(null) const logPresentationRef = React.useRef(null) const websocket = props.websocket @@ -115,7 +113,10 @@ export default function Game (props: GameProps): JSX.Element { }, 300) if (stateGame === StateGame.SelectingWord) { return ( - + ) } if (stateGame === StateGame.MainScreen) { @@ -134,7 +135,7 @@ export default function Game (props: GameProps): JSX.Element { ) diff --git a/js-src/components/talk-npc.tsx b/js-src/components/talk-npc.tsx index cf5a310..f3d979b 100644 --- a/js-src/components/talk-npc.tsx +++ b/js-src/components/talk-npc.tsx @@ -1,7 +1,6 @@ import * as React from 'react' import type { TalkNPC } from '@lastres/talk-npc' -import type { OnWordSelectCallback } from '@lastres/components/game' import { StateGame } from '@lastres/components/game' import OutputPacketTalk from '@lastres/output-packet/talk' @@ -11,7 +10,7 @@ export interface TalkNPCComponentData { websocket: WebSocket | null key: string setStateGame: (set: StateGame) => void - setOnWordSelect: (set: OnWordSelectCallback) => void + setNPCToSayWord: (set: TalkNPC | null) => void } export default function TalkNPCComponent (props: TalkNPCComponentData): JSX.Element { @@ -25,9 +24,7 @@ export default function TalkNPCComponent (props: TalkNPCComponentData): JSX.Elem function onWantToSayWord (): void { props.setStateGame(StateGame.SelectingWord) - props.setOnWordSelect((npc: TalkNPC, word: string) => { - console.log(`Trying to say ${word} to `, props.npc) - }) + props.setNPCToSayWord(npc) } function printAvatar (npc: TalkNPC): JSX.Element { diff --git a/js-src/components/talk-npcs.tsx b/js-src/components/talk-npcs.tsx index e3d70df..3691a6f 100644 --- a/js-src/components/talk-npcs.tsx +++ b/js-src/components/talk-npcs.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import type { TalkNPCs } from '@lastres/talk-npc' -import type { StateGame, OnWordSelectCallback } from '@lastres/components/game' +import type { TalkNPCs, TalkNPC } from '@lastres/talk-npc' +import type { StateGame } from '@lastres/components/game' import TalkNPCComponent from '@lastres/components/talk-npc' @@ -9,7 +9,7 @@ export interface TalkNPCsComponentProps { talkNPCs: TalkNPCs | null websocket: WebSocket | null setStateGame: (set: StateGame) => void - setOnWordSelect: (set: OnWordSelectCallback) => void + setNPCToSayWord: (set: TalkNPC | null) => void } export default function TalkNPCsComponent (props: TalkNPCsComponentProps): JSX.Element { const npcs = props.talkNPCs @@ -32,7 +32,7 @@ export default function TalkNPCsComponent (props: TalkNPCsComponentProps): JSX.E npc={npc} websocket={props.websocket} setStateGame={props.setStateGame} - setOnWordSelect={props.setOnWordSelect}/> + setNPCToSayWord={props.setNPCToSayWord}/> ) }) } diff --git a/js-src/components/word-selector.tsx b/js-src/components/word-selector.tsx index 77e234e..c19d38e 100644 --- a/js-src/components/word-selector.tsx +++ b/js-src/components/word-selector.tsx @@ -1,15 +1,62 @@ import * as React from 'react' -import type { Words } from '@lastres/word' +import type { Words, Word } from '@lastres/word' import { StateGame } from '@lastres/components/game' +import OutputPacketTalk from '@lastres/output-packet/talk' +import type { TalkNPC } from '@lastres/talk-npc' export interface WordSelectorProps { words: Words | null setStateGame: (set: StateGame) => void + websocket: WebSocket | null + NPCToSayWord: TalkNPC | null } export default function WordSelector (props: WordSelectorProps): JSX.Element { const words = props.words + if (props.NPCToSayWord === null) { + console.log('Error, should be a NPC to talk with, exiting this screen.') + props.setStateGame(StateGame.MainScreen) + return <> + } + function onClickWord (word: Word): void { + if (props.NPCToSayWord === null || props.websocket === null) { + return + } + new OutputPacketTalk(props.NPCToSayWord.identifier, word.identifier).send(props.websocket) + props.setStateGame(StateGame.MainScreen) + } + function printWord (word: Word): JSX.Element { + return ( + { + onClickWord(word) + }} + href="#" + className="word"> + { + word.name + } + + ) + } + + function wordList (): JSX.Element { + if (words === null) { + return

No hay palabras para poder decir aun.

+ } + return ( +
+ { + Object.keys(words).map((key) => { + const word = words[key] + return printWord(word) + }) + } +
+ ) + } + return (
x

Selecciona una palabra.

+ { + wordList() + }
) } diff --git a/js-src/input-packets.ts b/js-src/input-packets.ts index 2ce1873..8617755 100644 --- a/js-src/input-packets.ts +++ b/js-src/input-packets.ts @@ -168,6 +168,7 @@ export default class InputPackets { }, 10) } if (data.known_words !== undefined) { + console.log(data.known_words); this.setWords(data.known_words) } if (data.append_log !== undefined) { diff --git a/lib/LasTres/Controller/Websocket/InputPacket/Talk.pm b/lib/LasTres/Controller/Websocket/InputPacket/Talk.pm index c346931..e35814f 100644 --- a/lib/LasTres/Controller/Websocket/InputPacket/Talk.pm +++ b/lib/LasTres/Controller/Websocket/InputPacket/Talk.pm @@ -10,6 +10,8 @@ use List::AllUtils; use JSON qw/to_json/; +use LasTres::Words; + sub identifier { return 'talk'; } @@ -40,14 +42,26 @@ sub handle ( $self, $ws, $session, $data ) { } my $possible_word_identifier = $data->{word}; if ( !defined $possible_word_identifier ) { - $self->handle_wordlessly_talk( $ws, $pj, $npc ); + $self->handle_wordlessly_talk( $pj, $npc ); return; } - return $ws->send( - to_json( { error => 'Sending a word still not supported.' } ) ); + my $word_identifier = $possible_word_identifier; + my $maybe_word = $pj->get_word($word_identifier); + if ( !defined $maybe_word ) { + return $ws->send( + to_json( { error => 'You do not know this word.' } ) ); + } + my $word = $maybe_word; + $self->handle_say_word($pj, $npc, $word); + } -sub handle_wordlessly_talk ( $self, $ws, $pj, $npc ) { +sub handle_say_word($self, $pj, $npc, $word) { + $npc->talk( $pj, $word ); + $self->end_conversation($pj) +} + +sub handle_wordlessly_talk ( $self, $pj, $npc ) { $npc->talk( $pj, undef ); $self->end_conversation($pj); } diff --git a/lib/LasTres/Schema/Result/PJ.pm b/lib/LasTres/Schema/Result/PJ.pm index 21b181e..a529a3f 100644 --- a/lib/LasTres/Schema/Result/PJ.pm +++ b/lib/LasTres/Schema/Result/PJ.pm @@ -158,6 +158,10 @@ sub known_words_hash ($self) { return \%result_words; } +sub get_word($self, $word_identifier) { + return $self->known_words_hash->{$word_identifier}; +} + sub known_words_hash_serialized ($self) { my %words = %{ $self->known_words_hash }; my @identifiers = keys %words; diff --git a/lib/LasTres/TalkingNPC.pm b/lib/LasTres/TalkingNPC.pm index a1b1b3a..52746d8 100644 --- a/lib/LasTres/TalkingNPC.pm +++ b/lib/LasTres/TalkingNPC.pm @@ -22,7 +22,7 @@ requires qw/identifier name/; # sub name($self, $pj); # ## IMPLEMENTORS MUST EXTEND -# sub talk($self,$pj,$word); +# sub talk($self,$pj,$word = undef); ## DO NOT EXTEND NOT SUPPORTED. sub hash ($self) { @@ -56,7 +56,7 @@ sub show_told_word ( $self, $pj, $word ) { $team->append_log_line( [ { - text => $pj, + text => $pj->nick, color => 'green', }, { @@ -64,7 +64,7 @@ sub show_told_word ( $self, $pj, $word ) { }, { - text => $word, + text => $word->name, color => 'purple', }, { @@ -142,7 +142,7 @@ sub show_wordlessly_talk_started ( $self, $pj ) { # the team members the contents of # the conversation so they get context about # what their partners need to do. -sub talk ( $self, $pj, $word ) { +sub talk ( $self, $pj, $word = undef ) { $pj = $pj->get_from_storage; my $team = $pj->team; if ( defined $word ) { diff --git a/lib/LasTres/TalkingNPC/AncianoTribuLima.pm b/lib/LasTres/TalkingNPC/AncianoTribuLima.pm index ea91127..cec99aa 100644 --- a/lib/LasTres/TalkingNPC/AncianoTribuLima.pm +++ b/lib/LasTres/TalkingNPC/AncianoTribuLima.pm @@ -14,12 +14,45 @@ use LasTres::Word::Devota; use parent 'LasTres::TalkingNPC'; -sub talk ( $self, $pj, $word ) { +sub talk ( $self, $pj, $word = undef ) { $self->SUPER::talk( $pj, $word ); if ( !defined $word ) { $self->wordlessly_talk($pj); return; } + $self->word_talk($pj, $word); +} + +sub word_talk($self, $pj, $word) { + require LasTres::Word::Devota; + if ($word->identifier eq LasTres::Word::Devota->instance->identifier) { + $self->word_devota($pj); + return; + } + $self->word_unknown($pj); + +} + +sub word_devota($self, $pj) { + $self->send_response_dialog( + $pj, + [ + { + text => '¿La Devota? Suele estar en la casa de piedra.' + } + ] + ); +} + +sub word_unknown($self, $pj) { + $self->send_response_dialog( + $pj, + [ + { + text => 'Mmmm seguro que eso es muy interesante para otra persona.' + } + ] + ); } sub identifier { @@ -35,10 +68,10 @@ sub name { } sub verb ( $self, $pj ) { - if ( $pj->knows_word( LasTres::Word::Devota->instance ) ) { - return 'indica'; + if ( !$pj->knows_word( LasTres::Word::Devota->instance ) ) { + return 'farfulla'; } - return 'farfulla'; + return 'indica'; } sub wordlessly_talk ( $self, $pj ) { diff --git a/public/css/styles.css b/public/css/styles.css index 456cfc8..9f08787 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -254,3 +254,18 @@ body { body div.word-selector a.close-button:hover { background: lightgray; color: black; } + body div.word-selector div.word-list { + width: 50%; } + body div.word-selector div.word-list a.word { + text-decoration: none; + color: black; + display: flex; + border: 1px solid black; + font-size: 30px; + height: 50px; + text-align: center; + flex-direction: column; + justify-content: center; } + body div.word-selector div.word-list a.word:hover { + color: white; + background: gray; } diff --git a/public/css/styles.scss b/public/css/styles.scss index d752009..1da04ba 100644 --- a/public/css/styles.scss +++ b/public/css/styles.scss @@ -310,5 +310,23 @@ body { color: black; } } + div.word-list { + width: 50%; + a.word { + text-decoration: none; + color: black; + display: flex; + border: 1px solid black; + font-size: 30px; + height: 50px; + text-align: center; + flex-direction: column; + justify-content: center; + &:hover { + color: white; + background: gray; + } + } + } } } diff --git a/public/js/bundle.js b/public/js/bundle.js index c777120..129641b 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -86,7 +86,7 @@ eval("\n\nif (false) {} else {\n module.exports = __webpack_require__(/*! ./cjs \********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ BottomPanel)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_output_packet_execute_action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/output-packet/execute_action */ \"./js-src/output-packet/execute_action.ts\");\n/* harmony import */ var _lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/components/presentation-item */ \"./js-src/components/presentation-item.tsx\");\n/* harmony import */ var _lastres_components_presentation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @lastres/components/presentation */ \"./js-src/components/presentation.tsx\");\n/* harmony import */ var _lastres_components_talk_npcs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lastres/components/talk-npcs */ \"./js-src/components/talk-npcs.tsx\");\n\n\n\n\n\nfunction BottomPanel(props) {\n const actionHash = props.actionHash;\n function printListActions() {\n if (actionHash === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n const listOfActionKeys = Object.keys(actionHash).sort((a, b) => {\n const isDisabledComparisionValue = +actionHash[a].is_disabled - +actionHash[b].is_disabled;\n if (isDisabledComparisionValue !== 0) {\n return isDisabledComparisionValue;\n }\n if (actionHash[a].name < actionHash[b].name) {\n return -1;\n }\n if (actionHash[a].name > actionHash[b].name) {\n return 1;\n }\n return 0;\n });\n function printDisabledReason(action) {\n if (!action.is_disabled || action.disabled_reason === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", { className: \"disabled-reason\", style: { color: 'red' } }, action.disabled_reason));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"Acciones disponibles.\"),\n listOfActionKeys.map((key) => {\n const style = {};\n const action = actionHash[key];\n if (action.is_disabled) {\n style.background = 'lightgray';\n }\n function onClick() {\n if (action.is_disabled) {\n return;\n }\n if (props.websocket !== null) {\n new _lastres_output_packet_execute_action__WEBPACK_IMPORTED_MODULE_1__[\"default\"](action.identifier)\n .send(props.websocket);\n }\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"a\", { onClick: onClick, className: \"action\", style: style, key: action.identifier },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, action.name),\n printDisabledReason(action));\n }));\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation__WEBPACK_IMPORTED_MODULE_3__[\"default\"], null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null, printListActions()),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_talk_npcs__WEBPACK_IMPORTED_MODULE_4__[\"default\"], { websocket: props.websocket, talkNPCs: props.talkNPCs, setStateGame: props.setStateGame, setOnWordSelect: props.setOnWordSelect })),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null)));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/bottom-panel.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ BottomPanel)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_output_packet_execute_action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/output-packet/execute_action */ \"./js-src/output-packet/execute_action.ts\");\n/* harmony import */ var _lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/components/presentation-item */ \"./js-src/components/presentation-item.tsx\");\n/* harmony import */ var _lastres_components_presentation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @lastres/components/presentation */ \"./js-src/components/presentation.tsx\");\n/* harmony import */ var _lastres_components_talk_npcs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lastres/components/talk-npcs */ \"./js-src/components/talk-npcs.tsx\");\n\n\n\n\n\nfunction BottomPanel(props) {\n const actionHash = props.actionHash;\n function printListActions() {\n if (actionHash === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n const listOfActionKeys = Object.keys(actionHash).sort((a, b) => {\n const isDisabledComparisionValue = +actionHash[a].is_disabled - +actionHash[b].is_disabled;\n if (isDisabledComparisionValue !== 0) {\n return isDisabledComparisionValue;\n }\n if (actionHash[a].name < actionHash[b].name) {\n return -1;\n }\n if (actionHash[a].name > actionHash[b].name) {\n return 1;\n }\n return 0;\n });\n function printDisabledReason(action) {\n if (!action.is_disabled || action.disabled_reason === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", { className: \"disabled-reason\", style: { color: 'red' } }, action.disabled_reason));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"Acciones disponibles.\"),\n listOfActionKeys.map((key) => {\n const style = {};\n const action = actionHash[key];\n if (action.is_disabled) {\n style.background = 'lightgray';\n }\n function onClick() {\n if (action.is_disabled) {\n return;\n }\n if (props.websocket !== null) {\n new _lastres_output_packet_execute_action__WEBPACK_IMPORTED_MODULE_1__[\"default\"](action.identifier)\n .send(props.websocket);\n }\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"a\", { onClick: onClick, className: \"action\", style: style, key: action.identifier },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, action.name),\n printDisabledReason(action));\n }));\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation__WEBPACK_IMPORTED_MODULE_3__[\"default\"], null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null, printListActions()),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_talk_npcs__WEBPACK_IMPORTED_MODULE_4__[\"default\"], { websocket: props.websocket, talkNPCs: props.talkNPCs, setStateGame: props.setStateGame, setNPCToSayWord: props.setNPCToSayWord })),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_presentation_item__WEBPACK_IMPORTED_MODULE_2__[\"default\"], null)));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/bottom-panel.tsx?"); /***/ }), @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StateGame: () => (/* binding */ StateGame),\n/* harmony export */ \"default\": () => (/* binding */ Game)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_upper_panel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/upper-panel */ \"./js-src/components/upper-panel.tsx\");\n/* harmony import */ var _lastres_components_bottom_panel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/components/bottom-panel */ \"./js-src/components/bottom-panel.tsx\");\n/* harmony import */ var _lastres_components_pj_selection_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @lastres/components/pj-selection-menu */ \"./js-src/components/pj-selection-menu.tsx\");\n/* harmony import */ var _lastres_components_word_selector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lastres/components/word-selector */ \"./js-src/components/word-selector.tsx\");\n/* harmony import */ var _lastres_output_packet_init__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @lastres/output-packet/init */ \"./js-src/output-packet/init.ts\");\n/* harmony import */ var _lastres_output_packet_ping__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @lastres/output-packet/ping */ \"./js-src/output-packet/ping.ts\");\n/* harmony import */ var _lastres_input_packets__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @lastres/input-packets */ \"./js-src/input-packets.ts\");\n\n\n\n\n\n\n\n\nvar StateGame;\n(function (StateGame) {\n StateGame[StateGame[\"MainScreen\"] = 0] = \"MainScreen\";\n StateGame[StateGame[\"SelectingWord\"] = 1] = \"SelectingWord\";\n})(StateGame || (StateGame = {}));\nfunction Game(props) {\n const selectedPJ = props.selectedPJ;\n if (selectedPJ === null) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_pj_selection_menu__WEBPACK_IMPORTED_MODULE_3__[\"default\"], { setSelectedPJ: props.setSelectedPJ, userWantsToCreatePJ: props.userWantsToCreatePJ, setUserWantsToCreatePJ: props.setUserWantsToCreatePJ, error: props.error, setError: props.setError })));\n }\n const [teamPJs, setTeamPJs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [enemyTeamPJs, setEnemyTeamPJs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [isBattling, setIsBattling] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [currentLocation, setCurrentLocation] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [connectedLocations, setConnectedLocations] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [logLines, setLogLines] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [error, setError] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [scrollLog, setScrollLog] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [movingTo, setMovingTo] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [remainingFrames, setRemainingFrames] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [actionHash, setActionHash] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [talkNPCs, setTalkNPCs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [onWordSelect, setOnWordSelect] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [stateGame, setStateGame] = react__WEBPACK_IMPORTED_MODULE_0__.useState(StateGame.MainScreen);\n const [words, setWords] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const logPresentationRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const websocket = props.websocket;\n const setWebsocket = props.setWebsocket;\n window.setTimeout(() => {\n setWebsocket((websocket) => {\n if (websocket === null) {\n console.log('Opening websocket');\n const locationProtocol = window.location.protocol;\n if (locationProtocol == null) {\n return null;\n }\n const protocol = locationProtocol.match(/https:/) != null ? 'wss' : 'ws';\n const webSocket = new WebSocket(`${protocol}://${window.location.host}/ws`);\n webSocket.onopen = () => {\n new _lastres_output_packet_init__WEBPACK_IMPORTED_MODULE_5__[\"default\"](selectedPJ.uuid).send(webSocket);\n let interval = 0;\n interval = window.setInterval(() => {\n if (webSocket.readyState === WebSocket.CONNECTING) {\n return;\n }\n if (webSocket.readyState === WebSocket.OPEN) {\n new _lastres_output_packet_ping__WEBPACK_IMPORTED_MODULE_6__[\"default\"]().send(webSocket);\n return;\n }\n window.clearInterval(interval);\n }, 50000);\n };\n const inputPackets = new _lastres_input_packets__WEBPACK_IMPORTED_MODULE_7__[\"default\"](setTeamPJs, setEnemyTeamPJs, setIsBattling, setCurrentLocation, setConnectedLocations, logLines, setLogLines, setError, setScrollLog, logPresentationRef, setMovingTo, setRemainingFrames, setActionHash, setTalkNPCs, setWords);\n webSocket.onmessage = (event) => {\n const packet = JSON.parse(event.data);\n inputPackets.handle(packet);\n };\n webSocket.onerror = (event) => {\n console.log(event);\n };\n webSocket.onclose = (event) => {\n console.log('Websocket closed');\n setWebsocket(null);\n };\n return webSocket;\n }\n return websocket;\n });\n }, 300);\n if (stateGame === StateGame.SelectingWord) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_word_selector__WEBPACK_IMPORTED_MODULE_4__[\"default\"], { words: words, setStateGame: setStateGame }));\n }\n if (stateGame === StateGame.MainScreen) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_upper_panel__WEBPACK_IMPORTED_MODULE_1__[\"default\"], { teamPJs: teamPJs, enemyTeamPJs: enemyTeamPJs, isBattling: isBattling, currentLocation: currentLocation, connectedLocations: connectedLocations, logLines: logLines, websocket: websocket, logPresentationRef: logPresentationRef, movingTo: movingTo, remainingFrames: remainingFrames }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_bottom_panel__WEBPACK_IMPORTED_MODULE_2__[\"default\"], { actionHash: actionHash, websocket: websocket, talkNPCs: talkNPCs, setOnWordSelect: setOnWordSelect, setStateGame: setStateGame })));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/game.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StateGame: () => (/* binding */ StateGame),\n/* harmony export */ \"default\": () => (/* binding */ Game)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_upper_panel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/upper-panel */ \"./js-src/components/upper-panel.tsx\");\n/* harmony import */ var _lastres_components_bottom_panel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/components/bottom-panel */ \"./js-src/components/bottom-panel.tsx\");\n/* harmony import */ var _lastres_components_pj_selection_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @lastres/components/pj-selection-menu */ \"./js-src/components/pj-selection-menu.tsx\");\n/* harmony import */ var _lastres_components_word_selector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lastres/components/word-selector */ \"./js-src/components/word-selector.tsx\");\n/* harmony import */ var _lastres_output_packet_init__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @lastres/output-packet/init */ \"./js-src/output-packet/init.ts\");\n/* harmony import */ var _lastres_output_packet_ping__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @lastres/output-packet/ping */ \"./js-src/output-packet/ping.ts\");\n/* harmony import */ var _lastres_input_packets__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @lastres/input-packets */ \"./js-src/input-packets.ts\");\n\n\n\n\n\n\n\n\nvar StateGame;\n(function (StateGame) {\n StateGame[StateGame[\"MainScreen\"] = 0] = \"MainScreen\";\n StateGame[StateGame[\"SelectingWord\"] = 1] = \"SelectingWord\";\n})(StateGame || (StateGame = {}));\nfunction Game(props) {\n const selectedPJ = props.selectedPJ;\n if (selectedPJ === null) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_pj_selection_menu__WEBPACK_IMPORTED_MODULE_3__[\"default\"], { setSelectedPJ: props.setSelectedPJ, userWantsToCreatePJ: props.userWantsToCreatePJ, setUserWantsToCreatePJ: props.setUserWantsToCreatePJ, error: props.error, setError: props.setError })));\n }\n const [teamPJs, setTeamPJs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [enemyTeamPJs, setEnemyTeamPJs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [isBattling, setIsBattling] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [currentLocation, setCurrentLocation] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [connectedLocations, setConnectedLocations] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [logLines, setLogLines] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [error, setError] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [scrollLog, setScrollLog] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [movingTo, setMovingTo] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [remainingFrames, setRemainingFrames] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [actionHash, setActionHash] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [talkNPCs, setTalkNPCs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [stateGame, setStateGame] = react__WEBPACK_IMPORTED_MODULE_0__.useState(StateGame.MainScreen);\n const [NPCToSayWord, setNPCToSayWord] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const [words, setWords] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n const logPresentationRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const websocket = props.websocket;\n const setWebsocket = props.setWebsocket;\n window.setTimeout(() => {\n setWebsocket((websocket) => {\n if (websocket === null) {\n console.log('Opening websocket');\n const locationProtocol = window.location.protocol;\n if (locationProtocol == null) {\n return null;\n }\n const protocol = locationProtocol.match(/https:/) != null ? 'wss' : 'ws';\n const webSocket = new WebSocket(`${protocol}://${window.location.host}/ws`);\n webSocket.onopen = () => {\n new _lastres_output_packet_init__WEBPACK_IMPORTED_MODULE_5__[\"default\"](selectedPJ.uuid).send(webSocket);\n let interval = 0;\n interval = window.setInterval(() => {\n if (webSocket.readyState === WebSocket.CONNECTING) {\n return;\n }\n if (webSocket.readyState === WebSocket.OPEN) {\n new _lastres_output_packet_ping__WEBPACK_IMPORTED_MODULE_6__[\"default\"]().send(webSocket);\n return;\n }\n window.clearInterval(interval);\n }, 50000);\n };\n const inputPackets = new _lastres_input_packets__WEBPACK_IMPORTED_MODULE_7__[\"default\"](setTeamPJs, setEnemyTeamPJs, setIsBattling, setCurrentLocation, setConnectedLocations, logLines, setLogLines, setError, setScrollLog, logPresentationRef, setMovingTo, setRemainingFrames, setActionHash, setTalkNPCs, setWords);\n webSocket.onmessage = (event) => {\n const packet = JSON.parse(event.data);\n inputPackets.handle(packet);\n };\n webSocket.onerror = (event) => {\n console.log(event);\n };\n webSocket.onclose = (event) => {\n console.log('Websocket closed');\n setWebsocket(null);\n };\n return webSocket;\n }\n return websocket;\n });\n }, 300);\n if (stateGame === StateGame.SelectingWord) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_word_selector__WEBPACK_IMPORTED_MODULE_4__[\"default\"], { words: words, setStateGame: setStateGame, websocket: websocket, NPCToSayWord: NPCToSayWord }));\n }\n if (stateGame === StateGame.MainScreen) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_upper_panel__WEBPACK_IMPORTED_MODULE_1__[\"default\"], { teamPJs: teamPJs, enemyTeamPJs: enemyTeamPJs, isBattling: isBattling, currentLocation: currentLocation, connectedLocations: connectedLocations, logLines: logLines, websocket: websocket, logPresentationRef: logPresentationRef, movingTo: movingTo, remainingFrames: remainingFrames }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_bottom_panel__WEBPACK_IMPORTED_MODULE_2__[\"default\"], { actionHash: actionHash, websocket: websocket, talkNPCs: talkNPCs, setNPCToSayWord: setNPCToSayWord, setStateGame: setStateGame })));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/game.tsx?"); /***/ }), @@ -216,7 +216,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TalkNPCComponent)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_game__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/game */ \"./js-src/components/game.tsx\");\n/* harmony import */ var _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/output-packet/talk */ \"./js-src/output-packet/talk.ts\");\n\n\n\nfunction TalkNPCComponent(props) {\n const npc = props.npc;\n function onWordlesslyTalk(npc) {\n if (props.websocket === null) {\n return;\n }\n new _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__[\"default\"](npc.identifier).send(props.websocket);\n }\n function onWantToSayWord() {\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.SelectingWord);\n props.setOnWordSelect((npc, word) => {\n console.log(`Trying to say ${word} to `, props.npc);\n });\n }\n function printAvatar(npc) {\n if (npc.icon === undefined) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"avatar\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"img\", { src: npc.icon }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"shadow\" }));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { key: npc.identifier, className: \"talk-npc\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"detail\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"name-container\" },\n printAvatar(npc),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"name\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, npc.name))),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"buttons\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", { onClick: () => {\n onWordlesslyTalk(npc);\n } }, \"Hablar\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", { onClick: () => {\n onWantToSayWord();\n } }, \"Decir palabra\"))));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/talk-npc.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TalkNPCComponent)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_game__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/game */ \"./js-src/components/game.tsx\");\n/* harmony import */ var _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/output-packet/talk */ \"./js-src/output-packet/talk.ts\");\n\n\n\nfunction TalkNPCComponent(props) {\n const npc = props.npc;\n function onWordlesslyTalk(npc) {\n if (props.websocket === null) {\n return;\n }\n new _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__[\"default\"](npc.identifier).send(props.websocket);\n }\n function onWantToSayWord() {\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.SelectingWord);\n props.setNPCToSayWord(npc);\n }\n function printAvatar(npc) {\n if (npc.icon === undefined) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"avatar\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"img\", { src: npc.icon }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"shadow\" }));\n }\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { key: npc.identifier, className: \"talk-npc\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"detail\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"name-container\" },\n printAvatar(npc),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"name\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, npc.name))),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"buttons\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", { onClick: () => {\n onWordlesslyTalk(npc);\n } }, \"Hablar\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", { onClick: () => {\n onWantToSayWord();\n } }, \"Decir palabra\"))));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/talk-npc.tsx?"); /***/ }), @@ -226,7 +226,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*****************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TalkNPCsComponent)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_talk_npc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/talk-npc */ \"./js-src/components/talk-npc.tsx\");\n\n\nfunction TalkNPCsComponent(props) {\n const npcs = props.talkNPCs;\n if (npcs === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n if (Object.keys(npcs).length < 1) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"No hay nadie para hablar ahora.\"));\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"Disponible para hablar:\"),\n Object.keys(npcs).map((identifier) => {\n const npc = npcs[identifier];\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_talk_npc__WEBPACK_IMPORTED_MODULE_1__[\"default\"], { key: identifier, npc: npc, websocket: props.websocket, setStateGame: props.setStateGame, setOnWordSelect: props.setOnWordSelect }));\n })));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/talk-npcs.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TalkNPCsComponent)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_talk_npc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/talk-npc */ \"./js-src/components/talk-npc.tsx\");\n\n\nfunction TalkNPCsComponent(props) {\n const npcs = props.talkNPCs;\n if (npcs === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n if (Object.keys(npcs).length < 1) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"No hay nadie para hablar ahora.\"));\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"Disponible para hablar:\"),\n Object.keys(npcs).map((identifier) => {\n const npc = npcs[identifier];\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lastres_components_talk_npc__WEBPACK_IMPORTED_MODULE_1__[\"default\"], { key: identifier, npc: npc, websocket: props.websocket, setStateGame: props.setStateGame, setNPCToSayWord: props.setNPCToSayWord }));\n })));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/talk-npcs.tsx?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ WordSelector)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_game__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/game */ \"./js-src/components/game.tsx\");\n\n\nfunction WordSelector(props) {\n const words = props.words;\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"word-selector\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"a\", { href: \"#\", className: \"close-button\", onClick: () => {\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.MainScreen);\n } }, \"x\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"h2\", null, \"Selecciona una palabra.\")));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/word-selector.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ WordSelector)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lastres_components_game__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/components/game */ \"./js-src/components/game.tsx\");\n/* harmony import */ var _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lastres/output-packet/talk */ \"./js-src/output-packet/talk.ts\");\n\n\n\nfunction WordSelector(props) {\n const words = props.words;\n if (props.NPCToSayWord === null) {\n console.log('Error, should be a NPC to talk with, exiting this screen.');\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.MainScreen);\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);\n }\n function onClickWord(word) {\n if (props.NPCToSayWord === null || props.websocket === null) {\n return;\n }\n new _lastres_output_packet_talk__WEBPACK_IMPORTED_MODULE_2__[\"default\"](props.NPCToSayWord.identifier, word.identifier).send(props.websocket);\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.MainScreen);\n }\n function printWord(word) {\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"a\", { key: word.identifier, onClick: () => {\n onClickWord(word);\n }, href: \"#\", className: \"word\" }, word.name));\n }\n function wordList() {\n if (words === null) {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", null, \"No hay palabras para poder decir aun.\");\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"word-list\" }, Object.keys(words).map((key) => {\n const word = words[key];\n return printWord(word);\n })));\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"word-selector\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"a\", { href: \"#\", className: \"close-button\", onClick: () => {\n props.setStateGame(_lastres_components_game__WEBPACK_IMPORTED_MODULE_1__.StateGame.MainScreen);\n } }, \"x\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"h2\", null, \"Selecciona una palabra.\"),\n wordList()));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/word-selector.tsx?"); /***/ }), @@ -296,7 +296,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ InputPackets)\n/* harmony export */ });\n/* harmony import */ var _lastres_input_packet_info__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lastres/input-packet/info */ \"./js-src/input-packet/info.ts\");\n/* harmony import */ var _lastres_input_packet_pong__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/input-packet/pong */ \"./js-src/input-packet/pong.ts\");\n\n\nclass InputPackets {\n constructor(setTeamPJs, setEnemyTeamPJs, setIsBattling, setCurrentLocation, setConnectedLocations, logLines, setLogLines, setError, setScrollLog, logPresentationRef, setMovingTo, setRemainingFrames, setActionHash, setTalkNPCs, setWords) {\n this.cachedHash = null;\n this.cachedArray = null;\n this.setTeamPJs = setTeamPJs;\n this.setEnemyTeamPJs = setEnemyTeamPJs;\n this.setCurrentLocation = setCurrentLocation;\n this.setConnectedLocations = setConnectedLocations;\n this.logLines = logLines;\n this.setLogLines = setLogLines;\n this.setError = setError;\n this.setScrollLog = setScrollLog;\n this.logPresentationRef = logPresentationRef;\n this.setMovingTo = setMovingTo;\n this.setRemainingFrames = setRemainingFrames;\n this.setIsBattling = setIsBattling;\n this.setActionHash = setActionHash;\n this.setTalkNPCs = setTalkNPCs;\n this.setWords = setWords;\n }\n handle(packet) {\n const hash = this.hashAvailablePackets();\n const identifier = packet.command;\n const inputPacket = hash[identifier];\n inputPacket.recv(packet);\n }\n listAvailablePackets() {\n let firstTime = true;\n if (this.cachedArray === null) {\n const infoPacket = new _lastres_input_packet_info__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n const pongPacket = new _lastres_input_packet_pong__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n infoPacket.onReceive((data) => {\n const logPresentationRef = this.logPresentationRef;\n let scrollData = [];\n function saveScroll() {\n if (logPresentationRef.current === null) {\n return;\n }\n scrollData = [\n logPresentationRef.current.scrollHeight,\n logPresentationRef.current.scrollTop,\n logPresentationRef.current.offsetHeight\n ];\n }\n function applyScroll() {\n if (scrollData.length < 3) {\n return;\n }\n if (logPresentationRef.current === null) {\n console.log('Not defined');\n return;\n }\n const logPresentation = logPresentationRef.current;\n const [scrollHeight, scrollTop, offsetHeight] = scrollData;\n if (firstTime) {\n firstTime = false;\n logPresentation.scrollTo(0, logPresentation.scrollHeight);\n return;\n }\n if (scrollHeight <= scrollTop + offsetHeight * (3 / 2)) {\n logPresentation.scrollTo(0, logPresentation.scrollHeight);\n }\n }\n if (data.error !== undefined) {\n this.setError(data.error);\n return;\n }\n if (data.team_pjs !== undefined) {\n this.setTeamPJs(data.team_pjs);\n }\n if (data.enemy_team_pjs !== undefined) {\n this.setEnemyTeamPJs(data.enemy_team_pjs);\n }\n if (data.is_battling !== undefined) {\n this.setIsBattling(data.is_battling);\n }\n if (data.location_data !== undefined) {\n console.log(data.location_data);\n if (data.location_data.connected_places !== undefined) {\n this.setConnectedLocations(data.location_data.connected_places);\n }\n if (data.location_data.current !== undefined) {\n this.setCurrentLocation(data.location_data.current);\n }\n if (data.location_data.moving_to !== undefined) {\n this.setMovingTo(data.location_data.moving_to);\n }\n else {\n this.setMovingTo(null);\n }\n }\n if (data.npcs !== undefined) {\n this.setTalkNPCs(data.npcs);\n }\n if (data.remaining_frames !== undefined) {\n this.setRemainingFrames(data.remaining_frames);\n }\n if (data.set_log !== undefined) {\n saveScroll();\n this.setLogLines(data.set_log);\n window.setTimeout(() => {\n applyScroll();\n }, 10);\n }\n if (data.known_words !== undefined) {\n this.setWords(data.known_words);\n }\n if (data.append_log !== undefined) {\n const logHash = {};\n saveScroll();\n this.setLogLines((logLines) => {\n if (logLines !== null) {\n for (const item of logLines) {\n logHash[item.uuid] = item;\n }\n logHash[data.append_log.uuid] = data.append_log;\n const outputLog = Object.keys(logHash).map((item, i) => {\n return logHash[item];\n });\n return outputLog;\n }\n return [];\n });\n window.setTimeout(() => {\n applyScroll();\n }, 10);\n }\n if (data.available_actions !== undefined) {\n this.setActionHash(data.available_actions);\n }\n });\n this.cachedArray = [infoPacket, pongPacket];\n }\n return this.cachedArray;\n }\n hashAvailablePackets() {\n if (this.cachedHash === null) {\n this.cachedHash = {};\n for (const inputPacket of this.listAvailablePackets()) {\n this.cachedHash[inputPacket.identifier()] = inputPacket;\n }\n }\n return this.cachedHash;\n }\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/input-packets.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ InputPackets)\n/* harmony export */ });\n/* harmony import */ var _lastres_input_packet_info__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lastres/input-packet/info */ \"./js-src/input-packet/info.ts\");\n/* harmony import */ var _lastres_input_packet_pong__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lastres/input-packet/pong */ \"./js-src/input-packet/pong.ts\");\n\n\nclass InputPackets {\n constructor(setTeamPJs, setEnemyTeamPJs, setIsBattling, setCurrentLocation, setConnectedLocations, logLines, setLogLines, setError, setScrollLog, logPresentationRef, setMovingTo, setRemainingFrames, setActionHash, setTalkNPCs, setWords) {\n this.cachedHash = null;\n this.cachedArray = null;\n this.setTeamPJs = setTeamPJs;\n this.setEnemyTeamPJs = setEnemyTeamPJs;\n this.setCurrentLocation = setCurrentLocation;\n this.setConnectedLocations = setConnectedLocations;\n this.logLines = logLines;\n this.setLogLines = setLogLines;\n this.setError = setError;\n this.setScrollLog = setScrollLog;\n this.logPresentationRef = logPresentationRef;\n this.setMovingTo = setMovingTo;\n this.setRemainingFrames = setRemainingFrames;\n this.setIsBattling = setIsBattling;\n this.setActionHash = setActionHash;\n this.setTalkNPCs = setTalkNPCs;\n this.setWords = setWords;\n }\n handle(packet) {\n const hash = this.hashAvailablePackets();\n const identifier = packet.command;\n const inputPacket = hash[identifier];\n inputPacket.recv(packet);\n }\n listAvailablePackets() {\n let firstTime = true;\n if (this.cachedArray === null) {\n const infoPacket = new _lastres_input_packet_info__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n const pongPacket = new _lastres_input_packet_pong__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n infoPacket.onReceive((data) => {\n const logPresentationRef = this.logPresentationRef;\n let scrollData = [];\n function saveScroll() {\n if (logPresentationRef.current === null) {\n return;\n }\n scrollData = [\n logPresentationRef.current.scrollHeight,\n logPresentationRef.current.scrollTop,\n logPresentationRef.current.offsetHeight\n ];\n }\n function applyScroll() {\n if (scrollData.length < 3) {\n return;\n }\n if (logPresentationRef.current === null) {\n console.log('Not defined');\n return;\n }\n const logPresentation = logPresentationRef.current;\n const [scrollHeight, scrollTop, offsetHeight] = scrollData;\n if (firstTime) {\n firstTime = false;\n logPresentation.scrollTo(0, logPresentation.scrollHeight);\n return;\n }\n if (scrollHeight <= scrollTop + offsetHeight * (3 / 2)) {\n logPresentation.scrollTo(0, logPresentation.scrollHeight);\n }\n }\n if (data.error !== undefined) {\n this.setError(data.error);\n return;\n }\n if (data.team_pjs !== undefined) {\n this.setTeamPJs(data.team_pjs);\n }\n if (data.enemy_team_pjs !== undefined) {\n this.setEnemyTeamPJs(data.enemy_team_pjs);\n }\n if (data.is_battling !== undefined) {\n this.setIsBattling(data.is_battling);\n }\n if (data.location_data !== undefined) {\n console.log(data.location_data);\n if (data.location_data.connected_places !== undefined) {\n this.setConnectedLocations(data.location_data.connected_places);\n }\n if (data.location_data.current !== undefined) {\n this.setCurrentLocation(data.location_data.current);\n }\n if (data.location_data.moving_to !== undefined) {\n this.setMovingTo(data.location_data.moving_to);\n }\n else {\n this.setMovingTo(null);\n }\n }\n if (data.npcs !== undefined) {\n this.setTalkNPCs(data.npcs);\n }\n if (data.remaining_frames !== undefined) {\n this.setRemainingFrames(data.remaining_frames);\n }\n if (data.set_log !== undefined) {\n saveScroll();\n this.setLogLines(data.set_log);\n window.setTimeout(() => {\n applyScroll();\n }, 10);\n }\n if (data.known_words !== undefined) {\n console.log(data.known_words);\n this.setWords(data.known_words);\n }\n if (data.append_log !== undefined) {\n const logHash = {};\n saveScroll();\n this.setLogLines((logLines) => {\n if (logLines !== null) {\n for (const item of logLines) {\n logHash[item.uuid] = item;\n }\n logHash[data.append_log.uuid] = data.append_log;\n const outputLog = Object.keys(logHash).map((item, i) => {\n return logHash[item];\n });\n return outputLog;\n }\n return [];\n });\n window.setTimeout(() => {\n applyScroll();\n }, 10);\n }\n if (data.available_actions !== undefined) {\n this.setActionHash(data.available_actions);\n }\n });\n this.cachedArray = [infoPacket, pongPacket];\n }\n return this.cachedArray;\n }\n hashAvailablePackets() {\n if (this.cachedHash === null) {\n this.cachedHash = {};\n for (const inputPacket of this.listAvailablePackets()) {\n this.cachedHash[inputPacket.identifier()] = inputPacket;\n }\n }\n return this.cachedHash;\n }\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/input-packets.ts?"); /***/ }),