9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 14 KB

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