神像:添加暴击

This commit is contained in:
luying
2021-08-19 15:56:56 +08:00
parent 7fedc5dfba
commit 76fa1104fc
2 changed files with 11 additions and 6 deletions

View File

@@ -137,7 +137,7 @@ export class RoleHandler {
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
// 随机神像中的一条属性并检查道具是否足够以及更新teraph
let { consumes } = checkTeraphMaterialEnough(count, attrs, dicTeraph, teraph);
let { consumes, criAttr } = checkTeraphMaterialEnough(count, attrs, dicTeraph, teraph);
let result = await handleCost(roleId, sid, consumes);
if (!result)
@@ -148,7 +148,7 @@ export class RoleHandler {
// 任务
await checkTask(roleId, sid, funcs, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, count, true, {});
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs });
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs, criAttr });
}
//神像进阶

View File

@@ -19,6 +19,7 @@ const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
*/
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++) {
@@ -28,8 +29,9 @@ export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphI
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 (critical <= teraphInfo.criRate)
if (isCritical)
criEffect = teraphInfo.criEffect;
for (let attrId of arr) {
let val = teraph.attr.get(attrId); // 已有的强化值
@@ -41,6 +43,7 @@ export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphI
attrs.splice(attrIndex, 1);
}
teraph.attr.set(attrId, val);
if(isCritical) criAttr.push(attrId);
}
times++;
}
@@ -51,8 +54,9 @@ export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphI
break;
}
let criEffect = 1;
let index = criticalArrTimes.indexOf(item)
if (index > 0) {
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);
@@ -68,6 +72,7 @@ export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphI
attrs.splice(attrIndex, 1);
}
teraph.attr.set(attrId, val);
if(isCritical) criAttr.push(attrId);
}
times++;
}
@@ -76,7 +81,7 @@ export function checkTeraphMaterialEnough(count: number, attrs:number[], teraphI
for (let {id, count} of teraphInfo.upMaterial) {
consumes.push({ id, count: count * times});
}
return { consumes};
return { consumes, criAttr };
}
/**
*