9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, ch, GameData, UINotify, Start, 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 _reportPossibleCrUseOfGameData(extras) {
  10. _reporterNs.report("GameData", "../../core/util_class/GameData", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfUINotify(extras) {
  13. _reporterNs.report("UINotify", "../../module_basic/ui_notify/UINotify", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfStart(extras) {
  16. _reporterNs.report("Start", "../../start/Start", _context.meta, extras);
  17. }
  18. _export("default", void 0);
  19. return {
  20. setters: [function (_unresolved_) {
  21. _reporterNs = _unresolved_;
  22. }, function (_cc) {
  23. _cclegacy = _cc.cclegacy;
  24. }, function (_unresolved_2) {
  25. ch = _unresolved_2.ch;
  26. }, function (_unresolved_3) {
  27. GameData = _unresolved_3.default;
  28. }, function (_unresolved_4) {
  29. UINotify = _unresolved_4.UINotify;
  30. }, function (_unresolved_5) {
  31. Start = _unresolved_5.Start;
  32. }],
  33. execute: function () {
  34. _crd = true;
  35. _cclegacy._RF.push({}, "b500dzoF+pEaLB1EsW0vW75", "PlayerData", undefined);
  36. //定义事件
  37. //排行榜key
  38. _export("rand_type", rand_type = /*#__PURE__*/function (rand_type) {
  39. rand_type["floor"] = "floor";
  40. return rand_type;
  41. }({})); //自定义数据
  42. _export("data_type", data_type = /*#__PURE__*/function (data_type) {
  43. data_type["last_gift_sidebar"] = "last_gift_sidebar";
  44. data_type["max_floor"] = "max_floor";
  45. data_type["coin"] = "coin";
  46. return data_type;
  47. }({})); //每日数据
  48. _export("day_data_type", day_data_type = /*#__PURE__*/function (day_data_type) {
  49. day_data_type["sign_gift"] = "sign_gift";
  50. day_data_type["isFavorite"] = "isFavorite";
  51. return day_data_type;
  52. }({})); //每周数据
  53. _export("week_data_type", week_data_type = /*#__PURE__*/function (week_data_type) {
  54. return week_data_type;
  55. }({})); //每月数据
  56. _export("month_data_type", month_data_type = /*#__PURE__*/function (month_data_type) {
  57. return month_data_type;
  58. }({}));
  59. _export("default", PlayerData = class PlayerData extends (_crd && GameData === void 0 ? (_reportPossibleCrUseOfGameData({
  60. error: Error()
  61. }), GameData) : GameData) {
  62. constructor() {
  63. super(...arguments);
  64. this.event = void 0;
  65. this.items = void 0;
  66. //////////////////////////////////////////////////////////////////////////////////////////
  67. this.user_info = void 0;
  68. }
  69. //道具容器
  70. static getInstance(gid, uid) {
  71. if (!this._instance) {
  72. this._instance = new PlayerData(gid, uid, "PlayerData", new Map([[data_type.coin, {
  73. min: 0,
  74. max: 1000000
  75. }]]), new Map([[day_data_type.sign_gift, {
  76. min: 0,
  77. max: 1
  78. }]]));
  79. }
  80. return this._instance;
  81. } //数据初始化
  82. on_init() {
  83. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  84. error: Error()
  85. }), ch) : ch).sign.init(2, null, 7); //道具初始化
  86. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  87. error: Error()
  88. }), ch) : ch).log.log("道具初始化", this);
  89. } //序列化加入自定义数据
  90. on_serialize(data) {
  91. data.sign = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  92. error: Error()
  93. }), ch) : ch).sign.getSignData();
  94. } //反序列化加入自定义数据
  95. on_unserialize(data) {
  96. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  97. error: Error()
  98. }), ch) : ch).sign.init(2, data.sign, 7);
  99. } //是否使用远程数据
  100. on_check(local, remote) {
  101. return true;
  102. } //使用道具
  103. useItem(type, count) {
  104. return _asyncToGenerator(function* () {})();
  105. } //增加道具
  106. add_item(type, count) {} //设置道具数量
  107. set_item(type, count) {} //获取道具数量
  108. get_item(type) {
  109. return 0;
  110. } //获取签到天数
  111. get_sign() {
  112. return this.day_data.get(day_data_type.sign_gift);
  113. } //设置签到天数
  114. set_sign(count) {
  115. this.day_data.set(day_data_type.sign_gift, count);
  116. } //获取是否当日首次通过收藏进入
  117. get_is_favorite() {
  118. return this.day_data.get(day_data_type.isFavorite);
  119. } //设置已从收藏进入
  120. set_is_favorite() {
  121. this.day_data.set(day_data_type.isFavorite, 1);
  122. this.setDirty();
  123. this.save();
  124. } //获取金币数量
  125. get_coin() {
  126. return this.data.get(data_type.coin);
  127. } //设置金币数量
  128. set_coin(coin) {
  129. this.data.set(data_type.coin, coin);
  130. }
  131. load_data() {
  132. var _superprop_getLoad_data = () => super.load_data,
  133. _this = this;
  134. return _asyncToGenerator(function* () {
  135. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  136. error: Error()
  137. }), Start) : Start).packId == 1) {
  138. return new Promise((resolve, reject) => {});
  139. } else {
  140. return _superprop_getLoad_data().call(_this);
  141. }
  142. })();
  143. }
  144. get nickName() {
  145. return this.user_info.nickName;
  146. }
  147. get avatarUrl() {
  148. return this.user_info.avatar;
  149. }
  150. init_user_info() {
  151. var _this2 = this;
  152. return _asyncToGenerator(function* () {
  153. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  154. error: Error()
  155. }), Start) : Start).packId == 1) {} else {
  156. _this2.user_info = {
  157. uid: _this2.uid,
  158. nickName: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  159. error: Error()
  160. }), ch) : ch).sdk.get_player_info().nickName,
  161. avatar: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  162. error: Error()
  163. }), ch) : ch).sdk.get_player_info().avatarUrl,
  164. province: (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  165. error: Error()
  166. }), ch) : ch).sdk.get_player_info().province
  167. };
  168. }
  169. })();
  170. }
  171. save_data(save_data) {
  172. var _superprop_getSave_data = () => super.save_data,
  173. _this3 = this;
  174. return _asyncToGenerator(function* () {
  175. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  176. error: Error()
  177. }), Start) : Start).packId == 1) {
  178. return true;
  179. } else {
  180. return _superprop_getSave_data().call(_this3, save_data);
  181. }
  182. })();
  183. }
  184. save_rank_floor() {
  185. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  186. error: Error()
  187. }), Start) : Start).packId == 1) {} else {
  188. var floor = this.data.get(data_type.max_floor) - 1;
  189. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  190. error: Error()
  191. }), ch) : ch).sdk.saveRankData(rand_type.floor, floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  192. error: Error()
  193. }), ch) : ch).sdk.updateType.none, 0, {
  194. province: this.user_info.province
  195. });
  196. }
  197. }
  198. get_rank_floor() {
  199. return _asyncToGenerator(function* () {
  200. var index = 0;
  201. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  202. error: Error()
  203. }), Start) : Start).packId == 1) {} else {
  204. var d = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  205. error: Error()
  206. }), ch) : ch).sdk.loadRankData(rand_type.floor, (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  207. error: Error()
  208. }), ch) : ch).sdk.updateType.none, 100, true);
  209. if (d.data.own) {
  210. for (var i = 0; i < d.data.list.length; i++) {
  211. if (d.data.own.userId === d.data.list[i].userId) {
  212. index = i + 1;
  213. }
  214. }
  215. } else {
  216. index = 101;
  217. }
  218. return {
  219. list: d.data.list,
  220. owner: d.data.own,
  221. index: index
  222. };
  223. }
  224. })();
  225. }
  226. loadPfInfo() {
  227. return _asyncToGenerator(function* () {
  228. return new Promise( /*#__PURE__*/_asyncToGenerator(function* (resolve) {
  229. var k = yield (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  230. error: Error()
  231. }), ch) : ch).sdk.getUserInfo();
  232. if (k) {
  233. if ((_crd && Start === void 0 ? (_reportPossibleCrUseOfStart({
  234. error: Error()
  235. }), Start) : Start).packId == 1) {}
  236. resolve(true);
  237. } else {
  238. (_crd && UINotify === void 0 ? (_reportPossibleCrUseOfUINotify({
  239. error: Error()
  240. }), UINotify) : UINotify).show("需要授权");
  241. resolve(false);
  242. }
  243. }));
  244. })();
  245. }
  246. });
  247. PlayerData._instance = void 0;
  248. _cclegacy._RF.pop();
  249. _crd = false;
  250. }
  251. };
  252. });
  253. //# sourceMappingURL=9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js.map