GameModel.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const s = t("App"),
  6. o = t("BaseModel"),
  7. a = (t("ControllerConst"), t("GameConst"));
  8. i.default = class extends o.default {
  9. constructor(t) {
  10. super(t), (this.data = null), s.default.SaveManage.add(this, "GAME_DATA", !1, !0);
  11. }
  12. init() {
  13. s.default.SaveManage.load("GAME_DATA");
  14. }
  15. getCurMapData() {
  16. return this.data.maps[this.data.curMapType];
  17. }
  18. getFBMapData() {
  19. return this.data.maps[a.EmMapType.FB];
  20. }
  21. getMainMapData() {
  22. return this.data.maps[a.EmMapType.MAIN];
  23. }
  24. createMemento(t) {
  25. return this.setIdleTime(), this.data;
  26. }
  27. resetMapData(t = -1) {
  28. return (
  29. (this.data.maps[this.data.curMapType] = {
  30. curId: t,
  31. money: s.default.ConfigManager.gameConf.game.originGold,
  32. machines: {}
  33. }),
  34. this.data.maps[this.data.curMapType]
  35. );
  36. }
  37. setMemento(t, e) {
  38. this.data = t || {
  39. maps: {
  40. [a.EmMapType.MAIN]: {curId: 1, money: s.default.ConfigManager.gameConf.game.originGold, machines: {}},
  41. [a.EmMapType.FB]: {curId: 10001, money: s.default.ConfigManager.gameConf.game.originGold, machines: {}}
  42. },
  43. curMapType: a.EmMapType.MAIN
  44. };
  45. }
  46. setIdleTime() {
  47. this.data.maps[this.data.curMapType].startIdleTime = s.default.DateUtils.secondNow();
  48. }
  49. };