@smartico/public-api 0.0.307 → 0.0.308
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.
- package/dist/Missions/AchievementTaskPublicMeta.d.ts +5 -0
- package/dist/Missions/MissionsUtils.d.ts +2 -0
- package/dist/Missions/UserAchievementTask.d.ts +5 -0
- package/dist/Missions/index.d.ts +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +38 -1
- package/dist/index.modern.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Missions/AchievementTaskPublicMeta.ts +6 -0
- package/src/Missions/MissionsUtils.ts +47 -0
- package/src/Missions/UserAchievement.ts +15 -11
- package/src/Missions/UserAchievementTask.ts +5 -0
- package/src/Missions/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { IntUtils } from "src/IntUtils";
|
|
1
2
|
import { AchievementAvailabilityStatus } from "./AchievementAvailabilityStatus";
|
|
2
3
|
import { AchievementStatus } from "./AchievementStatus";
|
|
3
4
|
import { UserAchievement } from "./UserAchievement";
|
|
5
|
+
import { UserAchievementTask } from "./UserAchievementTask";
|
|
4
6
|
|
|
5
7
|
export class MissionUtils {
|
|
6
8
|
|
|
@@ -163,4 +165,49 @@ export class MissionUtils {
|
|
|
163
165
|
public static getMs = (ts: number): number => {
|
|
164
166
|
return new Date(ts).getTime();
|
|
165
167
|
}
|
|
168
|
+
|
|
169
|
+
public static replaceFavGameNameTag = (task: UserAchievementTask) => {
|
|
170
|
+
if (!task) {
|
|
171
|
+
return task;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const userStateParams = (task.user_state_params?.map || {});
|
|
175
|
+
const userStateOperator = task.task_public_meta?.user_state_operations;
|
|
176
|
+
const userStateParamsKeys = Object.keys(userStateParams);
|
|
177
|
+
|
|
178
|
+
if (userStateParamsKeys.length === 0 || !userStateOperator) {
|
|
179
|
+
return task;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const operatorsMulti = ['has', '!has'];
|
|
183
|
+
const operatorsPos = ['pos1', 'pos2', 'pos3'];
|
|
184
|
+
|
|
185
|
+
let replacementValue: string = '';
|
|
186
|
+
|
|
187
|
+
userStateParamsKeys.forEach((k: 'core_fav_game_top3' | 'core_fav_game_type_top3') => {
|
|
188
|
+
const operator = userStateOperator[k]?.op;
|
|
189
|
+
|
|
190
|
+
if (operatorsMulti.includes(operator)) {
|
|
191
|
+
const value = userStateParams[k];
|
|
192
|
+
if (value && value.length > 0) {
|
|
193
|
+
replacementValue = value.join(' ,');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (operatorsPos.includes(operator)) {
|
|
198
|
+
const value = userStateParams[k];
|
|
199
|
+
const pos = Number(operator.replace('pos', '')) - 1;
|
|
200
|
+
|
|
201
|
+
if (IntUtils.isNotNull(pos) && value && value[pos]) {
|
|
202
|
+
replacementValue = value[pos];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (replacementValue) {
|
|
208
|
+
task.task_public_meta.name =task.task_public_meta.name.replace('{{suggested_games}}', replacementValue);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return task;
|
|
212
|
+
}
|
|
166
213
|
}
|
|
@@ -83,17 +83,21 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
|
|
|
83
83
|
r.ach_public_meta.label_tag === 'custom' ? r.ach_public_meta.custom_label_tag : r.ach_public_meta.label_tag,
|
|
84
84
|
tasks: (r.achievementTasks || [])
|
|
85
85
|
.filter((t) => t.task_type_id === AchievementTaskType.CompleteAchievement)
|
|
86
|
-
.map((t) =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
.map((t) => {
|
|
87
|
+
MissionUtils.replaceFavGameNameTag(t);
|
|
88
|
+
|
|
89
|
+
return ({
|
|
90
|
+
id: t.task_id,
|
|
91
|
+
name: t.task_public_meta?.name,
|
|
92
|
+
points_reward: t.points_reward,
|
|
93
|
+
is_completed: t.isCompleted,
|
|
94
|
+
progress: t.userProgress,
|
|
95
|
+
execution_count_expected: t.executionCount,
|
|
96
|
+
execution_count_actual: t.userExecutedCount,
|
|
97
|
+
display_progress_as_count: t.task_public_meta.display_progress_as_count,
|
|
98
|
+
stage_image: t.task_public_meta.stage_image,
|
|
99
|
+
})
|
|
100
|
+
}),
|
|
97
101
|
related_games: (r.related_games || []).map((g) => ({
|
|
98
102
|
ext_game_id: g.ext_game_id,
|
|
99
103
|
game_public_meta: {
|
package/src/Missions/index.ts
CHANGED