@battle-racing/br-common-lib 6.2.0-rc.8 → 6.2.0
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/.claude/settings.local.json +8 -0
- package/dist/data/all-tutorial-steps.js +37 -0
- package/dist/domains/arcade/Arcade.const.d.ts +9 -0
- package/dist/domains/arcade/Arcade.const.js +12 -0
- package/dist/domains/arcade/Arcade.schema.d.ts +83 -0
- package/dist/domains/arcade/Arcade.schema.js +48 -0
- package/dist/domains/arcade/Arcade.types.d.ts +11 -0
- package/dist/domains/arcade/Arcade.types.js +2 -0
- package/dist/domains/arcade/index.d.ts +3 -0
- package/dist/domains/arcade/index.js +19 -0
- package/dist/domains/command/Command.schema.d.ts +24 -4
- package/dist/domains/command/Command.schema.js +10 -2
- package/dist/domains/flow/Flow.schema.d.ts +10 -2
- package/dist/domains/game/Game.schema.d.ts +1 -1
- package/dist/domains/game/Game.schema.js +1 -1
- package/dist/domains/game/battle/Battle.schema.d.ts +1 -2
- package/dist/domains/game/battle/Battle.schema.js +0 -1
- package/dist/domains/game/race/Race.schema.d.ts +2 -3
- package/dist/domains/game/race/Race.schema.js +0 -1
- package/dist/domains/gameTrack/GameTrack.schema.d.ts +4 -0
- package/dist/domains/gameTrack/GameTrack.schema.js +2 -0
- package/dist/domains/hardware/KartHardwareState.schema.d.ts +4 -1
- package/dist/domains/hardware/KartHardwareState.schema.js +2 -1
- package/dist/domains/hardware/ModuleStatus.schema.d.ts +5 -0
- package/dist/domains/hardware/rgb/RGB.const.d.ts +4 -0
- package/dist/domains/hardware/rgb/RGB.const.js +5 -1
- package/dist/domains/hardware/rgb/RGB.schema.d.ts +21 -0
- package/dist/domains/hardware/rgb/RGB.schema.js +8 -1
- package/dist/domains/hardware/rgb/RGB.types.d.ts +3 -1
- package/dist/domains/hardware/screen/ScreenDebug.schema.d.ts +4 -1
- package/dist/domains/kart/Kart.schema.d.ts +4 -1
- package/dist/domains/powerUp/PowerUp.schema.d.ts +30 -6
- package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.d.ts +13 -0
- package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.js +2 -0
- package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.d.ts +7 -0
- package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.js +10 -0
- package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.d.ts +9 -0
- package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.js +2 -0
- package/dist/domains/socket/serverToClient/SocketWebAppServerToClientEventsParams.d.ts +4 -0
- package/dist/domains/socket/utils/SocketParamsToEventsWithAck.d.ts +5 -0
- package/dist/domains/socket/utils/SocketParamsToEventsWithAck.js +2 -0
- package/dist/domains/tutorial/Tutorial.const.d.ts +0 -2
- package/dist/domains/tutorial/Tutorial.const.js +1 -16
- package/dist/domains/tutorial/Tutorial.schema.d.ts +45 -31
- package/dist/domains/tutorial/Tutorial.schema.js +21 -23
- package/dist/domains/tutorial/Tutorial.types.d.ts +4 -2
- package/dist/domains/tutorial/TutorialConfig.schema.d.ts +33 -6
- package/dist/domains/tutorial/TutorialConfig.schema.js +1 -0
- package/dist/domains/utils/Utils.schema.d.ts +2 -0
- package/dist/domains/utils/Utils.schema.js +8 -3
- package/dist/domains/wallet/Wallet.const.d.ts +4 -0
- package/dist/domains/wallet/Wallet.const.js +7 -0
- package/dist/domains/wallet/Wallet.schema.d.ts +57 -0
- package/dist/domains/wallet/Wallet.schema.js +43 -0
- package/dist/domains/wallet/Wallet.types.d.ts +9 -0
- package/dist/domains/wallet/Wallet.types.js +2 -0
- package/dist/domains/wallet/index.d.ts +3 -0
- package/dist/domains/wallet/index.js +19 -0
- package/package.json +1 -1
- package/src/data/all-tutorial-steps.ts +41 -0
- package/src/domains/command/Command.schema.ts +10 -2
- package/src/domains/game/Game.schema.ts +1 -1
- package/src/domains/game/battle/Battle.schema.ts +0 -1
- package/src/domains/game/race/Race.schema.ts +0 -1
- package/src/domains/gameTrack/GameTrack.schema.ts +2 -0
- package/src/domains/hardware/KartHardwareState.schema.ts +3 -2
- package/src/domains/hardware/rgb/RGB.const.ts +5 -0
- package/src/domains/hardware/rgb/RGB.schema.ts +10 -1
- package/src/domains/hardware/rgb/RGB.types.ts +4 -0
- package/src/domains/socket/serverToClient/SocketWebAppServerToClientEventsParams.ts +2 -0
- package/src/domains/tutorial/Tutorial.const.ts +0 -16
- package/src/domains/tutorial/Tutorial.schema.ts +22 -22
- package/src/domains/tutorial/Tutorial.types.ts +6 -3
- package/src/domains/tutorial/TutorialConfig.schema.ts +1 -0
- package/src/domains/utils/Utils.schema.ts +8 -3
|
@@ -3,6 +3,7 @@ import type { GameTrack } from '../../gameTrack';
|
|
|
3
3
|
import type { Kart } from '../../kart';
|
|
4
4
|
import type { CheckpointEvent } from '../../kartTracking';
|
|
5
5
|
import type { Response } from '../../response';
|
|
6
|
+
import type { TutorialSession } from '../../tutorial';
|
|
6
7
|
import type { MacAddressGameTrackConnections } from '../inputs';
|
|
7
8
|
import type { SocketHardwareOnDataEventsParams } from '../SocketHardwareOnDataEventsParams';
|
|
8
9
|
|
|
@@ -19,6 +20,7 @@ export interface SocketWebAppServerToClientEventsParams {
|
|
|
19
20
|
checkpointEvent: CheckpointEvent;
|
|
20
21
|
};
|
|
21
22
|
'game:changed': { game: Game };
|
|
23
|
+
'tutorial:session:changed': { session: TutorialSession };
|
|
22
24
|
'gameTracks:onGameTrackUpdated': GameTrack[];
|
|
23
25
|
'gameTracks:connectedRasperries': { macAddress: string }[];
|
|
24
26
|
'gameTracks:list:response': Response<MacAddressGameTrackConnections>;
|
|
@@ -61,19 +61,3 @@ export const TUTORIAL_CHECKPOINT_TARGET = {
|
|
|
61
61
|
export const TUTORIAL_INPUT_SIGNAL_TYPE = {
|
|
62
62
|
STEERING_WHEEL_BUTTON_PRESSED: 'SteeringWheelButtonPressed',
|
|
63
63
|
} as const;
|
|
64
|
-
|
|
65
|
-
export const DRIVING_TUTORIAL_STEPS = [
|
|
66
|
-
TUTORIAL_SCREEN_STEP.PEDAL,
|
|
67
|
-
TUTORIAL_SCREEN_STEP.DRIVE_TO_CONTROLS,
|
|
68
|
-
TUTORIAL_SCREEN_STEP.HUD_OVERVIEW,
|
|
69
|
-
TUTORIAL_SCREEN_STEP.POWER_UP_WAITING,
|
|
70
|
-
TUTORIAL_SCREEN_STEP.POWER_UP_NITRO_READY,
|
|
71
|
-
TUTORIAL_SCREEN_STEP.POWER_UP_RETURN_TO_HUD,
|
|
72
|
-
] as const;
|
|
73
|
-
|
|
74
|
-
export const isDrivingTutorialStep = (step?: string | null): boolean => {
|
|
75
|
-
if (!step) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return (DRIVING_TUTORIAL_STEPS as readonly string[]).includes(step);
|
|
79
|
-
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { startBattleSchema } from '../game/battle/Battle.schema';
|
|
3
|
+
import { gameTypeSchema } from '../game/Game.schema';
|
|
4
|
+
import { startRaceSchema } from '../game/race/Race.schema';
|
|
2
5
|
import { screenTutorialHudSchema } from '../hardware/screen/ScreenTutorial.schema';
|
|
3
6
|
import {
|
|
4
7
|
TUTORIAL_INPUT_SIGNAL_TYPE,
|
|
@@ -59,6 +62,11 @@ export const tutorialSteeringWheelButtonSchema = z.enum([
|
|
|
59
62
|
TUTORIAL_STEERING_WHEEL_BUTTON.ANY,
|
|
60
63
|
]);
|
|
61
64
|
|
|
65
|
+
export const tutorialInputButtonSchema = z.enum([
|
|
66
|
+
TUTORIAL_STEERING_WHEEL_BUTTON.RIGHT,
|
|
67
|
+
TUTORIAL_STEERING_WHEEL_BUTTON.LEFT,
|
|
68
|
+
]);
|
|
69
|
+
|
|
62
70
|
export const tutorialCheckpointTargetSchema = z.enum([
|
|
63
71
|
TUTORIAL_CHECKPOINT_TARGET.TRACK,
|
|
64
72
|
TUTORIAL_CHECKPOINT_TARGET.POWER_UP,
|
|
@@ -79,7 +87,7 @@ export const tutorialKartSnapshotSchema = z.object({
|
|
|
79
87
|
awaitingCheckpointTarget: tutorialCheckpointTargetSchema.nullable().optional(),
|
|
80
88
|
latestCheckpointId: z.string().optional(),
|
|
81
89
|
latestCheckpointProgress: z.number().optional(),
|
|
82
|
-
updatedAtISO: z.
|
|
90
|
+
updatedAtISO: z.iso.datetime(),
|
|
83
91
|
});
|
|
84
92
|
|
|
85
93
|
export const tutorialInputSignalTypeSchema = z.enum([TUTORIAL_INPUT_SIGNAL_TYPE.STEERING_WHEEL_BUTTON_PRESSED]);
|
|
@@ -89,12 +97,12 @@ export const tutorialKartEventBaseSchema = z.object({
|
|
|
89
97
|
deviceId: z.string().min(1),
|
|
90
98
|
revision: z.number().int().nonnegative(),
|
|
91
99
|
sequence: z.number().int().nonnegative(),
|
|
92
|
-
originTimestampISO: z.
|
|
100
|
+
originTimestampISO: z.iso.datetime(),
|
|
93
101
|
});
|
|
94
102
|
|
|
95
103
|
export const tutorialSteeringWheelButtonPressedSchema = tutorialKartEventBaseSchema.extend({
|
|
96
104
|
type: z.literal(TUTORIAL_INPUT_SIGNAL_TYPE.STEERING_WHEEL_BUTTON_PRESSED),
|
|
97
|
-
button:
|
|
105
|
+
button: tutorialInputButtonSchema,
|
|
98
106
|
});
|
|
99
107
|
|
|
100
108
|
export const tutorialInputSignalSchema = z.discriminatedUnion('type', [tutorialSteeringWheelButtonPressedSchema]);
|
|
@@ -107,7 +115,7 @@ export const tutorialConfigurationSchema = z.object({
|
|
|
107
115
|
});
|
|
108
116
|
|
|
109
117
|
export const tutorialParticipantSchema = z.object({
|
|
110
|
-
|
|
118
|
+
kartGuid: z.string().min(1),
|
|
111
119
|
playerId: z.string().optional(),
|
|
112
120
|
status: tutorialStatusSchema,
|
|
113
121
|
currentPhaseId: tutorialPhaseIdSchema,
|
|
@@ -126,34 +134,26 @@ export const tutorialParticipantSchema = z.object({
|
|
|
126
134
|
})
|
|
127
135
|
.optional(),
|
|
128
136
|
totalDurationSeconds: z.number().int().default(180),
|
|
129
|
-
startedAtISO: z.
|
|
130
|
-
updatedAtISO: z.
|
|
137
|
+
startedAtISO: z.iso.datetime().optional(),
|
|
138
|
+
updatedAtISO: z.iso.datetime(),
|
|
131
139
|
});
|
|
132
140
|
|
|
133
141
|
export const tutorialSessionSchema = z.object({
|
|
134
142
|
id: z.string().min(1),
|
|
135
143
|
gameTurnId: z.string().optional(),
|
|
136
|
-
gameId: z.
|
|
144
|
+
gameId: z.number().int(),
|
|
145
|
+
gameType: gameTypeSchema,
|
|
137
146
|
status: tutorialStatusSchema,
|
|
138
147
|
participants: z.array(tutorialParticipantSchema),
|
|
139
|
-
createdAtISO: z.
|
|
140
|
-
updatedAtISO: z.
|
|
148
|
+
createdAtISO: z.iso.datetime(),
|
|
149
|
+
updatedAtISO: z.iso.datetime(),
|
|
141
150
|
});
|
|
142
151
|
|
|
143
|
-
|
|
144
|
-
gameId: z.number().int(),
|
|
145
|
-
gameType: z.enum(['Race', 'Battle']),
|
|
152
|
+
const startTutorialOptionsSchema = z.object({
|
|
146
153
|
tutorialConfigId: z.string().optional().default('BR_TUTORIAL_DEFAULT'),
|
|
147
|
-
params: z.object({
|
|
148
|
-
laps: z.number().int().optional(),
|
|
149
|
-
lives: z.number().int().optional(),
|
|
150
|
-
coins: z.number().int().min(0).max(254),
|
|
151
|
-
kartsGuids: z.array(z.string()).min(1),
|
|
152
|
-
powerUpsIds: z.array(z.string()).min(1),
|
|
153
|
-
time: z.number().int().min(30).max(1200),
|
|
154
|
-
speedConfig: z.number().int().min(20).max(100),
|
|
155
|
-
playerKartMap: z.record(z.string(), z.string()).optional(),
|
|
156
|
-
}),
|
|
157
154
|
tutorialParams: tutorialConfigurationSchema.optional(),
|
|
158
155
|
});
|
|
159
156
|
|
|
157
|
+
export const startRaceTutorialSchema = startRaceSchema.extend(startTutorialOptionsSchema.shape);
|
|
158
|
+
|
|
159
|
+
export const startBattleTutorialSchema = startBattleSchema.extend(startTutorialOptionsSchema.shape);
|
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
tutorialStatusSchema,
|
|
11
11
|
tutorialSteeringWheelButtonPressedSchema,
|
|
12
12
|
tutorialSteeringWheelButtonSchema,
|
|
13
|
+
tutorialInputButtonSchema,
|
|
13
14
|
tutorialConfigurationSchema,
|
|
14
15
|
tutorialParticipantSchema,
|
|
15
16
|
tutorialSessionSchema,
|
|
16
|
-
|
|
17
|
+
startRaceTutorialSchema,
|
|
18
|
+
startBattleTutorialSchema,
|
|
17
19
|
} from './Tutorial.schema';
|
|
18
20
|
|
|
19
21
|
export type TutorialScreenStep = z.infer<typeof tutorialScreenStepSchema>;
|
|
@@ -21,6 +23,7 @@ export type TutorialStatus = z.infer<typeof tutorialStatusSchema>;
|
|
|
21
23
|
export type TutorialPhaseId = z.infer<typeof tutorialPhaseIdSchema>;
|
|
22
24
|
export type TutorialListenEventOn = z.infer<typeof tutorialListenEventOnSchema>;
|
|
23
25
|
export type TutorialSteeringWheelButton = z.infer<typeof tutorialSteeringWheelButtonSchema>;
|
|
26
|
+
export type TutorialInputButton = z.infer<typeof tutorialInputButtonSchema>;
|
|
24
27
|
export type TutorialCheckpointTarget = z.infer<typeof tutorialCheckpointTargetSchema>;
|
|
25
28
|
export type TutorialKartSnapshot = z.infer<typeof tutorialKartSnapshotSchema>;
|
|
26
29
|
export type TutorialInputSignalType = z.infer<typeof tutorialInputSignalTypeSchema>;
|
|
@@ -29,5 +32,5 @@ export type TutorialInputSignal = z.infer<typeof tutorialInputSignalSchema>;
|
|
|
29
32
|
export type TutorialConfiguration = z.infer<typeof tutorialConfigurationSchema>;
|
|
30
33
|
export type TutorialParticipant = z.infer<typeof tutorialParticipantSchema>;
|
|
31
34
|
export type TutorialSession = z.infer<typeof tutorialSessionSchema>;
|
|
32
|
-
export type
|
|
33
|
-
|
|
35
|
+
export type StartRaceTutorial = z.infer<typeof startRaceTutorialSchema>;
|
|
36
|
+
export type StartBattleTutorial = z.infer<typeof startBattleTutorialSchema>;
|
|
@@ -36,6 +36,7 @@ export const tutorialStepConfigSchema = z.object({
|
|
|
36
36
|
screenStep: tutorialScreenStepSchema,
|
|
37
37
|
listenEvent: tutorialListenEventSchema,
|
|
38
38
|
triggerCommands: z.array(allCommandsConfigSchema),
|
|
39
|
+
executePowerUpId: z.string().optional(),
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export const tutorialPhaseConfigSchema = z.object({
|
|
@@ -5,10 +5,15 @@ export const arithmeticOperatorSchema = z.enum(['+', '-', '*', '/']);
|
|
|
5
5
|
// Regex for SimpleArithmeticString: check for operator followed by numbers
|
|
6
6
|
export const simpleArithmeticStringSchema = z.string().regex(/^[\+\-\*\/]-?\d+(\.\d+)?$/);
|
|
7
7
|
|
|
8
|
-
// Regex for ContextArithmeticString: $variable operator number
|
|
9
|
-
export const kartContextVariableSchema = z.enum([
|
|
8
|
+
// Regex for ContextArithmeticString: $variable, optionally followed by operator number
|
|
9
|
+
export const kartContextVariableSchema = z.enum([
|
|
10
|
+
'$kart.configuredSpeed',
|
|
11
|
+
'$kart.powerUpTime',
|
|
12
|
+
'$kart.tutorialSpeed',
|
|
13
|
+
'$kart.tutorialReturnSpeed',
|
|
14
|
+
]);
|
|
10
15
|
|
|
11
|
-
export const contextArithmeticStringSchema = z.string().regex(/^\$[a-zA-Z0-9\.]
|
|
16
|
+
export const contextArithmeticStringSchema = z.string().regex(/^\$[a-zA-Z0-9\.]+(\s[\+\-\*\/]\s-?\d+(\.\d+)?)?$/);
|
|
12
17
|
|
|
13
18
|
export const arithmeticExpressionSchema = z.union([
|
|
14
19
|
z.number(),
|