Open item dummy verb

main
Ashelyn Dawn 4 years ago
parent 1ba5d33ff7
commit f6e233d474

@ -3,7 +3,7 @@
height: 25px;
display: flex;
flex-direction: row;
padding: 0 16px;
padding: 8px 16px;
padding-top: 16px;
}

@ -97,7 +97,7 @@ export default function Text({promptVisible: promptEnabled, handleCommand, showR
<>
<div ref={textRef} className={styles.playArea}>
<Menu containerRef={menuRef}/>
<div ref={outputRef} onScroll={() => setCurrentScroll(outputRef.current?.scrollTop)} className={styles.output + (currentMenu !== null ? ' ' + styles.noMouse : '')}>
<div ref={outputRef} onScroll={() => setCurrentScroll(outputRef.current?.scrollTop)} className={styles.output + (!!currentMenu ? ' ' + styles.noMouse : '')}>
{finalMessages.map((message, i) => {
if(message.type === 'message')
return <ReactMarkdown key={i}>{message.message}</ReactMarkdown>

@ -23,4 +23,12 @@ export default function(parser : Parser, rules : RulesEngine, game : Game) {
const mutable = game.findObjectByName(door.name, ObjectType.Door);
(mutable as Draft<Door>).open = true
})
}
parser.understand('openItem')
.as('open [item]')
rules.onCommand('openItem', () => {
game.say(`You don't believe that can be opened!`)
})
}

@ -1,6 +1,7 @@
import {game, rules, renderer} from './engine/'
import './rooms.tsx'
import { ValidCommandDetails } from './engine/types/ParsedCommand'
// Initial player location
game.getState().player.location = 'cabin'
@ -20,7 +21,7 @@ const setItemLastLoc = () => game.findObjectsInRoom(game.getCurrentRoom()!.name)
rules.onGameStart(setItemLastLoc)
rules.onAfterCommand(setItemLastLoc)
game.addItem('Block', 'A boring wooden block', 'commons')
game.addItem('block', 'A boring wooden block', 'commons')
game.saveDraft()
@ -33,6 +34,15 @@ rules.onGameStart(() => {
game.clear()
})
rules.onBeforeCommand(command => {
if(command.verb.name !== 'openItem') return
if(command.subject?.name !== 'block') return;
console.log('opening block')
throw new Error()
})
renderer.start(document.getElementById('root'))

Loading…
Cancel
Save