Skip to content

Commit

Permalink
feat: add 1999 calendar (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayerOrnstein authored Dec 19, 2024
1 parent 1544d87 commit 1eb91a8
Show file tree
Hide file tree
Showing 5 changed files with 1,759 additions and 4,157 deletions.
3 changes: 3 additions & 0 deletions lib/WorldState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import WorldEvent from './models/WorldEvent.js';
import News from './models/News.js';
import Kinepage from './models/Kinepage.js';
import DeepArchimedea from './models/DeepArchidemea.js';
import Calendar from './models/Calendar.js';

const { sortieData } = wsData;

Expand Down Expand Up @@ -376,6 +377,8 @@ export class WorldState {
*/
this.deepArchimedea = new DeepArchimedea(activation, expiry, tmp.lqo27);
}

this.calendar = parseArray(Calendar, data.KnownCalendarSeasons, deps);
}
}

Expand Down
59 changes: 59 additions & 0 deletions lib/models/Calendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
languageDesc,
languageString,
parseDate,
translateCalendarEvent,
translateSeason,
} from 'warframe-worldstate-data/utilities';

const EventTypes = Object.freeze({
PLOT: 'CET_PLOT',
REWARD: 'CET_REWARD',
CHALLENGE: 'CET_CHALLENGE',
UPGRADE: 'CET_UPGRADE',
});

/**
* Event data for a 1999 calendar day
* @param {object} event raw event data
*/
class DayEvent {
constructor(event) {
this.type = translateCalendarEvent(event.type);

if (event.challenge) this.challenge = this.eventDescription(event.challenge);

if (event.upgrade) this.upgrade = this.eventDescription(event.upgrade);

if (event.reward) this.reward = languageString(event.reward);

if (event.type === EventTypes.PLOT) {
this.dialogueName = event.dialogueName;
this.dialogueConvo = event.dialogueConvo;
}
}

eventDescription(name) {
return { title: languageString(name), description: languageDesc(name) };
}
}

export default class Calendar {
constructor(calendar) {
this.activation = parseDate(calendar.Activation);

this.expiry = parseDate(calendar.Expiry);

this.days = Array.isArray(calendar.Days)
? calendar.Days.filter(Boolean).map((d) => ({ ...d, events: d.events.map((e) => new DayEvent(e)) }))
: [];

this.season = translateSeason(calendar.Season);

this.yearIteration = calendar.YearIteration;

this.version = calendar.Version;

this.requirements = calendar.UpgradeAvaliabilityRequirements;
}
}
Loading

0 comments on commit 1eb91a8

Please sign in to comment.