-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1544d87
commit 1eb91a8
Showing
5 changed files
with
1,759 additions
and
4,157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.