✨ 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
+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;
}