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

This commit is contained in:
luying
2023-07-12 20:25:45 +08:00
parent 1eb6f76cce
commit b6cd9e6784
5 changed files with 17 additions and 20 deletions

View File

@@ -1,19 +1,13 @@
import { Application, BackendSession, HandlerService, } from "pinus";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE } from "../../../consts";
import { ArtifactModel, ArtifactModelType, ArtifactModelUpdate } from "../../../db/Artifact";
import { HeroModel } from "../../../db/Hero";
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 { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
import { gameData, getDicAuthorBookSub } from "../../../pubUtils/data";
import { RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr, arrToMap, genCode } from "../../../pubUtils/util";
import { checkArtifactCanCompose, getRebuildConsume, hasArtifactStrength } from "../../../services/equipService";
import { calculateCeWithHero, calculateCeWithRole } from "../../../services/playerCeService";
import { resResult } from "../../../pubUtils/util";
import { calculateCeWithRole } from "../../../services/playerCeService";
import { CheckMeterial } from "../../../services/role/checkMaterial";
import { addItems, handleCost } from "../../../services/role/rewardService";
import { combineItems } from "../../../services/role/util";
import { checkTask } from "../../../services/task/taskService";
import { AuthorBookModel } from "../../../db/AuthorBook";
import { checkAuthorBookLimit, replaceAuthorBooks } from "../../../services/roleService";
@@ -47,12 +41,10 @@ export class AuthorsBookHandler {
// 英灵是否够
let check = new CheckMeterial(roleId);
let isEnough = await check.decreaseItemsContinue(dicAuthorsBookSub.spirits);
console.log('@@@@@@@@@@ isEnough', isEnough, dicAuthorsBookSub.spirits)
let useItemCnt = 0;
if(useItem) { // 使用英灵石代替
if(!isEnough) {
let notEnoughItems = check.getNotEnoughItems();
console.log('@@@@@@@@ getNotEnoughItems', notEnoughItems)
let replaceItems: RewardInter[] = [];
for(let [ id, count ] of notEnoughItems) {
let dicSpirit = gameData.spirit.get(id);

View File

@@ -30,6 +30,7 @@ import { CalCe } from "../../../services/role/calCe";
import { getSchoolPoint } from "../../../services/roleService";
import { LadderMatchModel } from "../../../db/LadderMatch";
import { ArtifactModel } from "../../../db/Artifact";
import { AuthorBookModel } from "../../../db/AuthorBook";
export default function (app: Application) {
@@ -745,6 +746,8 @@ export class FriendHandler {
let school = await getSchoolPoint(hisRoleId);
let authorBooks = await AuthorBookModel.findByRoleId(hisRoleId, '-_id bookId progress');
let myRoleCe = await RoleCeModel.findByRoleId(roleId);
if (!myRoleCe) return resResult(STATUS.ROLE_NOT_FOUND);
let mycalCe = new CalCe(roleId);
@@ -776,6 +779,7 @@ export class FriendHandler {
mycalCe.calSingleGlobalPartCe(hero.hid, 'scroll'),
mycalCe.calSingleGlobalPartCe(hero.hid, 'teraph')
)
heroParam.setAuthorBook(authorBooks);
list.push(heroParam);
}

View File

@@ -49,9 +49,7 @@ export class CheckMeterial {
this.notEnoughItems.clear();
let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
for(let { id, count} of items) {
console.log('#####', id, count)
let notEnoughCount = await this.decreaseItem(id, count);
console.log('##### notEnoughCount', id, notEnoughCount, this.canReplace)
if(notEnoughCount > 0) {
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
if(isEnough) {
@@ -100,10 +98,8 @@ export class CheckMeterial {
}
private async decreaseItem(id: number, count: number) {
console.log('#### decreaseItem 1', id, count);
if(!this.itemsIndb.has(id)) {
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
console.log('#### decreaseItem', item);
if(!item) {
this.pushToNotEnoughItems(id, count);
return count;

View File

@@ -1,5 +1,5 @@
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 })
authors: Author[];
public static async findByRoleId(roleId: string) {
let result: AuthorBookType[] = await AuthorBookModel.find({ roleId }).select('-_id -roleId').lean();
public static async findByRoleId(roleId: string, select = '-_id') {
let result: AuthorBookType[] = await AuthorBookModel.find({ roleId }).select(select).lean();
return result;
}

View File

@@ -216,6 +216,7 @@ export class HeroDetailParam {
scroll: number;
teraph: number;
}
authorBooks: { bookId: number, progress: number }[] = [];
constructor(hero: HeroType) {
this.roleId = hero.roleId;
@@ -263,4 +264,8 @@ export class HeroDetailParam {
setArtifact(artifact: ArtifactModelType) {
this.artifacts.push({ artifactId: artifact.artifactId, lv: artifact.lv });
}
setAuthorBook(authorBooks: { bookId: number, progress: number }[]) {
this.authorBooks = authorBooks;
}
}