pvp:头像框解锁
This commit is contained in:
@@ -12,10 +12,10 @@ import { PVPConfigModel } from '../../../db/SystemConfig';
|
|||||||
import { Rank } from '../../../services/rankService';
|
import { Rank } from '../../../services/rankService';
|
||||||
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
||||||
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
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 { PVP } from '../../../pubUtils/dicParam';
|
||||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||||
import { addItems, handleCost } from '../../../services/rewardService';
|
import { addItems, handleCost, unlockFigure } from '../../../services/rewardService';
|
||||||
import { pick } from "underscore";
|
import { pick } from "underscore";
|
||||||
import { HeroModel } from '../../../db/Hero';
|
import { HeroModel } from '../../../db/Hero';
|
||||||
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
|
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
|
||||||
@@ -216,6 +216,7 @@ export class PvpHandler {
|
|||||||
// 更新军功
|
// 更新军功
|
||||||
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
||||||
if (!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
if (!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
||||||
|
let { hisWinStreakNum = 0 } = pvpDefense;
|
||||||
|
|
||||||
let update: pvpUpdateInter = {};
|
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, 1)
|
||||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP_WIN_SERIES, 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, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
battleCode, isSuccess,
|
battleCode, isSuccess,
|
||||||
|
|||||||
@@ -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[]) {
|
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;
|
let { roleId } = role;
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
winStreakNum ++;
|
winStreakNum ++;
|
||||||
} else {
|
} else {
|
||||||
winStreakNum = 0;
|
winStreakNum = 0;
|
||||||
}
|
}
|
||||||
|
if(winStreakNum > hisWinStreakNum) {
|
||||||
|
hisWinStreakNum = winStreakNum;
|
||||||
|
}
|
||||||
|
|
||||||
const dicOpp = gameData.pvpOpponent.get(pos);
|
const dicOpp = gameData.pvpOpponent.get(pos);
|
||||||
const plusScore = getPlusScore(winStreakNum);
|
const plusScore = getPlusScore(winStreakNum);
|
||||||
@@ -450,7 +453,7 @@ export async function generMyRecInfo(pvpDefense: PvpDefenseType, role: RoleType,
|
|||||||
let newDefense = <Defense>calLineupScore(defense, heroScores);
|
let newDefense = <Defense>calLineupScore(defense, heroScores);
|
||||||
|
|
||||||
let updateParam = {
|
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 }
|
return { attackInfo, showHeroScores, updateParam }
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ export async function checkHeroes(roleId: string, hids: number[]) {
|
|||||||
return true
|
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);
|
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
|
||||||
await pushFigureUpdate(roleId, sid, figureInfo);
|
await pushFigureUpdate(roleId, sid, figureInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ export function getDropItems() {
|
|||||||
export enum FIGURE_UNLOCK_CONDITION {
|
export enum FIGURE_UNLOCK_CONDITION {
|
||||||
GET_HERO = 1, // 获取武将
|
GET_HERO = 1, // 获取武将
|
||||||
HERO_FAVOR = 2, // 武将好感度达到
|
HERO_FAVOR = 2, // 武将好感度达到
|
||||||
|
PVP_WIN_SERIES = 3, // pvp连胜
|
||||||
GET_SKIN = 7, // 获得时装
|
GET_SKIN = 7, // 获得时装
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ export default class PvpDefense extends BaseModel {
|
|||||||
hisScore: number; //历史最高积分
|
hisScore: number; //历史最高积分
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
winStreakNum: number; //连胜次数
|
winStreakNum: number; //连胜次数
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
hisWinStreakNum: number; //历史最高连胜次数
|
||||||
|
|
||||||
@prop({ required: true, default: () => { return new Date() } })
|
@prop({ required: true, default: () => { return new Date() } })
|
||||||
refDaily: Date; // 每日刷新,控制refOppCnt和setAttackCnt
|
refDaily: Date; // 每日刷新,控制refOppCnt和setAttackCnt
|
||||||
|
|||||||
@@ -190,11 +190,11 @@ export function getHonourObject(count: number) {
|
|||||||
* @param conditions 解锁条件
|
* @param conditions 解锁条件
|
||||||
* @param role 如果已查询过role表就直接可以使用
|
* @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 { heads, frames, spines } = role;
|
||||||
let figureInfo = { heads: new Array<Figure>(), frames: new Array<Figure>(), spines: new Array<Figure>() };
|
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);
|
let canUnLockList = gameData.figureCondition.get(type);
|
||||||
if (canUnLockList) {
|
if (canUnLockList) {
|
||||||
for (let { id, params, gid } of 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) {
|
} else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) {
|
||||||
let [id] = params;
|
let [id] = params;
|
||||||
if (paramSkinId == id) flag = true;
|
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;
|
if (!flag) continue;
|
||||||
let dicGood = gameData.goods.get(gid);
|
let dicGood = gameData.goods.get(gid);
|
||||||
@@ -241,7 +244,7 @@ export function getHonourObject(count: number) {
|
|||||||
* @param conditions 解锁条件
|
* @param conditions 解锁条件
|
||||||
* @param role 如果已查询过role表就直接可以使用
|
* @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) {
|
if (!role || !role.heads || !role.frames) {
|
||||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user