UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

35 lines (26 loc) 883 B
import { CellMatcherBinary } from "./CellMatcherBinary.js"; import { assert } from "../../../core/assert.js"; export class CellMatcherAnd extends CellMatcherBinary { match(grid, x, y, rotation) { if (!this.left.match(grid, x, y, rotation)) { return false; } return this.right.match(grid, x, y, rotation); } /** * * @param {CellMatcher} left * @param {CellMatcher} right * @returns {CellMatcherAnd} */ static from(left, right) { assert.defined(left, 'left'); assert.defined(right, 'right'); assert.equal(left.isCellMatcher, true, 'left.isGridCellRule'); assert.equal(right.isCellMatcher, true, 'right.isGridCellRule'); const r = new CellMatcherAnd(); r.left = left; r.right = right; return r; } }