UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

58 lines (49 loc) 1.03 kB
import { assert } from "../../../core/assert.js"; /** * @template T */ 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); } }