StageUpgradeData.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const s = t("GameText"),
  6. o = t("GlobalAttr"),
  7. a = t("MyBigLong"),
  8. n = t("DeskService"),
  9. r = t("MachineService"),
  10. l = t("MapService"),
  11. h = t("StageUpgradeService");
  12. i.default = class {
  13. constructor() {
  14. (this.cfg = null), (this.cost = 0), (this._baseCost = 0), (this._desc = ""), (this.title = "");
  15. }
  16. init(t) {
  17. (this.cfg = t),
  18. (this._baseCost = a.default.unpackData(t.cost)),
  19. (this.title = s.GameText.getTextByStr(`str_title_stage_${this.cfg.ability_type}`)),
  20. this.calCost();
  21. }
  22. calCost() {
  23. this.cost = Math.ceil(o.default.ins.upgradeDiscount * this._baseCost);
  24. }
  25. canBuy() {
  26. return l.default.ins.mapSaveData.money >= this.cost;
  27. }
  28. get desc() {
  29. if (!this._desc) {
  30. let t = "";
  31. switch (this.cfg.ability_type) {
  32. case h.AbilityType.menuprofit:
  33. (t = r.default.ins.machineDatas[this.cfg.ability_target - 1].name),
  34. (this._desc = s.GameText.getTextByStr(`stage_upgrade_type_${this.cfg.ability_type}`).format(
  35. this.cfg.ability_value,
  36. s.GameText.getTextByStr(t)
  37. ));
  38. break;
  39. case h.AbilityType.fastermenu:
  40. (t = r.default.ins.machineDatas[this.cfg.ability_target - 1].name),
  41. (this._desc = s.GameText.getTextByStr(`stage_upgrade_type_${this.cfg.ability_type}`).format(
  42. s.GameText.getTextByStr(t)
  43. ));
  44. break;
  45. case h.AbilityType.addcustomer2:
  46. this._desc = s.GameText.getTextByStr(`stage_upgrade_type_${this.cfg.ability_type}`).format(
  47. n.default.ins.deskDatas[this.cfg.ability_target].customers.length
  48. );
  49. break;
  50. case h.AbilityType.chefspeed:
  51. case h.AbilityType.cashirespeed:
  52. this._desc = s.GameText.getTextByStr(`stage_upgrade_type_${this.cfg.ability_type}`);
  53. break;
  54. default:
  55. this._desc = s.GameText.getTextByStr(`stage_upgrade_type_${this.cfg.ability_type}`).format(
  56. this.cfg.ability_value
  57. );
  58. }
  59. }
  60. return this._desc;
  61. }
  62. getIconUrl() {
  63. let t = "Texture/stageUpgradeIcon/icon_";
  64. switch (this.cfg.ability_type) {
  65. case h.AbilityType.cashirespeed:
  66. case h.AbilityType.chefspeed:
  67. t += 50;
  68. break;
  69. case h.AbilityType.menuprofit:
  70. case h.AbilityType.fastermenu:
  71. t = "";
  72. break;
  73. default:
  74. t += this.cfg.ability_type;
  75. }
  76. return t;
  77. }
  78. getFoodImg() {
  79. return r.default.ins.machineDatas[this.cfg.ability_target - 1].foodImg;
  80. }
  81. };