123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- o,
- a =
- (this && this.__decorate) ||
- function (t, e, i, s) {
- var o,
- a = arguments.length,
- n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
- else
- for (var r = t.length - 1; 0 <= r; r--)
- (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
- return 3 < a && n && Object.defineProperty(e, i, n), n;
- };
- Object.defineProperty(i, "__esModule", {value: !0}), (i.HelperCatState = void 0);
- const h = t("App"),
- n = t("ControllerConst"),
- c = t("CostumeConst"),
- d = t("CostumeController"),
- r = t("HelperCatData"),
- l = t("GameConst"),
- u = t("GlobalAttr"),
- p = t("CatTimeOut"),
- f = t("BaseService"),
- g = t("RoleService");
- ((e = o = i.HelperCatState || (i.HelperCatState = {}))[(e.NONE = 0)] = "NONE"),
- (e[(e.READY = 1)] = "READY"),
- (e[(e.WORKING = 2)] = "WORKING"),
- (e[(e.CD = 3)] = "CD");
- var {ccclass: t} = cc._decorator,
- e = (s = class extends f.default {
- constructor() {
- super(...arguments),
- (this.helperCatDatas = []),
- (this.curHelprCatData = null),
- (this.cfgs = []),
- (this.define = null),
- (this.saveData = null),
- (this._curCat = null);
- }
- onLoad() {
- s.ins = this;
- }
- getCfgsByTier(t) {
- const e = [];
- for (const i of this.cfgs) i.tier === t && e.push(i);
- return e;
- }
- isCatTimeOut() {
- return h.default.DateUtils.Now() - this.saveData.hireTime > 1e3 * this.define.invite_appear_timer;
- }
- getCatLeftTime() {
- return 1e3 * this.define.invite_appear_timer - h.default.DateUtils.Now() + this.saveData.hireTime;
- }
- getCatLeftCDTime() {
- return 1e3 * this.define.invite_appear_cooltime - h.default.DateUtils.Now() + this.saveData.hireTime;
- }
- refresh() {
- this._curCat && this._curCat.getComponent(p.default).removeImmediately(),
- (this.saveData.hireTime = 0),
- (this._curCat = null);
- }
- getState() {
- var t = (h.default.DateUtils.Now() - this.saveData.hireTime) / 1e3;
- return !this.curHelprCatData || t > this.define.invite_appear_timer
- ? t > this.define.invite_appear_cooltime
- ? o.READY
- : o.CD
- : o.WORKING;
- }
- init() {
- const t = h.default.ControllerManager.getControllerModel(n.ControllerConst.Game);
- if (
- ((this.define = h.default.ConfigManager.getConfig("Define")),
- (this.cfgs = h.default.ConfigManager.getConfig("Helper")),
- t.data.helper || (t.data.helper = {hireTime: 0}),
- (this.saveData = t.data.helper),
- this.saveData.cur)
- )
- if (this.isCatTimeOut()) delete this.saveData.cur;
- else {
- const t = new r.default();
- t.init(this.saveData.cur, this.getCfgById(this.saveData.cur.id)),
- t.initAttr(),
- this.setCurHelperCatData(t),
- this.createHelpCat();
- }
- }
- removeCurCat() {
- (this.curHelprCatData = null), delete this.saveData.cur, (this._curCat = null);
- }
- onCatRemove() {
- if (this.curHelprCatData) {
- const t = d.default.ins.getModel().attr;
- t.removeAttrDict("HELP_CAT"),
- t.claFinishAttr(),
- h.default.NotificationCenter.dispatch(
- l.GameNotificationConst.UPDATE_EQUIP_COSTUME_ATTR,
- this.curHelprCatData.recalMap
- ),
- this.removeCurCat();
- }
- }
- createHelpCat() {
- const t = this.curHelprCatData.attr,
- e = (this._curCat = g.default.ins.createManCat(t, "")),
- i = e.addComponent(p.default),
- s = 1e3 * this.define.invite_appear_timer;
- i.setLeftTime(this.saveData.hireTime + s, s),
- i.setCallBack(this.onCatRemove, this),
- e.updateSlot(this.curHelprCatData.equipItems),
- (e.getCookMoneyRate = () =>
- u.default.ins.cookMoneyRate + t.getAttrValue(c.CostumeAbilityType.base, 0) / 100);
- }
- setCurHelperCatData(t) {
- this.curHelprCatData = t;
- const e = d.default.ins.getModel().attr;
- e.addAttrDict("HELP_CAT", t.getGlobalAttr()),
- e.claFinishAttr(),
- h.default.NotificationCenter.dispatch(l.GameNotificationConst.UPDATE_EQUIP_COSTUME_ATTR, t.recalMap);
- }
- hireCat(t) {
- return (
- this.setCurHelperCatData(this.helperCatDatas[t]),
- (this.helperCatDatas.length = 0),
- (this.saveData.cur = this.saveData.items[t]),
- delete this.saveData.items,
- (this.saveData.hireTime = h.default.DateUtils.Now()),
- this.createHelpCat(),
- this.curHelprCatData
- );
- }
- getCfgById(e) {
- var i = this.cfgs.length;
- for (let t = 0; t < i; t++) if (this.cfgs[t].idx === e) return this.cfgs[t];
- }
- getHelpCatDatas() {
- if (this.helperCatDatas.length) return this.helperCatDatas;
- var e = this.getCostumeCacheData();
- let i = e.length;
- for (let t = 0; t < i; t++) {
- const i = e[t],
- s = new r.default();
- s.init(i, this.getCfgById(i.id)), s.initAttr(), (this.helperCatDatas[t] = s);
- }
- return this.helperCatDatas;
- }
- getCostumeCacheData() {
- if (this.saveData.items) return this.saveData.items;
- const e = this.randomData(),
- i = (this.saveData.items = []),
- s = d.default.ins.getModel().equipItems;
- let o = e.length;
- for (let t = 0; t < o; t++) {
- const o = e[t],
- a = {};
- for (let t = c.CostumeParts.head; t <= c.CostumeParts.hand; t++) {
- const i = s[t],
- n = i ? i.data.grade : c.RarityType.common,
- d = i ? i.data.lv : 0,
- r = h.default.RandomUtils.limitInteger(
- Math.max(n + o.costume_grade_min, c.RarityType.common),
- Math.max(n + o.costume_grade_max, c.RarityType.common)
- ),
- l = h.default.RandomUtils.limitInteger(
- Math.max(o.costume_lv_min + d, 1),
- Math.max(o.costume_lv_max + d, 1)
- );
- a[t] = {lv: l, grade: r};
- }
- i.push({id: o.idx, costume: a});
- }
- return this.saveData.items;
- }
- randomData() {
- var t = h.default.ConfigManager.getConfig("Define"),
- e = h.default.RandomUtils.limitInteger(t.tier1_min_count, t.tier1_max_count),
- i = h.default.RandomUtils.limitInteger(t.tier2_min_count, t.tier2_max_count),
- t = h.default.RandomUtils.limitInteger(t.tier3_min_count, t.tier3_max_count);
- return [
- ...h.default.RandomUtils.shuffle(this.getCfgsByTier(3)).splice(0, t),
- ...h.default.RandomUtils.shuffle(this.getCfgsByTier(2)).splice(0, i),
- ...h.default.RandomUtils.shuffle(this.getCfgsByTier(1)).splice(0, e)
- ];
- }
- desotrySelf() {
- this._curCat = null;
- }
- });
- (e.ins = null), (e = s = a([t], e)), (i.default = e = s);
|