354ff9a96c31eba22617e0be63fbc536039c93e2.js 13 KB

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