System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7"], function (_export, _context) { "use strict"; var _reporterNs, _cclegacy, ch, gui, Container, GameData, UINotify, Start, 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 _reportPossibleCrUseOfUINotify(extras) { _reporterNs.report("UINotify", "../../module_basic/ui_notify/UINotify", _context.meta, extras); } function _reportPossibleCrUseOfStart(extras) { _reporterNs.report("Start", "../../start/Start", _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) { UINotify = _unresolved_6.UINotify; }, function (_unresolved_7) { Start = _unresolved_7.Start; }, function (_unresolved_8) { UI_Main = _unresolved_8.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"; return data_type; }({})); //每日数据 _export("day_data_type", day_data_type = /*#__PURE__*/function (day_data_type) { day_data_type["sign_gift"] = "sign_gift"; day_data_type["isFavorite"] = "isFavorite"; return day_data_type; }({})); //每周数据 _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) { 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 }]]), new Map([[day_data_type.sign_gift, { 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 }); //道具初始化 (_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(); } if (!b) { this.items.addCount(type, count); } else { 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 = 4) { 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.day_data.get(day_data_type.sign_gift); } //设置签到天数 set_sign(count) { this.day_data.set(day_data_type.sign_gift, 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); } ////////////////////////////////////////////////////////////////////////////////////////// async load_data() { if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) { return new Promise((resolve, reject) => {}); } else { return super.load_data(); } } get nickName() { return this.user_info.nickName; } get avatarUrl() { return this.user_info.avatar; } async init_user_info() { if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) {} else { 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) { if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) { return true; } else { return super.save_data(save_data); } } async save_rank_floor() { if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) {} else { 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; if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) {} else { 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; } } } 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) { if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({ error: Error() }), Start) : Start).packId == 1) {} resolve(true); } else { (_crd && UINotify === void 0 ? (_reportPossibleCrUseOfUINotify({ error: Error() }), UINotify) : UINotify).show("需要授权"); resolve(false); } }); } }); PlayerData._instance = void 0; _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js.map