initial bot commit
This commit is contained in:
commit
9eda4abcf7
10 changed files with 503 additions and 0 deletions
49
lights/light_parser.js
Normal file
49
lights/light_parser.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
class Target {
|
||||
constructor(channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
channel;
|
||||
value;
|
||||
}
|
||||
|
||||
const available_targets = {
|
||||
r: new Target("r"),
|
||||
g: new Target("g"),
|
||||
b: new Target("b")
|
||||
};
|
||||
|
||||
class Instruction {
|
||||
constructor(t1ets, args) {
|
||||
let valid_targets = [];
|
||||
targets.forEach(t => {
|
||||
if (t instanceof Target) {
|
||||
let match = Object.keys(available_targets).find(key => available_targets[key].channel === t.channel);
|
||||
if (match) {
|
||||
valid_targets.push(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.targets = valid_targets;
|
||||
this.args = args;
|
||||
}
|
||||
name;
|
||||
targets;
|
||||
args;
|
||||
transform(index, time, channel_target, channel_in) {}
|
||||
transformAll(index, time) {
|
||||
let new_targets = [];
|
||||
this.targets.forEach(target => {
|
||||
this.transform(index, time, target, this.args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class ConstantColor extends Instruction {
|
||||
name = "CONSTANT";
|
||||
transform(index, time, channel_target) {}
|
||||
}
|
||||
export const instructions = [ConstantColor];
|
||||
|
||||
export default function parse(str) {
|
||||
return [{}];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue