@smartico/public-api 0.0.435 → 0.0.436
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/WSAPI/WSAPITypes.d.ts +2 -2
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +17 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +1 -1
- package/package.json +1 -1
- package/src/MiniGames/SAWGetTemplatesResponse.ts +20 -2
- package/src/WSAPI/WSAPITypes.ts +2 -2
|
@@ -25,7 +25,7 @@ Fields rendered per row:
|
|
|
25
25
|
|---|---|---|
|
|
26
26
|
| Template icon | `template.thumbnail` (or similar) | 1:1 |
|
|
27
27
|
| Prize name | Look up `template.prizes[i]` by `saw_prize_id` | Display the prize's `name`. A spin finalised as lost (`miniGameWinAcknowledgeRequest` with `lose: true`) has no prize attached — render it as a loss. |
|
|
28
|
-
| Prize amount | `template.prizes[i].prize_value` or `prize_amount` | E.g. "100 points" |
|
|
28
|
+
| Prize amount | `template.prizes[i].prize_value` or `prize_amount`; for gems/diamonds prizes `prize_details_json.gems` / `.diamonds`, for raffle-ticket prizes `prize_details_json.tickets_count` | E.g. "100 points", "50 Diamonds". The history row carries the template as sent by the server, where `prize_value` of a gems/diamonds or raffle-ticket prize is only a default — `getMiniGames()` already resolves it into `prize_value` |
|
|
29
29
|
| Spin date | `create_date_ts` | Format as user-local relative time ("2h ago") or short date |
|
|
30
30
|
| Claim status | `is_claimed` | Show check-mark when true; "Pending claim" CTA when false |
|
|
31
31
|
| Acknowledge date | `acknowledge_date_ts` | Only when `is_claimed === true` |
|
package/package.json
CHANGED
|
@@ -6,13 +6,31 @@ import { SAWBuyInType, SAWBuyInTypeNamed } from './SAWBuyInType';
|
|
|
6
6
|
import { SAWExposeUserSpinIdNamed } from './SAWExposeUserSpinId';
|
|
7
7
|
import { SAWGameLayoutNamed } from './SAWGameLayout';
|
|
8
8
|
import { SAWGameType, SAWGameTypeNamed } from './SAWGameType';
|
|
9
|
-
import {
|
|
9
|
+
import { SAWPrize } from './SAWPrize';
|
|
10
|
+
import { MiniGamePrizeTypeNamed, SAWPrizeType } from './SAWPrizeType';
|
|
10
11
|
import { SAWTemplate } from './SAWTemplate';
|
|
11
12
|
|
|
12
13
|
export interface SAWGetTemplatesResponse extends ProtocolResponse {
|
|
13
14
|
templates: SAWTemplate[];
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The amount a prize gives. Gems/diamonds and raffle-ticket prizes carry it in
|
|
19
|
+
* `prize_details_json` (their `prize_value` is only a default), the same way the
|
|
20
|
+
* default Smartico UI reads it; every other type keeps `prize_value`.
|
|
21
|
+
*/
|
|
22
|
+
const sawPrizeValue = (p: SAWPrize): number => {
|
|
23
|
+
const d = p.prize_details_json;
|
|
24
|
+
let n = 0;
|
|
25
|
+
if (p.prize_type_id === SAWPrizeType.GEMS_AND_DIAMONDS && d) {
|
|
26
|
+
// _gems_diamonds_type: 0 gems, 1 diamonds, 2 both
|
|
27
|
+
n = (d._gems_diamonds_type === 1 ? 0 : d.gems || 0) + (d._gems_diamonds_type === 0 ? 0 : d.diamonds || 0);
|
|
28
|
+
} else if (p.prize_type_id === SAWPrizeType.RAFFLE_TICKET && d) {
|
|
29
|
+
n = d.tickets_count || 0;
|
|
30
|
+
}
|
|
31
|
+
return n > 0 ? n : p.prize_value;
|
|
32
|
+
};
|
|
33
|
+
|
|
16
34
|
export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[] => {
|
|
17
35
|
return items.map((r) => {
|
|
18
36
|
const x: TMiniGameTemplate = {
|
|
@@ -66,7 +84,7 @@ export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[]
|
|
|
66
84
|
id: p.saw_prize_id,
|
|
67
85
|
name: p.saw_prize_ui_definition.name,
|
|
68
86
|
prize_type: MiniGamePrizeTypeNamed(p.prize_type_id),
|
|
69
|
-
prize_value: p
|
|
87
|
+
prize_value: sawPrizeValue(p),
|
|
70
88
|
font_size: p.saw_prize_ui_definition.font_size,
|
|
71
89
|
font_size_mobile: p.saw_prize_ui_definition.font_size_mobile,
|
|
72
90
|
icon: p.saw_prize_ui_definition.icon,
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -29,8 +29,8 @@ export interface TMiniGamePrize {
|
|
|
29
29
|
name: string;
|
|
30
30
|
/** The type of the prize — see {@link MiniGamePrizeTypeName} ('no-prize', 'points', 'gems-and-diamonds', 'spin', 'bonus', 'jackpot', 'raffle-ticket', 'mission', 'change-level', 'manual') */
|
|
31
31
|
prize_type: MiniGamePrizeTypeName;
|
|
32
|
-
/**
|
|
33
|
-
* For example for prize
|
|
32
|
+
/** Amount of the prize: points for 'points', attempts for 'spin', gems or diamonds for 'gems-and-diamonds' (their sum when the prize gives both), tickets for 'raffle-ticket'. Not relevant for other types.
|
|
33
|
+
* For example for prize '100 points' the prize_value will be 100, for '100 free spins' 100, for '50 Diamonds' 50.
|
|
34
34
|
*/
|
|
35
35
|
prize_value?: number;
|
|
36
36
|
/** Custom font size in px for rendering the prize name on the game surface (e.g. a wheel sector), desktop */
|