System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6"], function (_export, _context) { "use strict"; var _reporterNs, _cclegacy, ch, gui, Container, GameData, Toast, UI_Main, PlayerData, _crd, rand_type, data_type, day_data_type, week_data_type, month_data_type; function _reportPossibleCrUseOfch(extras) { _reporterNs.report("ch", "../../ch/ch", _context.meta, extras); } function _reportPossibleCrUseOfgui(extras) { _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras); } function _reportPossibleCrUseOfContainer(extras) { _reporterNs.report("Container", "../../core/util_class/Container", _context.meta, extras); } function _reportPossibleCrUseOfGameData(extras) { _reporterNs.report("GameData", "../../core/util_class/GameData", _context.meta, extras); } function _reportPossibleCrUseOfToast(extras) { _reporterNs.report("Toast", "../../core/util_class/Toast", _context.meta, extras); } function _reportPossibleCrUseOfLayout_Main(extras) { _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras); } function _reportPossibleCrUseOfUI_Main(extras) { _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras); } _export("default", void 0); return { setters: [function (_unresolved_) { _reporterNs = _unresolved_; }, function (_cc) { _cclegacy = _cc.cclegacy; }, function (_unresolved_2) { ch = _unresolved_2.ch; }, function (_unresolved_3) { gui = _unresolved_3.gui; }, function (_unresolved_4) { Container = _unresolved_4.Container; }, function (_unresolved_5) { GameData = _unresolved_5.default; }, function (_unresolved_6) { Toast = _unresolved_6.Toast; }, function (_unresolved_7) { UI_Main = _unresolved_7.UI_Main; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "b500dzoF+pEaLB1EsW0vW75", "PlayerData", undefined); //定义事件 //排行榜key _export("rand_type", rand_type = /*#__PURE__*/function (rand_type) { rand_type["floor"] = "floor"; return rand_type; }({})); //自定义数据 _export("data_type", data_type = /*#__PURE__*/function (data_type) { data_type["last_gift_sidebar"] = "last_gift_sidebar"; data_type["max_floor"] = "max_floor"; data_type["coin"] = "coin"; data_type["life"] = "life"; data_type["life_countdown"] = "life_countdown"; data_type["last_exit_time"] = "last_exit_time"; return data_type; }({})); //每日数据 _export("day_data_type", day_data_type = /*#__PURE__*/function (day_data_type) { day_data_type["isFavorite"] = "isFavorite"; day_data_type["pass_level"] = "pass_level"; day_data_type["combine_num"] = "combine_num"; day_data_type["login_num"] = "login_num"; day_data_type["use_item"] = "use_item"; day_data_type["watch_ad"] = "watch_ad"; day_data_type["task_reward_state"] = "task_reward_state"; day_data_type["store_state"] = "store_state"; return day_data_type; }({})); //每周数据 _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) { week_data_type["sign_day"] = "sign_day"; return week_data_type; }({})); //每月数据 _export("month_data_type", month_data_type = /*#__PURE__*/function (month_data_type) { return month_data_type; }({})); _export("default", PlayerData = class PlayerData extends (_crd && GameData === void 0 ? (_reportPossibleCrUseOfGameData({ error: Error() }), GameData) : GameData) { constructor(...args) { super(...args); this.event = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).get_new_event(); //道具容器 this.items = new (_crd && Container === void 0 ? (_reportPossibleCrUseOfContainer({ error: Error() }), Container) : Container)(); this.user_info = void 0; } static getInstance(gid, uid) { if (!this._instance) { this._instance = new PlayerData(gid, uid, "PlayerData", new Map([[data_type.max_floor, { min: 0 }], [data_type.coin, { min: 0 }], [data_type.life, { min: 0, max: 5 }]]), new Map([[day_data_type.isFavorite, { min: 0 }], [day_data_type.pass_level, { min: 0, max: 5 }], [day_data_type.combine_num, { min: 0, max: 100 }], [day_data_type.login_num, { min: 0, max: 1 }], [day_data_type.use_item, { min: 0, max: 3 }], [day_data_type.watch_ad, { min: 0, max: 8 }]]), new Map([[week_data_type.sign_day, { min: 0, max: 7 }]])); } return this._instance; } //数据初始化 on_init() { (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sign.init(2, null, 7); this.items.addItem({ type: 1, count: 1 }); this.items.addItem({ type: 2, count: 1 }); this.items.addItem({ type: 3, count: 1 }); this.items.addItem({ type: 5, count: 0 }); //道具初始化 (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).log.log("道具初始化", this); } //序列化加入自定义数据 on_serialize(data) { data.sign = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sign.getSignData(); data.items = this.items.serialize(); } //反序列化加入自定义数据 on_unserialize(data) { this.items.unserialize(data.items); (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sign.init(2, data.sign, 7); } //是否使用远程数据 on_check(local, remote) { return true; } /**使用道具*/ async use_item(type, count = 1) { // if (GameLink.getInst().state != GameState.wait) return; const layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({ error: Error() }), UI_Main) : UI_Main).getLayout(); let ret = this.items.useCount(type, count); if (ret) { let b = true; if (type == 1) { layout.Container.eliminate(); } else if (type == 2) { layout.Container.shuffle(); } else if (type == 3) { layout.Container.Empty(); } else if (type == 5) { layout.Container.AddTime(); } this.set_use_item_num(1); this.event.emit(this.event.key.item_count, ret.type, ret.count); this.setDirty(); } } /**增加道具*/ add_item(type, count = 1) { let ret = this.items.addCount(type, count); if (ret) { this.event.emit(this.event.key.item_count, ret.type, ret.count); this.setDirty(); } } set_item(type, count = -1) { const c = this.get_item(type); if (type < count) { this.add_item(type, count - c); } } get_item(type) { return this.items.getCount(type); } //获取签到天数 get_sign() { return this.week_data.get(week_data_type.sign_day); } //设置签到天数 set_sign(count) { this.week_data.set(week_data_type.sign_day, count); } //获取是否当日首次通过收藏进入 get_is_favorite() { return this.day_data.get(day_data_type.isFavorite); } //设置已从收藏进入 set_is_favorite() { this.day_data.set(day_data_type.isFavorite, 1); this.setDirty(); } //获取关卡数 get_max_floor() { return this.data.get(data_type.max_floor); } //设置关卡数 set_max_floor(floor) { this.data.set(data_type.max_floor, floor); } //获取铜币数量 get_coin() { return this.data.get(data_type.coin); } //设置铜币数量 set_coin(coin) { this.data.set(data_type.coin, coin); this.setDirty(); } //获取今日通关数 get_pass_level() { return this.day_data.get(day_data_type.pass_level); } //设置今日通关数 set_pass_level(level) { this.day_data.add(day_data_type.pass_level, level); } //获取匹配成语数量 get_combine_num() { return this.day_data.get(day_data_type.combine_num); } //设置匹配成语数量 set_combine_num(num) { this.day_data.add(day_data_type.combine_num, num); this.setDirty(); } //获取登录次数 get_login_num() { return this.day_data.get(day_data_type.login_num); } //设置登录次数 set_login_num(num) { this.day_data.add(day_data_type.login_num, num); this.setDirty(); } //获取今日使用道具数量 get_use_item_num() { return this.day_data.get(day_data_type.use_item); } //设置今日使用道具数量 set_use_item_num(num) { this.day_data.add(day_data_type.use_item, num); } //获取今日广告观看数量 get_watch_ad_num() { return this.day_data.get(day_data_type.watch_ad); } //设置今日广告观看数量 set_watch_ad_num(num) { this.day_data.add(day_data_type.watch_ad, num); this.setDirty(); } //获取任务奖励状态 get_task_state() { return this.day_data.get_Array(day_data_type.task_reward_state); } //设置任务奖励状态 set_task_state(task_state) { this.day_data.set_Array(day_data_type.task_reward_state, task_state); this.setDirty(); } //获取商店免费领取状态 get_store_state() { return this.day_data.get_Array(day_data_type.store_state); } //设置商店免费领取状态 set_store_state(shop_state) { this.day_data.set_Array(day_data_type.store_state, shop_state); this.setDirty(); } //获取体力 get_life() { return this.data.get(data_type.life); } //设置体力 set_life(life) { if (life > 5) { life = 5; } else if (life < 0) { life = 0; } this.data.set(data_type.life, life); this.setDirty(); } //获取体力倒计时 get_life_countdown() { return this.data.get(data_type.life_countdown); } //设置体力倒计时 set_life_countdown(life_countdown) { this.data.set(data_type.life_countdown, life_countdown); this.setDirty(); } //获取上次退出时间 get_last_exit_time() { return this.data.get(data_type.last_exit_time); } //设置上次退出时间 set_last_exit_time(last_exit_time) { this.data.set(data_type.last_exit_time, last_exit_time); this.setDirty(); } ////////////////////////////////////////////////////////////////////////////////////////// async load_data() { return super.load_data(); } get nickName() { return this.user_info.nickName; } get avatarUrl() { return this.user_info.avatar; } async init_user_info() { this.user_info = { uid: this.uid, nickName: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.get_player_info().nickName, avatar: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.get_player_info().avatarUrl, province: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.get_player_info().province }; } async save_data(save_data) { return super.save_data(save_data); } async save_rank_floor() { const floor = this.data.get(data_type.max_floor); (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.saveRankData(rand_type.floor, floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.updateType.none, 0, { province: this.user_info.province }); } async get_rank_floor() { let index = 0; const d = await (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.loadRankData(rand_type.floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.updateType.none, 100, true, false); console.log("排行榜", d); if (d.data.own) { for (let i = 0; i < d.data.list.length; i++) { if (d.data.own.userId === d.data.list[i].userId) { index = i + 1; } } if (d.data.own.rank > 100) { index = 101; } } else { index = 101; } return { list: d.data.list, owner: d.data.own, index: index }; } async loadPfInfo() { return new Promise(async resolve => { let k = await (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.getUserInfo(); if (k) { resolve(true); } else { (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({ error: Error() }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).getLayerNode(5), '需要授权').show(); resolve(false); } }); } }); PlayerData._instance = void 0; _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=f4d2caaedb68c7cfbc7404fad5d909315a34b1a0.js.map