CurrencyService.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s,
  5. e =
  6. (this && this.__decorate) ||
  7. function (t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", {value: !0});
  18. const o = t("App"),
  19. a = t("ControllerConst"),
  20. n = t("NotificationConst"),
  21. r = t("BaseService"),
  22. l = t("MachineService"),
  23. {ccclass: h} = cc._decorator;
  24. t = s = class extends r.default {
  25. constructor() {
  26. super(...arguments), (this.mapSaveData = null), (this.player = null);
  27. }
  28. onLoad() {
  29. s.ins = this;
  30. }
  31. init() {
  32. const t = o.default.ControllerManager.getControllerModel(a.ControllerConst.Game);
  33. (this.mapSaveData = t.getCurMapData()), (this.player = o.default.GameDataMsr.playerInfo);
  34. }
  35. desotrySelf() {}
  36. checkMoneyEnough(t) {
  37. return this.mapSaveData.money >= t;
  38. }
  39. checkDiamondEnough(t) {
  40. return this.player.diamond >= t;
  41. }
  42. diamondChange(t) {
  43. return !(
  44. (t < 0 && this.player.diamond < -t) ||
  45. ((this.player.diamond += t),
  46. o.default.NotificationCenter.dispatch(n.NotificationConst.UPDATE_SUPER_CASH, this.player.diamond, t),
  47. 0)
  48. );
  49. }
  50. addMoneyByIdle(t) {
  51. this.moneyChange(l.default.ins.calculateIdleMoney(t, !0));
  52. }
  53. getIdleMoney(t) {
  54. return l.default.ins.calculateIdleMoney(t, !0);
  55. }
  56. moneyChange(t) {
  57. return !(
  58. (t < 0 && this.mapSaveData.money < -t) ||
  59. ((this.mapSaveData.money += t),
  60. o.default.NotificationCenter.dispatch(n.NotificationConst.UPDATE_MONEY, this.mapSaveData.money, t),
  61. 0)
  62. );
  63. }
  64. };
  65. (t.ins = null), (t = s = e([h], t)), (i.default = t = s);