助战:神像强化暴击逻辑
This commit is contained in:
@@ -3,86 +3,64 @@ import { Channel } from 'pinus';
|
||||
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
|
||||
import { TERAPH_RANDOM } from "../consts";
|
||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||
import { Teraph, RoleModel } from '../db/Role';
|
||||
import { Teraph, RoleModel, RoleType } from '../db/Role';
|
||||
import { ROLE_SELECT } from '../consts';
|
||||
import { SCHOOL } from '../pubUtils/dicParam';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { SclResultInter, SclPosInter } from '../pubUtils/interface';
|
||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
/**
|
||||
* 计算强化次数和消耗
|
||||
* @param count 强化次数
|
||||
* @param attrs 可以强化的属性名字
|
||||
* @param teraphInfo 字典表对应的神像信息
|
||||
* @param teraph 数据库内单个神像信息
|
||||
*/
|
||||
export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphInfo: DicTeraph, teraph: Teraph) {
|
||||
let consumes = [];
|
||||
let criAttr: number[] = [];
|
||||
let times = 0;
|
||||
if (count < 10) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (!attrs.length) {
|
||||
break;
|
||||
}
|
||||
let num = getRandValueByMinMax(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX); // 强化时随机增加 2-4 属性
|
||||
let arr = getRandEelm(attrs, num); // 随机出的属性id
|
||||
let critical = getRandValueByMinMax(0, 100);//属性暴击率
|
||||
let isCritical = critical <= teraphInfo.criRate;
|
||||
let criEffect = 1; // 暴击效果
|
||||
if (isCritical)
|
||||
criEffect = teraphInfo.criEffect;
|
||||
for (let attrId of arr) {
|
||||
let val = teraph.attr.get(attrId); // 已有的强化值
|
||||
val += teraphInfo.mainAttrUp.get(attrId) * criEffect;
|
||||
let max = teraphInfo.mainAttrMax.get(attrId);
|
||||
if(val > max) {
|
||||
val = max;
|
||||
let attrIndex = attrs.indexOf(attrId);
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
teraph.attr.set(attrId, val);
|
||||
if(isCritical) criAttr.push(attrId);
|
||||
}
|
||||
times++;
|
||||
}
|
||||
} else if (count == 10){
|
||||
let criticalArrTimes = getRandEelm(TERAPH_STRENGTHEN, 2);//10次中随机2次发生暴击
|
||||
for (let item of TERAPH_STRENGTHEN) {
|
||||
if (!attrs.length) {
|
||||
break;
|
||||
}
|
||||
let criEffect = 1;
|
||||
let index = criticalArrTimes.indexOf(item);
|
||||
let isCritical = index >= 0;
|
||||
if (isCritical) {
|
||||
criEffect = teraphInfo.criEffect;//本次是暴击 item 在 criticalArrTimes 中
|
||||
}
|
||||
let num = getRandValueByMinMax(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr: number[] = getRandEelm(attrs, num);
|
||||
for (let attrId of arr) {
|
||||
let val = teraph.attr.get(attrId); // 已有的强化值
|
||||
val += teraphInfo.mainAttrUp.get(attrId) * criEffect;
|
||||
let max = teraphInfo.mainAttrMax.get(attrId);
|
||||
import { CheckMeterial } from './rewardService';
|
||||
|
||||
if(val > max) {
|
||||
val = max;
|
||||
let attrIndex = attrs.indexOf(attrId);
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
teraph.attr.set(attrId, val);
|
||||
if(isCritical) criAttr.push(attrId);
|
||||
export async function getTeraphStrengthenResult(role: RoleType, count: number, dicTeraph: DicTeraph, teraph: Teraph) {
|
||||
let criAttr: number[] = [], times = 0;
|
||||
let check = new CheckMeterial(role.roleId, role);
|
||||
for(let i = 0; i < count; i++) {
|
||||
let attrs: number[] = []; // 可以强化的属性
|
||||
dicTeraph.mainAttrMax.forEach((max, id) => {
|
||||
if (teraph.attr.get(id) < max) {
|
||||
attrs.push(id);
|
||||
}
|
||||
times++;
|
||||
});
|
||||
if(attrs.length <= 0) break; // 如果所有属性都到最高
|
||||
let isEnough = await check.decrease(dicTeraph.upMaterial);
|
||||
|
||||
if(!isEnough) break; // 消耗不足
|
||||
|
||||
let num = getRandValueByMinMax(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX); // 强化时随机增加 2-4 属性
|
||||
let arr = getRandEelm(attrs, num); // 随机出的属性id
|
||||
let critical = getRandValueByMinMax(0, 100);//属性暴击率
|
||||
if(teraph.criCount == undefined || teraph.count == undefined) {
|
||||
teraph.criCount = 0;
|
||||
teraph.count = 0;
|
||||
}
|
||||
}
|
||||
//计算消耗
|
||||
for (let {id, count} of teraphInfo.upMaterial) {
|
||||
consumes.push({ id, count: count * times});
|
||||
let isCritical = critical <= dicTeraph.criRate; // 每10次需要2次保底暴击
|
||||
if(!isCritical && Math.floor((teraph.count + 2)/10) * 2 > teraph.criCount) {
|
||||
isCritical = true;
|
||||
} else if (isCritical && Math.ceil(teraph.count/10) * 2 <= teraph.criCount) {
|
||||
isCritical = false;
|
||||
}
|
||||
teraph.count ++;
|
||||
if(isCritical) teraph.criCount ++;
|
||||
|
||||
let criEffect = isCritical?dicTeraph.criEffect: 1; // 暴击效果
|
||||
for (let attrId of arr) {
|
||||
let val = teraph.attr.get(attrId); // 已有的强化值
|
||||
val += dicTeraph.mainAttrUp.get(attrId) * criEffect;
|
||||
let max = dicTeraph.mainAttrMax.get(attrId);
|
||||
if(val > max) {
|
||||
val = max;
|
||||
let attrIndex = attrs.indexOf(attrId);
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
teraph.attr.set(attrId, val);
|
||||
if(isCritical) criAttr.push(attrId);
|
||||
}
|
||||
times++;
|
||||
|
||||
}
|
||||
return { consumes, criAttr };
|
||||
return { times, consumes: check.getConsume(), criAttr }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channel
|
||||
|
||||
Reference in New Issue
Block a user