354ff9a96c31eba22617e0be63fbc536039c93e2.js 15 KB

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