UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

60 lines (51 loc) 1.1 kB
import { assert } from "../../../core/assert.js"; /** * @template T * @author Alex Goldring * @copyright Company Named Limited (c) 2025 */ export class Resource { /** * @template T * @param {number} amount * @param {T} type */ constructor(amount, type) { assert.isNumber(amount, 'amount'); assert.defined(type, 'type'); assert.notNull(type, 'type'); /** * * @type {T} */ this.type = type; /** * * @type {number} */ this.amount = amount; } /** * * @param {Resource} other * @returns {boolean} */ equals(other) { return this.type === other.type && this.amount === other.amount; } /** * * @param {Resource}other */ copy(other) { this.amount = other.amount; this.type = other.type; } /** * * @returns {Resource} */ clone() { return new Resource(this.amount, this.type); } }