hadean-old/src/TaskList.ts

36 lines
858 B
TypeScript
Raw Normal View History

2021-06-14 22:03:55 -04:00
import { Serializable } from 'frigid';
2021-06-16 15:26:42 -04:00
import { ChopTreeTask } from "./tasks/ChopTreeTask.js";
2021-06-14 22:03:55 -04:00
import { Game } from './Game.js';
2021-06-16 15:26:42 -04:00
import { Task } from "./tasks/Task.js";
import { render, Renderable, tasksPanel } from './ui/UI.js';
2021-06-14 22:03:55 -04:00
export class TaskList extends Serializable implements Renderable {
tasks: Task[] = [];
2021-06-15 15:02:47 -04:00
clear() {
for(const task of this.tasks) {
this.removeTask(task);
}
}
2021-06-14 22:03:55 -04:00
static serializationDependencies() {
return [ChopTreeTask, Task];
}
addTask(task) {
this.tasks = [...this.tasks, task];
}
removeTask(task) {
this.tasks = this.tasks.filter(v => v !== task);
}
render() {
// const width = tasksPanel.width;
tasksPanel.setContent(`${this.tasks.map(task => {
return task.toString();
}).join('\n')}`);
// return this.tasks.map(task => task.toString()).join('\n');
}
}