import { assert } from "../../../core/assert.js";

/**
 * @template T
 * @author Alex Goldring
 * @copyright Company Named Limited (c) 2026
 */
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);
    }
}
