@sparted/shared-library 1.7.36 → 1.7.38
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Content, GameType } from './content';
|
|
2
2
|
import type { Image } from './media';
|
|
3
3
|
import type { MultilingualLabel } from './multilingual';
|
|
4
|
-
import type { Points } from './score';
|
|
4
|
+
import type { Points, Stars } from './score';
|
|
5
5
|
export type CampaignInformations = {
|
|
6
6
|
coverImage: Image;
|
|
7
7
|
name: MultilingualLabel;
|
|
@@ -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;
|
|
@@ -72,6 +71,7 @@ export type CampaignCardScheduling = {
|
|
|
72
71
|
export type LiveCampaignCardDetails = BaseCampaignCardDetails & CampaignCardScheduling;
|
|
73
72
|
export type CampaignCardAchievement = {
|
|
74
73
|
lastSessionPlayed: number;
|
|
74
|
+
stars: Stars;
|
|
75
75
|
points: Points;
|
|
76
76
|
};
|
|
77
77
|
export type SessionInsight = {
|
|
@@ -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, Stars } 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 stars: Stars;\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":";;;;AAuGO,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,KAAK;AAE3F,MAAA,qBAAqB,GAAG,CAAC,IAAsB,KAAY;AACtE,IAAA,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;AAEtC,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE;AAC/B,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,iBAAiB,GAAG,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;AAC1E,KAAA;AAED,IAAA,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C,IAAA,MAAM,0BAA0B,GAAG,CAAC,IAAU,EAAE,cAAsB,KAAY;AAChF,QAAA,IAAI,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,cAAc,IAAI,OAAO,CAAC,YAAY,EAAE;AAC3F,YAAA,OAAO,cAAc,CAAC;AACvB,SAAA;AAED,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAC5B,QAAA,MAAM,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAEpC,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3D,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAE3F,QAAA,MAAM,WAAW,GAAG,YAAY,IAAI,iBAAiB,GAAG,cAAc,GAAG,CAAC,GAAG,cAAc,CAAC;QAE5F,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AAEjC,QAAA,OAAO,0BAA0B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AACvD,KAAC,CAAC;AAEF,IAAA,OAAO,0BAA0B,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAClD;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"score.js","sources":["../../../src/business/types/score.ts"],"sourcesContent":["export type Points = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Timer = {\n timespent: number;\n timeout: boolean;\n};\n\nexport type BaseScore = {\n id?: number;\n playerId: number;\n contentId: number;\n points: Points;\n timer: Timer;\n createdAt: Date;\n};\n\nexport type CampaignScore = BaseScore & {\n campaignId: number;\n sessionNumber?: number; // TODO: should be required after conversion\n};\n\nexport type BattleScore = BaseScore & {\n battleId: number;\n};\n\nexport type Score = CampaignScore | BattleScore;\n\nexport const isCampaignScore = (score: Score): score is CampaignScore => 'campaignId' in score;\nexport const isBattleScore = (score: Score): score is BattleScore => 'battleId' in score;\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"score.js","sources":["../../../src/business/types/score.ts"],"sourcesContent":["export type Points = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Stars = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Timer = {\n timespent: number;\n timeout: boolean;\n};\n\nexport type BaseScore = {\n id?: number;\n playerId: number;\n contentId: number;\n points: Points;\n timer: Timer;\n createdAt: Date;\n};\n\nexport type CampaignScore = BaseScore & {\n campaignId: number;\n sessionNumber?: number; // TODO: should be required after conversion\n};\n\nexport type BattleScore = BaseScore & {\n battleId: number;\n};\n\nexport type Score = CampaignScore | BattleScore;\n\nexport const isCampaignScore = (score: Score): score is CampaignScore => 'campaignId' in score;\nexport const isBattleScore = (score: Score): score is BattleScore => 'battleId' in score;\n"],"names":[],"mappings":";;;;AAqCO,MAAM,eAAe,GAAG,CAAC,KAAY,KAA6B,YAAY,IAAI,MAAM;AACxF,MAAM,aAAa,GAAG,CAAC,KAAY,KAA2B,UAAU,IAAI;;;;;"}
|