✨ feat(诸子列传): 添加功能
This commit is contained in:
179
game-server/app/servers/role/handler/authorBookHandler.ts
Normal file
179
game-server/app/servers/role/handler/authorBookHandler.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
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 { resResult, parseGoodStr, arrToMap, genCode } from "../../../pubUtils/util";
|
||||
import { checkArtifactCanCompose, getRebuildConsume, hasArtifactStrength } from "../../../services/equipService";
|
||||
import { calculateCeWithHero, 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";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new AuthorsBookHandler(app);
|
||||
}
|
||||
|
||||
export class AuthorsBookHandler {
|
||||
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
public async starUp(msg: { bookId: number, subId: number, star: number, useItem: boolean }, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
const sid: string = session.get('sid');
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = session.get('serverId');
|
||||
|
||||
const { bookId, subId, star, useItem } = msg;
|
||||
let allAuthorBooks = await AuthorBookModel.findByRoleId(roleId);
|
||||
let authorBookData = allAuthorBooks.find(authorBook => authorBook.bookId == bookId);
|
||||
let starInData = authorBookData?.authors?.find(cur => cur.subId == subId)?.star??0;
|
||||
if(star != starInData) return resResult(STATUS.ACCESS_BUSY);
|
||||
|
||||
let dicAuthorsBookSub = getDicAuthorBookSub(bookId, subId, star + 1);
|
||||
if(!dicAuthorsBookSub) return resResult(STATUS.AUTHOR_BOOK_SUB_MAX);
|
||||
|
||||
// 是否解锁(进度解锁)
|
||||
if(!checkAuthorBookLimit(allAuthorBooks, bookId)) return resResult(STATUS.AUTHOR_BOOK_LOCK);
|
||||
// 英灵是否够
|
||||
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);
|
||||
if(!dicSpirit) return resResult(STATUS.DIC_DATA_NOT_FOUND); // 应该是表填错,正常情况不可能出现
|
||||
|
||||
for(let item of dicSpirit.composeItem) {
|
||||
replaceItems.push({ id: item.id, count: item.count * count });
|
||||
useItemCnt += item.count * count;
|
||||
}
|
||||
}
|
||||
isEnough = await check.decreaseItemsContinue(replaceItems);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isEnough) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.AUTHOR_BOOK_STAR_UP);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
// 升星
|
||||
authorBookData = await AuthorBookModel.upStar(roleId, bookId, subId, star, dicAuthorsBookSub.value, gameData.authorBookSubs.get(bookId)||[]);
|
||||
if(!authorBookData) {
|
||||
// 防并发问题
|
||||
await addItems(roleId, roleName, sid, consumes, ITEM_CHANGE_REASON.AUTHOR_BOOK_STAR_RETURN);
|
||||
return resResult(STATUS.ACCESS_BUSY);
|
||||
}
|
||||
// 计算战力更新
|
||||
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.AUTHOR_BOOK_STAR, roleId, serverId, sid, {}, { authorBooks: replaceAuthorBooks(allAuthorBooks, authorBookData), bookId, subId });
|
||||
|
||||
let curAuthorBook = authorBookData.authors?.find(cur => cur.subId == subId);
|
||||
let maxProgress = gameData.authorBookMaxProgress.get(bookId)??0;
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
bookId,
|
||||
subId,
|
||||
star: curAuthorBook?.star??0,
|
||||
progress: authorBookData.progress,
|
||||
maxProgress,
|
||||
useItemCnt
|
||||
});
|
||||
}
|
||||
|
||||
// 重置条目
|
||||
public async resetAuthor(msg: { bookId: number, subId: number, star: number }, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
const sid: string = session.get('sid');
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = session.get('serverId');
|
||||
|
||||
const { bookId, subId, star } = msg;
|
||||
let allAuthorBooks = await AuthorBookModel.findByRoleId(roleId);
|
||||
let authorBookData = allAuthorBooks.find(authorBook => authorBook.bookId == bookId);
|
||||
if(!authorBookData) return resResult(STATUS.ACCESS_BUSY)
|
||||
let starInData = authorBookData?.authors?.find(cur => cur.subId == subId)?.star??0;
|
||||
if(star != starInData) return resResult(STATUS.ACCESS_BUSY);
|
||||
|
||||
let progress = 0, spirits: RewardInter[] = [];
|
||||
for(let i = 1; i <= star; i++) {
|
||||
let dicAuthorsBookSub = getDicAuthorBookSub(bookId, subId, i);
|
||||
if(!dicAuthorsBookSub) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
progress += dicAuthorsBookSub.value;
|
||||
spirits.push(...dicAuthorsBookSub.spirits);
|
||||
}
|
||||
// 重置诸子列传
|
||||
authorBookData = await AuthorBookModel.resetSub(roleId, bookId, subId, star, -progress);
|
||||
if(!authorBookData) return resResult(STATUS.ACCESS_BUSY);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, combineItems(spirits), ITEM_CHANGE_REASON.AUTHOR_BOOK_SUB_RESET);
|
||||
|
||||
// 计算战力更新
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.AUTHOR_BOOK_SUB_RESET, roleId, serverId, sid, {}, { authorBooks: replaceAuthorBooks(allAuthorBooks, authorBookData), bookId, subId });
|
||||
|
||||
let curAuthorBook = authorBookData.authors?.find(cur => cur.subId == subId);
|
||||
let maxProgress = gameData.authorBookMaxProgress.get(bookId)??0;
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
bookId,
|
||||
subId,
|
||||
star: curAuthorBook?.star??0,
|
||||
progress: authorBookData.progress,
|
||||
maxProgress,
|
||||
goods
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 买英灵
|
||||
public async buySpirit(msg: { id: number, count: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let roleName: string = session.get('roleName');
|
||||
|
||||
const { id, count } = msg;
|
||||
let dicSpirit = gameData.spirit.get(id);
|
||||
if(!dicSpirit) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let consumes = dicSpirit.composeItem.map(cur => ({ id: cur.id, count: cur.count * count }));
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.BUY_SPIRIT);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let reward = [{ id, count }];
|
||||
let goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BUY_SPIRIT);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
|
||||
public async decomposeSpirit(msg: { id: number, count: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let roleName: string = session.get('roleName');
|
||||
|
||||
const { id, count } = msg;
|
||||
let dicSpirit = gameData.spirit.get(id);
|
||||
if(!dicSpirit) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let consumes = [{ id, count }];
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.DECOMPOSE_SPIRIT);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let reward = dicSpirit.decomposeItem;
|
||||
let goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.DECOMPOSE_SPIRIT);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
}
|
||||
@@ -2012,6 +2012,23 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
if(!isBoolean(msg.hasComment)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.authorsBookHandler.starUp":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.bookId, msg.subId, msg.star)) return false;
|
||||
if(!isBoolean(msg.useItem)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.authorsBookHandler.resetAuthor":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.bookId, msg.subId, msg.star)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.authorsBookHandler.buySpirit":
|
||||
case "role.authorsBookHandler.decomposeSpirit":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.id, msg.count)) return false;
|
||||
break;
|
||||
}
|
||||
case 'activity.dragonBoatHandler.gameStart':
|
||||
case 'activity.dragonBoatHandler.gameEnd':
|
||||
{
|
||||
|
||||
@@ -52,6 +52,8 @@ import { ArtifactModel } from '../db/Artifact';
|
||||
import { ActivityItemModel } from '../db/ActivityItem';
|
||||
import { LinkModel } from '../db/Link';
|
||||
import { getHiddenData } from './memoryCache/hiddenData';
|
||||
import { AuthorBookModel } from '../db/AuthorBook';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
|
||||
/**
|
||||
* init: 初始的时候是否推送 true-推 false-不推
|
||||
@@ -128,7 +130,6 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
let artifacts = await ArtifactModel.findbyRole(role.roleId, ARTIFACT_SELECT.ENTRY);
|
||||
let activityItems = await ActivityItemModel.findbyRole(role.roleId, ACTIVITYITEM_SELECT.ENTRY);
|
||||
let link = await LinkModel.findByType(SNS_LINK_TYPE.CUSTOMER);
|
||||
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
role['jewels'] = jewels;
|
||||
role['consumeGoods'] = items;
|
||||
@@ -138,6 +139,7 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
role['ipLocation'] = role.fixedIpLocation||role.ipLocation||'未知';
|
||||
role['artifacts'] = artifacts;
|
||||
role['activityItems'] = activityItems;
|
||||
role['authorBook'] = await getAuthorBook(role.roleId);
|
||||
|
||||
if (!role.showLineup) role.showLineup = role.topLineup.map(cur => cur.hid);
|
||||
role.heads = role.heads.filter(cur => cur.status);
|
||||
@@ -432,4 +434,13 @@ export async function leaveServer(session: FrontendOrBackendSession) {
|
||||
|
||||
incServerNum(sid, -1);
|
||||
incConnectorNum(sid, -1);
|
||||
}
|
||||
|
||||
async function getAuthorBook(roleId: string) {
|
||||
let authorBooks = await AuthorBookModel.findByRoleId(roleId);
|
||||
return authorBooks.map(authorBook => {
|
||||
let maxProgress = gameData.authorBookMaxProgress.get(authorBook.bookId);
|
||||
let { bookId, authors, progress } = authorBook;
|
||||
return { bookId, authors, progress, maxProgress: maxProgress??0 }
|
||||
})
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import { SkinType } from '../db/Skin';
|
||||
import { LadderMatchModel } from '../db/LadderMatch';
|
||||
import { ArtifactModelType } from '../db/Artifact';
|
||||
import { GVGVestigeRankModel } from '../db/GVGVestigeRank';
|
||||
import { AuthorBookType } from '../db/AuthorBook';
|
||||
|
||||
interface Param {
|
||||
isInitRole?: boolean,
|
||||
@@ -49,6 +50,9 @@ interface Param {
|
||||
artifact?: ArtifactModelType,
|
||||
artifacts?: ArtifactModelType[],
|
||||
job?: number,
|
||||
authorBooks?: AuthorBookType[],
|
||||
bookId?: number,
|
||||
subId?: number,
|
||||
}
|
||||
|
||||
export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, hid: number, heroUpdate: HeroUpdate, param: Param = {}) {
|
||||
@@ -427,6 +431,14 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HERO_SYSTEM_TYPE.AUTHOR_BOOK_STAR: // 40. 诸子百家升星
|
||||
{
|
||||
let { authorBooks = [], bookId, subId } = param;
|
||||
calCe.setAuthorBooks(authorBooks);
|
||||
ceChangeTxt.push(`诸子列传 ${bookId} 的 ${subId} 重置星级`);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力
|
||||
let changeHids: number[] = [];
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE, ABI_TYPE_MAIN, LINEUP_NUM, SEID_TYPE, TALENT_RELATION_TYPE } from "../../consts";
|
||||
import { ArtifactModelType } from "../../db/Artifact";
|
||||
import { AuthorBookType } from "../../db/AuthorBook";
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Stone, Talent } from "../../db/Hero";
|
||||
import { JewelType } from "../../db/Jewel";
|
||||
import { RoleUpdate, Teraph } from "../../db/Role";
|
||||
import { AttrCell, Attribute, EquipAttr, HeroAttr, RoleCeType, SchoolAttr, ScrollAttr } from "../../db/RoleCe";
|
||||
import { TopHero } from "../../domain/dbGeneral";
|
||||
import { AttributeCal } from "../../domain/roleField/attribute";
|
||||
import { gameData, getDicArtifactLvByPlanId, getEquipQualityIdByEquipIdAndPoint, getEquipStarAttrByStage, getEquipStrenthenAttr, getEquipSuitByHero, getFriendShipByIdAndLv, getHeroStarByQuality, getHeroWakeByQuality, getJewelConditionByLvAndSeId, getJobByGradeAndClass, getSchoolRateByStar, getScollByStar, getTeraph } from "../../pubUtils/data";
|
||||
import { gameData, getDicArtifactLvByPlanId, getDicAuthorBookSub, getEquipQualityIdByEquipIdAndPoint, getEquipStarAttrByStage, getEquipStrenthenAttr, getEquipSuitByHero, getFriendShipByIdAndLv, getHeroStarByQuality, getHeroWakeByQuality, getJewelConditionByLvAndSeId, getJobByGradeAndClass, getSchoolRateByStar, getScollByStar, getTeraph } from "../../pubUtils/data";
|
||||
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
|
||||
import { DicSe } from "../../pubUtils/dictionary/DicSe";
|
||||
import { addToMap, deepCopy } from "../../pubUtils/util";
|
||||
@@ -47,20 +48,20 @@ export class CalCe {
|
||||
for(let attrId = ABI_TYPE.ABI_HP; attrId < ABI_TYPE.ABI_MAX; attrId++) {
|
||||
if(!this.data.heroAttrs.has(`${hid}_${attrId}`) && !this.data.globalAttrs.has(attrId)) continue;
|
||||
let { mainBase = 0, mainBaseUp = 0, subBase = 0, job = 0, starUp = 0, connect = 0, talent = 0, equipQuality = 0, equipStrength = 0, equipStar = 0, equipSuit = 0, jewel = 0, stone = 0, artifactLv = 0, artifactQuality = 0, artifactSeid = 0, jewelBase = 0 } = this.data.heroAttrs.get(`${hid}_${attrId}`)||{};
|
||||
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.data.getGlobalAttrById(attrId)||{};
|
||||
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0, authorBook = 0 } = this.data.getGlobalAttrById(attrId)||{};
|
||||
let val = 0, ceVal = 0, str = '', ceStr = '';
|
||||
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
||||
// {[ hp1 + lv * hp2 ] * ( 1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )]} * ( 1 + hp9 ) + hp10 + hp11 + hp14
|
||||
val = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality + jewelBase;
|
||||
ceVal = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality + jewelBase;
|
||||
str += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}+${jewelBase}`;
|
||||
ceStr += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}+${jewelBase}`;
|
||||
val = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality + jewelBase + authorBook;
|
||||
ceVal = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality + jewelBase + authorBook;
|
||||
str += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}+${jewelBase}+${authorBook}`;
|
||||
ceStr += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}+${jewelBase}+${authorBook}`;
|
||||
} else {
|
||||
// attr1 + attr2 + attr4 + attr5 + attr6 + attr7 + attr9
|
||||
val = subBase + job + teraph + school + title + jewel + equipStar;
|
||||
ceVal = job + teraph + school + title + jewel + equipStar;
|
||||
str += `${subBase}+${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}`;
|
||||
ceStr += `${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}`;
|
||||
// attr1 + attr2 + attr4 + attr5 + attr6 + attr7 + attr9 + attr10
|
||||
val = subBase + job + teraph + school + title + jewel + equipStar + authorBook;
|
||||
ceVal = job + teraph + school + title + jewel + equipStar + authorBook;
|
||||
str += `${subBase}+${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}+${authorBook}`;
|
||||
ceStr += `${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}+${authorBook}`;
|
||||
}
|
||||
if(!attrs.has(hid)) attrs.set(hid, []);
|
||||
attrs.get(hid).push({ id: attrId, val, ceVal, str, ceStr });
|
||||
@@ -566,6 +567,34 @@ export class CalCe {
|
||||
}
|
||||
}
|
||||
|
||||
// 诸子列传属性
|
||||
public setAuthorBooks(authorBooks: AuthorBookType[]) {
|
||||
|
||||
this.data.clearRoleAttr('authorBook');
|
||||
let attrResult = new Map<number, number>();
|
||||
for(let { bookId, progress, authors } of authorBooks) {
|
||||
// 升星的属性
|
||||
for(let { subId, star } of authors) {
|
||||
let dicAuthorBook = getDicAuthorBookSub(bookId, subId, star);
|
||||
if(dicAuthorBook) {
|
||||
for(let {id, val} of dicAuthorBook.attr) addToMap(attrResult, id, val);
|
||||
}
|
||||
}
|
||||
|
||||
let dicPoints = gameData.authorBookPoint.get(bookId)||[];
|
||||
for(let { value, attr } of dicPoints) {
|
||||
if(progress > value) {
|
||||
for(let { id, val } of attr) addToMap(attrResult, id, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let [attrId, value] of attrResult) {
|
||||
let globalAttr = this.data.getGlobalAttrById(attrId);
|
||||
globalAttr.authorBook = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 宝物品质
|
||||
public setArtifactQuality(hid: number, artifactId: number) {
|
||||
this.data.clearHeroAttrByHid(hid, 'artifactQuality');
|
||||
@@ -969,6 +998,7 @@ abstract class GlobalAllAttr {
|
||||
title: number = 0;
|
||||
scroll: number = 0;
|
||||
skin: number = 0;
|
||||
authorBook: number = 0;
|
||||
|
||||
constructor(attrId: number) {
|
||||
this.attrId = attrId;
|
||||
@@ -1003,6 +1033,8 @@ class GlobalMainAttr extends GlobalAllAttr {
|
||||
this.scroll = value; break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
|
||||
this.skin = value; break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.AUTH_BOOK:
|
||||
this.authorBook = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1027,6 +1059,9 @@ class GlobalMainAttr extends GlobalAllAttr {
|
||||
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
|
||||
values.push(this.skin);
|
||||
break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.AUTH_BOOK:
|
||||
values.push(this.authorBook);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -1042,12 +1077,14 @@ class GlobalSubAttr extends GlobalAllAttr {
|
||||
switch(i) {
|
||||
case GLOBAL_SUB_ATTR_INDEX.SCHOOL:
|
||||
this.school = value; break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.TERAPH:
|
||||
case GLOBAL_SUB_ATTR_INDEX.TERAPH:
|
||||
this.teraph = value; break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.TITLE:
|
||||
case GLOBAL_SUB_ATTR_INDEX.TITLE:
|
||||
this.title = value; break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
|
||||
case GLOBAL_SUB_ATTR_INDEX.SKIN:
|
||||
this.skin = value; break;
|
||||
case GLOBAL_SUB_ATTR_INDEX.AUTH_BOOK:
|
||||
this.authorBook = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1055,20 +1092,23 @@ class GlobalSubAttr extends GlobalAllAttr {
|
||||
|
||||
public getValues() {
|
||||
let values: number[] = [];
|
||||
for(let i = GLOBAL_MAIN_ATTR_INDEX.START; i < GLOBAL_MAIN_ATTR_INDEX.END; i++) {
|
||||
for(let i = GLOBAL_SUB_ATTR_INDEX.START; i < GLOBAL_SUB_ATTR_INDEX.END; i++) {
|
||||
switch(i) {
|
||||
case GLOBAL_MAIN_ATTR_INDEX.SCHOOL:
|
||||
case GLOBAL_SUB_ATTR_INDEX.SCHOOL:
|
||||
values.push(this.school);
|
||||
break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.TERAPH:
|
||||
case GLOBAL_SUB_ATTR_INDEX.TERAPH:
|
||||
values.push(this.teraph);
|
||||
break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.TITLE:
|
||||
case GLOBAL_SUB_ATTR_INDEX.TITLE:
|
||||
values.push(this.title);
|
||||
break;
|
||||
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
|
||||
case GLOBAL_SUB_ATTR_INDEX.SKIN:
|
||||
values.push(this.skin);
|
||||
break;
|
||||
case GLOBAL_SUB_ATTR_INDEX.AUTH_BOOK:
|
||||
values.push(this.authorBook);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -1382,6 +1422,7 @@ enum GLOBAL_MAIN_ATTR_INDEX {
|
||||
TITLE = 2, // hp11, 爵位加成(dic_zyz_title的hp)
|
||||
SCROLL = 3, // hp11,名将谱加成(dic_zyz_heroScroll的hp)
|
||||
SKIN = 4, // hp12, 皮肤加成(dic_zyz_fashion的actorAttr)
|
||||
AUTH_BOOK = 5, // hp16,诸子列传
|
||||
END
|
||||
}
|
||||
|
||||
@@ -1391,6 +1432,7 @@ enum GLOBAL_SUB_ATTR_INDEX {
|
||||
TERAPH = 1, // attr4, 神像加成(dic_zyz_teraph中的assistAttrValue)
|
||||
TITLE = 2, // attr6, 爵位(dic_zyz_title中的pdi、mdi)
|
||||
SKIN = 3, // attr8, 皮肤
|
||||
AUTH_BOOK = 4, // attr10,诸子列传
|
||||
END
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export class CheckMeterial {
|
||||
this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count);
|
||||
}
|
||||
|
||||
private getNotEnoughItems() {
|
||||
public getNotEnoughItems() {
|
||||
let map = new Map<number, number>();
|
||||
for(let [ id, count ] of this.notEnoughItems) {
|
||||
map.set(id, count);
|
||||
@@ -74,6 +74,27 @@ export class CheckMeterial {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 当消耗不足的时候,不提前返回,也不去算元宝和铜币
|
||||
public async decreaseItemsContinue(goods: {id: number, count: number}[]) {
|
||||
this.tempConsumes.splice(0, this.tempConsumes.length);
|
||||
this.notEnoughItems.clear();
|
||||
let { items } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let itemIsEnough = true;
|
||||
for(let { id, count} of items) {
|
||||
let notEnoughCount = await this.decreaseItem(id, count);
|
||||
if(notEnoughCount > 0) {
|
||||
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
|
||||
if(isEnough) {
|
||||
this.tempConsumes.push({ id, count: count - notEnoughCount });
|
||||
} else {
|
||||
itemIsEnough = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.consumes.push(...this.tempConsumes);
|
||||
return itemIsEnough;
|
||||
}
|
||||
|
||||
public setCanReplace(canReplace: boolean) {
|
||||
this.canReplace = canReplace;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Channel, pinus } from 'pinus';
|
||||
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr, compareVersion } from '../pubUtils/util';
|
||||
import { DEFAULT_HEROES, LINEUP_NUM, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM, SYSTEM_OPEN_ID, GuideUnloadNum, CHECK_HERO_CONSUME, ABI_STAGE } from "../consts";
|
||||
import { DEFAULT_HEROES, LINEUP_NUM, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM, SYSTEM_OPEN_ID, GuideUnloadNum, CHECK_HERO_CONSUME, ABI_STAGE, AUTHOR_BOOK_LIMIT_TYPE } from "../consts";
|
||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||
import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
|
||||
import { SCHOOL } from '../pubUtils/dicParam';
|
||||
@@ -18,6 +18,7 @@ import { getServerCreateTime } from './redisService';
|
||||
import { checkWhiteList } from '../pubUtils/sysUtil';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { ServerlistModel } from '../db/Serverlist';
|
||||
import { AuthorBookModel, AuthorBookType } from '../db/AuthorBook';
|
||||
const query = new IP2Region({ disableIpv6: true });
|
||||
|
||||
|
||||
@@ -356,4 +357,37 @@ function decreaseConsume(origin: Reward[], pieceId: number, decrease: number) {
|
||||
}
|
||||
}
|
||||
return { consumes, newConsumes };
|
||||
}
|
||||
|
||||
/**
|
||||
* 诸子列表是否解锁
|
||||
* @param roleId
|
||||
* @param bookId
|
||||
* @returns true: 可以解锁 false:不可解锁
|
||||
*/
|
||||
export function checkAuthorBookLimit(authorBooks: AuthorBookType[], bookId: number) {
|
||||
let dicAuthorsBook = gameData.authorBook.get(bookId);
|
||||
if(!dicAuthorsBook) return false;
|
||||
|
||||
for(let { type, bookId, value } of dicAuthorsBook.limit) {
|
||||
if(type == AUTHOR_BOOK_LIMIT_TYPE.ALL) {
|
||||
let allProgress = authorBooks.reduce((pre, cur) => pre + cur.progress, 0);
|
||||
if(allProgress < value) return false;
|
||||
} else if(type == AUTHOR_BOOK_LIMIT_TYPE.ASSIGN) {
|
||||
let curBook = authorBooks.find(cur => cur.bookId == bookId);
|
||||
let progress = curBook?.progress??0;
|
||||
if(progress < value) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function replaceAuthorBooks(authorBooks: AuthorBookType[], authorBook: AuthorBookType) {
|
||||
let index = authorBooks.findIndex(cur => cur.bookId == authorBook.bookId);
|
||||
if(index == -1) {
|
||||
authorBooks.push(authorBook);
|
||||
} else {
|
||||
authorBooks[index] = authorBook;
|
||||
}
|
||||
return authorBooks;
|
||||
}
|
||||
Reference in New Issue
Block a user