9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 15 KB

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