### Install UI and Core Packages Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/intro.md Install both the core game engine and the UI components packages using bun. ```bash bun add @react-text-game/core @react-text-game/ui ``` -------------------------------- ### Initialize and Run a Basic Text Game Source: https://github.com/laruss/react-text-game/blob/main/README.md This example demonstrates the core setup for a React Text Game. It initializes the game, creates a player entity, defines an introductory passage, and renders the game UI. Ensure all necessary imports are included. ```tsx import { Game, createEntity, newStory } from "@react-text-game/core"; import { GameProvider, PassageController } from "@react-text-game/ui"; import "@react-text-game/ui/styles"; // Initialize the game await Game.init({ gameId: "my-game", gameName: "My Adventure", translations: { defaultLanguage: "en", fallbackLanguage: "en", resources: { en: { passages: { intro: "Welcome to the Game", }, }, }, }, }); // Create a game entity (factory-first approach) const player = createEntity("player", { name: "Hero", stats: { health: 100, mana: 50, }, inventory: [] as string[], }); // Create a story passage const intro = newStory("intro", () => [ { type: "header", content: "Welcome to the Game", props: { level: 1 }, }, { type: "text", content: `Hello, ${player.name}!`, }, { type: "actions", content: [ { label: "Start Adventure", action: () => Game.jumpTo("chapter-1"), }, ], }, ]); // React component function App() { return ( ); } // Start the game Game.jumpTo(intro); ``` -------------------------------- ### Install @react-text-game/core Source: https://github.com/laruss/react-text-game/blob/main/packages/core/README.md Install the core package using your preferred package manager. ```bash # bun bun add @react-text-game/core # npm npm install @react-text-game/core # yarn yarn add @react-text-game/core # pnpm pnpm add @react-text-game/core ``` -------------------------------- ### Install Core Package Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/intro.md Install the core game engine package using bun. ```bash bun add @react-text-game/core ``` -------------------------------- ### Bun Development Setup Commands Source: https://github.com/laruss/react-text-game/blob/main/README.md These bash commands outline the development workflow for a Turborepo monorepo using Bun. They cover dependency installation, running in watch mode, building, type checking, linting, and code formatting. ```bash # Install dependencies bun install # Run all packages in watch mode bun run dev # Build all packages bun run build # Type checking bun run check-types # Linting bun run lint # Code formatting bun run format ``` -------------------------------- ### Start Local Development Server Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/README.md Starts a local development server and opens the project in a browser. Changes are reflected live without server restarts. ```bash yarn start ``` -------------------------------- ### Install Project Dependencies with Bun Source: https://github.com/laruss/react-text-game/blob/main/apps/core-test-app/README.md Use this command to install all necessary packages for the project. Ensure Bun is installed globally. ```bash bun install ``` -------------------------------- ### Install MDX, Core, and MDX.js Packages Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/intro.md Install the MDX integration package along with its core dependencies using bun. ```bash bun add @react-text-game/mdx @react-text-game/core @mdx-js/mdx @mdx-js/react ``` -------------------------------- ### Basic GameProvider Setup Source: https://context7.com/laruss/react-text-game/llms.txt Wrap your application with GameProvider to initialize the game. Configure game ID, name, development mode, and translations. ```typescript import { GameProvider, PassageController } from "@react-text-game/ui"; import "@react-text-game/ui/styles"; // Basic setup function App() { return ( ); } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/README.md Installs project dependencies using Yarn. Run this command after cloning the repository. ```bash yarn ``` -------------------------------- ### Install Core and UI Packages Source: https://github.com/laruss/react-text-game/blob/main/README.md Install the core engine and UI components for React Text Game. Use npm, yarn, or pnpm. ```bash bun add @react-text-game/core @react-text-game/ui npm install @react-text-game/core @react-text-game/ui ``` -------------------------------- ### Basic Setup with Core + UI Packages Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/getting-started.md Set up the game using the UI package for a complete interface. Wrap your game with GameProvider and use PassageController. ```tsx // src/App.tsx import { GameProvider, PassageController } from "@react-text-game/ui"; export function App() { return ( ); } ``` -------------------------------- ### Basic Setup with Core Package Only Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/getting-started.md Initialize the game engine and define entities and stories for a text-based game. Ensure Game.init is called before other game operations. ```tsx import { Game, createEntity, newStory } from "@react-text-game/core"; // IMPORTANT: Initialize the game first await Game.init({ gameName: "My Text Adventure", isDevMode: true, }); // Create game entities const player = createEntity("player", { name: "Hero", health: 100, }); // Create story passages const intro = newStory("intro", () => [ { type: "header", content: "Welcome!", props: { level: 1 }, }, { type: "text", content: "Your adventure begins...", }, ]); // Start the game Game.jumpTo(intro); ``` -------------------------------- ### Install react-text-game Packages Source: https://github.com/laruss/react-text-game/blob/main/packages/ui/README.md Install the core and UI packages for react-text-game using your preferred package manager. ```bash # Bun (repo default) bun add @react-text-game/core @react-text-game/ui ``` ```bash # npm npm install @react-text-game/core @react-text-game/ui ``` ```bash # yarn yarn add @react-text-game/core @react-text-game/ui ``` -------------------------------- ### Install React Text Game Core + UI Packages Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/getting-started.md Install both the core engine and UI components for a complete solution. Supports Bun, npm, yarn, and pnpm. ```bash # Bun bun add @react-text-game/core @react-text-game/ui # npm npm install @react-text-game/core @react-text-game/ui # yarn yarn add @react-text-game/core @react-text-game/ui # pnpm pnpm add @react-text-game/core @react-text-game/ui ``` -------------------------------- ### Run Production Build with Bun Source: https://github.com/laruss/react-text-game/blob/main/apps/core-test-app/README.md Execute this command to start the application in a production-ready environment. This command is used after the project has been built for deployment. ```bash bun start ``` -------------------------------- ### Run Development Server Source: https://github.com/laruss/react-text-game/blob/main/apps/ui-test-app/README.md Use these commands to start the development server for the Next.js project. Open http://localhost:3000 in your browser to view the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Install React Text Game Core Package Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/getting-started.md Install the core engine package for building your own UI. Supports Bun, npm, yarn, and pnpm. ```bash # Bun bun add @react-text-game/core # npm npm install @react-text-game/core # yarn yarn add @react-text-game/core # pnpm pnpm add @react-text-game/core ``` -------------------------------- ### Run Docusaurus Documentation Site Source: https://github.com/laruss/react-text-game/blob/main/CLAUDE.md This command starts the Docusaurus documentation site locally. ```bash # Documentation site (Docusaurus) bun run docs ``` -------------------------------- ### Install MDX Support Source: https://github.com/laruss/react-text-game/blob/main/README.md Optionally install MDX support for Markdown-based passages, including the MDX package and its dependencies. Use npm, yarn, or pnpm. ```bash # Optional: Add MDX support for Markdown-based passages bun add @react-text-game/mdx @mdx-js/mdx @mdx-js/react # Or use npm/yarn/pnpm npm install @react-text-game/mdx @mdx-js/mdx @mdx-js/react ``` -------------------------------- ### Install @react-text-game/mdx with Peer Dependencies Source: https://github.com/laruss/react-text-game/blob/main/packages/mdx/README.md Install the MDX package along with its required peer dependencies using your preferred package manager. ```bash # Using Bun bun add @react-text-game/mdx @react-text-game/core @mdx-js/mdx @mdx-js/react ``` ```bash # Using npm npm install @react-text-game/mdx @react-text-game/core @mdx-js/mdx @mdx-js/react ``` ```bash # Using yarn yarn add @react-text-game/mdx @react-text-game/core @mdx-js/mdx @mdx-js/react ``` ```bash # Using pnpm pnpm add @react-text-game/mdx @react-text-game/core @mdx-js/mdx @mdx-js/react ``` -------------------------------- ### Install MDX Package Dependencies Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/mdx-integration.md Install the @react-text-game/mdx package along with its peer dependencies using Bun or npm. ```bash # Using Bun bun add @react-text-game/mdx @mdx-js/mdx @mdx-js/react # Using npm npm install @react-text-game/mdx @mdx-js/mdx @mdx-js/react ``` -------------------------------- ### Quick Game Initialization and Setup Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/intro.md Initialize the game engine, create a player entity, define an introductory story passage, and navigate to it. Ensure Game.init is called before other game operations. ```tsx import { Game, createEntity, newStory } from "@react-text-game/core"; // Initialize the game first (required!) await Game.init({ gameName: "My Text Adventure", isDevMode: true, }); // Create a game entity const player = createEntity("player", { name: "Hero", health: 100, }); // Create a story passage const intro = newStory("intro", () => [ { type: "header", content: "Welcome to the Game", props: { level: 1 }, }, { type: "text", content: `Hello, ${player.name}!`, }, { type: "actions", content: [ { label: "Start Adventure", action: () => Game.jumpTo("adventure"), }, ], }, ]); // Navigate to passage Game.jumpTo(intro); ``` -------------------------------- ### Example MDX Passage Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/intro.md An example of an MDX passage demonstrating how to import components and entities, and define actions within a narrative. ```mdx --- passageId: intro --- import { Action, Actions } from "@react-text-game/mdx"; import { player } from "../entities/player"; # Welcome, {player.name}! Your adventure begins in a dark forest... Game.jumpTo("forest")}>Enter the forest ``` -------------------------------- ### Run Development Mode Source: https://github.com/laruss/react-text-game/blob/main/CLAUDE.md Use this command to start all workspaces in watch mode for development. ```bash # Development (runs all workspaces in watch mode) bun run dev ``` -------------------------------- ### Quick Start: Initialize Game and Create Player Source: https://github.com/laruss/react-text-game/blob/main/packages/core/README.md Initialize the game and create a player entity. Direct property updates on entities are automatically reactive. Use `player.save()` to persist manual changes. ```tsx import { Game, createEntity, newStory } from "@react-text-game/core"; // IMPORTANT: Initialize the game first await Game.init({ gameName: "My Adventure", translations: { defaultLanguage: "en", fallbackLanguage: "en", resources: { en: { passages: { intro: "Welcome to the Game" }, common: { save: "Save", load: "Load" }, }, ru: { passages: { intro: "Добро пожаловать в игру" }, }, }, }, // ...other options }); // Create a game entity with the factory (recommended) const player = createEntity("player", { name: "Hero", stats: { health: 100, mana: 50, }, inventory: [] as string[], }); // Direct property updates automatically stay reactive player.stats.health -= 10; // Persist manual changes when you need them stored player.save(); // Create a story passage const introStory = newStory("intro", () => [ { type: "header", content: "Welcome to the Game", props: { level: 1 }, }, { type: "text", content: `Hello, ${player.name}!`, }, { type: "actions", content: [ { label: "Start Adventure", action: () => Game.jumpTo("adventure"), }, ], }, ]); // Navigate to passage Game.jumpTo(introStory); ``` -------------------------------- ### Start Development Server with Bun Source: https://github.com/laruss/react-text-game/blob/main/apps/core-test-app/README.md This command launches the development server, enabling hot-reloading and other development features. It's typically used during active development. ```bash bun dev ``` -------------------------------- ### Initialize Game and Register Migrations Source: https://github.com/laruss/react-text-game/blob/main/packages/core/MIGRATIONS.md Initialize the game engine and then register all necessary migrations. This setup ensures that migrations are available before any saves are loaded. ```typescript // src/index.tsx or src/App.tsx import { Game, registerMigration } from "@react-text-game/core"; async function initGame() { await Game.init({ gameName: "My Adventure Game", gameVersion: "2.0.0", // Your current version isDevMode: import.meta.env.DEV, }); // Register all your migrations registerMigration({ from: "1.0.0", to: "1.1.0", description: "Added inventory", migrate: addInventorySystem, }); registerMigration({ from: "1.1.0", to: "2.0.0", description: "Renamed 'hp' to 'health'", migrate: renameHpToHealth, }); } ``` -------------------------------- ### MDX Passage Structure Example Source: https://github.com/laruss/react-text-game/blob/main/CLAUDE.md An example of an MDX file structure, including frontmatter for metadata and content with markdown and custom components. ```mdx --- id: passage-id title: Passage Title tags: [tag1, tag2] --- # Header Text content with **markdown** formatting. [[Link to another passage->other-passage]] ``` -------------------------------- ### Run Changeset Command Source: https://github.com/laruss/react-text-game/blob/main/docs/publish.md Execute this command to initiate the Changesets publishing process. It will guide you through selecting packages and determining the version bump type. ```shell bunx changeset ``` -------------------------------- ### Run Project Tests with Bun Source: https://github.com/laruss/react-text-game/blob/main/CLAUDE.md Execute all project tests using Bun's built-in test runner. Ensure all dependencies are installed before running. ```bash bun test ``` -------------------------------- ### Start Watch Mode Source: https://github.com/laruss/react-text-game/blob/main/docs/todo-i18n-plan.md Initiate watch mode using the CLI to monitor for changes in source files and automatically regenerate translation assets. ```bash # Start watch mode during development bun run rtg-i18n watch # Watches for changes in src/passages/** # Automatically regenerates shadow files and updates JSONs ``` -------------------------------- ### Basic MDX Story File Structure Source: https://github.com/laruss/react-text-game/blob/main/apps/docs/docs/mdx-integration.md Example of an MDX file for a game story, including frontmatter, imports, and basic content with interactive actions. ```mdx --- passageId: intro --- import { Action, Actions } from "@react-text-game/mdx"; import { player } from "../entities/player"; # Welcome to the Adventure Hello, {player.name}! This is your first passage. alert("Started!")}>Start Adventure ``` -------------------------------- ### Using Supported MDX Components Source: https://github.com/laruss/react-text-game/blob/main/packages/mdx/README.md Examples of using package-provided components and standard HTML/Markdown syntax within MDX. Custom React components are not supported. ```mdx {}}>Click ``` ```mdx Hello ``` ```mdx ``` ```mdx