@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
35 lines (28 loc) • 770 B
JavaScript
import { Matcher } from "../Matcher.js";
import { NullDescription } from "../NullDescription.js";
import { BaseMatcher } from "../BaseMatcher.js";
export class AnyOf extends BaseMatcher {
/**
* @type {Matcher[]}
*/
#matchers;
/**
*
* @param {Matcher[]} matchers
*/
constructor(matchers) {
super();
this.#matchers = matchers;
}
matches(item, mismatch_description) {
for (const matcher of this.#matchers) {
if (matcher.matches(item, NullDescription.INSTANCE)) {
return true;
}
}
return false;
}
describeTo(description) {
description.appendList("(", " or ", ")", this.#matchers);
}
}