✨ feat(诸子列传): 添加功能

This commit is contained in:
luying
2023-07-13 16:23:29 +08:00
parent b1af8ad204
commit 1eb6f76cce
25 changed files with 5475 additions and 71 deletions
+17
View File
@@ -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':
{
+12 -1
View File
@@ -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[] = [];
+61 -19
View File
@@ -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
}
+22 -1
View File
@@ -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;
}
+35 -1
View File
@@ -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;
}