Door can be forced open

main
Ashelyn Dawn 4 years ago
parent 7523173d8a
commit cdc82511a3

@ -53,6 +53,9 @@ export default function Help({parentRef}) {
<li>turn on [thing]</li>
<li>take apart [thing]</li>
</ul>
<p>
Finally, if you get stuck on how to solve a puzzle, try the <Cmd>hint</Cmd> command.
</p>
</>
}

@ -8,6 +8,9 @@ export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('openItem')
.as('open [item]')
.as('open [item] with [item|object]')
.as('pry open [item] with [item|object]')
.as('unlock [item] with [item|object]')
.as('use [item|object] on [item]')
rules.onCommand('openItem', () => {
game.say(`You don't believe that can be opened!`)

@ -5,6 +5,7 @@ import Game from "../Game";
export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('take apart')
.as('take apart [item]')
.as('take [item] apart')
.as('disassemble [item]')
.as('dissassemble [item]')

@ -149,4 +149,4 @@ game.setNeighbor('cabin', 'port', 'comms')
game.setNeighbor('medbay', 'starboard', 'comms')
// DEBUG hallways
game.setNeighbor('bathroom', 'down', 'docking')
// game.setNeighbor('bathroom', 'down', 'docking')

@ -34,6 +34,15 @@ rules.onBeforeCommand(command => {
if(command.verb.name !== 'go' || playerLocation !== 'medbay' || command.subject?.name !== 'starboard')
return;
if((game.findObjectByName('chair leg', ObjectType.Item) as Item)?.location === 'inventory') {
try {
parser.runCommand(`open door with chair leg`)
} catch {
game.pause()
game.clear()
}
}
if(game.getProperty('gamePhase') < Phase.openedDoor)
throw new Error(`The security doors have sealed - you're either going to need to restart the mainframe or find a way to force these open before you can access the comms room.`)
})
@ -43,7 +52,7 @@ rules.onBeforeCommand(command => {
*/
rules.onBeforeCommand(command => {
const playerLocation = game.getCurrentRoom()?.name
if(command.verb.name !== 'openItem' || !command.subject?.aliases.includes('security doors'))
if(command.verb.name !== 'openItem' || !command.subject?.aliases.includes('security doors') || command.object !== null)
return;
if(playerLocation === 'cabin')
@ -311,11 +320,13 @@ rules.onBeforeCommand(command => {
}
game.setProperty('gamePhase', Phase.destroyedChair)
game.addItem('chair leg', 'A sturdy, curved piece of metal about a meter and a half long.', 'inventory')
const leg = game.addItem('chair leg', 'A sturdy, curved piece of metal about a meter and a half long.', 'inventory')
leg.aliases = ['leg', 'prybar', 'stick', 'rod', 'piece of metal']
leg.seen = true
const chair = game.findObjectByName('chair', ObjectType.Item) as Draft<Item>
chair.location = 'bridge'
chair.description += `\n\nHopefully you won't have to destroy this one.`
chair.description += `\n\nHopefully you won't have to destroy this one - they're actually rather expensive.`
chair.lastKnownLocation = undefined
game.say(`(You place the chair leg in your inventory)`)
@ -343,3 +354,21 @@ rules.onBeforeCommand(command => {
game.say(`Climbing on the chair, you just barely manage to reach up to the hole in the ceiling.`)
})
/**
* Open door with leg
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'openItem' || command.subject?.name !== 'med door' || game.getCurrentRoom()?.name !== 'medbay')
return
game.say(`With an uncomfortable grinding noise, and much effort, the security doors slide open allowing you access to the comms room.`)
game.say(`Unfortunately it looks like your chair leg got caught in the mechanism - the good news is this door will stay open, the bad news is you're not getting that back.`)
game.getState().items.delete('med door')
game.getState().items.delete('chair leg')
game.setProperty('gamePhase', Phase.openedDoor)
throw new Error()
})

Loading…
Cancel
Save