cbt-game-generator
v1.0.72
Published
Configuration generator for CBT animation apps
Readme
CBT Game Generator
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
npm install -g cbt-game-generatorUsage
- Create a
config.jsonfile in your project:
{
"skillName": "expressive-skill",
"gameName": "LabelPlaces",
"gameType": "SPEECH",
"numberOfVariants": 3,
"targets": {
"sub-lo-1": ["ZOO", "PARK", "SCHOOL"],
"sub-lo-2": ["MARKET", "HOSPITAL", "LIBRARY"]
}
}- Run the generator:
cbt-game-generator --config config.jsonOr specify the config file path:
cbt-game-generator --config path/to/your/config.jsonIncremental Updates
To add a new sub-level to an existing game configuration, create a config file with only the new sub-level:
{
"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:
cbt-game-generator --config config.jsonThe generator will:
- Update existing type definitions
- Add new variants to the configuration
- Generate new variant files
- Update the Main component
- Create new asset directories
Config File Format
| 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:
Textures Directory:
- Contains
.webpfiles for backgrounds - Contains
.jsonfiles for Lottie animations - Organized by sub-levels
- Contains
Videos Directory:
- Contains
.mp4files for face prompts - Contains
*_half.mp4files for half face prompts - Organized by sub-levels
- Contains
Placeholder files are created for all required assets. You can replace these with your actual asset files.
