This commit is contained in:
@@ -7,7 +7,7 @@ import type { GetInventoryResponse } from './inventory.js';
|
|||||||
import type { GetRankingResponse, SubmitScoreRequest } from './leaderboards.js';
|
import type { GetRankingResponse, SubmitScoreRequest } from './leaderboards.js';
|
||||||
import type { PlayerProfile } from './player.js';
|
import type { PlayerProfile } from './player.js';
|
||||||
import type { GetProjectStorageResponse, UpdateProjectStorageRequest } from './project-storage.js';
|
import type { GetProjectStorageResponse, UpdateProjectStorageRequest } from './project-storage.js';
|
||||||
import type { ClaimQuestRequest, ClaimQuestResponse, ListQuestsRequest, ListQuestsResponse } from './quests.js';
|
import type { ClaimQuestRequest, ClaimQuestResponse, ListQuestsRequest, ListQuestsResponse, ReportQuestProgressRequest, ReportQuestProgressResponse } from './quests.js';
|
||||||
import type { ListRemoteConfigsResponse, RemoteConfig } from './remote-config.js';
|
import type { ListRemoteConfigsResponse, RemoteConfig } from './remote-config.js';
|
||||||
import type { GetScenarioRunRequest, GetScenarioRunResponse, HandleScenarioCallbackRequest, HandleScenarioCallbackResponse, TriggerScenarioRequest, TriggerScenarioResponse, UpdateScenarioCounterRequest, UpdateScenarioCounterResponse } from './scenarios.js';
|
import type { GetScenarioRunRequest, GetScenarioRunResponse, HandleScenarioCallbackRequest, HandleScenarioCallbackResponse, TriggerScenarioRequest, TriggerScenarioResponse, UpdateScenarioCounterRequest, UpdateScenarioCounterResponse } from './scenarios.js';
|
||||||
import type { GetStorageResponse, UpdateStorageRequest } from './storage.js';
|
import type { GetStorageResponse, UpdateStorageRequest } from './storage.js';
|
||||||
@@ -201,6 +201,12 @@ export const api = {
|
|||||||
): Promise<RefreshAccessTokenResponse> =>
|
): Promise<RefreshAccessTokenResponse> =>
|
||||||
t.request<RefreshAccessTokenResponse>('POST', '/sdk/v1/authorization/refresh', body),
|
t.request<RefreshAccessTokenResponse>('POST', '/sdk/v1/authorization/refresh', body),
|
||||||
|
|
||||||
|
reportQuestProgress: (
|
||||||
|
t: Transport,
|
||||||
|
body: ReportQuestProgressRequest,
|
||||||
|
): Promise<ReportQuestProgressResponse> =>
|
||||||
|
t.request<ReportQuestProgressResponse>('POST', '/sdk/v1/quests/progress', body),
|
||||||
|
|
||||||
submitScore: (
|
submitScore: (
|
||||||
t: Transport,
|
t: Transport,
|
||||||
path: { slug: string },
|
path: { slug: string },
|
||||||
|
|||||||
@@ -40,3 +40,12 @@ export interface QuestReward {
|
|||||||
"itemId"?: string;
|
"itemId"?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReportQuestProgressRequest {
|
||||||
|
"amount"?: number;
|
||||||
|
"metric"?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportQuestProgressResponse {
|
||||||
|
"completedQuestIds"?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,10 @@ export class QuestsService {
|
|||||||
claim(questId: string): Promise<ClaimQuestResponse> {
|
claim(questId: string): Promise<ClaimQuestResponse> {
|
||||||
return api.claimQuest(this.ctx, { questId });
|
return api.claimQuest(this.ctx, { questId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Reports metric progress; returns ids of quests completed by this report. */
|
||||||
|
async reportProgress(metric: string, amount: number): Promise<string[]> {
|
||||||
|
const response = await api.reportQuestProgress(this.ctx, { metric, amount });
|
||||||
|
return response.completedQuestIds ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user