9fa0e63ffe0a92f6cd390b9195c28487e3487e7c.js 9.1 KB

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