@sparted/shared-library 1.7.36 → 1.7.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,10 +40,9 @@ export type BaseCampaignCardDetails = {
|
|
|
40
40
|
description: MultilingualLabel;
|
|
41
41
|
utcStartDate: string;
|
|
42
42
|
utcEndDate: string;
|
|
43
|
-
};
|
|
44
|
-
export type WikiCardDetails = BaseCampaignCardDetails & {
|
|
45
43
|
contentCount: number;
|
|
46
44
|
};
|
|
45
|
+
export type WikiCardDetails = BaseCampaignCardDetails;
|
|
47
46
|
export type WikiCardPlayerInteraction = {
|
|
48
47
|
contentPlayedCount: number;
|
|
49
48
|
favorite: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { Points } from './score';\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n coverImage: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails
|
|
1
|
+
{"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { Points } from './score';\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n coverImage: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n contentCount: number;\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedCount: number;\n favorite: boolean;\n};\n\nexport type WikiCard = {\n details: WikiCardDetails;\n playerInteraction: WikiCardPlayerInteraction;\n};\n\nexport type WikiContentCardDetails = {\n id: number;\n coverImage: string;\n title: MultilingualLabel;\n session: number;\n};\n\nexport type WikiContentCard = {\n contentDetails: WikiContentCardDetails;\n points: Points;\n};\n\nexport type CampaignCardScheduling = {\n type: 'flexible' | 'intense';\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n sessionCount: number;\n};\n\nexport type LiveCampaignCardDetails = BaseCampaignCardDetails & CampaignCardScheduling;\n\nexport type CampaignCardAchievement = {\n lastSessionPlayed: number;\n points: Points;\n};\n\nexport type SessionInsight = {\n sessionNumber: number;\n gameTypes: GameType[];\n};\n\nexport type LiveCampaignCard = {\n details: LiveCampaignCardDetails;\n achievement: CampaignCardAchievement;\n sessionInsights: SessionInsight[];\n};\n\nexport const isCampaignSchedulingRandom = (scheduling: CampaignScheduling): scheduling is RandomCampaignScheduling =>\n scheduling.mode === 'random';\n\nexport const isCampaignSchedulingManual = (scheduling: CampaignScheduling): scheduling is ManualCampaignScheduling =>\n scheduling.mode === 'manual';\n\nexport const isWikiCard = (item: unknown): item is WikiCard =>\n typeof item === 'object' && item !== null && 'activityDetails' in item && 'playerInteraction' in item;\n\nexport const computeCurrentSession = (card: LiveCampaignCard): number => {\n const { details, achievement } = card;\n\n if (details.type === 'flexible') {\n return Math.min(achievement.lastSessionPlayed + 1, details.sessionCount);\n }\n\n const today = new Date();\n const startDate = new Date(details.utcStartDate);\n const endData = new Date(details.utcEndDate);\n\n const calculateCurrentSessionAux = (date: Date, currentSession: number): number => {\n if (date >= today || (endData && date >= endData) || currentSession >= details.sessionCount) {\n return currentSession;\n }\n\n const jsDay = date.getDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n const isEnabledDay = details.enabledWeekDays.includes(day);\n const isNotDisabledDate = !details.disabledDates.includes(date.toISOString().slice(0, 10));\n\n const nextSession = isEnabledDay && isNotDisabledDate ? currentSession + 1 : currentSession;\n\n date.setDate(date.getDate() + 1);\n\n return calculateCurrentSessionAux(date, nextSession);\n };\n\n return calculateCurrentSessionAux(startDate, 1);\n};\n"],"names":[],"mappings":";;;;AAsGO,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAExB,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAElB,MAAA,UAAU,GAAG,CAAC,IAAa,KACtC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,iBAAiB,IAAI,IAAI,IAAI,mBAAmB,IAAI,KA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