✨ feat(gvg): 组建期
This commit is contained in:
@@ -118,6 +118,7 @@ import { dicArtifactSeid, loadArtifactSeid } from "./dictionary/DicArtifactSeid"
|
||||
import { DicArtifact } from "./dictionary/DicArtifact";
|
||||
import { DicArtifactQuality } from "./dictionary/DicArtifactQuality";
|
||||
import { dicGiftPackagePlan, loadGiftPackagePlan } from "./dictionary/DicGiftPackagePlan";
|
||||
import { dicGVGPeriod, loadGVGPeriod } from './dictionary/DicGVGPeriod';
|
||||
|
||||
export const gameData = {
|
||||
daily: dicDaily,
|
||||
@@ -295,6 +296,7 @@ export const gameData = {
|
||||
artifactQualityPlan: dicArtifactQualityPlan,
|
||||
artifactSeid: dicArtifactSeid,
|
||||
artifactByGroupAndQuality: dicArtifactsByGroup,
|
||||
gvgPeriod: dicGVGPeriod,
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -1262,6 +1264,7 @@ function loadDatas() {
|
||||
loadArtifactQuality();
|
||||
loadArtifactQualityPlan();
|
||||
loadArtifactSeid();
|
||||
loadGVGPeriod();
|
||||
}
|
||||
|
||||
// 重载dicParam
|
||||
|
||||
42
shared/pubUtils/dictionary/DicGVGPeriod.ts
Normal file
42
shared/pubUtils/dictionary/DicGVGPeriod.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
// GVG周期表
|
||||
|
||||
import { FILENAME } from '../../consts'
|
||||
import { parseNumberList, readFileAndParse } from '../util'
|
||||
|
||||
export interface DicGVGPeriod {
|
||||
// 1-组建期 2-备战期 3-激战期
|
||||
readonly periodType: number;
|
||||
// 星期几 1-7
|
||||
readonly day: number[];
|
||||
// 星期几 1-7
|
||||
readonly startDay: number;
|
||||
// HH:mm, 组建期备战期填05:00。激战期填20:40
|
||||
readonly startHour: number;
|
||||
readonly startMinute: number;
|
||||
readonly startSecond: number;
|
||||
// HH:mm,组建期填截止创建联军时间,备战期填22:00,激战期填21:40
|
||||
readonly endHour: number;
|
||||
readonly endMinute: number;
|
||||
readonly endSecond: number;
|
||||
}
|
||||
|
||||
export const dicGVGPeriod = new Map<number, DicGVGPeriod>();
|
||||
export function loadGVGPeriod() {
|
||||
dicGVGPeriod.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_GVG_PERIOD);
|
||||
arr.forEach(o => {
|
||||
o.day = parseNumberList(o.day);
|
||||
o.startDay = o.day[0];
|
||||
let startTime = o.startTime.split(':');
|
||||
o.startHour = parseInt(startTime[0]);
|
||||
o.startMinute = parseInt(startTime[1]);
|
||||
o.startSecond = parseInt(startTime[2]);
|
||||
let endTime = o.endTime.split(':');
|
||||
o.endHour = parseInt(endTime[0]);
|
||||
o.endMinute = parseInt(endTime[1]);
|
||||
o.endSecond = parseInt(endTime[2]);
|
||||
dicGVGPeriod.set(o.periodType, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,21 +1,22 @@
|
||||
import { REFRESH_TIME, TIME_OUTPUT_TYPE, SHOP_REFRESH_TYPE } from '../consts';
|
||||
import { isDebugTime } from './sdkUtil';
|
||||
|
||||
export const WEEK_TO_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
export const WEEK_TO_SECOND = 7 * 24 * 60 * 60;
|
||||
export const DAY_TO_HOUR = 24;
|
||||
export const DAY_TO_SECOND = 24 * 60 * 60;
|
||||
export const DAY_TO_MS = 24 * 60 * 60 * 1000;
|
||||
export const HOUR_TO_MINUTE = 60;
|
||||
export const HOUR_TO_SECOND = 60 * 60;
|
||||
export const HOUR_TO_MS = 60 * 60 * 1000;
|
||||
export const MINUTE_TO_MS = 60 * 1000;
|
||||
export const SECOND_TO_MS = 1000;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
* @class
|
||||
*/
|
||||
class Time {
|
||||
WEEK_TO_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
DAY_TO_HOUR = 24;
|
||||
DAY_TO_SECOND = 24 * 60 * 60;
|
||||
DAY_TO_MS = 24 * 60 * 60 * 1000;
|
||||
HOUR_TO_MINUTE = 60;
|
||||
HOUR_TO_SECOND = 60 * 60;
|
||||
HOUR_TO_MS = 60 * 60 * 1000;
|
||||
MINUTE_TO_MS = 60 * 1000;
|
||||
SECOND_TO_MS = 1000;
|
||||
|
||||
now: Date; // 当前时间
|
||||
time: Date; // 处理时间原料
|
||||
outputType: number; // 输出格式
|
||||
@@ -106,7 +107,7 @@ class Time {
|
||||
if(time >= t) {
|
||||
return t;
|
||||
} else {
|
||||
return new Date(t.getTime() - this.DAY_TO_MS);
|
||||
return new Date(t.getTime() - DAY_TO_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ class Time {
|
||||
let cur = this._getDayZeroPoint(curDate);
|
||||
let pre = this._getDayZeroPoint(preDate);
|
||||
|
||||
return Math.floor((cur.getTime() - pre.getTime()) / this.DAY_TO_MS)
|
||||
return Math.floor((cur.getTime() - pre.getTime()) / DAY_TO_MS)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +257,7 @@ class Time {
|
||||
if(this.time >= t) {
|
||||
return this._returnResult(t);
|
||||
} else {
|
||||
return this._returnResult(t.getTime() - this.WEEK_TO_MS);
|
||||
return this._returnResult(t.getTime() - WEEK_TO_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,10 +288,10 @@ class Time {
|
||||
public getBeforeDayWithHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
|
||||
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
|
||||
if(this.time >= t) {
|
||||
let timestamp = t.getTime() - day * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() - day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
} else {
|
||||
let timestamp = t.getTime() - (day + 1) * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() - (day + 1) * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
}
|
||||
@@ -306,10 +307,10 @@ class Time {
|
||||
let t = this._setHour(this.time.getTime(), hour, minute, seconds, 0);
|
||||
// console.log(t.getTime(), this.time.getTime());
|
||||
if(this.time.getTime() > t.getTime()) {
|
||||
let timestamp = t.getTime() + (day + 1) * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() + (day + 1) * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
} else {
|
||||
let timestamp = t.getTime() + day * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() + day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +324,7 @@ class Time {
|
||||
*/
|
||||
public getBeforeDayAndSetHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
|
||||
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
|
||||
let timestamp = t.getTime() - day * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() - day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -336,7 +337,7 @@ class Time {
|
||||
*/
|
||||
public getAfterDayAndSetHour(day: number = 0, hour = REFRESH_TIME, minute = 0, seconds = 0) {
|
||||
let t = this._setHour(this.time.getTime(), hour, minute, seconds);
|
||||
let timestamp = t.getTime() + day * this.DAY_TO_MS;
|
||||
let timestamp = t.getTime() + day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -345,7 +346,7 @@ class Time {
|
||||
* @param day 几天前
|
||||
*/
|
||||
public getBeforeDay(day: number) {
|
||||
let timestamp = this.time.getTime() - day * this.DAY_TO_MS;
|
||||
let timestamp = this.time.getTime() - day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -354,7 +355,7 @@ class Time {
|
||||
* @param day 几天后
|
||||
*/
|
||||
public getAfterDay(day: number) {
|
||||
let timestamp = this.time.getTime() + day * this.DAY_TO_MS;
|
||||
let timestamp = this.time.getTime() + day * DAY_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ class Time {
|
||||
* @param hour 几小时前
|
||||
*/
|
||||
public getBeforeHour(hour: number) {
|
||||
let timestamp = this.time.getTime() - hour * this.HOUR_TO_MS;
|
||||
let timestamp = this.time.getTime() - hour * HOUR_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -372,7 +373,7 @@ class Time {
|
||||
* @param hour 几分钟前
|
||||
*/
|
||||
public getBeforeMinute(minute: number) {
|
||||
let timestamp = this.time.getTime() - minute * this.MINUTE_TO_MS;
|
||||
let timestamp = this.time.getTime() - minute * MINUTE_TO_MS;
|
||||
return this._returnResult(timestamp);
|
||||
}
|
||||
|
||||
@@ -393,7 +394,7 @@ class Time {
|
||||
public getAfterDayByGap(preDate: Date, day: number) {
|
||||
let gap = this._getDayGap(preDate, this.time);
|
||||
let n = Math.floor(gap / day);
|
||||
return this._returnResult(preDate.getTime() + n * day * this.DAY_TO_MS);
|
||||
return this._returnResult(preDate.getTime() + n * day * DAY_TO_MS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +402,7 @@ class Time {
|
||||
* @param day day天以内
|
||||
*/
|
||||
public checkDay(day: number = 1) {
|
||||
if (this.time.getTime() - this.now.getTime() <= day * this.DAY_TO_MS) {
|
||||
if (this.time.getTime() - this.now.getTime() <= day * DAY_TO_MS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user