From the archive

This commit is contained in:
Nevernown
2025-03-16 15:02:23 +01:00
commit 7ed0202142
21 changed files with 1081 additions and 0 deletions

80
game/scenario/scenario.js Normal file
View File

@@ -0,0 +1,80 @@
const fs = require('fs');
const _ = require('underscore');
let storylines = {};
fs.readdirSync('./game/scenario/storylines').forEach(file => {
require(`./storylines/${file}`)(storylines);
});
function l(context) {
return _.keys(storylines);
}
function v(context) {
return new Promise((resolve, reject) => {
let ok = true;
console.info(`[${context.id}] Verifying map integrity...`);
let uniques = _.chain(context.scenario.map.locations)
.map(location => location.id)
.uniq().value();
if(uniques.length !== context.scenario.map.locations.length) {
console.error(`[${context.id}] ID collision detected`);
reject(new Error("ID Collision in map data"));
}
_.each(context.scenario.map.connections, connection => {
if(!_.contains(uniques, connection.locations[0])) {
console.error(`[${context.id}] Invalid connection detected [${connection.locations[0]}]`);
ok = false;
} else if(!_.contains(uniques, connection.locations[1])) {
console.error(`[${context.id}] Invalid connection detected [${connection.locations[1]}]`);
ok = false;
}
});
if(ok) {
console.info(`[${context.id}] ... Verified map integrity`);
resolve(context);
} else {
reject(new Error("Invalid map data"));
}
});
}
function i(context) {
return new Promise((resolve, reject) => {
if(!context.scenario) {
if(context.storyline) {
if(_.has(storylines, context.storyline)) {
storylines[context.storyline].initialize(context)
.then(context => {
context.state.scenario = context.scenario;
v(context)
.then(context => {
context.message.reply(`Initiated scenario \`[${context.storyline}]\``)
.then(() => {
context.stateChanged = true;
resolve(context);
})
.catch(err => reject(err))
})
.catch(err => reject(err));
})
.catch(err => reject(err));
} else {
console.warn(`[${context.id}] No such storyline named ${context.storyline}.`)
reject(new Error(`No such storyline named ${context.storyline}.`));
}
} else {
console.error(`[${context.id}] Missing storyline context`);
reject(new Error(`Invalid context`));
}
} else {
console.warn(`[${context.id}] Scenario already initiated.`);
reject(new Error(`Scenario already initiated.`));
}
});
}
module.exports = {
init: i,
list: l
}

View File

@@ -0,0 +1,28 @@
let map = require(`./zeppelin/map.json`);
const _ = require('underscore');
function i(context) {
return new Promise((resolve, reject) => {
//Build from here.
let scenario = {};
console.info(`[${context.id}] Loading zeppelin map information`);
scenario.map = map;
console.info(`[${context.id}] Setting auxiliary context`);
scenario.timer = 0;
console.info(`[${context.id}] Succesfully loaded zeppelin scenario`);
context.scenario = scenario;
resolve(context);
});
}
function t(context) {
//populate with triggers.js
//later, calm down.
}
module.exports = storylines => {
storylines['zeppelin'] = {
initialize: i,
trigger: t
}
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,265 @@
{
"locations": [
{
"id": "FRP",
"name": "The freight platform",
"objects": [
{
"id": "CRATE",
"count": 5
},
{
"id": "CRATE_2",
"count": 17
},
{
"id": "CANNISTER",
"count": 3
}
]
},
{
"id": "WTR",
"name": "The waiting room",
"objects": [
{
"id": "BENCH",
"count": 3
}
]
},
{
"id": "PSP",
"name": "The passenger platform",
"objects": [
{
"id": "BENCH",
"count": 1
}
]
},
{
"id": "ENG_L",
"name": "The lower engine room",
"objects": [
{
"id": "ENGINE",
"count": 1
},
{
"id": "RACK",
"count": 2
}
]
},
{
"id": "ENT",
"name": "The entrance hallway",
"objects": [
{
"id": "WARDROBE",
"count": 2
}
]
},
{
"id": "DNH",
"name": "The dining hall",
"objects": [
{
"id": "TABLE",
"count": 3
},
{
"id": "CHAIR",
"count": 24
},
{
"id": "LAMP",
"count": 6
}
]
},
{
"id": "SLN",
"name": "The outlook salon"
},
{
"id": "GLY",
"name": "The galley"
},
{
"id": "FST",
"name": "The food storage"
},
{
"id": "WHL",
"name": "The wheelhouse"
},
{
"id": "ENG_U",
"name": "The upper engine room"
},
{
"id": "GHL",
"name": "The left balloon gangway"
},
{
"id": "GHR",
"name": "The right balloon gangway"
},
{
"id": "CBG",
"name": "The cabin gangway"
},
{
"id": "FRC",
"name": "The freight compartiment"
},
{
"id": "RYL",
"name": "The royal suite"
},
{
"id": "FCL_1",
"name": "First class suite 1"
},
{
"id": "FCL_2",
"name": "First class suite 2"
},
{
"id": "BNK_1",
"name": "Bunkbed cabin 1"
},
{
"id": "BNK_2",
"name": "Bunkbed cabin 2"
},
{
"id": "CRW_1",
"name": "Crew compartiments 1"
},
{
"id": "CRW_2",
"name": "Crew compartiments 2"
},
{
"id": "STR",
"name": "Storage closet"
}
],
"connections": [
{
"locations": ["PSP", "ENT"],
"type": "Steel sealed rolling door",
"blocked": {
"reason": "The rolling door is closed and sealed shut."
}
},
{
"locations": ["FRP", "FRC"],
"type": "Steel sealed rolling door",
"blocked": {
"reason": "The rolling door is closed and sealed shut."
}
},
{
"locations": ["PSP", "FRP"]
},
{
"locations": ["WTR", "PSP"]
},
{
"locations": ["CBG", "ENT"]
},
{
"locations": ["FST", "ENT"],
"type": "Reinforced door",
"blocked": {
"reason": "It's locked.",
"key": ""
}
},
{
"locations": ["GLY", "ENT"],
"type": "Reinforced door"
},
{
"locations": ["DNH", "ENT"],
"type": "Reinforced door"
},
{
"locations": ["DNH", "SLN"],
"type": "Stairs"
},
{
"locations": ["WHL", "SLN"],
"type": "Stairs"
},
{
"locations": ["WHL", "GHR"],
"type": "Reinforced door"
},
{
"locations": ["WHL", "GHL"],
"type": "Reinforced door"
},
{
"locations": ["ENG_U", "GHR"]
},
{
"locations": ["ENG_U", "GHL"]
},
{
"locations": ["ENG_U", "ENG_L"],
"type": "welded steel ladder"
},
{
"locations": ["ENG_L", "FRC"]
},
{
"locations": ["FRC", "CBG"]
},
{
"locations": ["RYL", "CBG"],
"type": "Reinforced door",
"blocked": {
"reason": "It's locked.",
"key": ""
}
},
{
"locations": ["FCL_1", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["FCL_2", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["BNK_1", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["BNK_2", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["CRW_1", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["CRW_2", "CBG"],
"type": "Reinforced door"
},
{
"locations": ["STR", "CBG"],
"type": "Reinforced door",
"blocked": {
"reason": "It's locked.",
"key": ""
}
}
]
}

View File

@@ -0,0 +1,106 @@
[
{
"id": "TABLE",
"name": "table",
"desc": "a regular table"
},
{
"id": "TABLE_2",
"name": "coffee table",
"desc": "a low table typically used to place drinks on"
},
{
"id": "CHAIR",
"name": "chair",
"desc": "a wooden chair"
},
{
"id": "SOFA",
"name": "sofa",
"desc": "a soft, fancy two-person chair"
},
{
"id": "CHAIR_2",
"name": "chair",
"desc": "a richly colored, soft chair"
},
{
"id": "BED",
"name": "bed",
"desc": "a place to sleep for one person"
},
{
"id": "BED_2",
"name": "bed",
"desc": "a place to sleep for two people"
},
{
"id": "BUNKBED",
"name": "bunkbed",
"desc": "a place to sleep for two single people"
},
{
"id": "ENGINE",
"name": "engine",
"desc": "without this, the zeppelin can only float"
},
{
"id": "CANNISTER",
"name": "spare cannister",
"desc": "holds extra gas to replenish the zeppelin"
},
{
"id": "CRATE",
"name": "crate",
"desc": "a big box"
},
{
"id": "CRATE_2",
"name": "small crate",
"desc": "a small box"
},
{
"id": "VASE",
"name": "vase",
"desc": "Glued in place to survive turbulence"
},
{
"id": "SAFE",
"name": "safe",
"desc": "a place to sleep for two people",
"inv": {
"locked": true,
"key": "SAFE_KEY_01"
}
},
{
"id": "WHEEL",
"name": "steering wheel",
"desc": "controls the rudder at the back of the zeppelin"
},
{
"id": "WINDOW",
"name": "window",
"desc": "the reinforced glass is not quite reassuring"
},
{
"id": "BENCH",
"name": "wooden bench",
"desc": "not quite first-class"
},
{
"id": "RACK",
"name": "tool rack",
"desc": "holds tools for quick use"
},
{
"id": "WARDROBE",
"name": "reinforced wardrobe",
"desc": "keeps clothing safe during the flight"
},
{
"id": "LAMP",
"name": "oil lamp",
"desc": "as safe as it gets, gives off some light"
}
]