✨ feat(诸子列传): 查询其他好友数据

This commit is contained in:
luying
2023-07-13 16:23:29 +08:00
parent 1eb6f76cce
commit b6cd9e6784
5 changed files with 17 additions and 20 deletions
@@ -1,19 +1,13 @@
import { Application, BackendSession, HandlerService, } from "pinus"; import { Application, BackendSession, HandlerService, } from "pinus";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE } from "../../../consts"; import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
import { ArtifactModel, ArtifactModelType, ArtifactModelUpdate } from "../../../db/Artifact"; import { gameData, getDicAuthorBookSub } from "../../../pubUtils/data";
import { HeroModel } from "../../../db/Hero"; import { RewardInter } from "../../../pubUtils/interface";
import { ArtifactParam } from "../../../domain/roleField/hero";
import { gameData, getArtifactByGidAndType, getArtifactStageZero, getArtifactWithQuality, getDicArtifactLvByPlanId, getDicAuthorBookSub, getNextArtifact } from "../../../pubUtils/data";
import { ARTIFACT, BAG } from "../../../pubUtils/dicParam";
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr, arrToMap, genCode } from "../../../pubUtils/util"; import { resResult } from "../../../pubUtils/util";
import { checkArtifactCanCompose, getRebuildConsume, hasArtifactStrength } from "../../../services/equipService"; import { calculateCeWithRole } from "../../../services/playerCeService";
import { calculateCeWithHero, calculateCeWithRole } from "../../../services/playerCeService";
import { CheckMeterial } from "../../../services/role/checkMaterial"; import { CheckMeterial } from "../../../services/role/checkMaterial";
import { addItems, handleCost } from "../../../services/role/rewardService"; import { addItems, handleCost } from "../../../services/role/rewardService";
import { combineItems } from "../../../services/role/util"; import { combineItems } from "../../../services/role/util";
import { checkTask } from "../../../services/task/taskService";
import { AuthorBookModel } from "../../../db/AuthorBook"; import { AuthorBookModel } from "../../../db/AuthorBook";
import { checkAuthorBookLimit, replaceAuthorBooks } from "../../../services/roleService"; import { checkAuthorBookLimit, replaceAuthorBooks } from "../../../services/roleService";
@@ -47,12 +41,10 @@ export class AuthorsBookHandler {
// 英灵是否够 // 英灵是否够
let check = new CheckMeterial(roleId); let check = new CheckMeterial(roleId);
let isEnough = await check.decreaseItemsContinue(dicAuthorsBookSub.spirits); let isEnough = await check.decreaseItemsContinue(dicAuthorsBookSub.spirits);
console.log('@@@@@@@@@@ isEnough', isEnough, dicAuthorsBookSub.spirits)
let useItemCnt = 0; let useItemCnt = 0;
if(useItem) { // 使用英灵石代替 if(useItem) { // 使用英灵石代替
if(!isEnough) { if(!isEnough) {
let notEnoughItems = check.getNotEnoughItems(); let notEnoughItems = check.getNotEnoughItems();
console.log('@@@@@@@@ getNotEnoughItems', notEnoughItems)
let replaceItems: RewardInter[] = []; let replaceItems: RewardInter[] = [];
for(let [ id, count ] of notEnoughItems) { for(let [ id, count ] of notEnoughItems) {
let dicSpirit = gameData.spirit.get(id); let dicSpirit = gameData.spirit.get(id);
@@ -30,6 +30,7 @@ import { CalCe } from "../../../services/role/calCe";
import { getSchoolPoint } from "../../../services/roleService"; import { getSchoolPoint } from "../../../services/roleService";
import { LadderMatchModel } from "../../../db/LadderMatch"; import { LadderMatchModel } from "../../../db/LadderMatch";
import { ArtifactModel } from "../../../db/Artifact"; import { ArtifactModel } from "../../../db/Artifact";
import { AuthorBookModel } from "../../../db/AuthorBook";
export default function (app: Application) { export default function (app: Application) {
@@ -745,6 +746,8 @@ export class FriendHandler {
let school = await getSchoolPoint(hisRoleId); let school = await getSchoolPoint(hisRoleId);
let authorBooks = await AuthorBookModel.findByRoleId(hisRoleId, '-_id bookId progress');
let myRoleCe = await RoleCeModel.findByRoleId(roleId); let myRoleCe = await RoleCeModel.findByRoleId(roleId);
if (!myRoleCe) return resResult(STATUS.ROLE_NOT_FOUND); if (!myRoleCe) return resResult(STATUS.ROLE_NOT_FOUND);
let mycalCe = new CalCe(roleId); let mycalCe = new CalCe(roleId);
@@ -776,6 +779,7 @@ export class FriendHandler {
mycalCe.calSingleGlobalPartCe(hero.hid, 'scroll'), mycalCe.calSingleGlobalPartCe(hero.hid, 'scroll'),
mycalCe.calSingleGlobalPartCe(hero.hid, 'teraph') mycalCe.calSingleGlobalPartCe(hero.hid, 'teraph')
) )
heroParam.setAuthorBook(authorBooks);
list.push(heroParam); list.push(heroParam);
} }
@@ -49,9 +49,7 @@ export class CheckMeterial {
this.notEnoughItems.clear(); this.notEnoughItems.clear();
let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST); let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
for(let { id, count} of items) { for(let { id, count} of items) {
console.log('#####', id, count)
let notEnoughCount = await this.decreaseItem(id, count); let notEnoughCount = await this.decreaseItem(id, count);
console.log('##### notEnoughCount', id, notEnoughCount, this.canReplace)
if(notEnoughCount > 0) { if(notEnoughCount > 0) {
let isEnough = await this.checkReplaceItem(id, notEnoughCount); let isEnough = await this.checkReplaceItem(id, notEnoughCount);
if(isEnough) { if(isEnough) {
@@ -100,10 +98,8 @@ export class CheckMeterial {
} }
private async decreaseItem(id: number, count: number) { private async decreaseItem(id: number, count: number) {
console.log('#### decreaseItem 1', id, count);
if(!this.itemsIndb.has(id)) { if(!this.itemsIndb.has(id)) {
let item = await ItemModel.findbyRoleAndGid(this.roleId, id); let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
console.log('#### decreaseItem', item);
if(!item) { if(!item) {
this.pushToNotEnoughItems(id, count); this.pushToNotEnoughItems(id, count);
return count; return count;
+3 -3
View File
@@ -1,5 +1,5 @@
import BaseModel from './BaseModel'; import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
/** /**
* 诸子百家 * 诸子百家
@@ -28,8 +28,8 @@ export default class AuthorBook extends BaseModel {
@prop({ required: true, default: [], type: Author, _id: false }) @prop({ required: true, default: [], type: Author, _id: false })
authors: Author[]; authors: Author[];
public static async findByRoleId(roleId: string) { public static async findByRoleId(roleId: string, select = '-_id') {
let result: AuthorBookType[] = await AuthorBookModel.find({ roleId }).select('-_id -roleId').lean(); let result: AuthorBookType[] = await AuthorBookModel.find({ roleId }).select(select).lean();
return result; return result;
} }
+5
View File
@@ -216,6 +216,7 @@ export class HeroDetailParam {
scroll: number; scroll: number;
teraph: number; teraph: number;
} }
authorBooks: { bookId: number, progress: number }[] = [];
constructor(hero: HeroType) { constructor(hero: HeroType) {
this.roleId = hero.roleId; this.roleId = hero.roleId;
@@ -263,4 +264,8 @@ export class HeroDetailParam {
setArtifact(artifact: ArtifactModelType) { setArtifact(artifact: ArtifactModelType) {
this.artifacts.push({ artifactId: artifact.artifactId, lv: artifact.lv }); this.artifacts.push({ artifactId: artifact.artifactId, lv: artifact.lv });
} }
setAuthorBook(authorBooks: { bookId: number, progress: number }[]) {
this.authorBooks = authorBooks;
}
} }