防沉迷:不使用厚土sdk
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user