feat(服务器): 更新维护逻辑

This commit is contained in:
luying
2023-05-06 11:44:05 +08:00
parent a651254821
commit f47d2d131f
24 changed files with 183 additions and 89 deletions
+11 -8
View File
@@ -1,5 +1,5 @@
import { Channel, pinus } from 'pinus';
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
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 { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
@@ -17,6 +17,7 @@ import IP2Region from "ip2region";
import { getServerCreateTime } from './redisService';
import { checkWhiteList } from '../pubUtils/sysUtil';
import { nowSeconds } from '../pubUtils/timeUtil';
import { ServerlistModel } from '../db/Serverlist';
const query = new IP2Region({ disableIpv6: true });
@@ -305,13 +306,15 @@ export async function getIpLocation(ip: string) {
}
}
// 服务器是否开启
export async function checkServerIsOpen(serverId: number, ip: string, uid: number) {
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, uid);
if(isWhiteList) return true;
let serverTime = await getServerCreateTime(serverId);
return serverTime <= nowSeconds();
// 玩家是否是新玩家
export async function checkIsNewUser(version: string, minVersion: string, uid: number, latestServerUniqId: number) {
let versionFlag = compareVersion(version, minVersion||'0.0.0.0');
if(versionFlag >= 0) {
let hasRole = await RoleModel.checkHasRole(uid, latestServerUniqId);
return !hasRole
} else {
return true;
}
}
export function calStarUpConsume(hero: HeroType) {