关卡:星级记录
This commit is contained in:
@@ -14,6 +14,7 @@ import { RScriptRecordModel } from '../db/RScriptRecord';
|
||||
import { setAp } from './actionPointService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { LineupParam } from '../domain/rank';
|
||||
import { WarStar } from '../domain/dbGeneral';
|
||||
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
@@ -114,19 +115,30 @@ export async function checkBattleHeroesByHid(roleId: string, heroes: Array<numbe
|
||||
return { isOK: flag, heroes: findHeroes };
|
||||
}
|
||||
|
||||
export async function updateWarStar(roleId: string, battleId: number, warType: number, star: number) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let { warStar = new Array<{ id: number, warType: number, star: number }>() } = role;
|
||||
let curStar = warStar.find(cur => cur.id == battleId);
|
||||
let result: Role;
|
||||
if (curStar) {
|
||||
if (star > curStar.star) {
|
||||
result = await Role.updateWarStar(roleId, battleId, star);
|
||||
export function calculateWarStar(warStar: WarStar[], battleId: number, stars: number[]) {
|
||||
let newWarStars: WarStar[] = [];
|
||||
let newStars: number[] = [], newStar = 0;
|
||||
let hasFound = false;
|
||||
for(let curWarStar of warStar) {
|
||||
if(curWarStar.id == battleId) {
|
||||
for(let i = 0; i < 3; i++) {
|
||||
let isOn = (curWarStar.stars[i] == 1)||(stars[i] == 1);
|
||||
newStars.push(isOn? 1: 0);
|
||||
if(isOn) newStar++;
|
||||
}
|
||||
newWarStars.push({...curWarStar, star: newStar, stars: newStars});
|
||||
hasFound = true;
|
||||
} else {
|
||||
newWarStars.push(curWarStar);
|
||||
}
|
||||
} else {
|
||||
result = await RoleModel.pushWarStar(roleId, battleId, warType, star);
|
||||
}
|
||||
return result
|
||||
if(!hasFound) {
|
||||
newStar = stars.filter(cur => cur == 1).length;
|
||||
newStars = stars;
|
||||
let dicWar = gameData.war.get(battleId);
|
||||
newWarStars.push({ id: battleId, warType: dicWar.warType, star: newStar, stars: newStars});
|
||||
}
|
||||
return { newWarStars, newStars, newStar };
|
||||
}
|
||||
|
||||
export async function getBattleListOfMain(role: RoleType) {
|
||||
@@ -151,21 +163,24 @@ export async function getBattleList(role: RoleType, type: number) {
|
||||
battleId,
|
||||
status: 0,
|
||||
star: 0,
|
||||
stars: [],
|
||||
scriptBefore,
|
||||
scriptAfter
|
||||
});
|
||||
}
|
||||
for (let { id, star, warType } of warStar) {
|
||||
for (let { id, star, stars = [], warType } of warStar) {
|
||||
if (warType == type) {
|
||||
let curResult = result.find(cur => cur.battleId == id);
|
||||
if (curResult) {
|
||||
curResult.status = 1;
|
||||
curResult.star = star;
|
||||
curResult.stars = stars;
|
||||
} else {
|
||||
result.push({
|
||||
battleId: id,
|
||||
status: 1,
|
||||
star,
|
||||
stars,
|
||||
scriptBefore: '',
|
||||
scriptAfter: ''
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user