Do not allow picking up scenery

main
Ashelyn Dawn 4 years ago
parent f0e9939cb5
commit 8b4a2086ac

@ -180,12 +180,13 @@ export default class Game {
return door
}
addItem(name : string, description : string, location : string) : Draft<Item> {
addItem(name : string, description : string, location : string, carryable : boolean = false) : Draft<Item> {
let item : Item = {
type: ObjectType.Item,
name, aliases: [], printableName: name, description,
location,
seen: false
seen: false,
carryable
}
let state = this.getState()

@ -17,6 +17,9 @@ export default function(parser : Parser, rules : RulesEngine, game : Game) {
rules.onCommand('take', command => {
const item = command.subject as Draft<Item>
if(!item.carryable)
throw new Error(`You cannot pick up the ${item.name}`)
item.location = 'inventory'
game.say('Taken.')
})

@ -54,5 +54,6 @@ export type Item = GameObject & {
readonly type : ObjectType.Item,
readonly location: ObjectID | 'inventory',
readonly seen : boolean,
readonly lastKnownLocation? : string
readonly lastKnownLocation? : string,
readonly carryable : boolean
}

@ -31,7 +31,7 @@ rules.onAfterCommand(() => {
if(flashlightLocation === 'inventory' && !wrenchExists){
if(game.getProperty('gamePhase') < Phase.hasFlashlight)
game.setProperty('gamePhase', Phase.hasFlashlight)
game.addItem('wrench', 'Just generally useful for repairs and adjustments to the various mechanical parts of the ship.', 'cabin')
game.addItem('wrench', 'Just generally useful for repairs and adjustments to the various mechanical parts of the ship.', 'cabin', true)
}
})
@ -55,7 +55,7 @@ The crew cabin is through the foreward door, and the little remaining space
is occupied with a sink and cabinet.
`)
const flashlight = game.addItem('flashlight', 'Metal rod with some LEDs embedded along its length', 'bathroom')
const flashlight = game.addItem('flashlight', 'Metal rod with some LEDs embedded along its length', 'bathroom', true)
flashlight.aliases.push('flash light')
flashlight.aliases.push('light')
flashlight.aliases.push('torch')

Loading…
Cancel
Save