Adding refresh pj list on pj creation.
This commit is contained in:
parent
12e6fb8524
commit
de2cfae5a7
@ -1,7 +1,18 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import PresentationItem from '@lastres/components/presentation-item'
|
||||
import Presentation from '@lastres/components/presentation'
|
||||
|
||||
export interface BottomPanelProps {
|
||||
websocket: WebSocket | null
|
||||
}
|
||||
|
||||
export default function BottomPanel (): JSX.Element {
|
||||
return (
|
||||
<>
|
||||
</>
|
||||
<Presentation>
|
||||
<PresentationItem>
|
||||
hola
|
||||
</PresentationItem>
|
||||
</Presentation>
|
||||
)
|
||||
}
|
||||
|
@ -73,6 +73,9 @@ export default function Game (props: GameProps): JSX.Element {
|
||||
webSocket.onerror = (event) => {
|
||||
console.log(event)
|
||||
}
|
||||
webSocket.onclose = (event) => {
|
||||
setWebsocket(null)
|
||||
}
|
||||
return webSocket
|
||||
}
|
||||
return websocket
|
||||
|
@ -1,22 +1,22 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import { PJ } from '@lastres/pj'
|
||||
import type { PJ } from '@lastres/pj'
|
||||
import { fetchMyPjs } from '@lastres/pj'
|
||||
|
||||
export interface PJCreationMenuProps {
|
||||
error: string | null
|
||||
setSelectedPJ: (set: PJ | null) => void
|
||||
setUserWantsToCreatePJ: (set: boolean) => void
|
||||
setError: (set: string | null) => void
|
||||
setPJs: (set: PJ[] | null) => void
|
||||
}
|
||||
|
||||
export interface Race {
|
||||
identifier: string;
|
||||
name_selection: string;
|
||||
description: string;
|
||||
}
|
||||
export interface Races {
|
||||
[id: string]: Race
|
||||
identifier: string
|
||||
name_selection: string
|
||||
description: string
|
||||
}
|
||||
export type Races = Record<string, Race>
|
||||
|
||||
export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element {
|
||||
const longNameInputRef = React.useRef<HTMLInputElement>(null)
|
||||
@ -33,8 +33,8 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element
|
||||
const statusCode = response.status
|
||||
const data = await response.json()
|
||||
if (statusCode !== 200) {
|
||||
props.setError(data.error)
|
||||
return;
|
||||
props.setError(data.error)
|
||||
return
|
||||
}
|
||||
setPlayableRaces(data)
|
||||
props.setError(null)
|
||||
@ -43,7 +43,7 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element
|
||||
props.setError('Imposible conectar al servidor para recibir las razas.')
|
||||
})
|
||||
}
|
||||
function createPJ(): void {
|
||||
function createPJ (): void {
|
||||
if (longNameInputRef.current === null) {
|
||||
return
|
||||
}
|
||||
@ -75,20 +75,21 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element
|
||||
}
|
||||
props.setError(null)
|
||||
props.setUserWantsToCreatePJ(false)
|
||||
const pjs = await fetchMyPjs(props.setError)
|
||||
props.setPJs(pjs)
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
props.setError('Imposible crear pj, no se pudo conectar al servidor.')
|
||||
});
|
||||
})
|
||||
}
|
||||
function renderRaces(): JSX.Element[] {
|
||||
function renderRaces (): JSX.Element[] {
|
||||
if (playableRaces !== null) {
|
||||
return Object.keys(playableRaces)
|
||||
.map((item, i) => {
|
||||
return <option key={i} value={playableRaces[item].identifier}>
|
||||
{`${playableRaces[item].name_selection} (${playableRaces[item].description})`}
|
||||
</option>
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
return ([])
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ export default function PJListSelection (props: PJListSelectionProps): JSX.Eleme
|
||||
if (pjs === null) {
|
||||
return (
|
||||
<>
|
||||
<p>Aun no se han descargado los pjs, espera un segundo...</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import * as React from 'react'
|
||||
import PJCreationMenu from '@lastres/components/pj-creation-menu'
|
||||
import PJListSelection from '@lastres/components/pj-list-selection'
|
||||
import { PJ, fetchMyPjs } from '@lastres/pj'
|
||||
import { fetchMyPjs } from '@lastres/pj'
|
||||
import type { PJ } from '@lastres/pj'
|
||||
|
||||
export interface PJSelectionMenuProps {
|
||||
setSelectedPJ: (set: PJ | null) => void
|
||||
@ -22,12 +23,14 @@ export default function PJSelectionMenu (props: PJSelectionMenuProps): JSX.Eleme
|
||||
setSelectedPJ={props.setSelectedPJ}
|
||||
setUserWantsToCreatePJ={props.setUserWantsToCreatePJ}
|
||||
error={props.error}
|
||||
setError={props.setError}/>
|
||||
setError={props.setError}
|
||||
setPJs={setPJs}/>
|
||||
)
|
||||
}
|
||||
if (pjs === null) {
|
||||
fetchMyPjs(props.setError)
|
||||
.then((pjs)=> { setPJs(pjs) })
|
||||
.then((pjs) => { setPJs(pjs) })
|
||||
.catch((error) => { console.log(error) })
|
||||
}
|
||||
return (
|
||||
<div className="pj-selection-menu">
|
||||
|
@ -31,6 +31,11 @@ sub frames_to_explore($self) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
sub can_explore {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub _build_children($self) {
|
||||
my $locations = $self->locations;
|
||||
my @locations = map { $locations->{$_} } keys %$locations;
|
||||
|
@ -21,6 +21,26 @@ sub can_visit($self, $pj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
sub can_discover($self, $pj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
sub chance_discover($self, $pj) {
|
||||
return 50;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
sub allow_forced_discovery($self, $pj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
sub order($self) {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
## OVERRIDE (Always use $self->SUPER::on_team_arrival.)
|
||||
sub on_team_arrival($self, $team) {
|
||||
$team = $team->get_from_storage;
|
||||
@ -41,7 +61,6 @@ sub on_pj_arrival($self, $pj) {
|
||||
$redis->publish( $redis->pj_subscription($pj), to_json({ command => 'update-location' }));
|
||||
}
|
||||
|
||||
|
||||
sub show_intro ( $self, $pj ) {
|
||||
$pj->append_log_line(
|
||||
[
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user