Map prints items seen in room, shortcuts to open save/load/video/map/etc

main
Ashelyn Dawn 4 years ago
parent 93477a290c
commit 8098a9ea17

@ -22,6 +22,7 @@ export default function Map() {
}, []) // eslint-disable-line
const currentRoom = (roomName && gameState.rooms.get(roomName)) || null
const itemsInRoom = Array.from(gameState.items.values()).filter(({lastKnownLocation}) => lastKnownLocation === roomName)
return (
<div className={styles.map}>
@ -53,7 +54,15 @@ export default function Map() {
<>
<h3>{currentRoom.printableName}</h3>
{currentRoom.visited
? <ReactMarkdown>{currentRoom.description}</ReactMarkdown>
? (<>
<ReactMarkdown>{currentRoom.description}</ReactMarkdown>
{itemsInRoom.length > 0 && (<>
<p>You {(playerLocation === roomName) ? 'see' : 'recall seeing'} the following items here:</p>
<ul>
{itemsInRoom.map(({name}) => <li>{name}</li>)}
</ul>
</>)}
</>)
: <p>Visit this room to unlock its description</p>}
</>
) : (

@ -7,5 +7,7 @@ export default [
require('./unlockDoor'),
require('./take'),
require('./inventory'),
require('./help')
require('./help'),
require('./options'),
require('./map')
]

@ -0,0 +1,15 @@
import Parser from "../Parser";
import RulesEngine from "../RulesEngine";
import Game from "../Game";
import {updateSharedState} from '../../hooks/useSharedState'
export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('map')
.as('map')
rules.onCommand('map', () => {
updateSharedState('currentMenu', 'map')
document.getElementById('gameInput')?.blur()
})
}

@ -0,0 +1,29 @@
import Parser from "../Parser";
import RulesEngine from "../RulesEngine";
import Game from "../Game";
import {updateSharedState} from '../../hooks/useSharedState'
export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('options')
.as('options')
.as('opt')
rules.onCommand('options', () => {
updateSharedState('currentMenu', 'options')
updateSharedState('optionsTab', 'video')
document.getElementById('gameInput')?.blur()
})
parser.understand('save')
.as('save')
.as('load')
.as('restore')
.as('data')
rules.onCommand('save', () => {
updateSharedState('currentMenu', 'options')
updateSharedState('optionsTab', 'data')
document.getElementById('gameInput')?.blur()
})
}
Loading…
Cancel
Save