From 4ed7a7b0ec7a2ced76bd33061c219588f87ee44a Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 11 Mar 2021 20:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=A2=E8=B1=A1=EF=BC=9A=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E6=AD=A6=E5=B0=86=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/role/handler/heroHandler.ts | 6 ++++-- game-server/app/services/rewardService.ts | 18 +++++++++++++++--- gm-server/app/service/users.ts | 4 +++- shared/pubUtils/itemUtils.ts | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/game-server/app/servers/role/handler/heroHandler.ts b/game-server/app/servers/role/handler/heroHandler.ts index 50c2ee987..1a463347b 100644 --- a/game-server/app/servers/role/handler/heroHandler.ts +++ b/game-server/app/servers/role/handler/heroHandler.ts @@ -1,5 +1,5 @@ import {Application, BackendSession, ChannelService} from 'pinus'; -import { handleCost, addItems } from '../../../services/rewardService'; +import { handleCost, addItems, unlockFigure } from '../../../services/rewardService'; import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService'; import { resResult, returnHeroCeRatio, deepCopy } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; @@ -9,7 +9,7 @@ import { RoleModel } from '../../../db/Role'; import { ItemModel } from '../../../db/Item'; import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp } from '../../../pubUtils/data'; import { RewardInter } from '../../../pubUtils/interface'; -import { getDropItems } from '../../../consts/constModules/itemConst' +import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst' import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax } from '../../../services/chatService'; import { calculatetopLineup } from '../../../pubUtils/playerCe'; import { PvpDefenseModel } from '../../../db/PvpDefense'; @@ -139,6 +139,7 @@ export class HeroHandler { let curHero = await HeroModel.createHero({ roleId, serverId, roleName, hid, hName, star, quality, job, skins:[{id: initialSkin, enable: true}] }); + await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.GET_HERO, num: hid }]); // 解锁头像 let hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, sid, roleId, curHero, {}); await calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [initialSkin]) pushComposeOrangeHero(roleId, roleName, serverId, hero); @@ -537,6 +538,7 @@ export class HeroHandler { //重算战力并下发 if (oldLv != hero.favourLv) { + await unlockFigure(sid, roleId, [{type: FIGURE_UNLOCK_CONDITION.HERO_FAVOR, num: hero.favourLv }]); hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.FAVOUR, sid, roleId, hero, { favour: newExp, favourLv: newLv }, [oldLv]); diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index e07f0ca83..c2ea2da03 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -1,14 +1,14 @@ -import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE } from './../consts'; +import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, FIGURE_UNLOCK_CONDITION } from './../consts'; import { EquipModel } from './../db/Equip'; import { resResult, parseGoodStr } from '../pubUtils/util'; import { getGoodById } from '../pubUtils/gamedata'; -import { RoleModel } from '../db/Role'; +import { RoleModel, RoleType } from '../db/Role'; import { setAp } from './actionPointService'; import { calAllHeroCe } from './playerCeService'; import { ItemModel } from '../db/Item'; import { STATUS } from '../consts/statusCode'; import { pinus } from 'pinus'; -import { addEquips, addBags, addSkins, addFigure } from '../pubUtils/itemUtils'; +import { addEquips, addBags, addSkins, addFigure, unlockFigure as pubUnlockFigure } from '../pubUtils/itemUtils'; import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface'; import { gameData } from '../pubUtils/data'; import { uniq, indexOf, findIndex } from 'underscore'; @@ -166,6 +166,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go } } if (!!skinInfos.length) { + let unlockedType = addSkinIds.map(cur => { return { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, num: cur } }); + await unlockFigure(sid, roleId, unlockedType); calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, addSkinIds); pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, {skinInfos}), uids); } @@ -279,4 +281,14 @@ export async function checkGoods(roleId: string, goodIds: Array) { return false; } return true; +} + + +export async function unlockFigure(sid: string, roleId: string, conditions: {type: number, num: number}[], role?: RoleType) { + let figureInfo = await pubUnlockFigure(roleId, conditions, role); + + if (!!figureInfo) { + let uids = [{uid: roleId, sid}]; + pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids); + } } \ No newline at end of file diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 0ad6ba1f9..e97079a7d 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -20,7 +20,7 @@ import { PvpDefenseModel } from '@db/PvpDefense'; import { Service } from 'egg'; import Counter from '@db/Counter'; -import { STATUS, HERO_SYSTEM_TYPE } from '@consts'; +import { STATUS, HERO_SYSTEM_TYPE, FIGURE_UNLOCK_CONDITION } from '@consts'; import { ITID, COUNTER } from '@consts'; import { ItemModel } from '@db/Item'; import { gameData, getHeroExpByLv } from '@pubUtils/data'; @@ -32,6 +32,7 @@ import { isString } from 'underscore'; import { FriendShipModel } from '@db/FriendShip'; import { FriendApplyModel } from '@db/FriendApply'; import { FriendRelationModel } from '@db/FriendRelation'; +import { unlockFigure } from '@pubUtils/itemUtils'; /** * Test Service @@ -267,6 +268,7 @@ export default class GMUsers extends Service { try { for(let heroInfo of heroInfos) { let hero = await HeroModel.createHero(heroInfo); + await unlockFigure(heroInfo.roleId, [{ type: FIGURE_UNLOCK_CONDITION.GET_HERO, num: heroInfo.hid }]); // 解锁头像 await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, heroInfo.roleId, hero, {}); } return ctx.service.utils.resResult(STATUS.SUCCESS, { uids }); diff --git a/shared/pubUtils/itemUtils.ts b/shared/pubUtils/itemUtils.ts index 2e44fad9e..cbeaa76b4 100644 --- a/shared/pubUtils/itemUtils.ts +++ b/shared/pubUtils/itemUtils.ts @@ -112,10 +112,10 @@ export async function unlockFigure(roleId: string, conditions: {type: number, nu if(figure && figure.unlocked) figureInfo.heads.push(figure); } else if (dicItid.type == CONSUME_TYPE.FRAME) { let figure = unlockSingleFigure(frames, id, false, type); - if(figure && figure.unlocked) figureInfo.heads.push(figure); + if(figure && figure.unlocked) figureInfo.frames.push(figure); } else if (dicItid.type == CONSUME_TYPE.SPINE) { let figure = unlockSingleFigure(spines, id, false, type); - if(figure && figure.unlocked) figureInfo.heads.push(figure); + if(figure && figure.unlocked) figureInfo.spines.push(figure); } else { continue; }