Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { DateTime, Duration } from 'luxon'
import { FluidType } from 'enum/fluid.enum'
export enum TypeChallenge {
CHALLENGE = 0,
ACHIEVEMENT = 1,
}
export class ChallengeType {
id: string
type: TypeChallenge
title: string
description: string
level: number
duration: Duration
fluidTypes: FluidType[]
availableEcogestures: EcogestureType[]
constructor(
id: string,
type: TypeChallenge,
title: string,
description: string,
level: number,
duration: Duration,
fluidTypes: FluidType[],
availaibleEcogestures: EcogestureType[]
) {
this.id = id
this.type = type
this.title = title
this.description = description
this.level = level
this.duration = duration
this.fluidTypes = fluidTypes
this.availableEcogestures = availaibleEcogestures
}
}
export class EcogestureType {
id: string
shortName: string
longName: string
shortDescription: string
longDescription: string
usage: string
fluidTypes: FluidType[]
nwh: number
unlocked?: boolean
constructor(
id: string,
shortName: string,
longName: string,
shortDescription: string,
longDescription: string,
usage: string,
fluidTypes: FluidType[],
nwh: number,
unlocked?: boolean
) {
this.id = id
this.shortName = shortName
this.shortDescription = shortDescription
this.longName = longName
this.longDescription = longDescription
this.usage = usage
this.fluidTypes = fluidTypes
this.nwh = nwh
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
this.unlocked = unlocked
}
}
export enum ChallengeState {
ONGOING = 0,
FINISHED = 1,
ABANDONED = 2,
}
export enum SelectView {
BADGES = 0,
ECOGESTURES = 1,
}
export enum BadgeState {
FAILED = 0,
SUCCESS = 1,
}
export class UserChallenge {
id?: string
startingDate: DateTime
endingDate: DateTime
state: ChallengeState
selectedEcogestures: EcogestureType[]
challengeType: ChallengeType | null
maxEnergy: number
currentEnergy: number
badge: BadgeState | null
constructor(
startingDate: DateTime,
endingDate: DateTime,
state: ChallengeState,
selectedEcogestures: EcogestureType[],
challengeType: ChallengeType | null,
maxEnergy: number,
currentEnergy: number,
badge: BadgeState | null,
id?: string
) {
this.startingDate = startingDate
this.endingDate = endingDate
this.state = state
this.selectedEcogestures = selectedEcogestures
this.challengeType = challengeType
this.maxEnergy = maxEnergy
this.currentEnergy = currentEnergy
this.badge = badge
this.id = id
}
public hasChallengeEnded(): boolean {
// TO DO: logic to check if the challenges has ended
return false
}
}
export class UserProfile {
id: string
level: number
challengeTypeHash: string
ecogestureHash: string
constructor(
id: string,
level: number,
challengeTypeHash: string,
ecogestureHash: string
) {
this.id = id
this.level = level
this.challengeTypeHash = challengeTypeHash
this.ecogestureHash = ecogestureHash
}
}
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface IChallengeManager {
getCurrentChallenge(withEcogestures?: boolean): Promise<UserChallenge | null>
updateChallengeState(
id: string,
newState: number
): Promise<UserChallenge | null>
cancelChallenge(id: string): Promise<UserChallenge | null>
fulfillChallenge(challenge: UserChallenge): Promise<UserChallenge | null>
startChallenge(
challenge: ChallengeType,
fluidTypes: FluidType[],
selectedEcogestes: EcogestureType[]
): Promise<UserChallenge | null>
getAvailableChallenges(
fluidTypes?: FluidType[]
): Promise<ChallengeType[] | null>
getUnlockedBadges(): Promise<ChallengeType[] | null>
getUnlockedEcogestures(): Promise<EcogestureType[] | null>
}
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface IUserProfileManager {
getUserProfile(): Promise<UserProfile | null>
}