9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 15 KB

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