9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, ch, gui, Container, GameData, UINotify, Start, 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 _reportPossibleCrUseOfStart(extras) {
  22. _reporterNs.report("Start", "../../start/Start", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfLayout_Main(extras) {
  25. _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras);
  26. }
  27. function _reportPossibleCrUseOfUI_Main(extras) {
  28. _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras);
  29. }
  30. _export("default", void 0);
  31. return {
  32. setters: [function (_unresolved_) {
  33. _reporterNs = _unresolved_;
  34. }, function (_cc) {
  35. _cclegacy = _cc.cclegacy;
  36. }, function (_unresolved_2) {
  37. ch = _unresolved_2.ch;
  38. }, function (_unresolved_3) {
  39. gui = _unresolved_3.gui;
  40. }, function (_unresolved_4) {
  41. Container = _unresolved_4.Container;
  42. }, function (_unresolved_5) {
  43. GameData = _unresolved_5.default;
  44. }, function (_unresolved_6) {
  45. UINotify = _unresolved_6.UINotify;
  46. }, function (_unresolved_7) {
  47. Start = _unresolved_7.Start;
  48. }, function (_unresolved_8) {
  49. UI_Main = _unresolved_8.UI_Main;
  50. }],
  51. execute: function () {
  52. _crd = true;
  53. _cclegacy._RF.push({}, "b500dzoF+pEaLB1EsW0vW75", "PlayerData", undefined);
  54. //定义事件
  55. //排行榜key
  56. _export("rand_type", rand_type = /*#__PURE__*/function (rand_type) {
  57. rand_type["floor"] = "floor";
  58. return rand_type;
  59. }({})); //自定义数据
  60. _export("data_type", data_type = /*#__PURE__*/function (data_type) {
  61. data_type["last_gift_sidebar"] = "last_gift_sidebar";
  62. data_type["max_floor"] = "max_floor";
  63. data_type["coin"] = "coin";
  64. return data_type;
  65. }({})); //每日数据
  66. _export("day_data_type", day_data_type = /*#__PURE__*/function (day_data_type) {
  67. day_data_type["sign_gift"] = "sign_gift";
  68. day_data_type["isFavorite"] = "isFavorite";
  69. return day_data_type;
  70. }({})); //每周数据
  71. _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) {
  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() {
  81. super(...arguments);
  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.sign_gift, {
  98. min: 0,
  99. max: 7
  100. }]]));
  101. }
  102. return this._instance;
  103. } //数据初始化
  104. on_init() {
  105. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  106. error: Error()
  107. }), ch) : ch).sign.init(2, null, 7);
  108. this.items.addItem({
  109. type: 1,
  110. count: 1
  111. });
  112. this.items.addItem({
  113. type: 2,
  114. count: 1
  115. });
  116. this.items.addItem({
  117. type: 3,
  118. count: 1
  119. }); //道具初始化
  120. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  121. error: Error()
  122. }), ch) : ch).log.log("道具初始化", this);
  123. } //序列化加入自定义数据
  124. on_serialize(data) {
  125. data.sign = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  126. error: Error()
  127. }), ch) : ch).sign.getSignData();
  128. data.items = this.items.serialize();
  129. } //反序列化加入自定义数据
  130. on_unserialize(data) {
  131. this.items.unserialize(data.items);
  132. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  133. error: Error()
  134. }), ch) : ch).sign.init(2, data.sign, 7);
  135. } //是否使用远程数据
  136. on_check(local, remote) {
  137. return true;
  138. }
  139. /**使用道具*/
  140. use_item(type, count) {
  141. var _this = this;
  142. return _asyncToGenerator(function* () {
  143. if (count === void 0) {
  144. count = 1;
  145. }
  146. // if (GameLink.getInst().state != GameState.wait) return;
  147. var layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  148. error: Error()
  149. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  150. error: Error()
  151. }), UI_Main) : UI_Main).getLayout();
  152. var ret = _this.items.useCount(type, count);
  153. if (ret) {
  154. var b = true;
  155. if (type == 1) {
  156. layout.Container.eliminate();
  157. } else if (type == 2) {
  158. layout.Container.shuffle();
  159. } else if (type == 3) {
  160. layout.Container.Empty();
  161. }
  162. if (!b) {
  163. _this.items.addCount(type, count);
  164. } else {
  165. _this.event.emit(_this.event.key.item_count, ret.type, ret.count);
  166. _this.setDirty();
  167. }
  168. }
  169. })();
  170. }
  171. /**增加道具*/
  172. add_item(type, count) {
  173. if (count === void 0) {
  174. count = 1;
  175. }
  176. var ret = this.items.addCount(type, count);
  177. if (ret) {
  178. this.event.emit(this.event.key.item_count, ret.type, ret.count);
  179. this.setDirty();
  180. }
  181. }
  182. set_item(type, count) {
  183. if (count === void 0) {
  184. count = 4;
  185. }
  186. var c = this.get_item(type);
  187. if (type < count) {
  188. this.add_item(type, count - c);
  189. }
  190. }
  191. get_item(type) {
  192. return this.items.getCount(type);
  193. } //获取签到天数
  194. get_sign() {
  195. return this.day_data.get(day_data_type.sign_gift);
  196. } //设置签到天数
  197. set_sign(count) {
  198. this.day_data.set(day_data_type.sign_gift, count);
  199. } //获取是否当日首次通过收藏进入
  200. get_is_favorite() {
  201. return this.day_data.get(day_data_type.isFavorite);
  202. } //设置已从收藏进入
  203. set_is_favorite() {
  204. this.day_data.set(day_data_type.isFavorite, 1);
  205. this.setDirty();
  206. } //获取关卡数
  207. get_max_floor() {
  208. return this.data.get(data_type.max_floor);
  209. } //设置关卡数
  210. set_max_floor(floor) {
  211. this.data.set(data_type.max_floor, floor);
  212. } //获取金币数量
  213. get_coin() {
  214. return this.data.get(data_type.coin);
  215. } //设置金币数量
  216. set_coin(coin) {
  217. this.data.set(data_type.coin, coin);
  218. } //////////////////////////////////////////////////////////////////////////////////////////
  219. load_data() {
  220. var _superprop_getLoad_data = () => super.load_data,
  221. _this2 = this;
  222. return _asyncToGenerator(function* () {
  223. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  224. error: Error()
  225. }), Start) : Start).packId == 1) {
  226. return new Promise((resolve, reject) => {});
  227. } else {
  228. return _superprop_getLoad_data().call(_this2);
  229. }
  230. })();
  231. }
  232. get nickName() {
  233. return this.user_info.nickName;
  234. }
  235. get avatarUrl() {
  236. return this.user_info.avatar;
  237. }
  238. init_user_info() {
  239. var _this3 = this;
  240. return _asyncToGenerator(function* () {
  241. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  242. error: Error()
  243. }), Start) : Start).packId == 1) {} else {
  244. _this3.user_info = {
  245. uid: _this3.uid,
  246. nickName: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  247. error: Error()
  248. }), ch) : ch).sdk.get_player_info().nickName,
  249. avatar: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  250. error: Error()
  251. }), ch) : ch).sdk.get_player_info().avatarUrl,
  252. province: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  253. error: Error()
  254. }), ch) : ch).sdk.get_player_info().province
  255. };
  256. }
  257. })();
  258. }
  259. save_data(save_data) {
  260. var _superprop_getSave_data = () => super.save_data,
  261. _this4 = this;
  262. return _asyncToGenerator(function* () {
  263. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  264. error: Error()
  265. }), Start) : Start).packId == 1) {
  266. return true;
  267. } else {
  268. return _superprop_getSave_data().call(_this4, save_data);
  269. }
  270. })();
  271. }
  272. save_rank_floor() {
  273. var _this5 = this;
  274. return _asyncToGenerator(function* () {
  275. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  276. error: Error()
  277. }), Start) : Start).packId == 1) {} else {
  278. var floor = _this5.data.get(data_type.max_floor);
  279. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  280. error: Error()
  281. }), ch) : ch).sdk.saveRankData(rand_type.floor, floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  282. error: Error()
  283. }), ch) : ch).sdk.updateType.none, 0, {
  284. province: _this5.user_info.province
  285. });
  286. }
  287. })();
  288. }
  289. get_rank_floor() {
  290. return _asyncToGenerator(function* () {
  291. var index = 0;
  292. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  293. error: Error()
  294. }), Start) : Start).packId == 1) {} else {
  295. var d = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  296. error: Error()
  297. }), ch) : ch).sdk.loadRankData(rand_type.floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  298. error: Error()
  299. }), ch) : ch).sdk.updateType.none, 100, true, false);
  300. console.log("排行榜", d);
  301. if (d.data.own) {
  302. for (var i = 0; i < d.data.list.length; i++) {
  303. if (d.data.own.userId === d.data.list[i].userId) {
  304. index = i + 1;
  305. }
  306. }
  307. } else {
  308. index = 101;
  309. }
  310. return {
  311. list: d.data.list,
  312. owner: d.data.own,
  313. index: index
  314. };
  315. }
  316. })();
  317. }
  318. loadPfInfo() {
  319. return _asyncToGenerator(function* () {
  320. return new Promise( /*#__PURE__*/_asyncToGenerator(function* (resolve) {
  321. var k = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  322. error: Error()
  323. }), ch) : ch).sdk.getUserInfo();
  324. if (k) {
  325. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  326. error: Error()
  327. }), Start) : Start).packId == 1) {}
  328. resolve(true);
  329. } else {
  330. (_crd && UINotify === void 0 ? (_reportPossibleCrUseOfUINotify({
  331. error: Error()
  332. }), UINotify) : UINotify).show("需要授权");
  333. resolve(false);
  334. }
  335. }));
  336. })();
  337. }
  338. });
  339. PlayerData._instance = void 0;
  340. _cclegacy._RF.pop();
  341. _crd = false;
  342. }
  343. };
  344. });
  345. //# sourceMappingURL=9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js.map