9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6"], function (_export, _context) {
  2. "use strict";
  3. 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;
  4. 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); } }
  5. 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); }); }; }
  6. function _reportPossibleCrUseOfch(extras) {
  7. _reporterNs.report("ch", "../../ch/ch", _context.meta, extras);
  8. }
  9. function _reportPossibleCrUseOfgui(extras) {
  10. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfContainer(extras) {
  13. _reporterNs.report("Container", "../../core/util_class/Container", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfGameData(extras) {
  16. _reporterNs.report("GameData", "../../core/util_class/GameData", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfToast(extras) {
  19. _reporterNs.report("Toast", "../../core/util_class/Toast", _context.meta, extras);
  20. }
  21. function _reportPossibleCrUseOfLayout_Main(extras) {
  22. _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfUI_Main(extras) {
  25. _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras);
  26. }
  27. _export("default", void 0);
  28. return {
  29. setters: [function (_unresolved_) {
  30. _reporterNs = _unresolved_;
  31. }, function (_cc) {
  32. _cclegacy = _cc.cclegacy;
  33. }, function (_unresolved_2) {
  34. ch = _unresolved_2.ch;
  35. }, function (_unresolved_3) {
  36. gui = _unresolved_3.gui;
  37. }, function (_unresolved_4) {
  38. Container = _unresolved_4.Container;
  39. }, function (_unresolved_5) {
  40. GameData = _unresolved_5.default;
  41. }, function (_unresolved_6) {
  42. Toast = _unresolved_6.Toast;
  43. }, function (_unresolved_7) {
  44. UI_Main = _unresolved_7.UI_Main;
  45. }],
  46. execute: function () {
  47. _crd = true;
  48. _cclegacy._RF.push({}, "b500dzoF+pEaLB1EsW0vW75", "PlayerData", undefined);
  49. //定义事件
  50. //排行榜key
  51. _export("rand_type", rand_type = /*#__PURE__*/function (rand_type) {
  52. rand_type["floor"] = "floor";
  53. return rand_type;
  54. }({})); //自定义数据
  55. _export("data_type", data_type = /*#__PURE__*/function (data_type) {
  56. data_type["last_gift_sidebar"] = "last_gift_sidebar";
  57. data_type["max_floor"] = "max_floor";
  58. data_type["coin"] = "coin";
  59. data_type["life"] = "life";
  60. data_type["life_countdown"] = "life_countdown";
  61. data_type["last_exit_time"] = "last_exit_time";
  62. return data_type;
  63. }({})); //每日数据
  64. _export("day_data_type", day_data_type = /*#__PURE__*/function (day_data_type) {
  65. day_data_type["isFavorite"] = "isFavorite";
  66. day_data_type["pass_level"] = "pass_level";
  67. day_data_type["combine_num"] = "combine_num";
  68. day_data_type["login_num"] = "login_num";
  69. day_data_type["use_item"] = "use_item";
  70. day_data_type["watch_ad"] = "watch_ad";
  71. day_data_type["task_reward_state"] = "task_reward_state";
  72. day_data_type["store_state"] = "store_state";
  73. return day_data_type;
  74. }({})); //每周数据
  75. _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) {
  76. week_data_type["sign_day"] = "sign_day";
  77. return week_data_type;
  78. }({})); //每月数据
  79. _export("month_data_type", month_data_type = /*#__PURE__*/function (month_data_type) {
  80. return month_data_type;
  81. }({}));
  82. _export("default", PlayerData = class PlayerData extends (_crd && GameData === void 0 ? (_reportPossibleCrUseOfGameData({
  83. error: Error()
  84. }), GameData) : GameData) {
  85. constructor() {
  86. super(...arguments);
  87. this.event = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  88. error: Error()
  89. }), ch) : ch).get_new_event();
  90. //道具容器
  91. this.items = new (_crd && Container === void 0 ? (_reportPossibleCrUseOfContainer({
  92. error: Error()
  93. }), Container) : Container)();
  94. this.user_info = void 0;
  95. }
  96. static getInstance(gid, uid) {
  97. if (!this._instance) {
  98. this._instance = new PlayerData(gid, uid, "PlayerData", new Map([[data_type.max_floor, {
  99. min: 0
  100. }], [data_type.coin, {
  101. min: 0
  102. }], [data_type.life, {
  103. min: 0,
  104. max: 5
  105. }]]), new Map([[day_data_type.isFavorite, {
  106. min: 0
  107. }], [day_data_type.pass_level, {
  108. min: 0,
  109. max: 5
  110. }], [day_data_type.combine_num, {
  111. min: 0,
  112. max: 100
  113. }], [day_data_type.login_num, {
  114. min: 0,
  115. max: 1
  116. }], [day_data_type.use_item, {
  117. min: 0,
  118. max: 3
  119. }], [day_data_type.watch_ad, {
  120. min: 0,
  121. max: 8
  122. }]]), new Map([[week_data_type.sign_day, {
  123. min: 0,
  124. max: 7
  125. }]]));
  126. }
  127. return this._instance;
  128. } //数据初始化
  129. on_init() {
  130. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  131. error: Error()
  132. }), ch) : ch).sign.init(2, null, 7);
  133. this.items.addItem({
  134. type: 1,
  135. count: 1
  136. });
  137. this.items.addItem({
  138. type: 2,
  139. count: 1
  140. });
  141. this.items.addItem({
  142. type: 3,
  143. count: 1
  144. });
  145. this.items.addItem({
  146. type: 5,
  147. count: 0
  148. }); //道具初始化
  149. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  150. error: Error()
  151. }), ch) : ch).log.log("道具初始化", this);
  152. } //序列化加入自定义数据
  153. on_serialize(data) {
  154. data.sign = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  155. error: Error()
  156. }), ch) : ch).sign.getSignData();
  157. data.items = this.items.serialize();
  158. } //反序列化加入自定义数据
  159. on_unserialize(data) {
  160. this.items.unserialize(data.items);
  161. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  162. error: Error()
  163. }), ch) : ch).sign.init(2, data.sign, 7);
  164. } //是否使用远程数据
  165. on_check(local, remote) {
  166. return true;
  167. }
  168. /**使用道具*/
  169. use_item(type, count) {
  170. var _this = this;
  171. return _asyncToGenerator(function* () {
  172. if (count === void 0) {
  173. count = 1;
  174. }
  175. // if (GameLink.getInst().state != GameState.wait) return;
  176. var layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  177. error: Error()
  178. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  179. error: Error()
  180. }), UI_Main) : UI_Main).getLayout();
  181. var ret = _this.items.useCount(type, count);
  182. if (ret) {
  183. var b = true;
  184. if (type == 1) {
  185. layout.Container.eliminate();
  186. } else if (type == 2) {
  187. layout.Container.shuffle();
  188. } else if (type == 3) {
  189. layout.Container.Empty();
  190. } else if (type == 5) {
  191. layout.Container.AddTime();
  192. }
  193. _this.set_use_item_num(1);
  194. _this.event.emit(_this.event.key.item_count, ret.type, ret.count);
  195. _this.setDirty();
  196. }
  197. })();
  198. }
  199. /**增加道具*/
  200. add_item(type, count) {
  201. if (count === void 0) {
  202. count = 1;
  203. }
  204. var ret = this.items.addCount(type, count);
  205. if (ret) {
  206. this.event.emit(this.event.key.item_count, ret.type, ret.count);
  207. this.setDirty();
  208. }
  209. }
  210. set_item(type, count) {
  211. if (count === void 0) {
  212. count = -1;
  213. }
  214. var c = this.get_item(type);
  215. if (type < count) {
  216. this.add_item(type, count - c);
  217. }
  218. }
  219. get_item(type) {
  220. return this.items.getCount(type);
  221. } //获取签到天数
  222. get_sign() {
  223. return this.week_data.get(week_data_type.sign_day);
  224. } //设置签到天数
  225. set_sign(count) {
  226. this.week_data.set(week_data_type.sign_day, count);
  227. } //获取是否当日首次通过收藏进入
  228. get_is_favorite() {
  229. return this.day_data.get(day_data_type.isFavorite);
  230. } //设置已从收藏进入
  231. set_is_favorite() {
  232. this.day_data.set(day_data_type.isFavorite, 1);
  233. this.setDirty();
  234. } //获取关卡数
  235. get_max_floor() {
  236. return this.data.get(data_type.max_floor);
  237. } //设置关卡数
  238. set_max_floor(floor) {
  239. this.data.set(data_type.max_floor, floor);
  240. } //获取铜币数量
  241. get_coin() {
  242. return this.data.get(data_type.coin);
  243. } //设置铜币数量
  244. set_coin(coin) {
  245. this.data.set(data_type.coin, coin);
  246. this.setDirty();
  247. } //获取今日通关数
  248. get_pass_level() {
  249. return this.day_data.get(day_data_type.pass_level);
  250. } //设置今日通关数
  251. set_pass_level(level) {
  252. this.day_data.add(day_data_type.pass_level, level);
  253. } //获取匹配成语数量
  254. get_combine_num() {
  255. return this.day_data.get(day_data_type.combine_num);
  256. } //设置匹配成语数量
  257. set_combine_num(num) {
  258. this.day_data.add(day_data_type.combine_num, num);
  259. this.setDirty();
  260. } //获取登录次数
  261. get_login_num() {
  262. return this.day_data.get(day_data_type.login_num);
  263. } //设置登录次数
  264. set_login_num(num) {
  265. this.day_data.add(day_data_type.login_num, num);
  266. this.setDirty();
  267. } //获取今日使用道具数量
  268. get_use_item_num() {
  269. return this.day_data.get(day_data_type.use_item);
  270. } //设置今日使用道具数量
  271. set_use_item_num(num) {
  272. this.day_data.add(day_data_type.use_item, num);
  273. } //获取今日广告观看数量
  274. get_watch_ad_num() {
  275. return this.day_data.get(day_data_type.watch_ad);
  276. } //设置今日广告观看数量
  277. set_watch_ad_num(num) {
  278. this.day_data.add(day_data_type.watch_ad, num);
  279. this.setDirty();
  280. } //获取任务奖励状态
  281. get_task_state() {
  282. return this.day_data.get_Array(day_data_type.task_reward_state);
  283. } //设置任务奖励状态
  284. set_task_state(task_state) {
  285. this.day_data.set_Array(day_data_type.task_reward_state, task_state);
  286. this.setDirty();
  287. } //获取商店免费领取状态
  288. get_store_state() {
  289. return this.day_data.get_Array(day_data_type.store_state);
  290. } //设置商店免费领取状态
  291. set_store_state(shop_state) {
  292. this.day_data.set_Array(day_data_type.store_state, shop_state);
  293. this.setDirty();
  294. } //获取体力
  295. get_life() {
  296. return this.data.get(data_type.life);
  297. } //设置体力
  298. set_life(life) {
  299. if (life > 5) {
  300. life = 5;
  301. } else if (life < 0) {
  302. life = 0;
  303. }
  304. this.data.set(data_type.life, life);
  305. this.setDirty();
  306. } //获取体力倒计时
  307. get_life_countdown() {
  308. return this.data.get(data_type.life_countdown);
  309. } //设置体力倒计时
  310. set_life_countdown(life_countdown) {
  311. this.data.set(data_type.life_countdown, life_countdown);
  312. this.setDirty();
  313. } //获取上次退出时间
  314. get_last_exit_time() {
  315. return this.data.get(data_type.last_exit_time);
  316. } //设置上次退出时间
  317. set_last_exit_time(last_exit_time) {
  318. this.data.set(data_type.last_exit_time, last_exit_time);
  319. this.setDirty();
  320. } //////////////////////////////////////////////////////////////////////////////////////////
  321. load_data() {
  322. var _superprop_getLoad_data = () => super.load_data,
  323. _this2 = this;
  324. return _asyncToGenerator(function* () {
  325. return _superprop_getLoad_data().call(_this2);
  326. })();
  327. }
  328. get nickName() {
  329. return this.user_info.nickName;
  330. }
  331. get avatarUrl() {
  332. return this.user_info.avatar;
  333. }
  334. init_user_info() {
  335. var _this3 = this;
  336. return _asyncToGenerator(function* () {
  337. _this3.user_info = {
  338. uid: _this3.uid,
  339. nickName: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  340. error: Error()
  341. }), ch) : ch).sdk.get_player_info().nickName,
  342. avatar: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  343. error: Error()
  344. }), ch) : ch).sdk.get_player_info().avatarUrl,
  345. province: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  346. error: Error()
  347. }), ch) : ch).sdk.get_player_info().province
  348. };
  349. })();
  350. }
  351. save_data(save_data) {
  352. var _superprop_getSave_data = () => super.save_data,
  353. _this4 = this;
  354. return _asyncToGenerator(function* () {
  355. return _superprop_getSave_data().call(_this4, save_data);
  356. })();
  357. }
  358. save_rank_floor() {
  359. var _this5 = this;
  360. return _asyncToGenerator(function* () {
  361. var floor = _this5.data.get(data_type.max_floor);
  362. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  363. error: Error()
  364. }), ch) : ch).sdk.saveRankData(rand_type.floor, floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  365. error: Error()
  366. }), ch) : ch).sdk.updateType.none, 0, {
  367. province: _this5.user_info.province
  368. });
  369. })();
  370. }
  371. get_rank_floor() {
  372. return _asyncToGenerator(function* () {
  373. var index = 0;
  374. var d = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  375. error: Error()
  376. }), ch) : ch).sdk.loadRankData(rand_type.floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  377. error: Error()
  378. }), ch) : ch).sdk.updateType.none, 100, true, false);
  379. console.log("排行榜", d);
  380. if (d.data.own) {
  381. for (var i = 0; i < d.data.list.length; i++) {
  382. if (d.data.own.userId === d.data.list[i].userId) {
  383. index = i + 1;
  384. }
  385. }
  386. if (d.data.own.rank > 100) {
  387. index = 101;
  388. }
  389. } else {
  390. index = 101;
  391. }
  392. return {
  393. list: d.data.list,
  394. owner: d.data.own,
  395. index: index
  396. };
  397. })();
  398. }
  399. loadPfInfo() {
  400. return _asyncToGenerator(function* () {
  401. return new Promise( /*#__PURE__*/_asyncToGenerator(function* (resolve) {
  402. var k = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  403. error: Error()
  404. }), ch) : ch).sdk.getUserInfo();
  405. if (k) {
  406. resolve(true);
  407. } else {
  408. (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  409. error: Error()
  410. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  411. error: Error()
  412. }), gui) : gui).getLayerNode(5), '需要授权').show();
  413. resolve(false);
  414. }
  415. }));
  416. })();
  417. }
  418. });
  419. PlayerData._instance = void 0;
  420. _cclegacy._RF.pop();
  421. _crd = false;
  422. }
  423. };
  424. });
  425. //# sourceMappingURL=9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js.map