cbt-game-generator
Version:
Configuration generator for CBT animation apps
167 lines (137 loc) • 5.02 kB
Markdown
A TypeScript-based library for generating game configurations for CBT (Computer-Based Training) applications. This library helps automate the creation of game configurations with support for multiple variants, sub-levels, and targets.
## Features
- Generate game configurations with multiple variants
- Support for different game types (e.g., SPEECH, VISION, ANIMATION)
- Automatic generation of TypeScript types and interfaces
- Dynamic variant configuration based on targets
- Support for multiple sub-levels (sub-los)
- Asset mapping for various media types (Lottie, WebP/SVG, Audio, Video)
- React component generation for game integration
- Automatic creation of asset directory structure with placeholder files
- Support for incremental updates to add new sub-levels
## Installation
```bash
npm install -g cbt-game-generator
```
## Usage
1. Create a `config.json` file in your project:
```json
{
"skillName": "expressive-skill",
"gameName": "LabelPlaces",
"gameType": "SPEECH",
"numberOfVariants": 3,
"targets": {
"sub-lo-1": ["ZOO", "PARK", "SCHOOL"],
"sub-lo-2": ["MARKET", "HOSPITAL", "LIBRARY"]
}
}
```
2. Run the generator:
```bash
cbt-game-generator --config config.json
```
Or specify the config file path:
```bash
cbt-game-generator --config path/to/your/config.json
```
To add a new sub-level to an existing game configuration, create a config file with only the new sub-level:
```json
{
"skillName": "expressive-skill",
"gameName": "LabelPlaces",
"gameType": "SPEECH",
"numberOfVariants": 3,
"targets": {
"sub-lo-3": ["BEACH", "MOUNTAIN", "FOREST"]
},
"isIncremental": true
}
```
Then run the generator with the same command:
```bash
cbt-game-generator --config config.json
```
The generator will:
1. Update existing type definitions
2. Add new variants to the configuration
3. Generate new variant files
4. Update the Main component
5. Create new asset directories
| Field | Type | Description | Required |
|-------|------|-------------|----------|
| skillName | string | Name of the skill (e.g., 'expressive-skill') | Yes |
| gameName | string | Name of the game (e.g., 'LabelPlaces') | Yes |
| gameType | string | Type of the game ('SPEECH', 'VISION', 'ANIMATION') | Yes |
| numberOfVariants | number | Number of variants per sub-level | Yes |
| targets | object | Mapping of sub-levels to their targets | Yes |
| isIncremental | boolean | Whether this is an incremental update | No |
## Generated Structure
The generator creates the following directory structure:
```
src/experience/games/
└── expressive-skill/
└── label-places/
├── types/
│ ├── configuration.ts
│ └── tagTypes.ts
├── constants/
│ ├── targets.ts
│ ├── variantsConfig.ts
│ └── defaults.ts
├── configuration/
│ ├── game-config/
│ │ ├── gameBaseConfig.ts
│ │ └── function.ts
│ └── variants-config/
│ ├── sub-lo-1/
│ │ ├── variantsBaseConfigSubLo1.ts
│ │ ├── LabelPlacesV1.ts
│ │ ├── LabelPlacesV2.ts
│ │ └── LabelPlacesV3.ts
│ └── sub-lo-2/
│ ├── variantsBaseConfigSubLo2.ts
│ ├── LabelPlacesV4.ts
│ ├── LabelPlacesV5.ts
│ └── LabelPlacesV6.ts
└── Main.tsx
public/assets/
└── expressive-skill/
└── label-places/
├── textures/
│ ├── sub-lo-1/
│ │ ├── zoo.webp
│ │ ├── zoo.json
│ │ ├── park.webp
│ │ ├── park.json
│ │ └── ...
│ └── sub-lo-2/
│ ├── market.webp
│ ├── market.json
│ └── ...
└── videos/
├── sub-lo-1/
│ ├── zoo.mp4
│ ├── zoo_half.mp4
│ ├── park.mp4
│ ├── park_half.mp4
│ └── ...
└── sub-lo-2/
├── market.mp4
├── market_half.mp4
└── ...
```
## Asset Structure
The generator automatically creates the following asset structure:
1. Textures Directory:
- Contains `.webp` files for backgrounds
- Contains `.json` files for Lottie animations
- Organized by sub-levels
2. Videos Directory:
- Contains `.mp4` files for face prompts
- Contains `*_half.mp4` files for half face prompts
- Organized by sub-levels
Placeholder files are created for all required assets. You can replace these with your actual asset files.