BuildingModel.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. export default class BuildingModel {
  2. /**@type {number} */
  3. rateUnit = 0;
  4. /**@type {number} */
  5. hasNext = 0;
  6. /**@type {number} */
  7. buildingId = 0;
  8. /**@type {number} */
  9. level = 0;
  10. /**@type {string} */
  11. name = "";
  12. /**@type {number} */
  13. nextRate = 0;
  14. /**@type {number} */
  15. nextUpScore = 0;
  16. /**@type {number} */
  17. rate = 0;
  18. /**@type {number} */
  19. jobId = 0;
  20. /**@type {number} */
  21. unlockScore = 0;
  22. /**@type {number} */
  23. isUnlocked = 0;
  24. /**@type {number} */
  25. coinCount = 0;
  26. constructor(data) {
  27. this.coinCount = data.coinCount || 0;
  28. this.rateUnit = data.rateUnit;
  29. this.hasNext = data.hasNext;
  30. this.buildingId = (data.buildingId === undefined) ? data.id : data.buildingId;
  31. this.level = data.level;
  32. this.name = data.name;
  33. this.nextRate = data.nextRate;
  34. this.nextUpScore = data.nextUpScore;
  35. this.rate = data.rate;
  36. this.jobId = data.jobId;
  37. if (data.unlockScore && data.unlockScore !== 0) {
  38. this.unlockScore = data.unlockScore;
  39. this.isUnlocked = 0;
  40. } else {
  41. this.isUnlocked = 1;
  42. }
  43. }
  44. isFull() {
  45. if (this.level && this.level == Global.BuildingManager.getLevelCount(this.buildingId)) {
  46. return true;
  47. } else {
  48. return false;
  49. }
  50. }
  51. }