9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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, UINotify, 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 _reportPossibleCrUseOfUINotify(extras) {
  17. _reporterNs.report("UINotify", "../../module_basic/ui_notify/UINotify", _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. UINotify = _unresolved_6.UINotify;
  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. return day_data_type;
  68. }({})); //每周数据
  69. _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) {
  70. week_data_type["sign_day"] = "sign_day";
  71. return week_data_type;
  72. }({})); //每月数据
  73. _export("month_data_type", month_data_type = /*#__PURE__*/function (month_data_type) {
  74. return month_data_type;
  75. }({}));
  76. _export("default", PlayerData = class PlayerData extends (_crd && GameData === void 0 ? (_reportPossibleCrUseOfGameData({
  77. error: Error()
  78. }), GameData) : GameData) {
  79. constructor(...args) {
  80. super(...args);
  81. this.event = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  82. error: Error()
  83. }), ch) : ch).get_new_event();
  84. //道具容器
  85. this.items = new (_crd && Container === void 0 ? (_reportPossibleCrUseOfContainer({
  86. error: Error()
  87. }), Container) : Container)();
  88. this.user_info = void 0;
  89. }
  90. static getInstance(gid, uid) {
  91. if (!this._instance) {
  92. this._instance = new PlayerData(gid, uid, "PlayerData", new Map([[data_type.max_floor, {
  93. min: 0
  94. }], [data_type.coin, {
  95. min: 0
  96. }]]), new Map([[day_data_type.isFavorite, {
  97. min: 0
  98. }], [day_data_type.pass_level, {
  99. min: 0,
  100. max: 5
  101. }], [day_data_type.combine_num, {
  102. min: 0,
  103. max: 100
  104. }], [day_data_type.login_num, {
  105. min: 0,
  106. max: 1
  107. }], [day_data_type.use_item, {
  108. min: 0,
  109. max: 3
  110. }], [day_data_type.watch_ad, {
  111. min: 0,
  112. max: 8
  113. }]]), new Map([[week_data_type.sign_day, {
  114. min: 0,
  115. max: 7
  116. }]]));
  117. }
  118. return this._instance;
  119. } //数据初始化
  120. on_init() {
  121. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  122. error: Error()
  123. }), ch) : ch).sign.init(2, null, 7);
  124. this.items.addItem({
  125. type: 1,
  126. count: 1
  127. });
  128. this.items.addItem({
  129. type: 2,
  130. count: 1
  131. });
  132. this.items.addItem({
  133. type: 3,
  134. count: 1
  135. });
  136. this.items.addItem({
  137. type: 5,
  138. count: 1
  139. }); //道具初始化
  140. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  141. error: Error()
  142. }), ch) : ch).log.log("道具初始化", this);
  143. } //序列化加入自定义数据
  144. on_serialize(data) {
  145. data.sign = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  146. error: Error()
  147. }), ch) : ch).sign.getSignData();
  148. data.items = this.items.serialize();
  149. } //反序列化加入自定义数据
  150. on_unserialize(data) {
  151. this.items.unserialize(data.items);
  152. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  153. error: Error()
  154. }), ch) : ch).sign.init(2, data.sign, 7);
  155. } //是否使用远程数据
  156. on_check(local, remote) {
  157. return true;
  158. }
  159. /**使用道具*/
  160. async use_item(type, count = 1) {
  161. // if (GameLink.getInst().state != GameState.wait) return;
  162. const layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  163. error: Error()
  164. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  165. error: Error()
  166. }), UI_Main) : UI_Main).getLayout();
  167. let ret = this.items.useCount(type, count);
  168. if (ret) {
  169. let b = true;
  170. if (type == 1) {
  171. layout.Container.eliminate();
  172. } else if (type == 2) {
  173. layout.Container.shuffle();
  174. } else if (type == 3) {
  175. layout.Container.Empty();
  176. }
  177. if (!b) {
  178. this.items.addCount(type, count);
  179. } else {
  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 = 1) {
  188. let ret = this.items.addCount(type, count);
  189. if (ret) {
  190. this.event.emit(this.event.key.item_count, ret.type, ret.count);
  191. this.setDirty();
  192. }
  193. }
  194. set_item(type, count = 4) {
  195. const c = this.get_item(type);
  196. if (type < count) {
  197. this.add_item(type, count - c);
  198. }
  199. }
  200. get_item(type) {
  201. return this.items.getCount(type);
  202. } //获取签到天数
  203. get_sign() {
  204. return this.week_data.get(week_data_type.sign_day);
  205. } //设置签到天数
  206. set_sign(count) {
  207. this.week_data.set(week_data_type.sign_day, count);
  208. } //获取是否当日首次通过收藏进入
  209. get_is_favorite() {
  210. return this.day_data.get(day_data_type.isFavorite);
  211. } //设置已从收藏进入
  212. set_is_favorite() {
  213. this.day_data.set(day_data_type.isFavorite, 1);
  214. this.setDirty();
  215. } //获取关卡数
  216. get_max_floor() {
  217. return this.data.get(data_type.max_floor);
  218. } //设置关卡数
  219. set_max_floor(floor) {
  220. this.data.set(data_type.max_floor, floor);
  221. } //获取金币数量
  222. get_coin() {
  223. return this.data.get(data_type.coin);
  224. } //设置金币数量
  225. set_coin(coin) {
  226. this.data.set(data_type.coin, coin);
  227. this.setDirty();
  228. } //获取今日通关数
  229. get_pass_level() {
  230. return this.day_data.get(day_data_type.pass_level);
  231. } //设置今日通关数
  232. set_pass_level(level) {
  233. this.day_data.add(day_data_type.pass_level, level);
  234. } //获取匹配成语数量
  235. get_combine_num() {
  236. return this.day_data.get(day_data_type.combine_num);
  237. } //设置匹配成语数量
  238. set_combine_num(num) {
  239. this.day_data.add(day_data_type.combine_num, num);
  240. this.setDirty();
  241. } //获取登录次数
  242. get_login_num() {
  243. return this.day_data.get(day_data_type.login_num);
  244. } //设置登录次数
  245. set_login_num(num) {
  246. this.day_data.add(day_data_type.login_num, num);
  247. this.setDirty();
  248. } //获取今日使用道具数量
  249. get_use_item_num() {
  250. return this.day_data.get(day_data_type.use_item);
  251. } //设置今日使用道具数量
  252. set_use_item_num(num) {
  253. this.day_data.add(day_data_type.use_item, num);
  254. } //获取今日广告观看数量
  255. get_watch_ad_num() {
  256. return this.day_data.get(day_data_type.watch_ad);
  257. } //设置今日广告观看数量
  258. set_watch_ad_num(num) {
  259. this.day_data.add(day_data_type.watch_ad, num);
  260. this.setDirty();
  261. } //获取任务奖励状态
  262. get_task_state() {
  263. return this.day_data.get_Array(day_data_type.task_reward_state);
  264. } //设置任务奖励状态
  265. set_task_state(task_state) {
  266. this.day_data.set_Array(day_data_type.task_reward_state, task_state);
  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 && UINotify === void 0 ? (_reportPossibleCrUseOfUINotify({
  336. error: Error()
  337. }), UINotify) : UINotify).show("需要授权");
  338. resolve(false);
  339. }
  340. });
  341. }
  342. });
  343. PlayerData._instance = void 0;
  344. _cclegacy._RF.pop();
  345. _crd = false;
  346. }
  347. };
  348. });
  349. //# sourceMappingURL=9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js.map