123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, ch, gui, Container, GameData, Toast, PlayerData, _crd, rand_type, data_type, day_data_type, week_data_type, month_data_type;
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- 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", "../module_game/ui/UI_Main/Layout_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;
- }],
- 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["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() {
- super(...arguments);
- 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.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;
- }
- /**使用道具*/
- use_item(type, count) {
- var _this = this;
- return _asyncToGenerator(function* () {
- if (count === void 0) {
- count = 1;
- }
- // if (GameLink.getInst().state != GameState.wait) return;
- var layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(UI_Main).getLayout();
- var ret = _this.items.useCount(type, count);
- if (ret) {
- var 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) {
- if (count === void 0) {
- count = 1;
- }
- var 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) {
- if (count === void 0) {
- count = -1;
- }
- var 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();
- } //////////////////////////////////////////////////////////////////////////////////////////
- load_data() {
- var _superprop_getLoad_data = () => super.load_data,
- _this2 = this;
- return _asyncToGenerator(function* () {
- return _superprop_getLoad_data().call(_this2);
- })();
- }
- get nickName() {
- return this.user_info.nickName;
- }
- get avatarUrl() {
- return this.user_info.avatar;
- }
- init_user_info() {
- var _this3 = this;
- return _asyncToGenerator(function* () {
- _this3.user_info = {
- uid: _this3.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
- };
- })();
- }
- save_data(save_data) {
- var _superprop_getSave_data = () => super.save_data,
- _this4 = this;
- return _asyncToGenerator(function* () {
- return _superprop_getSave_data().call(_this4, save_data);
- })();
- }
- save_rank_floor() {
- var _this5 = this;
- return _asyncToGenerator(function* () {
- var floor = _this5.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: _this5.user_info.province
- });
- })();
- }
- get_rank_floor() {
- return _asyncToGenerator(function* () {
- var index = 0;
- var d = yield (_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 (var 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
- };
- })();
- }
- loadPfInfo() {
- return _asyncToGenerator(function* () {
- return new Promise( /*#__PURE__*/_asyncToGenerator(function* (resolve) {
- var k = yield (_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=354ff9a96c31eba22617e0be63fbc536039c93e2.js.map
|