关卡:星级结算
This commit is contained in:
@@ -12,7 +12,7 @@ import { addItems } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { calculateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
@@ -177,9 +177,9 @@ export class ExpeditionBattleHandler {
|
||||
* 战斗结算
|
||||
* 结算战斗奖励,更新远征状态
|
||||
*/
|
||||
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number }, session: BackendSession) {
|
||||
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: number[] }, session: BackendSession) {
|
||||
|
||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, enemies } = msg;
|
||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, stars = [], enemies } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -228,16 +228,24 @@ export class ExpeditionBattleHandler {
|
||||
}, true);
|
||||
// 更新点数
|
||||
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
|
||||
let { expeditionPoint = 0 } = role;
|
||||
let { expeditionPoint = 0, warStar = [] } = role;
|
||||
|
||||
// 关卡奖励
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
|
||||
let curWarStar = warStar.find(cur => cur.id == battleId);
|
||||
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, stars);
|
||||
|
||||
if (isSuccess) {
|
||||
// 更新下一关状态
|
||||
await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
||||
|
||||
if (!curWarStar || newStar > curWarStar.star) {
|
||||
await RoleModel.updateRoleInfo(roleId, { warStar: newWarStars });
|
||||
}
|
||||
}
|
||||
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, star);
|
||||
|
||||
|
||||
@@ -227,16 +227,15 @@ export class orderHandler {
|
||||
// }
|
||||
let activityData = await getActivityById(activityId);
|
||||
if (!activityData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message);
|
||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message);
|
||||
|
||||
//订单成功
|
||||
let orderInfo = await UserOrderModel.findOrder(localOrderID);
|
||||
if(!orderInfo) {
|
||||
return resResult(STATUS.NO_ORDER);
|
||||
}
|
||||
let result = await settleOrder(orderInfo, serverId, sid);
|
||||
orderInfo = await UserOrderModel.success(roleId, localOrderID, result);
|
||||
orderInfo = await UserOrderModel.success(roleId, localOrderID, JSON.stringify(result));
|
||||
console.log(`测试支付完成!!!!!!!!!!!!! serverId:${serverId}, productID:${productID}, productType:${productType}, roleId:${roleId}, localOrderID:${localOrderID}, payType:${payType}`)
|
||||
return resResult(STATUS.SUCCESS, JSON.parse(result));
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { setAp } from './actionPointService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { LineupParam } from '../domain/rank';
|
||||
import { WarStar } from '../domain/dbGeneral';
|
||||
import { uniq } from 'underscore';
|
||||
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
@@ -121,11 +122,8 @@ export function calculateWarStar(warStar: WarStar[] = [], battleId: number, star
|
||||
let hasFound = false;
|
||||
for(let curWarStar of warStar) {
|
||||
if(curWarStar.id == battleId) {
|
||||
for(let i = 0; i < 3; i++) {
|
||||
let isOn = (curWarStar.stars && curWarStar.stars[i] == 1)||(stars[i] == 1);
|
||||
newStars.push(isOn? 1: 0);
|
||||
if(isOn) newStar++;
|
||||
}
|
||||
newStars = uniq([...stars, ...curWarStar.stars]);
|
||||
newStar = newStars.filter(cur => cur > 0).length;
|
||||
newWarStars.push({...curWarStar, star: newStar, stars: newStars});
|
||||
hasFound = true;
|
||||
} else {
|
||||
@@ -133,7 +131,7 @@ export function calculateWarStar(warStar: WarStar[] = [], battleId: number, star
|
||||
}
|
||||
}
|
||||
if(!hasFound) {
|
||||
newStar = stars.filter(cur => cur == 1).length;
|
||||
newStar = stars.filter(cur => cur > 0).length;
|
||||
newStars = stars;
|
||||
let dicWar = gameData.war.get(battleId);
|
||||
newWarStars.push({ id: battleId, warType: dicWar.warType, star: newStar, stars: newStars});
|
||||
|
||||
Reference in New Issue
Block a user