好友:武将详情
This commit is contained in:
@@ -4,7 +4,7 @@ import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_T
|
|||||||
import { RoleModel, RoleType } from "../../../db/Role";
|
import { RoleModel, RoleType } from "../../../db/Role";
|
||||||
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||||
import { FriendApplyModel } from "../../../db/FriendApply";
|
import { FriendApplyModel } from "../../../db/FriendApply";
|
||||||
import { FriendListParam, FriendRecommendParams, BlackListParam, FriendValueListParam } from "../../../domain/roleField/friend";
|
import { FriendListParam, FriendRecommendParams, BlackListParam, FriendValueListParam, HeroDetailParam } from "../../../domain/roleField/friend";
|
||||||
import { FriendShipModel, FriendShipType } from "../../../db/FriendShip";
|
import { FriendShipModel, FriendShipType } from "../../../db/FriendShip";
|
||||||
import { FriendRelationModel, Relation } from "../../../db/FriendRelation";
|
import { FriendRelationModel, Relation } from "../../../db/FriendRelation";
|
||||||
import { isRoleOnline, getServerName, getRoleOnlineInfo } from "../../../services/redisService";
|
import { isRoleOnline, getServerName, getRoleOnlineInfo } from "../../../services/redisService";
|
||||||
@@ -24,6 +24,7 @@ import { createPrivateMsg, pushMsgToRole, pushPresent } from "../../../services/
|
|||||||
import { Rank } from "../../../services/rankService";
|
import { Rank } from "../../../services/rankService";
|
||||||
import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../services/taskService";
|
import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../services/taskService";
|
||||||
import { ComBattleTeamModel } from "../../../db/ComBattleTeam";
|
import { ComBattleTeamModel } from "../../../db/ComBattleTeam";
|
||||||
|
import { JewelModel } from "../../../db/Jewel";
|
||||||
|
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
@@ -730,24 +731,17 @@ export class FriendHandler {
|
|||||||
let heroList = await HeroModel.findByHidRange(hids, hisRoleId, HERO_SELECT.HERO_DETAIL, true);
|
let heroList = await HeroModel.findByHidRange(hids, hisRoleId, HERO_SELECT.HERO_DETAIL, true);
|
||||||
if (heroList.length <= 0) return resResult(STATUS.HERO_NOT_FIND);
|
if (heroList.length <= 0) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
|
|
||||||
let list = new Array();
|
let jewels = await JewelModel.findMapbyRoleAndHids(hisRoleId, hids);
|
||||||
// for (let { roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId, attr: heroAttrs, ePlace } of heroList) {
|
console.log(jewels);
|
||||||
|
|
||||||
// let equips = await EquipModel.findListByHidAndRole(hisRoleId, hid, EQUIP_SELECT.HERO_DETAIL);
|
|
||||||
|
|
||||||
// let attributes = getPlayerMainAttribute(heroAttrs, role.attr);
|
|
||||||
|
|
||||||
// list.push({
|
|
||||||
// roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId,
|
|
||||||
// equips: equips.map(cur => {
|
|
||||||
// let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id) || new EPlace();
|
|
||||||
// let { lv = 0, refineLv = 0 } = curEplace;
|
|
||||||
// return { ...cur, lv, refineLv }
|
|
||||||
// }), attributes
|
|
||||||
// });
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
let list: HeroDetailParam[] = [];
|
||||||
|
for (let hero of heroList) {
|
||||||
|
let attributes = getPlayerMainAttribute(hero.attr, role.attr);
|
||||||
|
let heroParam = new HeroDetailParam(hero);
|
||||||
|
heroParam.setAttributes(attributes);
|
||||||
|
heroParam.setJewels(jewels);
|
||||||
|
list.push(heroParam);
|
||||||
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { list });
|
return resResult(STATUS.SUCCESS, { list });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], rol
|
|||||||
export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) {
|
export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) {
|
||||||
let newAttribute = new AttributeCal();
|
let newAttribute = new AttributeCal();
|
||||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||||
let mainAttributes = newAttribute.getReduceAttributes();
|
let mainAttributes = newAttribute.getReduceMainAttributes();
|
||||||
return mainAttributes;
|
return mainAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,20 @@ export default class Jewel extends BaseModel {
|
|||||||
return jewels;
|
return jewels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async findbyRoleAndHids(roleId: string, hids: number[]) {
|
||||||
|
const jewels: JewelType[] = await JewelModel.find({ roleId, hid: { $in: hids } }).lean();
|
||||||
|
return jewels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async findMapbyRoleAndHids(roleId: string, hids: number[]) {
|
||||||
|
const jewels = await JewelModel.findbyRoleAndHids(roleId, hids);
|
||||||
|
let map = new Map<number, JewelType>();
|
||||||
|
for(let jewel of jewels) {
|
||||||
|
map.set(jewel.seqId, jewel);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public static async findbySeqId(seqId: number, select?: string ) {
|
public static async findbySeqId(seqId: number, select?: string ) {
|
||||||
const jewel: JewelType = await JewelModel.findOne({ seqId }).select(select).lean();
|
const jewel: JewelType = await JewelModel.findOne({ seqId }).select(select).lean();
|
||||||
return jewel;
|
return jewel;
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { RoleType } from "../../db/Role";
|
|||||||
import { FriendShipType } from "../../db/FriendShip";
|
import { FriendShipType } from "../../db/FriendShip";
|
||||||
import * as friendUtil from '../../pubUtils/friendUtil'
|
import * as friendUtil from '../../pubUtils/friendUtil'
|
||||||
import { FRIEND_RELATION_TYPE } from "../../consts";
|
import { FRIEND_RELATION_TYPE } from "../../consts";
|
||||||
|
import { EPlace, HeroType, Stone } from "../../db/Hero";
|
||||||
|
import { JewelType, RandSe } from "../../db/Jewel";
|
||||||
|
import { reduceCe } from "../../pubUtils/util";
|
||||||
|
|
||||||
export class FriendParams {
|
export class FriendParams {
|
||||||
roleId: string;
|
roleId: string;
|
||||||
@@ -119,3 +122,101 @@ export class BlackListParam extends FriendParams {
|
|||||||
this.isOnline = isOnline;
|
this.isOnline = isOnline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class HeroDetailJewelRandSeParam {
|
||||||
|
id: number;
|
||||||
|
seid: number;
|
||||||
|
rand: number;
|
||||||
|
|
||||||
|
constructor(randSe: RandSe) {
|
||||||
|
this.id = randSe.id;
|
||||||
|
this.seid = randSe.seid;
|
||||||
|
this.rand = randSe.rand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HeroDetailJewelParam {
|
||||||
|
seqId: number;
|
||||||
|
id: number;
|
||||||
|
randSe: HeroDetailJewelRandSeParam[] = [];
|
||||||
|
|
||||||
|
constructor(jewel: JewelType) {
|
||||||
|
this.seqId = jewel.seqId;
|
||||||
|
this.id = jewel.id;
|
||||||
|
for(let randSe of jewel.randSe) {
|
||||||
|
this.randSe.push(new HeroDetailJewelRandSeParam(randSe));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HeroDetailEplaceParam {
|
||||||
|
id: number;
|
||||||
|
equipId: number;
|
||||||
|
lv: number;
|
||||||
|
quality: number;
|
||||||
|
star: number;
|
||||||
|
stone: Stone[];
|
||||||
|
jewelId: number;
|
||||||
|
jewel: HeroDetailJewelParam = null;
|
||||||
|
|
||||||
|
constructor(equip: EPlace) {
|
||||||
|
this.id = equip.id;
|
||||||
|
this.equipId = equip.equipId;
|
||||||
|
this.lv = equip.lv;
|
||||||
|
this.quality = equip.quality;
|
||||||
|
this.star = equip.star;
|
||||||
|
this.stone = equip.stones;
|
||||||
|
this.jewelId = equip.jewel;
|
||||||
|
}
|
||||||
|
|
||||||
|
setJewel(jewel: JewelType) {
|
||||||
|
this.jewel = new HeroDetailJewelParam(jewel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HeroDetailParam {
|
||||||
|
roleId: string;
|
||||||
|
hid: number;
|
||||||
|
ce: number;
|
||||||
|
lv: number;
|
||||||
|
star: number;
|
||||||
|
colorStar: number;
|
||||||
|
quality: number;
|
||||||
|
job: number;
|
||||||
|
skinId: number;
|
||||||
|
ePlace: HeroDetailEplaceParam[] = [];
|
||||||
|
attributes: {
|
||||||
|
hp: number;
|
||||||
|
atk: number;
|
||||||
|
def: number;
|
||||||
|
mdef: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(hero: HeroType) {
|
||||||
|
this.roleId = hero.roleId;
|
||||||
|
this.hid = hero.hid;
|
||||||
|
this.ce = reduceCe(hero.ce);
|
||||||
|
this.lv = hero.lv;
|
||||||
|
this.star = hero.star;
|
||||||
|
this.colorStar = hero.colorStar;
|
||||||
|
this.quality = hero.quality;
|
||||||
|
this.job = hero.job;
|
||||||
|
this.skinId = hero.skinId;
|
||||||
|
for(let equip of hero.ePlace) {
|
||||||
|
this.ePlace.push(new HeroDetailEplaceParam(equip));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setAttributes(attributes: {hp: number, atk: number, def: number, mdef: number}) {
|
||||||
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
setJewels(jewels: Map<number, JewelType>) {
|
||||||
|
for(let eplaceParam of this.ePlace) {
|
||||||
|
if(jewels.has(eplaceParam.jewelId)) {
|
||||||
|
eplaceParam.setJewel(jewels.get(eplaceParam.jewelId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -736,7 +736,7 @@ export function calEquipPutOnOrOffJewelIncAttr(hero: HeroType, update: HeroUpdat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setRandSeToSeidList(jewel: JewelType, equip: EPlace, list: number[]) {
|
function setRandSeToSeidList(jewel: JewelType, equip: EPlace, list: number[]) {
|
||||||
if(equip && equip.jewel) {
|
if(equip && jewel) {
|
||||||
for(let { id, seid, rand } of jewel.randSe) {
|
for(let { id, seid, rand } of jewel.randSe) {
|
||||||
if(isRandSeUnLock(jewel.id, id, equip.stones)) {
|
if(isRandSeUnLock(jewel.id, id, equip.stones)) {
|
||||||
list.push(seid, rand);
|
list.push(seid, rand);
|
||||||
|
|||||||
Reference in New Issue
Block a user