const EMPTY = "empty" const FILL = "fill" const POUR = "pour" const UNKNOWN = "unknown" class Action { constructor({ kind = UNKNOWN, target, src } = {}) { this.kind = kind this.target = target this.src = src } isEmpty() { return this.kind === EMPTY; } isFill() { return this.kind === FILL; } isPour() { return this.kind === POUR; } string() { if (this.kind === POUR) { return `${this.kind} ${this.src} → ${this.target}` } return `${this.kind} ${this.target}` } } module.exports = { fill(index) { return new Action({ kind: FILL, target: index }) }, empty(index) { return new Action({ kind: EMPTY, target: index }) }, pour(src, target) { return new Action({ kind: POUR, target, src }) }, }