123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- var t = require;
- var e = module;
- var i = exports;
- Object.defineProperty(i, "__esModule", {value: !0});
- const l = t("App"),
- a = t("GameConst"),
- r = t("IBuff"),
- h = {
- ADD_IDLE: 1,
- CUSTOMER_MOVE_SPEED: 0,
- WAITER_SPEED: 0,
- CHEF_SPEED: 0,
- COOK_SPEED: 0,
- FOOD_SELL_RATE: 1,
- ALL_EMPLOYEES_MOVE_SPEED: 0
- };
- class s {
- constructor() {
- (this._buffDataList = {}),
- (this._globalBuffList = {}),
- (this._regionBuffList = {}),
- (this._globalBuffAttrList = null),
- (this._regionBuffAttrList = {}),
- ObjectPool.registerClass(r.BuffAttr, "BuffAttr"),
- (this._globalBuffAttrList = r.BuffAttr.create(h)),
- (this.buffDataManager = l.default.ConfigManager.getConfig("BuffDataManager")),
- l.default.TimerManager.doTimer(500, 0, this.routine, this),
- l.default.SaveManage.add(this, "buff", !1, !0),
- l.default.SaveManage.load("buff");
- }
- checkBuff(t, e) {
- return !!(t.buffEndTime && t.buffEndTime < e);
- }
- routine(t) {
- var e,
- i,
- s = l.default.DateUtils.Now();
- for (e in this._globalBuffList) {
- var o = this._globalBuffList[e];
- o.buffEndTime && o.buffEndTime < s && this.removeGlobalBuff(o.buffIndex);
- }
- for (i in this._regionBuffList) {
- var a,
- n = this._regionBuffList[i];
- for (a in n) {
- var r = n[a];
- this.checkBuff(r, s) && this.removeRegionBuff(Number(i), r.buffIndex);
- }
- }
- }
- getGlobalBuffList() {
- return this._globalBuffList;
- }
- getGlobalBuffByIndex(t) {
- return this._globalBuffList[t];
- }
- addGlobalBuff(t) {
- t.buffType || (t.buffType = this.buffDataManager.getType(t.buffIndex));
- let e = this._globalBuffList[t.buffIndex];
- var i;
- e && e.buffValue == t.buffValue
- ? ((i = l.default.DateUtils.Now()),
- e.buffEndTime && e.buffEndTime > i
- ? (e.buffEndTime += t.buffEndTime - i)
- : e.buffEndTime && e.buffEndTime <= i
- ? (e.buffEndTime = t.buffEndTime)
- : (this._globalBuffList[t.buffIndex] = t))
- : (this._globalBuffList[t.buffIndex] = t),
- this.calGlobalBuffAttr(),
- l.default.NotificationCenter.dispatch(a.GameNotificationConst.UPDATE_BUFF, -1, -1, t.buffType);
- }
- removeGlobalBuff(t) {
- var e = this._globalBuffList[t];
- delete this._globalBuffList[t],
- this.calGlobalBuffAttr(),
- l.default.NotificationCenter.dispatch(a.GameNotificationConst.UPDATE_BUFF, -1, -1, e.buffType);
- }
- getKcBuffList() {
- return this._regionBuffList;
- }
- getKcBuffListById(t) {
- return this._regionBuffList[t];
- }
- getKcBuffByIndex(t, e) {
- return this._regionBuffList[t] || (this._regionBuffList[t] = {}), this._regionBuffList[t][e];
- }
- openNewRegion(t) {
- (this._regionBuffList[t] = this._regionBuffList[t] || {}),
- this._regionBuffAttrList[t] && (this._regionBuffAttrList[t] = r.BuffAttr.create(h)),
- this.calRegionBuffAttrById(t);
- }
- closeRegion(t) {
- delete this._regionBuffList[t];
- }
- addRegionBuff(t, e) {
- e.buffType || (e.buffType = this.buffDataManager.getType(e.buffIndex)),
- this._regionBuffList[t] || (this._regionBuffList[t] = {});
- let i = this._regionBuffList[t],
- s = i[e.buffIndex];
- var o;
- s && s.buffValue == e.buffValue
- ? ((o = l.default.DateUtils.Now()),
- s.buffEndTime && s.buffEndTime > o
- ? (s.buffEndTime += e.buffEndTime - o)
- : s.buffEndTime && s.buffEndTime <= o
- ? (s.buffEndTime = e.buffEndTime)
- : (i[e.buffIndex] = e))
- : (i[e.buffIndex] = e),
- this.calRegionBuffAttrById(t, !0),
- l.default.NotificationCenter.dispatch(a.GameNotificationConst.UPDATE_BUFF, t, -1, e.buffType);
- }
- removeRegionBuff(t, e) {
- this._regionBuffList[t] || (this._regionBuffList[t] = {});
- let i = this._regionBuffList[t];
- var s = i[e];
- delete i[e],
- this.calRegionBuffAttrById(t, !0),
- l.default.NotificationCenter.dispatch(a.GameNotificationConst.UPDATE_BUFF, t, -1, s.buffType);
- }
- calGlobalBuffAttr() {
- for (var t in (this._globalBuffAttrList.reset(), this._globalBuffList)) {
- var e = this._globalBuffList[t],
- t = e.buffType;
- this._globalBuffAttrList.addBuffValue(t, e.buffValue);
- }
- this._globalBuffAttrList.claFinish(), this.calRegionBuffAttr();
- }
- calRegionBuffAttrById(t, e = 0) {
- var i,
- s = this._regionBuffList[t];
- this._regionBuffAttrList[t] || (this._regionBuffAttrList[t] = r.BuffAttr.create(h));
- let o = this._regionBuffAttrList[t];
- for (i in (o.reset(), s)) {
- var a = s[i],
- n = a.buffType;
- o.addBuffValue(n, a.buffValue);
- }
- o.claFinish(), o.addBuffAttr(this._globalBuffAttrList);
- }
- calRegionBuffAttr() {
- for (var t in this._regionBuffList) this.calRegionBuffAttrById(t);
- }
- getRegionBuffAttrList(t) {
- return (
- (this._regionBuffAttrList[t] = this._regionBuffAttrList[t] || r.BuffAttr.create()),
- this._regionBuffAttrList[t]
- );
- }
- setMemento(t) {
- t
- ? ((this._globalBuffList = this._buffDataList[0] = t[0] || {}),
- (this._regionBuffList = this._buffDataList[1] = t[1] || {}))
- : ((this._globalBuffList = this._buffDataList[0] = this._buffDataList[0] || {}),
- (this._regionBuffList = this._buffDataList[1] = this._buffDataList[1] || {})),
- this.calGlobalBuffAttr();
- }
- createMemento() {
- return this._buffDataList;
- }
- save() {}
- }
- (i.default = s).ins = null;
|