From 76fa1104fc6c6d26e37e5388c6b0c4b18e4ea38e Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 19 Aug 2021 15:56:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A5=9E=E5=83=8F=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9A=B4=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/servers/role/handler/roleHandler.ts | 4 ++-- game-server/app/services/roleService.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/game-server/app/servers/role/handler/roleHandler.ts b/game-server/app/servers/role/handler/roleHandler.ts index 7c0de881b..cc5ec9d7f 100644 --- a/game-server/app/servers/role/handler/roleHandler.ts +++ b/game-server/app/servers/role/handler/roleHandler.ts @@ -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 }); } //神像进阶 diff --git a/game-server/app/services/roleService.ts b/game-server/app/services/roleService.ts index 64b79f7d2..ee3cb31e4 100644 --- a/game-server/app/services/roleService.ts +++ b/game-server/app/services/roleService.ts @@ -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 }; } /** *