parent
3f7987f482
commit
c54f9b6273
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@ |
||||
const express = require("express"); |
||||
const socketIO = require("socket.io"); |
||||
const state = require("./state.js"); |
||||
|
||||
const PORT = 3001; |
||||
|
||||
const app = express(); |
||||
const server = app.listen(PORT, () => console.log(`Example app listening on port ${PORT}!`)); |
||||
const io = socketIO(server); |
||||
|
||||
app.get('/', (req, res) => res.send('<pre>' + JSON.stringify(state) + '</pre>')); |
||||
|
||||
module.exports = { |
||||
app, server, io |
||||
}; |
@ -0,0 +1,39 @@ |
||||
const timeline = require('../data/timeline.js'); |
||||
|
||||
/** |
||||
* |
||||
* @param i |
||||
* @returns {*} |
||||
*/ |
||||
function getIndex(i) { |
||||
if (i >= timeline.length) { |
||||
return; |
||||
} |
||||
|
||||
return timeline[i]; |
||||
} |
||||
|
||||
/** |
||||
* @param {number} i - the index. |
||||
* @returns {{count: number, timestamp: number}|undefined} |
||||
*/ |
||||
function getNextShot(i) { |
||||
for (; i < timeline.length; i++) { |
||||
const time = getIndex(i); |
||||
|
||||
for (let event of time.events) { |
||||
if (event.type === 'shot') { |
||||
return { |
||||
timestamp: time.timestamp, |
||||
count: event.shotCount |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return undefined; |
||||
} |
||||
|
||||
module.exports = { |
||||
getIndex, getNextShot |
||||
}; |
@ -1,15 +0,0 @@ |
||||
const express = require('express'); |
||||
const state = require('./state.js'); |
||||
const b = require('./b.js'); |
||||
|
||||
const PORT = 3002; |
||||
|
||||
const app = express(); |
||||
const server = app.listen(PORT, () => console.log(`Example app listening on port ${PORT}!`)); |
||||
|
||||
app.get('/', (req, res) => { |
||||
let i = state.a; |
||||
b.test(i += 1); |
||||
|
||||
return res.send('<pre>' + JSON.stringify(state) + '</pre>') |
||||
}); |
@ -1,7 +0,0 @@ |
||||
const state = require('./state.js'); |
||||
|
||||
module.exports = { |
||||
test: (i) => { |
||||
state.setA(i); |
||||
} |
||||
}; |
@ -1,12 +0,0 @@ |
||||
class State { |
||||
a = 3; |
||||
constructor() { |
||||
|
||||
} |
||||
|
||||
setA(i) { |
||||
this.a = i; |
||||
} |
||||
} |
||||
|
||||
module.exports = new State(); |
@ -0,0 +1,17 @@ |
||||
export interface Tick { |
||||
current: number, |
||||
next: { |
||||
timestamp: number, |
||||
events: TimestampEvent[] |
||||
}, |
||||
nextShot?: { |
||||
timestamp: number, |
||||
count: number |
||||
} |
||||
} |
||||
|
||||
export interface TimestampEvent { |
||||
type: 'talk' | 'shot' | 'song' | 'time', |
||||
text: string[], |
||||
shotCount?: number |
||||
} |
Loading…
Reference in new issue