

export default class BuildingModel {

    /**@type {number} */
    goldUnit = 0;
    
    /**@type {number} */
    hasNext = 0;

    /**@type {number} */
    roomId = 0;

    /**@type {number} */
    level = 0;

    /**@type {string} */
    name = "";

    /**@type {number} */
    nextRate = 0;

    /**@type {number} */
    nextUpGold = 0;

    /**@type {number} */
    nextGold = 0;

    /**@type {number} */
    rate = 0;

    /**@type {number} */
    jobId = 0;

    /**@type {number} */
    unlockScore = 0;

    /**@type {number} */
    isUnlocked = 0;

    /**@type {number} */
    coinCount = 0;

    /**@type {number} */
    gold = 0;

    /**@type {number} */
    buildingLevel = 0;

    constructor(data) {

        // this.coinCount = data.coinCount || 0;
        this.goldUnit = data.goldUnit;
        this.gold = data.gold;
        this.hasNext = data.hasNext;
        this.roomId = (data.roomId === undefined) ? data.id : data.roomId;
        this.level = data.level;
        this.name = data.name;
        this.nextRate = data.nextRate;
        this.nextUpGold = data.nextUpGold;
        this.nextGold = data.nextGold;
        this.rate = data.rate;
        this.jobId = data.jobId;
        this.buildingLevel = data.buildingLevel;
        
        if (data.unlockScore && data.unlockScore !== 0) {
            this.unlockScore = data.unlockScore;    
            this.isUnlocked = 0;
        } else {
            this.isUnlocked = 1;
        }
    }

    isFull() {

        if (this.roomLevel && this.roomLevel == Global.BuildingManager.getLevelCount(this.roomId)) {
            return true;
        } else {
            return false;
        }
    }
}

