aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/sources/scripts/source.js
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-21 11:48:39 +1200
committerDevine Lu Linvega <[email protected]>2018-12-21 11:48:39 +1200
commit4bc30cd84560ded39297b036854095a8784a78c8 (patch)
tree113d6fc6923bc2a98c61e071c6729dbd18f87a4f /desktop/sources/scripts/source.js
parent0523e594420b7346032799919e5d6e57a96647ac (diff)
downloadOrca-4bc30cd84560ded39297b036854095a8784a78c8.tar.gz
Orca-4bc30cd84560ded39297b036854095a8784a78c8.zip
Removed the concept of rooms.
Diffstat (limited to 'desktop/sources/scripts/source.js')
-rw-r--r--desktop/sources/scripts/source.js43
1 files changed, 8 insertions, 35 deletions
diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js
index a662b0f..82cfe45 100644
--- a/desktop/sources/scripts/source.js
+++ b/desktop/sources/scripts/source.js
@@ -12,9 +12,7 @@ function Source (terminal) {
this.path = null
- terminal.rooms = { lobby: new Orca(terminal) }
- terminal.room = terminal.rooms.lobby
- terminal.enter()
+ terminal.orca = new Orca(terminal)
terminal.resize()
terminal.history.reset()
}
@@ -57,48 +55,23 @@ function Source (terminal) {
this.read = function (path) {
fs.readFile(path, 'utf8', (err, data) => {
if (err) throw err
- const rooms = this.parse(data)
- terminal.load(rooms)
+ terminal.load(this.parse(data))
terminal.history.record()
})
}
// Converters
- this.generate = function (rooms = terminal.rooms) {
- let html = `${rooms.lobby}\n\n`
- for (const id in rooms) {
- if (id !== 'lobby') {
- const room = rooms[id]
- html += `${id}\n\n${room}\n\n`
- }
- }
- return html.trim()
+ this.generate = function (orca = terminal.orca) {
+ return `${orca}`
}
this.parse = function (text) {
const lines = text.split('\n')
- const blocks = { lobby: [] }
- const rooms = { lobby: [] }
- const room = []
- let key = 'lobby'
- // Blocks
- for (const id in lines) {
- const line = lines[id].trim()
- if (line.length === 0) { continue }
- if (line.length === 1) { key = line; continue }
- if (!blocks[key]) { blocks[key] = [] }
- blocks[key].push(line)
- }
- // Rooms
- for (const id in blocks) {
- const block = blocks[id]
- const w = block[0].length
- const h = block.length
- const s = block.join('\n').trim()
- rooms[id] = new Orca(terminal).load(w, h, s)
- }
- return rooms
+ const w = lines[0].length
+ const h = lines.length
+ const s = lines.join('\n').trim()
+ return new Orca(terminal).load(w, h, s)
}
// Etc