关卡:星级结算
This commit is contained in:
@@ -12,7 +12,7 @@ import { addItems } from '../../../services/rewardService';
|
|||||||
import { getAp, setAp } from '../../../services/actionPointService';
|
import { getAp, setAp } from '../../../services/actionPointService';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
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 { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
import * as dicParam from '../../../pubUtils/dicParam';
|
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 roleId = session.get('roleId');
|
||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
@@ -228,16 +228,24 @@ export class ExpeditionBattleHandler {
|
|||||||
}, true);
|
}, true);
|
||||||
// 更新点数
|
// 更新点数
|
||||||
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
|
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 warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||||
let reward = await warReward.saveReward(1);
|
let reward = await warReward.saveReward(1);
|
||||||
|
|
||||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
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) {
|
if (isSuccess) {
|
||||||
// 更新下一关状态
|
// 更新下一关状态
|
||||||
await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
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);
|
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, star);
|
||||||
|
|
||||||
|
|||||||
@@ -227,16 +227,15 @@ export class orderHandler {
|
|||||||
// }
|
// }
|
||||||
let activityData = await getActivityById(activityId);
|
let activityData = await getActivityById(activityId);
|
||||||
if (!activityData) return resResult(STATUS.ACTIVITY_MISSING);
|
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) {
|
if(!orderInfo) {
|
||||||
return resResult(STATUS.NO_ORDER);
|
return resResult(STATUS.NO_ORDER);
|
||||||
}
|
}
|
||||||
let result = await settleOrder(orderInfo, serverId, sid);
|
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}`)
|
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 { resResult } from '../pubUtils/util';
|
||||||
import { LineupParam } from '../domain/rank';
|
import { LineupParam } from '../domain/rank';
|
||||||
import { WarStar } from '../domain/dbGeneral';
|
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) {
|
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
@@ -121,11 +122,8 @@ export function calculateWarStar(warStar: WarStar[] = [], battleId: number, star
|
|||||||
let hasFound = false;
|
let hasFound = false;
|
||||||
for(let curWarStar of warStar) {
|
for(let curWarStar of warStar) {
|
||||||
if(curWarStar.id == battleId) {
|
if(curWarStar.id == battleId) {
|
||||||
for(let i = 0; i < 3; i++) {
|
newStars = uniq([...stars, ...curWarStar.stars]);
|
||||||
let isOn = (curWarStar.stars && curWarStar.stars[i] == 1)||(stars[i] == 1);
|
newStar = newStars.filter(cur => cur > 0).length;
|
||||||
newStars.push(isOn? 1: 0);
|
|
||||||
if(isOn) newStar++;
|
|
||||||
}
|
|
||||||
newWarStars.push({...curWarStar, star: newStar, stars: newStars});
|
newWarStars.push({...curWarStar, star: newStar, stars: newStars});
|
||||||
hasFound = true;
|
hasFound = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -133,7 +131,7 @@ export function calculateWarStar(warStar: WarStar[] = [], battleId: number, star
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hasFound) {
|
if(!hasFound) {
|
||||||
newStar = stars.filter(cur => cur == 1).length;
|
newStar = stars.filter(cur => cur > 0).length;
|
||||||
newStars = stars;
|
newStars = stars;
|
||||||
let dicWar = gameData.war.get(battleId);
|
let dicWar = gameData.war.get(battleId);
|
||||||
newWarStars.push({ id: battleId, warType: dicWar.warType, star: newStar, stars: newStars});
|
newWarStars.push({ id: battleId, warType: dicWar.warType, star: newStar, stars: newStars});
|
||||||
|
|||||||
Reference in New Issue
Block a user