Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create season info #141

Merged
merged 3 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion data/seasons/d2-season-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
export default {
export enum D2SeasonEnum {
DEBUG = 0,
RED_WAR,
CURSE_OF_OSIRIS,
WARMIND,
FORSAKEN,
BLACK_ARMORY,
JOKERS_WILD,
PENUMBRA,
SHADOWKEEP,
DAWN,
WORTHY,

__LENGTH, // This always needs to be last
}

export const D2CurrentSeason: number = D2SeasonEnum.__LENGTH - 1;

export const D2SeasonInfo = {
0: {
DLCName: 'Debug',
seasonName: 'Debug',
seasonTag: 'debug',
season: 0,
year: 0,
maxLevel: 0,
maxPower: 0,
softCap: 0,
releaseDate: '2017-09-06',
resetTime: '09:00:00Z',
numWeeks: 0,
},
1: {
DLCName: 'Red War',
seasonName: 'Red War',
Expand All @@ -10,6 +41,7 @@ export default {
softCap: 285,
releaseDate: '2017-09-06',
resetTime: '09:00:00Z',
numWeeks: 13,
},
2: {
DLCName: 'Curse of Osiris',
Expand All @@ -22,6 +54,7 @@ export default {
softCap: 320,
releaseDate: '2017-12-05',
resetTime: '17:00:00Z',
numWeeks: 22,
},
3: {
DLCName: 'Warmind',
Expand All @@ -34,6 +67,7 @@ export default {
softCap: 340,
releaseDate: '2018-05-08',
resetTime: '18:00:00Z',
numWeeks: 17,
},
4: {
DLCName: 'Forsaken',
Expand All @@ -46,6 +80,7 @@ export default {
softCap: 500,
releaseDate: '2018-09-04',
resetTime: '17:00:00Z',
numWeeks: 13,
},
5: {
DLCName: 'Black Armory',
Expand All @@ -58,6 +93,7 @@ export default {
softCap: 500,
releaseDate: '2018-11-27',
resetTime: '17:00:00Z',
numWeeks: 12,
},
6: {
DLCName: "Joker's Wild",
Expand All @@ -70,6 +106,7 @@ export default {
softCap: 500,
releaseDate: '2019-03-05',
resetTime: '17:00:00Z',
numWeeks: 14,
},
7: {
DLCName: 'Penumbra',
Expand All @@ -82,6 +119,7 @@ export default {
softCap: 500,
releaseDate: '2019-06-04',
resetTime: '17:00:00Z',
numWeeks: 13,
},
8: {
DLCName: 'Shadowkeep',
Expand All @@ -94,6 +132,7 @@ export default {
softCap: 900,
releaseDate: '2019-10-01',
resetTime: '17:00:00Z',
numWeeks: 10,
},
9: {
DLCName: '',
Expand All @@ -106,6 +145,7 @@ export default {
softCap: 900,
releaseDate: '2019-12-10',
resetTime: '17:00:00Z',
numWeeks: 13,
},
10: {
DLCName: '',
Expand All @@ -118,6 +158,7 @@ export default {
softCap: 950,
releaseDate: '2020-03-10',
resetTime: '17:00:00Z',
numWeeks: 13,
},
} as Record<
number,
Expand All @@ -132,5 +173,20 @@ export default {
softCap: number;
releaseDate: string;
resetTime: string;
numWeeks: number;
}
>;

function getCurrentSeason(): number {
let seasonDate: Date;
const today = new Date();
for (let i = D2SeasonEnum.__LENGTH - 1; i > 0; i--) {
seasonDate = new Date(`${D2SeasonInfo[i].releaseDate}T${D2SeasonInfo[i].resetTime}`);
if (today >= seasonDate) {
return D2SeasonInfo[i].season;
}
}
return 0;
}

export const D2CalculatedSeason: number = getCurrentSeason();
192 changes: 192 additions & 0 deletions output/d2-season-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
export enum D2SeasonEnum {
DEBUG = 0,
RED_WAR,
CURSE_OF_OSIRIS,
WARMIND,
FORSAKEN,
BLACK_ARMORY,
JOKERS_WILD,
PENUMBRA,
SHADOWKEEP,
DAWN,
WORTHY,

__LENGTH, // This always needs to be last
}

export const D2CurrentSeason: number = D2SeasonEnum.__LENGTH - 1;

export const D2SeasonInfo = {
0: {
DLCName: 'Debug',
seasonName: 'Debug',
seasonTag: 'debug',
season: 0,
year: 0,
maxLevel: 0,
maxPower: 0,
softCap: 0,
releaseDate: '2017-09-06',
resetTime: '09:00:00Z',
numWeeks: 0,
},
1: {
DLCName: 'Red War',
seasonName: 'Red War',
seasonTag: 'redwar',
season: 1,
year: 1,
maxLevel: 20,
maxPower: 300,
softCap: 285,
releaseDate: '2017-09-06',
resetTime: '09:00:00Z',
numWeeks: 13,
},
2: {
DLCName: 'Curse of Osiris',
seasonName: 'Curse of Osiris',
seasonTag: 'osiris',
season: 2,
year: 1,
maxLevel: 25,
maxPower: 330,
softCap: 320,
releaseDate: '2017-12-05',
resetTime: '17:00:00Z',
numWeeks: 22,
},
3: {
DLCName: 'Warmind',
seasonName: 'Warmind',
seasonTag: 'warmind',
season: 3,
year: 1,
maxLevel: 30,
maxPower: 380,
softCap: 340,
releaseDate: '2018-05-08',
resetTime: '18:00:00Z',
numWeeks: 17,
},
4: {
DLCName: 'Forsaken',
seasonName: 'Season of the Outlaw',
seasonTag: 'outlaw',
season: 4,
year: 2,
maxLevel: 50,
maxPower: 600,
softCap: 500,
releaseDate: '2018-09-04',
resetTime: '17:00:00Z',
numWeeks: 13,
},
5: {
DLCName: 'Black Armory',
seasonName: 'Season of the Forge',
seasonTag: 'forge',
season: 5,
year: 2,
maxLevel: 50,
maxPower: 650,
softCap: 500,
releaseDate: '2018-11-27',
resetTime: '17:00:00Z',
numWeeks: 12,
},
6: {
DLCName: "Joker's Wild",
seasonName: 'Season of the Drifter',
seasonTag: 'drifter',
season: 6,
year: 2,
maxLevel: 50,
maxPower: 700,
softCap: 500,
releaseDate: '2019-03-05',
resetTime: '17:00:00Z',
numWeeks: 14,
},
7: {
DLCName: 'Penumbra',
seasonName: 'Season of Opulence',
seasonTag: 'opulence',
season: 7,
year: 2,
maxLevel: 50,
maxPower: 750,
softCap: 500,
releaseDate: '2019-06-04',
resetTime: '17:00:00Z',
numWeeks: 13,
},
8: {
DLCName: 'Shadowkeep',
seasonName: 'Season of the Undying',
seasonTag: 'undying',
season: 8,
year: 3,
maxLevel: 50,
maxPower: 960,
softCap: 900,
releaseDate: '2019-10-01',
resetTime: '17:00:00Z',
numWeeks: 10,
},
9: {
DLCName: '',
seasonName: 'Season of Dawn',
seasonTag: 'dawn',
season: 9,
year: 3,
maxLevel: 50,
maxPower: 970,
softCap: 900,
releaseDate: '2019-12-10',
resetTime: '17:00:00Z',
numWeeks: 13,
},
10: {
DLCName: '',
seasonName: 'Season of the Worthy',
seasonTag: 'worthy',
season: 10,
year: 3,
maxLevel: 50,
maxPower: 1010,
softCap: 950,
releaseDate: '2020-03-10',
resetTime: '17:00:00Z',
numWeeks: 13,
},
} as Record<
number,
{
DLCName: string;
seasonName: string;
seasonTag: string;
season: number;
year: number;
maxLevel: number;
maxPower: number;
softCap: number;
releaseDate: string;
resetTime: string;
numWeeks: number;
}
>;

function getCurrentSeason(): number {
let seasonDate: Date;
const today = new Date();
for (let i = D2SeasonEnum.__LENGTH - 1; i > 0; i--) {
seasonDate = new Date(`${D2SeasonInfo[i].releaseDate}T${D2SeasonInfo[i].resetTime}`);
if (today >= seasonDate) {
return D2SeasonInfo[i].season;
}
}
return 0;
}

export const D2CalculatedSeason: number = getCurrentSeason();
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"dependencies": {
"@types/btoa": "^1.2.3",
"@types/fs-extra": "^9.0.1",
"@types/node": "^14.0.1",
"@types/stringify-object": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^2.34.0",
Expand All @@ -44,7 +45,7 @@
"cross-fetch": "^3.0.4",
"destiny2-manifest": "^2.2.4",
"destiny2-utils": "^2.0.3",
"fs": "^0.0.1-security",
"fs-extra": "^9.0.0",
"gist-client": "^1.1.1",
"npm-run-all": "^4.1.5",
"stringify-object": "^3.3.0",
Expand Down
9 changes: 5 additions & 4 deletions src/generate-season-info.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getAll, loadLocal } from 'destiny2-manifest/node';
import { getCurrentSeason, writeFile } from './helpers';
import { getCurrentSeason, writeFile, copyFile } from './helpers';

import seasons from '../data/seasons/seasons_master.json';
import seasonsInfo from '../data/seasons/d2-season-info';
import { D2SeasonInfo } from '../data/seasons/d2-season-info';

loadLocal();
const inventoryItems = getAll('DestinyInventoryItemDefinition');
Expand All @@ -20,9 +20,10 @@ inventoryItems.forEach((inventoryItem) => {

writeFile('./data/seasons/seasons_master.json', seasons);

const seasonTags = Object.values(seasonsInfo)
.filter((seasonInfo) => seasonInfo.season <= calculatedSeason)
const seasonTags = Object.values(D2SeasonInfo)
.filter((seasonInfo) => seasonInfo.season > 0 && seasonInfo.season <= calculatedSeason)
.map((seasonInfo) => [seasonInfo.seasonTag, seasonInfo.season] as const)
.reduce((acc: Record<string, number>, [tag, num]) => ((acc[tag] = num), acc), {});

writeFile('./output/season-tags.json', seasonTags);
copyFile('./data/seasons/d2-season-info.ts', './output/d2-season-info.ts');
Loading