2fd85bd2-9545-4c6f-9505-8993896582f0.js 3.19 KB
"use strict";
cc._RF.push(module, '2fd85vSlUVMb5UFiZOJZYLw', 'ActivitiesItemModelManager');
// script/game/model/ActivitiesItemModelManager.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivitiesItemModelManager = void 0;
const simba_config_manager_1 = require("simba-config-manager");
const simba_sdk_1 = require("simba-sdk");
const AVG_1 = require("../../avg/AVG");
const ActivitiesConifg_1 = require("../../config/ActivitiesConifg");
const ActivitiesTypeConfig_1 = require("../../config/ActivitiesTypeConfig");
class ActivitiesItemModelManager1 {
    constructor() {
        /**存档Key */
        this.ActivitiesReaded = "ActivitiesReaded";
    }
    /**
     * 获取有效的活动配置信息
     * @returns 返回值为有效的活动配置信息
     */
    getValidActivitiesConfigs() {
        let ret = [];
        let cfg = simba_config_manager_1.ConfigManager.getAllConfig(ActivitiesConifg_1.activitiesConifg);
        for (let id in cfg) {
            let currentTime = simba_sdk_1.TimeManager.getTime();
            if (!cfg[id].isForever && (currentTime < cfg[id].startTime || currentTime > cfg[id].endTime)) {
                continue;
            }
            let typeConfig = simba_config_manager_1.ConfigManager.getConfig(ActivitiesTypeConfig_1.activitiesTypeConfig, cfg[id].activityTypeConfig);
            ret.push({
                activityId: cfg[id].activityId,
                index: cfg[id].index,
                activityTypeConfig: {
                    activityType: typeConfig.activityType,
                    taobaoTempId: typeConfig.taobaoTempId,
                    pageIndex: typeConfig.pageIndex,
                },
                isForever: cfg[id].isForever,
                startTime: cfg[id].startTime,
                endTime: cfg[id].endTime,
                canClick: cfg[id].canClick,
                describe: cfg[id].describe,
            });
        }
        //根据活动配置索引进行排序
        ret.sort((a, b) => {
            if (a.index < b.index) {
                return -1;
            }
            else if (a.index > b.index) {
                return 1;
            }
            return 0;
        });
        return ret;
    }
    /**
     * 保存活动的已读状态
     * @param activityId 活动ID
     */
    setActivitiesReaded(activityId) {
        let readed = AVG_1.GameRecord.globalVariables[this.ActivitiesReaded];
        readed = readed ? readed : [];
        if (readed.indexOf(activityId) == -1) {
            readed.push(activityId);
        }
        let newReaded = [...readed];
        AVG_1.GameRecord.globalVariables[this.ActivitiesReaded] = newReaded;
        AVG_1.GameRecord.saveRecord();
    }
    /**
     * 获取活动的已读状态
     * @param activityId 活动ID
     * @returns 返回值为活动是否已读
     */
    getActivitiesReaded(activityId) {
        let isReaded = false;
        let readed = AVG_1.GameRecord.globalVariables[this.ActivitiesReaded];
        readed = readed ? readed : [];
        if (readed.indexOf(activityId) !== -1) {
            isReaded = true;
        }
        return isReaded;
    }
}
exports.ActivitiesItemModelManager = new ActivitiesItemModelManager1();

cc._RF.pop();