123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- var t = require;
- var e = module;
- var i = exports;
- Object.defineProperty(i, "__esModule", {value: !0});
- const o = t("GameText"),
- a = t("GameUtils"),
- n = t("CurrencyService"),
- r = t("CostumeConst"),
- l = [
- "costume/Dynamic_Icon_CostumeType_Head",
- "costume/Dynamic_Icon_CostumeType_Body",
- "costume/Dynamic_Icon_CostumeType_Hand"
- ];
- i.default = class s {
- constructor() {
- (this.cfg = null),
- (this.data = null),
- (this.costumeUpgrade = null),
- (this.costumeMergeCfg = null),
- (this.gradeCfg = null),
- (this.cost = 0),
- (this.canMerge = !1),
- (this.recommend = !1),
- (this.isEquip = !1),
- (this.attr = null);
- }
- init(t, e, i, s) {
- (this.cfg = e),
- (e = i[(this.data = t).grade]),
- (this.costumeMergeCfg = s),
- (this.costumeUpgrade = i),
- (this.gradeCfg = e),
- (this.attr = {[r.CostumeAbilityType.base]: e.value + (t.lv - 1) * e.value_add}),
- (this.cost = e.upgrade_cost + (t.lv - 1) * e.upgrade_cost_add),
- this.initSpecialAbilitys();
- }
- getNextGradeItem() {
- const t = new s(),
- e = Object.assign(Object.create(null), this.data);
- return (e.lv = 1), e.grade++, t.init(e, this.cfg, this.costumeUpgrade, this.costumeMergeCfg), t;
- }
- getLastGradeItem() {
- const t = new s(),
- e = Object.assign(Object.create(null), this.data);
- return (e.lv = 1) < e.grade && e.grade--, t.init(e, this.cfg, this.costumeUpgrade, this.costumeMergeCfg), t;
- }
- getGradeItemByGrade(t) {
- const e = new s(),
- i = Object.assign(Object.create(null), this.data);
- return (i.lv = 1), (i.grade = t), e.init(i, this.cfg, this.costumeUpgrade, this.costumeMergeCfg), e;
- }
- getName() {
- return o.GameText.getTextByStr(this.cfg.name);
- }
- getValue() {
- return this.attr[r.CostumeAbilityType.base];
- }
- getNextLvValue() {
- return this.attr[r.CostumeAbilityType.base] + this.gradeCfg.value_add;
- }
- getMaxLvValue() {
- return this.gradeCfg.value + (this.gradeCfg.max_level - 1) * this.gradeCfg.value_add;
- }
- getLvUpAddRate() {
- var t = this.attr[r.CostumeAbilityType.base];
- return Math.round((this.gradeCfg.value_add / (t + this.gradeCfg.value_add)) * 100);
- }
- getTypeIcon() {
- return l[this.cfg.parts - 1];
- }
- getIcon() {
- return "costume/" + this.cfg.icon_basic;
- }
- toString() {
- var t = this.data,
- e = t.grade;
- let i = `${this.cfg.name} uuid:${t.uuid}, id:${this.cfg.idx}, lv:${t.lv}, grade:${e}(${o.GameText.getTextByStr(
- "str_grade" + e
- )}), cost:${this.cost}`;
- return (
- (i += `\n\u57fa\u7840\u5c5e\u6027\u52a0\u6210:${this.attr[r.CostumeAbilityType.base]}%`),
- e < r.RarityType.uncommon
- ? i
- : ((i += "\n已解锁特殊属性:"),
- (i += "\n 1." + this.getSpecialAbilityStr1()),
- e < r.RarityType.epic
- ? i
- : ((i += "\n 2." + this.getSpecialAbilityStr2()),
- e < r.RarityType.legendary
- ? i
- : ((i += "\n 3." + this.getSpecialAbilityStr3()),
- e < r.RarityType.mystic ? i : i + ("\n 4." + this.getSpecialAbilityStr4()))))
- );
- }
- isMaxGrade() {
- return this.data.grade >= r.RarityType.mystic;
- }
- getMergeCfg() {
- return this.costumeMergeCfg[this.data.grade];
- }
- checkIsCanMerge(t) {
- var e = this.costumeMergeCfg[this.data.grade];
- if (1 === e.ingredient_costume_type) {
- if (t.data.id !== this.data.id || t.data.grade !== e.costume_type_grade) return !1;
- } else if (t.cfg.parts !== this.cfg.parts || t.data.grade !== e.costume_type_grade) return !1;
- return !0;
- }
- initSpecialAbilitys() {
- return this.data.grade < r.RarityType.uncommon
- ? this.attr
- : ((this.attr[this.cfg.special_ability1_type] = this.cfg.special_ability1_value),
- this.data.grade < r.RarityType.epic
- ? this.attr
- : ((this.attr[this.cfg.special_ability2_type] = this.cfg.special_ability2_value),
- this.data.grade < r.RarityType.legendary
- ? this.attr
- : ((this.attr[this.cfg.special_ability3_type] = this.cfg.special_ability3_value),
- this.data.grade < r.RarityType.mystic
- ? this.attr
- : void (this.attr[this.cfg.special_ability4_type] = this.cfg.special_ability4_value))));
- }
- getSpecialAbilityStr1() {
- return a.getCostumeAttrStr(this.cfg.special_ability1_type, this.cfg.special_ability1_value);
- }
- getSpecialAbilityStr2() {
- return a.getCostumeAttrStr(this.cfg.special_ability2_type, this.cfg.special_ability2_value);
- }
- getSpecialAbilityStr3() {
- return a.getCostumeAttrStr(this.cfg.special_ability3_type, this.cfg.special_ability3_value);
- }
- getSpecialAbilityStr4() {
- return a.getCostumeAttrStr(
- this.cfg.special_ability4_type,
- this.cfg.special_ability4_value,
- this.getName(),
- 2 * this.getValue()
- );
- }
- getCurMaxSpecialAbilityStr(t) {
- let e = null;
- return (
- (t = t || this.data.grade) >= r.RarityType.rare && (e = this.getSpecialAbilityStr1()),
- t >= r.RarityType.epic && (e = this.getSpecialAbilityStr2()),
- t >= r.RarityType.legendary && (e = this.getSpecialAbilityStr3()),
- t >= r.RarityType.mystic && (e = this.getSpecialAbilityStr4()),
- e
- );
- }
- getBaseValueStr() {
- return `+${this.attr[r.CostumeAbilityType.base]}%`;
- }
- isMaxLv() {
- return this.data.lv >= this.gradeCfg.max_level;
- }
- getLvCost(t) {
- if (1 === t) return 0;
- var e = this.gradeCfg;
- return t > e.max_level && (t = e.max_level), --t * (e.upgrade_cost + (e.upgrade_cost_add * (t - 1)) / 2);
- }
- canLvUp() {
- return !this.isMaxLv() && n.default.ins.checkDiamondEnough(this.cost);
- }
- refund() {
- (this.data.lv = 1),
- (this.attr[r.CostumeAbilityType.base] = this.gradeCfg.value),
- (this.cost = this.gradeCfg.upgrade_cost);
- }
- lvUp() {
- return (
- !this.isMaxLv() &&
- (this.data.lv++,
- (this.attr[r.CostumeAbilityType.base] += this.gradeCfg.value_add),
- (this.cost += this.gradeCfg.upgrade_cost_add),
- !0)
- );
- }
- canUpgradeGrade() {
- return 0 < this.gradeCfg.upgrade_grade_cost;
- }
- gradeUp() {
- if (this.isMaxGrade()) return !1;
- this.data.grade++, (this.gradeCfg = this.costumeUpgrade[this.data.grade]);
- var t = this.gradeCfg;
- if (
- ((this.data.lv = 1),
- (this.attr[r.CostumeAbilityType.base] = t.value),
- (this.cost = t.upgrade_cost),
- this.attr)
- )
- switch (this.data.grade) {
- case r.RarityType.uncommon:
- this.attr[this.cfg.special_ability1_type] = this.cfg.special_ability1_value;
- break;
- case r.RarityType.epic:
- this.attr[this.cfg.special_ability2_type] = this.cfg.special_ability2_value;
- break;
- case r.RarityType.legendary:
- this.attr[this.cfg.special_ability3_type] = this.cfg.special_ability3_value;
- break;
- case r.RarityType.mystic:
- this.attr[this.cfg.special_ability4_type] = this.cfg.special_ability4_value;
- }
- return !0;
- }
- equip() {
- this.isEquip = !0;
- }
- unEquip() {
- this.isEquip = !1;
- }
- };
|