You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.0 KiB
134 lines
4.0 KiB
import CsvMgr from "../Mgr_CSV/CsvMgr";
|
|
import { EGongFaType } from "./GameEnum";
|
|
import { wugong } from "./GameInterface";
|
|
|
|
export default class WuGongData{
|
|
|
|
archive:wugong;
|
|
|
|
levelUp_paycoin = 0; // 升级所需花费(银两消耗)
|
|
levelUp_condition = 0; // 升级条件(所需武学修为)
|
|
isUseing = false; // 是否正在使用
|
|
value_keyAtt = 0;
|
|
constructor(archive:wugong){
|
|
this.archive = archive;
|
|
this.refresh();
|
|
}
|
|
|
|
refresh() {
|
|
this.refreshAttribute()
|
|
this.refreshCondition()
|
|
this.refreshCost();
|
|
}
|
|
|
|
upgrade(){
|
|
this.level++;
|
|
this.refresh();
|
|
// var e = this.config;
|
|
// app.manager.toast.pop(a.CONDITION, o[e.type] + "造诣 +" + this.config.quality);
|
|
// e.type < EGongFaType.轻功 && app.manager.toast.pop(a.GONGFA, "基础武学 +" + this.config.quality);
|
|
}
|
|
|
|
// 计算主属性值
|
|
refreshAttribute(){
|
|
var e = this.config;
|
|
this.value_keyAtt = e.attr + 4 * (e.grow + e.quality) / 2 * this.level;
|
|
for (let i = this.level; i > 0; i--) {
|
|
this.value_keyAtt += Math.floor(i / 10);
|
|
}
|
|
}
|
|
|
|
// 获取升级所需条件(所需武学修为)
|
|
refreshCondition(){
|
|
const config = this.config;
|
|
const isSpecialType = (EGongFaType.轻功 == config.type || EGongFaType.内功 == config.type);
|
|
const commonCalculation = Math.round((this.level + 1) * (this.level + 1) * (config.quality + 5) / 30);
|
|
|
|
// 是轻功或内功,且等级大于等于5的特殊计算公式
|
|
if (isSpecialType && this.level >= 5) {
|
|
this.levelUp_condition = commonCalculation + 2 * (config.quality + 5) * this.level + 1;
|
|
} else if (this.level >= 20 && config.quality > 1) {
|
|
// 20级以上且品质大于1的通用计算公式
|
|
this.levelUp_condition = commonCalculation + this.level + 1;
|
|
}
|
|
}
|
|
|
|
// 计算升级所需金币消耗
|
|
refreshCost() {
|
|
const config = this.config;
|
|
if (!config || typeof this.level !== 'number') return;
|
|
|
|
const QUALITY_FACTOR = 1.01;
|
|
const BASE_MULTIPLIER = 7;
|
|
const LEVEL_THRESHOLD_HIGH = 80;
|
|
const COST_MULTIPLIER_LIGHT_INTERNAL = 2;
|
|
|
|
let cost = 0;
|
|
|
|
// 10级以下采用斐波那契数列算法计算经验消耗
|
|
if (this.level < 10) {
|
|
let fibPrev = 1;
|
|
let fibCurr = 1;
|
|
let fibNext = 0;
|
|
|
|
for (let i = 0; i < this.level + 1; i++) {
|
|
fibNext = fibPrev + fibCurr;
|
|
fibPrev = fibCurr;
|
|
fibCurr = fibNext;
|
|
}
|
|
|
|
cost = fibNext * (config.quality + QUALITY_FACTOR) * (config.quality + QUALITY_FACTOR);
|
|
} else {
|
|
// 10级以上采用立方增长算法计算经验消耗
|
|
const levelPlusOne = this.level + 1;
|
|
cost = Math.round(
|
|
(levelPlusOne * levelPlusOne * levelPlusOne) *
|
|
(config.quality + QUALITY_FACTOR) *
|
|
(config.quality + QUALITY_FACTOR) /
|
|
BASE_MULTIPLIER
|
|
);
|
|
|
|
// 80级以上额外增加消耗
|
|
if (this.level > LEVEL_THRESHOLD_HIGH) {
|
|
const adjustmentFactor = 2 * (this.level - LEVEL_THRESHOLD_HIGH) + 100;
|
|
cost = Math.round(cost * adjustmentFactor / 100);
|
|
}
|
|
}
|
|
|
|
// 轻功内功升级额外消耗
|
|
if (
|
|
config.type === EGongFaType.轻功 ||
|
|
config.type === EGongFaType.内功
|
|
) {
|
|
cost *= COST_MULTIPLIER_LIGHT_INTERNAL;
|
|
}
|
|
|
|
this.levelUp_paycoin = Math.floor(cost);
|
|
}
|
|
|
|
get id(){
|
|
return this.archive.id;
|
|
}
|
|
|
|
set id(value: number) {
|
|
this.archive.id = value;
|
|
}
|
|
|
|
get level() {
|
|
return this.archive.level;
|
|
}
|
|
|
|
set level(value: number) {
|
|
this.archive.level = value;
|
|
}
|
|
|
|
|
|
get config(){
|
|
return CsvMgr.WuGong_csv[this.id];
|
|
}
|
|
|
|
get attainment(){
|
|
return this.level * this.config.overAll;
|
|
}
|
|
|
|
}
|