quests: QuestMetrics helpers, README quests section
This commit is contained in:
@@ -53,7 +53,7 @@ stack.
|
|||||||
| `Auth` | `AuthService` | `LoginWithDeviceAsync`, `RefreshAsync`, `Logout`, `AuthStateChanged` |
|
| `Auth` | `AuthService` | `LoginWithDeviceAsync`, `RefreshAsync`, `Logout`, `AuthStateChanged` |
|
||||||
| `Player` | `PlayerService` | `GetProfileAsync` |
|
| `Player` | `PlayerService` | `GetProfileAsync` |
|
||||||
| `BattlePass` | `BattlePassService` | `GetProgressAsync`, `AddXpAsync`, `ClaimRewardAsync`, `PurchasePremiumAsync` |
|
| `BattlePass` | `BattlePassService` | `GetProgressAsync`, `AddXpAsync`, `ClaimRewardAsync`, `PurchasePremiumAsync` |
|
||||||
| `Quests` | `QuestsService` | `ListAsync`, `ClaimAsync` |
|
| `Quests` | `QuestsService` | `ListAsync`, `ClaimAsync`, `ReportProgressAsync` |
|
||||||
| `Stores` | `StoresService` | `ListAsync`, `GetAsync`, `PurchaseAsync` |
|
| `Stores` | `StoresService` | `ListAsync`, `GetAsync`, `PurchaseAsync` |
|
||||||
| `Inventory` | `InventoryService` | `GetAsync` |
|
| `Inventory` | `InventoryService` | `GetAsync` |
|
||||||
| `Leaderboards` | `LeaderboardsService` | `FindBySlug(slug)` → handle: `SubmitAsync`, `ListAsync` |
|
| `Leaderboards` | `LeaderboardsService` | `FindBySlug(slug)` → handle: `SubmitAsync`, `ListAsync` |
|
||||||
@@ -62,6 +62,30 @@ stack.
|
|||||||
| `Storage` | `StorageService` | `GetAsync`, `ListAllAsync`, `SaveAsync`, `DeleteAsync` |
|
| `Storage` | `StorageService` | `GetAsync`, `ListAllAsync`, `SaveAsync`, `DeleteAsync` |
|
||||||
| `Realtime` | `RealtimeService` | `ConnectAsync`, `DisconnectAsync` |
|
| `Realtime` | `RealtimeService` | `ConnectAsync`, `DisconnectAsync` |
|
||||||
|
|
||||||
|
## Quests
|
||||||
|
|
||||||
|
`client.Quests` covers the player's global quests — list with per-objective
|
||||||
|
progress, claim, and metric reports. These are distinct from scenario quest
|
||||||
|
nodes, which advance through `QuestSession` (`Scenario.OnQuest`).
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var quests = await client.Quests.ListAsync();
|
||||||
|
foreach (var quest in quests)
|
||||||
|
{
|
||||||
|
if (quest.Status == "completed")
|
||||||
|
await client.Quests.ClaimAsync(quest.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom metrics advance matching objectives server-side; the call returns
|
||||||
|
// the ids of quests completed by this report.
|
||||||
|
var completedIds = await client.Quests.ReportProgressAsync("kills", 1);
|
||||||
|
```
|
||||||
|
|
||||||
|
Purchase metrics are reported automatically by store purchases;
|
||||||
|
`QuestMetrics.PurchaseOffer(offerId)` / `QuestMetrics.PurchaseItem(itemId)`
|
||||||
|
name the format (`purchase.offer:<offerId>`, `purchase.item:<itemId>`) so
|
||||||
|
quest configs and client code agree on it.
|
||||||
|
|
||||||
## Sessions
|
## Sessions
|
||||||
|
|
||||||
Every API call goes through the client's session pipeline: a 401 triggers a
|
Every API call goes through the client's session pipeline: a 401 triggers a
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace RudderSdk.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builders for the quest metric strings known to the platform. Purchase
|
||||||
|
/// metrics are reported automatically by the shop purchase fan-out; any other
|
||||||
|
/// metric is a custom string reported via
|
||||||
|
/// <see cref="QuestsService.ReportProgressAsync"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class QuestMetrics
|
||||||
|
{
|
||||||
|
/// <summary>Metric for purchasing a store offer; auto-reported on purchase.</summary>
|
||||||
|
public static string PurchaseOffer(string offerId) => $"purchase.offer:{offerId}";
|
||||||
|
|
||||||
|
/// <summary>Metric for purchasing a catalog item; auto-reported on purchase.</summary>
|
||||||
|
public static string PurchaseItem(string itemId) => $"purchase.item:{itemId}";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user