9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 12 KB

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