防沉迷:不使用厚土sdk
This commit is contained in:
@@ -17,7 +17,7 @@ import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../../services/redisService';
|
||||
|
||||
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGuildChannel, leaveSysChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
|
||||
import { reportOneOnline } from '../../../services/timeTaskService';
|
||||
import { reportOneOnline, savePlayTime } from '../../../services/authenticateService';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTaskWithRole, } from '../../../services/taskService';
|
||||
import { pushData, everydayRefresh } from '../../../services/connectorService';
|
||||
@@ -81,7 +81,7 @@ export class EntryHandler {
|
||||
let skins = await SkinModel.findbyRole(role.roleId);
|
||||
await chackFunOpenWhenLogin(role, session);
|
||||
if (role.hasInit) await loginRefresh(role.roleId);
|
||||
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName);
|
||||
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), true, user);
|
||||
|
||||
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
||||
r.setRankWithRoleInfo(role.roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
||||
@@ -196,7 +196,7 @@ export class EntryHandler {
|
||||
const teamCode: string = session.get('teamCode');
|
||||
roleLeave(roleId).then(function (roleInfo) {
|
||||
if (roleInfo.isOnline) {
|
||||
reportOneOnline(roleId, roleInfo.userCode, sid, roleInfo.pkgName);
|
||||
savePlayTime(roleInfo.userCode);
|
||||
}
|
||||
});
|
||||
rmRoleFromQueue(roleId, sid, COM_BTL_QUALITY, null); // 删除redis中寻宝的匹配记录
|
||||
|
||||
60
game-server/app/services/authenticateService.ts
Normal file
60
game-server/app/services/authenticateService.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import moment = require("moment");
|
||||
import { pinus } from "pinus";
|
||||
import { ADDICTION_PREVENTION_CODE, ADULT_AGE, GUEST_MAX_TIME, STATUS } from "../consts";
|
||||
import { UserModel, UserType } from "../db/User";
|
||||
import { getAge } from "../pubUtils/timeUtil";
|
||||
import { resResult } from "../pubUtils/util";
|
||||
import { incOnlineTime, setOnlineTime } from "./redisService";
|
||||
import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil';
|
||||
|
||||
export async function reportOneOnline(roleId: string, userCode: string, sid: string, isLogin: boolean = false, user?: UserType) {
|
||||
if (!user) user = await UserModel.findUserByUserCode(userCode);
|
||||
if (!user) return false;
|
||||
|
||||
let sumTime = await incOnlineTime(userCode, false, 5 * 60); // 返回单位为分
|
||||
let todaySumTime = await incOnlineTime(userCode, true, 5 * 60);
|
||||
|
||||
let { isGuest, hasAuthenticated, birthday } = user;
|
||||
let age = getAge(birthday);
|
||||
let isAdult = age >= ADULT_AGE;
|
||||
|
||||
if (isGuest || !hasAuthenticated) {
|
||||
if (sumTime > GUEST_MAX_TIME) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
isGuest,
|
||||
guestTime: sumTime, // 游客已体验时间
|
||||
hasAuthenticated, // 是否进行过实名认证
|
||||
isAdult, // 是否已成年
|
||||
todayPlayTime: todaySumTime, // 今天已游戏时长
|
||||
type: ADDICTION_PREVENTION_CODE.GUEST,
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}
|
||||
} else {
|
||||
let code = checkTeeanAgerTime(isAdult, todaySumTime);
|
||||
if(code != ADDICTION_PREVENTION_CODE.SUCCESS) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
isGuest,
|
||||
guestTime: 0, // 游客已体验时间
|
||||
hasAuthenticated, // 是否进行过实名认证
|
||||
isAdult, // 是否已成年
|
||||
todayPlayTime: todaySumTime, // 今天已游戏时长
|
||||
type: code
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function savePlayTime(userCode: string, user?: UserType) {
|
||||
if (!user) user = await UserModel.findUserByUserCode(userCode);
|
||||
if (!user) return false;
|
||||
|
||||
let time = Date.now() - user.lastLoginTime.getTime();
|
||||
let setsumTime = (user.playTime||0) + Math.floor(time/1000);
|
||||
let settodaySumTime = (user.todayPlayTime||0) + Math.floor(time/1000);
|
||||
|
||||
let sumTime = await setOnlineTime(userCode, false, setsumTime); // 返回单位为分
|
||||
let todaySumTime = await setOnlineTime(userCode, true, settodaySumTime);
|
||||
|
||||
let { isGuest, hasAuthenticated } = user;
|
||||
await UserModel.updatePlayTime(userCode, isGuest || !hasAuthenticated, settodaySumTime, setsumTime);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { GuildRankParam, GuildLeader, RankParam, LineupParam } from '../domain/r
|
||||
import { comBtlRanges } from '../pubUtils/data';
|
||||
import { setRankRedisFromDb } from './rankService';
|
||||
import { ServerlistModel } from '../db/Serverlist';
|
||||
import moment = require('moment');
|
||||
/**
|
||||
* 在服务重新启动时,将信息存入redis
|
||||
*/
|
||||
@@ -346,6 +347,34 @@ export async function getAllOnlineRoles() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将玩家登录时间记录到
|
||||
* @param userCode 玩家user表里的userCode
|
||||
* @param isToday 累计记录还是当日记录
|
||||
* @returns 分钟
|
||||
*/
|
||||
export async function incOnlineTime(userCode: string, isToday: boolean, incTime: number) {
|
||||
moment.locale('zh-cn');
|
||||
let today = moment().format('YYYYMMDD');
|
||||
let key = isToday? REDIS_KEY.ONLINE_TIME: `${REDIS_KEY.ONLINE_TIME}:${today}`;
|
||||
if(isToday) {
|
||||
let tomorrow = moment().add(1, 'days').hours(0).minutes(0).seconds(0).format('x');
|
||||
await redisClient().expireatAsync(key, parseInt(tomorrow));
|
||||
}
|
||||
return await redisClient().hincrbyAsync(key, userCode, incTime);
|
||||
}
|
||||
|
||||
export async function setOnlineTime(userCode: string, isToday: boolean, setTime: number) {
|
||||
moment.locale('zh-cn');
|
||||
let today = moment().format('YYYYMMDD');
|
||||
let key = isToday? REDIS_KEY.ONLINE_TIME: `${REDIS_KEY.ONLINE_TIME}:${today}`;
|
||||
if(isToday) {
|
||||
let tomorrow = moment().add(1, 'days').hours(0).minutes(0).seconds(0).format('x');
|
||||
await redisClient().expireatAsync(key, parseInt(tomorrow));
|
||||
}
|
||||
return await redisClient().hsetAsync(key, userCode, setTime);
|
||||
}
|
||||
|
||||
|
||||
// 排行榜是否存在
|
||||
export async function smembersAsync(key: string) {
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
|
||||
import { scheduleJob, Job, scheduledJobs } from 'node-schedule';
|
||||
import { scheduleJob, Job, } from 'node-schedule';
|
||||
import { PVPConfigModel } from '../db/SystemConfig';
|
||||
import PvpDefenseType, { PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
import { nowSeconds, getAge, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { getPvpGkWarIds, getPvpRankRewards, getPvpHeroRewards, getResultMaxRank, getTodayGuildActivity } from '../pubUtils/data';
|
||||
import { deepCopy, resResult, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { deepCopy, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { getLvByScore } from './pvpService';
|
||||
import { getAllOnlineRoles, getAllServers, initSingleRank, delGuildActivityRank } from './redisService';
|
||||
import { MAIL_TYPE, REDIS_KEY, ADULT_AGE, GUEST_MAX_TIME, ADDICTION_PREVENTION_CODE, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE, TIME_OUTPUT_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER } from '../consts';
|
||||
import { MAIL_TYPE, REDIS_KEY, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE, TIME_OUTPUT_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER } from '../consts';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { MailModel, MailType } from '../db/Mail';
|
||||
import { pinus } from 'pinus';
|
||||
import { indexOf } from 'underscore';
|
||||
import { PvpSeasonResultModel } from '../db/PvpSeasonResult';
|
||||
import { settleGuildWeekly } from './guildService';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { sendMailByContent } from './mailService';
|
||||
import { reportOnline } from '../pubUtils/httpUtil';
|
||||
import { UserModel } from '../db/User';
|
||||
import { getGuildActivityByDic, setMedianCe, sendEndMsgToAll, autoDeclare, sendGuildActivityStatus } from './guildActivityService';
|
||||
import { getGuildActivityByDic, sendEndMsgToAll, autoDeclare, sendGuildActivityStatus } from './guildActivityService';
|
||||
import { sendUngotDividendJob, startGuildAuction, startWorldAuction, stopAuction } from './auctionService';
|
||||
import { DicGuildActivity } from '../pubUtils/dictionary/DicGuildActivity';
|
||||
import { GuildModel } from '../db/Guild';
|
||||
import { dispatch } from '../util/dispatcher';
|
||||
import { Rank } from './rankService';
|
||||
import { checkTask } from './taskService';
|
||||
@@ -30,6 +25,7 @@ import { everydayRefresh } from './connectorService';
|
||||
import { initMarquee, initMaintenance } from './gmService';
|
||||
import moment = require('moment');
|
||||
import { CounterModel } from '../db/Counter';
|
||||
import { reportOneOnline } from './authenticateService';
|
||||
|
||||
const PER_SECOND = 1 * 1000;
|
||||
const PER_DAY = 24 * 60 * 60;
|
||||
@@ -336,56 +332,12 @@ export async function resetPvpRanks() {
|
||||
export async function reportOnlineSchedule() {
|
||||
let allRoles = await getAllOnlineRoles();
|
||||
console.log('reportOnlineSchedule all roles count: ', allRoles.length)
|
||||
for (let { roleId, userCode, sid, pkgName } of allRoles) {
|
||||
let result = reportOneOnline(roleId, userCode, sid, pkgName);
|
||||
for (let { roleId, userCode, sid } of allRoles) {
|
||||
let result = reportOneOnline(roleId, userCode, sid, false);
|
||||
if (!result) continue;
|
||||
}
|
||||
}
|
||||
|
||||
export async function reportOneOnline(roleId: string, userCode: string, sid: string, pkgName: string) {
|
||||
|
||||
let result = await reportOnline(userCode, pkgName); // 连接sdk
|
||||
if (!result || result.code == -1) return false;
|
||||
|
||||
let user = await UserModel.findUserByUserCode(userCode);
|
||||
if (!user) return false;
|
||||
let { reportTime = new Date(), lastLoginTime = new Date(), guestTime, isGuest, hasAuthenticated, birthday } = user;
|
||||
|
||||
let age = getAge(birthday);
|
||||
let isAdult = age >= ADULT_AGE;
|
||||
|
||||
if (isGuest || !hasAuthenticated) {
|
||||
let lastTime = lastLoginTime > reportTime ? lastLoginTime.getTime() : reportTime.getTime();
|
||||
let guestTimeInc = Math.floor((Date.now() - lastTime) / 1000);
|
||||
user = await UserModel.updatePlayTime(userCode, guestTimeInc, result.total); // 记录时间
|
||||
|
||||
guestTime = user.guestTime;
|
||||
|
||||
if (guestTime > GUEST_MAX_TIME) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
isGuest,
|
||||
guestTime, // 游客已体验时间
|
||||
hasAuthenticated, // 是否进行过实名认证
|
||||
isAdult, // 是否已成年
|
||||
todayPlayTime: result.total, // 今天已游戏时长
|
||||
type: ADDICTION_PREVENTION_CODE.GUEST,
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}
|
||||
} else {
|
||||
if (result.code != ADDICTION_PREVENTION_CODE.SUCCESS && result.age != -1) { // 未成年人防沉迷
|
||||
user = await UserModel.updatePlayTime(userCode, 0, result.total, result.code); // 记录时间
|
||||
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
isGuest,
|
||||
guestTime, // 游客已体验时间
|
||||
hasAuthenticated, // 是否进行过实名认证
|
||||
isAdult, // 是否已成年
|
||||
todayPlayTime: result.total, // 今天已游戏时长
|
||||
type: result.code
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 军团活动,每晚8点开启
|
||||
|
||||
@@ -23,13 +23,15 @@ declare module 'redis' {
|
||||
// 删除哈希表 key 中的一个或多个指定字段
|
||||
hdelAsync(key: string, field: string): Promise<number>;
|
||||
// 将哈希表 key 中的字段 field 的值设为 value
|
||||
hsetAsync(key: string, field: string, value: string): Promise<number>;
|
||||
hsetAsync<T>(key: string, field: string, value: T): Promise<T>;
|
||||
// 获取存储在哈希表中指定字段的值
|
||||
hgetAsync(key: string, field: string): Promise<string>;
|
||||
hgetAsync(key: string, field: string): Promise<any>;
|
||||
// 获取存储在哈希表中指定字段的值。
|
||||
hexistsAsync(key: string, field: string): Promise<number>;
|
||||
// 获取哈希表中所有字段和值
|
||||
hgetallAsync(key: string): Promise<any>;
|
||||
// 增值
|
||||
hincrbyAsync(key: string, field: string, inc: number): Promise<number>;
|
||||
|
||||
// 移除并返回集合中的一个随机元素
|
||||
spopAsync(key: string, count?: number): Promise<number>;
|
||||
|
||||
@@ -16,6 +16,8 @@ export const AUTH_SMS_CNT_PER_DAY = 8;
|
||||
|
||||
export const ADULT_AGE = 18;
|
||||
export const GUEST_MAX_TIME = 60 * 60; // 游客体验时间
|
||||
export const TEEN_HOLIDAY_MAX_TIME = 3 * 60 * 60; // 未成年人节假日每天3小时
|
||||
export const TEEN_DAILY_MAX_TIME = 1.5 * 60 * 60; // 未成年人工作日每天1.5小时
|
||||
export const GUEST_DAY = 15; // 同一设备15天内不得重复体验游客模式
|
||||
|
||||
export const REFRESH_TIME = 5; // 统一一天刷新时间
|
||||
@@ -206,6 +208,7 @@ export const REDIS_KEY = {
|
||||
GUILD_ACTIVE_RANK: "guildActiveRank", // 公会周活跃排行榜
|
||||
DB_GAME: 'dbGame', // 服务器列表
|
||||
ONLINE_USERS: 'onlineUsers', // 在线用户情况
|
||||
ONLINE_TIME: 'onlineTime', // 玩家在线时间
|
||||
CHANNEL_SERVERS: 'chat:channelServers', // 渠道对应的 chat 服务器 Id,
|
||||
USER_GATE_ACTIVITY: 'usrGateAct', // 蛮夷入侵玩家排行
|
||||
GATE_ACTIVITY: 'gateAct', // 蛮夷入侵军团排行
|
||||
@@ -461,6 +464,7 @@ export const FILENAME = {
|
||||
DIC_GK_PROBATION: 'dic_zyz_gk_probation',
|
||||
DIC_QUENCH_QUALITY: 'dic_zyz_quench_quality',
|
||||
DIC_QUENCH_CONSUME: 'dic_zyz_quench_consume',
|
||||
DIC_HOLIDAY: 'dic_holiday',
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
@@ -513,10 +517,6 @@ export enum BLOCK_OPEATE {
|
||||
REMOVE_FRIEND = 4
|
||||
}
|
||||
|
||||
export enum TIME_FORMAT {
|
||||
TYPE_SLASH = 1
|
||||
}
|
||||
|
||||
export enum ADDICTION_PREVENTION_CODE {
|
||||
FAIL = -1,
|
||||
SUCCESS = 1, // 接口的返回
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { formatTime } from '../pubUtils/timeUtil';
|
||||
import { TIME_FORMAT, COUNTER } from '../consts'
|
||||
import { COUNTER } from '../consts'
|
||||
import { CounterModel } from './Counter';
|
||||
import moment = require('moment');
|
||||
|
||||
/**
|
||||
* 游戏字段接口
|
||||
@@ -29,8 +29,8 @@ export default class Notice extends BaseModel {
|
||||
@prop({ required: true })
|
||||
endTime: Date; // 活动结束时间
|
||||
public get time() {
|
||||
let startTime = formatTime(this.startTime, TIME_FORMAT.TYPE_SLASH);
|
||||
let endTime = formatTime(this.endTime, TIME_FORMAT.TYPE_SLASH);
|
||||
let startTime = moment(this.startTime).format('YYYY/MM/DD');
|
||||
let endTime = moment(this.endTime).format('YYYY/MM/DD');
|
||||
|
||||
return this.timeStr.replace(/%startTime/g, startTime).replace(/%endTime/g, endTime);
|
||||
}
|
||||
|
||||
@@ -64,10 +64,8 @@ export default class User extends BaseModel {
|
||||
pi: string; // 已通过实名认证用户唯一标识
|
||||
@prop({ required: false, default: 0 })
|
||||
todayPlayTime: number; // 今日游戏时间
|
||||
@prop({ required: false, default: 0 })
|
||||
todayPlayType: number; // 未成年防沉迷类型
|
||||
@prop({ required: false })
|
||||
reportTime: Date; // 汇报时间
|
||||
playTime: number; // 总游戏时间
|
||||
|
||||
@prop({ required: false, default: false })
|
||||
hasSetPw: boolean; // 是否设置过密码
|
||||
@@ -242,10 +240,8 @@ export default class User extends BaseModel {
|
||||
}
|
||||
|
||||
|
||||
public static async updatePlayTime(userCode: string, guestTimeInc: number, todayPlayTime: number, todayPlayType?: number) {
|
||||
let update = { todayPlayTime, todayPlayType, reportTime: new Date() };
|
||||
if (todayPlayType) update.todayPlayType;
|
||||
const user: UserType = await UserModel.findOneAndUpdate({ userCode }, { $inc: { guestTime: guestTimeInc }, $set: update }, { new: true }).lean({ getters: true });
|
||||
public static async updatePlayTime(userCode: string, isGuest: boolean, todayPlayTime: number, playTime: number) {
|
||||
const user: UserType = await UserModel.findOneAndUpdate({ userCode }, { $set: { guestTime: isGuest?playTime: 0, todayPlayTime: todayPlayTime, playTime } }, { new: true }).lean({ getters: true });
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
27
shared/pubUtils/authenticateUtil.ts
Normal file
27
shared/pubUtils/authenticateUtil.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import * as moment from "moment";
|
||||
import { ADDICTION_PREVENTION_CODE, TEEN_DAILY_MAX_TIME, TEEN_HOLIDAY_MAX_TIME } from "../consts";
|
||||
import { gameData } from './data';
|
||||
|
||||
export function checkTeeanAgerTime(isAdult: boolean, todaySumTime: number) {
|
||||
if(isAdult) return ADDICTION_PREVENTION_CODE.SUCCESS;
|
||||
|
||||
let now = new Date();
|
||||
let hour = now.getHours();
|
||||
if(hour < 8 || hour > 22) return ADDICTION_PREVENTION_CODE.CURFEW;
|
||||
|
||||
let isHoliday = checkIsHoliday();
|
||||
if(isHoliday && todaySumTime > TEEN_HOLIDAY_MAX_TIME) {
|
||||
return ADDICTION_PREVENTION_CODE.HOLIDAY;
|
||||
} else if (!isHoliday && todaySumTime > TEEN_DAILY_MAX_TIME) {
|
||||
return ADDICTION_PREVENTION_CODE.WORKDAY;
|
||||
}
|
||||
return ADDICTION_PREVENTION_CODE.SUCCESS;
|
||||
}
|
||||
|
||||
export function checkIsHoliday() {
|
||||
let now = new Date();
|
||||
let day = now.getDay();
|
||||
let str = moment().format('YYYY-MM-DD');
|
||||
return day == 0 || day == 6 || gameData.holiday.indexOf(str) != -1;
|
||||
}
|
||||
@@ -90,6 +90,7 @@ import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
|
||||
import { dicTaskExp, loadTskExp} from './dictionary/DicTaskExp';
|
||||
import { dicQuenchByQuality, dicQuenchRangeByQuality, dicQuenchRangeByQualityAndGrade, loadQuenchQuality } from './dictionary/DicQuenchQuality';
|
||||
import { dicQuenchConsume, loadQuenchConsume } from './dictionary/DicQuenchConsume';
|
||||
import { dicHoliday, loadHoliday } from './dictionary/DicHoliday';
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
@@ -224,7 +225,8 @@ export const gameData = {
|
||||
quenchConsume: dicQuenchConsume,
|
||||
quenchByQuality: dicQuenchByQuality,
|
||||
equipAttributeRatio: new Map<number, number>(),
|
||||
ceRatio: new Array<{type: number, val: number}>()
|
||||
ceRatio: new Array<{type: number, val: number}>(),
|
||||
holiday: dicHoliday
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -866,6 +868,7 @@ function loadDatas() {
|
||||
loadQuenchQuality();
|
||||
loadQuenchConsume();
|
||||
loadEquipAttributeRatio();
|
||||
loadHoliday();
|
||||
}
|
||||
|
||||
// 重载dicParam
|
||||
|
||||
23
shared/pubUtils/dictionary/DicHoliday.ts
Normal file
23
shared/pubUtils/dictionary/DicHoliday.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// 武将觉醒表
|
||||
import { readFileAndParse } from '../util'
|
||||
import { FILENAME } from '../../consts';
|
||||
|
||||
export interface DicHoliday {
|
||||
|
||||
// 唯一id
|
||||
readonly id: number;
|
||||
// 节假日
|
||||
readonly holiday: string;
|
||||
|
||||
}
|
||||
|
||||
export const dicHoliday = new Array<string>();
|
||||
export function loadHoliday() {
|
||||
dicHoliday.splice(0, dicHoliday.length);
|
||||
let arr = readFileAndParse(FILENAME.DIC_HOLIDAY);
|
||||
|
||||
arr.forEach(o => {
|
||||
dicHoliday.push(o.holiday)
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TIME_FORMAT, REFRESH_TIME, TIME_OUTPUT_TYPE, SHOP_REFRESH_TYPE } from '../consts';
|
||||
import { REFRESH_TIME, TIME_OUTPUT_TYPE, SHOP_REFRESH_TYPE } from '../consts';
|
||||
|
||||
/**
|
||||
* 时间
|
||||
@@ -488,26 +488,6 @@ export function getAge(birthday: string) {
|
||||
return age
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Date格式的数据转为string格式
|
||||
* @param {Date} d 时间
|
||||
* @param {TIME_FORMAT} type 类型
|
||||
*/
|
||||
export function formatTime(d: Date, type: TIME_FORMAT) {
|
||||
let year = d.getFullYear();
|
||||
let month = d.getMonth() + 1;
|
||||
let day = d.getDate();
|
||||
let yearStr = year.toString();
|
||||
let monthStr = month.toString();
|
||||
let dayStr = day.toString();
|
||||
|
||||
if(type == TIME_FORMAT.TYPE_SLASH) {
|
||||
if(day < 10) dayStr = '0' + dayStr;
|
||||
if(month < 10) monthStr = '0' + monthStr;
|
||||
return `${yearStr}/${monthStr}/${dayStr}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得某个时间是星期几
|
||||
* @param needHandle 是否处理周日
|
||||
|
||||
@@ -4,7 +4,7 @@ import { HeroModel, HeroType } from '../db/Hero';
|
||||
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME } from '../consts';
|
||||
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, } from '../consts';
|
||||
|
||||
import { findIndex } from 'underscore';
|
||||
import { getTimeFunM } from './timeUtil';
|
||||
|
||||
@@ -9,7 +9,8 @@ import Counter from '@db/Counter';
|
||||
import { getExpByLv } from '../pubUtils/data';
|
||||
import { isString } from 'underscore';
|
||||
import { getAge } from '../pubUtils/timeUtil';
|
||||
import { shouldRefresh, resResult } from '../pubUtils/util';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil';
|
||||
import { authenticate } from '../pubUtils/httpUtil';
|
||||
import { checkTask, getCreateUserFuncs } from 'app/pubUtils/taskUtil';
|
||||
|
||||
@@ -82,11 +83,7 @@ export default class Auth extends Service {
|
||||
let age = getAge(user.birthday);
|
||||
let isAdult = age >= ADULT_AGE;
|
||||
let todayPlayTime = user.todayPlayTime;
|
||||
let type = user.todayPlayType;
|
||||
if (shouldRefresh(user.reportTime, new Date(), 0)) {
|
||||
todayPlayTime = 0;
|
||||
type = 0;
|
||||
}
|
||||
let type = checkTeeanAgerTime(isAdult, todayPlayTime);
|
||||
if ((user.isGuest || !user.hasAuthenticated) && user.guestTime > GUEST_MAX_TIME) {
|
||||
type = ADDICTION_PREVENTION_CODE.GUEST;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user