pvp:头像框解锁

This commit is contained in:
luying
2021-11-02 19:35:58 +08:00
parent 4fde6af1c4
commit cb3583276c
6 changed files with 21 additions and 9 deletions

View File

@@ -12,10 +12,10 @@ import { PVPConfigModel } from '../../../db/SystemConfig';
import { Rank } from '../../../services/rankService';
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
import { LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
import { FIGURE_UNLOCK_CONDITION, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
import { PVP } from '../../../pubUtils/dicParam';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { addItems, handleCost } from '../../../services/rewardService';
import { addItems, handleCost, unlockFigure } from '../../../services/rewardService';
import { pick } from "underscore";
import { HeroModel } from '../../../db/Hero';
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
@@ -216,6 +216,7 @@ export class PvpHandler {
// 更新军功
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
if (!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
let { hisWinStreakNum = 0 } = pvpDefense;
let update: pvpUpdateInter = {};
@@ -271,7 +272,9 @@ export class PvpHandler {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP_WIN, 1)
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP_WIN_SERIES, 1)
}
if(hisWinStreakNum < pvpDefense.hisWinStreakNum) {
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES, paramWinStreakNum: pvpDefense.hisWinStreakNum }]);
}
return resResult(STATUS.SUCCESS, {
battleCode, isSuccess,

View File

@@ -399,13 +399,16 @@ export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAtt
// 获取我方战报记录
export async function generMyRecInfo(pvpDefense: PvpDefenseType, role: RoleType, isSuccess: boolean, pos: number, myHeroes: pvpEndParamInter[]) {
let { attack, defense, heroScores, winStreakNum, score, hisScore } = pvpDefense;
let { attack, defense, heroScores, winStreakNum, hisWinStreakNum = 0, score, hisScore } = pvpDefense;
let { roleId } = role;
if (isSuccess) {
winStreakNum ++;
} else {
winStreakNum = 0;
}
if(winStreakNum > hisWinStreakNum) {
hisWinStreakNum = winStreakNum;
}
const dicOpp = gameData.pvpOpponent.get(pos);
const plusScore = getPlusScore(winStreakNum);
@@ -450,7 +453,7 @@ export async function generMyRecInfo(pvpDefense: PvpDefenseType, role: RoleType,
let newDefense = <Defense>calLineupScore(defense, heroScores);
let updateParam = {
winStreakNum, attack: newAttack, defense: newDefense, heroScores, score: score + addSumScore, hisScore: hisScore > score + addSumScore? hisScore: score + addSumScore
winStreakNum, hisWinStreakNum, attack: newAttack, defense: newDefense, heroScores, score: score + addSumScore, hisScore: hisScore > score + addSumScore? hisScore: score + addSumScore
}
return { attackInfo, showHeroScores, updateParam }

View File

@@ -426,7 +426,7 @@ export async function checkHeroes(roleId: string, hids: number[]) {
return true
}
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }[], role?: RoleType) {
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) {
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
await pushFigureUpdate(roleId, sid, figureInfo);
}

View File

@@ -254,6 +254,7 @@ export function getDropItems() {
export enum FIGURE_UNLOCK_CONDITION {
GET_HERO = 1, // 获取武将
HERO_FAVOR = 2, // 武将好感度达到
PVP_WIN_SERIES = 3, // pvp连胜
GET_SKIN = 7, // 获得时装
}

View File

@@ -31,6 +31,8 @@ export default class PvpDefense extends BaseModel {
hisScore: number; //历史最高积分
@prop({ required: true, default: 0 })
winStreakNum: number; //连胜次数
@prop({ required: true, default: 0 })
hisWinStreakNum: number; //历史最高连胜次数
@prop({ required: true, default: () => { return new Date() } })
refDaily: Date; // 每日刷新控制refOppCnt和setAttackCnt

View File

@@ -190,11 +190,11 @@ export function getHonourObject(count: number) {
* @param conditions 解锁条件
* @param role 如果已查询过role表就直接可以使用
*/
export function unlockFigureWithoutSave(conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }[], role: RoleType) {
export function unlockFigureWithoutSave(conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role: RoleType) {
let { heads, frames, spines } = role;
let figureInfo = { heads: new Array<Figure>(), frames: new Array<Figure>(), spines: new Array<Figure>() };
for (let { type, paramHid, paramFavourLv, paramSkinId } of conditions) {
for (let { type, paramHid, paramFavourLv, paramSkinId, paramWinStreakNum } of conditions) {
let canUnLockList = gameData.figureCondition.get(type);
if (canUnLockList) {
for (let { id, params, gid } of canUnLockList) {
@@ -208,6 +208,9 @@ export function getHonourObject(count: number) {
} else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) {
let [id] = params;
if (paramSkinId == id) flag = true;
} else if (type == FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES) {
let [winStreakNum] = params;
if (paramWinStreakNum >= winStreakNum) flag = true;
}
if (!flag) continue;
let dicGood = gameData.goods.get(gid);
@@ -241,7 +244,7 @@ export function getHonourObject(count: number) {
* @param conditions 解锁条件
* @param role 如果已查询过role表就直接可以使用
*/
export async function unlockFigure(roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }[], role?: RoleType) {
export async function unlockFigure(roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) {
if (!role || !role.heads || !role.frames) {
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
}