Skip to content

M0nkeyFl0wer/A-Trading-Game-WTF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฐ The Trading Game โ€“ Open Strategy Project

A voice-enabled, character-driven trading game that brings markets to life through personality, sound, and social play. Learn trading through interactive characters who speak, react, and guide you through the excitement of the trading floor.

MIT License React TypeScript pnpm

๐ŸŽฎ Play Now

Development Server Running: http://localhost:3001

โœจ Features

๐ŸŽ™๏ธ Voice-Enabled Characters

  • 5 Unique Trading Personalities with distinct voices via ElevenLabs API
  • Real-time voice announcements for game events
  • Character catchphrases and contextual dialogue
  • Emotional voice tones matching game situations

๐ŸŽญ Visual Character System

  • Animated Character Avatars with 8 expressions each
  • Dynamic particle effects and animations
  • Expression changes based on game events
  • Interactive character selection gallery

๐ŸŽฏ Game Modes

  • Physical Card Game: 17 custom cards with values from -10 to 20
  • Online Multiplayer: Real-time trading with 2-5 players
  • Solo Practice: Play against AI personalities
  • Web3 Integration: Optional crypto-backed micro-stakes (coming soon)

๐Ÿ”ฅ Production-Ready Infrastructure

  • Firebase Authentication & Real-time Database
  • Socket.io for multiplayer functionality
  • CI/CD with GitHub Actions
  • Vercel deployment configuration
  • Environment-based configuration

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • pnpm (npm install -g pnpm)
  • Git

Installation

# Clone the repository
git clone https://github.com/M0nkeyFl0wer/A-Trading-Game-WTF.git
cd A-Trading-Game-WTF

# Install dependencies
pnpm install

# Build workspace packages
pnpm --filter @trading-game/shared build
pnpm --filter @trading-game/core build
pnpm --filter @trading-game/bot build

# Set up environment variables
cp apps/web/.env.example apps/web/.env
# Edit .env with your API keys

Required API Keys

  1. ElevenLabs API (for voice features)

  2. Firebase (for authentication & database)

Development

# Start development server
cd apps/web
pnpm dev

# Access at http://localhost:3000

๐ŸŽจ Meet the Characters

๐ŸŽฐ The Dealer

  • Personality: Professional, neutral, authoritative
  • Voice Style: Calm and measured
  • Catchphrase: "The market waits for no one"

๐Ÿ‚ Bull Runner

  • Personality: Optimistic, aggressive, risk-taker
  • Voice Style: Excited and confident
  • Catchphrase: "To the moon!"

๐Ÿป Bear Necessities

  • Personality: Pessimistic, analytical, conservative
  • Voice Style: Cautious and skeptical
  • Catchphrase: "The crash is coming"

๐Ÿ‹ The Whale

  • Personality: Mysterious, strategic, influential
  • Voice Style: Deep and commanding
  • Catchphrase: "I move markets"

๐Ÿ‘ถ Fresh Trader

  • Personality: Naive, enthusiastic, learning
  • Voice Style: Young and energetic
  • Catchphrase: "YOLO!"

๐Ÿ—๏ธ Architecture

A-Trading-Game-WTF/
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ web/                    # React web application
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ lib/            # Core libraries
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ elevenlabs.ts      # Voice integration
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ firebase.ts        # Firebase config
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ gameRoom.ts        # Multiplayer logic
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ characterVisuals.ts # Visual system
โ”‚       โ”‚   โ”œโ”€โ”€ ui/             # UI components
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ VoiceControls.tsx
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ CharacterAvatar.tsx
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ CharacterGallery.tsx
โ”‚       โ”‚   โ”œโ”€โ”€ hooks/          # Custom React hooks
โ”‚       โ”‚   โ”œโ”€โ”€ pages/          # Page components
โ”‚       โ”‚   โ””โ”€โ”€ contexts/       # React contexts
โ”œโ”€โ”€ packages/                    # Shared packages
โ”‚   โ”œโ”€โ”€ shared/                 # Shared types & utils
โ”‚   โ”œโ”€โ”€ core/                   # Game logic
โ”‚   โ”œโ”€โ”€ bot/                    # AI players
โ”‚   โ””โ”€โ”€ contract/              # Smart contracts
โ”œโ”€โ”€ api/                        # Serverless functions
โ”œโ”€โ”€ .github/workflows/          # CI/CD pipelines
โ””โ”€โ”€ vercel.json                # Deployment config

๐Ÿ”Š Voice Integration

The game features full voice integration with:

  • Pre-game lobby announcements
  • Round start/end notifications
  • Trade confirmations
  • Win/loss reactions
  • Character-specific commentary

Voice Control Features:

  • Toggle on/off
  • Volume control
  • Character selection
  • Manual phrase triggering
  • Queue management for sequential dialogue

๐Ÿ”„ Front-End UX Refresh (Beta Prep)

Recent red-team and UX feedback led to a full lobby and table overhaul:

  • Adaptive Layouts โ€“ lobby/table pages now use responsive cards, skeleton loading states, and accessible ARIA labels.
  • State Management Overhaul โ€“ a normalized zustand store exposes trades, rounds, players, and voice preferences for deterministic renders.
  • Voice Fallbacks โ€“ ElevenLabs requests gracefully downgrade to the browser SpeechSynthesis API (or console logs in SSR/tests) when API keys are missing.
  • Accessible Modals & Controls โ€“ table creation, quoting, and voice controls trap focus, surface live regions, and support keyboard flows.
  • Offline Lobby Cache โ€“ when the realtime backend is offline, the lobby hydrates with sanitized mock table data so QA can rehearse the flow.

๐Ÿ’ณ Payment Portal Scaffold

Navigate to /payments to review the new payment experience skeleton:

  • Multi-Rail Selector โ€“ wallet deposits, card checkout, and ACH transfers with statuses (available, coming soon).
  • Workflow Blueprint โ€“ disabled forms outline required data capture while highlighting integration points (Stripe, Plaid, compliance vendors).
  • Risk & Compliance Sidebar โ€“ checklists reference Travel Rule, AML screening, PCI, and SOC2 tasks surfaced in the security audit.
  • Escrow Notes โ€“ copy documents the pull-payment settlement strategy and latency expectations per network.

โš™๏ธ Everything renders with sandbox placeholders. Replace the disabled buttons with real provider SDK calls once credentials and compliance gates are cleared.

โœ… Verification Checklist

  1. Install & run the web app โ€“ pnpm install && pnpm --filter @trading-game/web dev then open http://localhost:3000.
  2. Lobby smoke test โ€“ ensure the lobby shows skeleton cards, then populated mock tables, and voice controls toggle without errors when ElevenLabs keys are absent (you should see SpeechSynthesis or console fallbacks).
  3. Table experience โ€“ join a table, trigger the quick actions, submit a sample quote, and confirm trades appear in the tape with timestamps.
  4. Payments scaffold โ€“ navigate to /payments, switch between rails, and review compliance notes against the SECURITY_AUDIT_PREBETA.md findings.
  5. Security regression script โ€“ rerun ./tests/red-team-termux.sh to ensure middleware, rate limiting, and headers still pass after UI updates (backend must be running).

๐ŸŽฎ Gameplay

Basic Rules:

  1. Each player receives one card (value: -10 to 20)
  2. Players trade shares based on expected total
  3. Market value = Sum of all cards รท Number of players
  4. Winners profit from accurate predictions

Game Flow:

  1. Deal Phase: Cards distributed
  2. Trading Phase: 2-minute trading window
  3. Reveal Phase: Cards shown, market value calculated
  4. Settlement Phase: Profits/losses determined

๐Ÿš€ Deployment

Vercel Deployment

# Install Vercel CLI
npm i -g vercel

# Deploy to production
vercel --prod

Environment Variables (Vercel Dashboard):

  • VITE_ELEVENLABS_API_KEY
  • VITE_FIREBASE_API_KEY
  • VITE_FIREBASE_AUTH_DOMAIN
  • VITE_FIREBASE_PROJECT_ID
  • All other Firebase config vars

๐Ÿงช Testing

# Run tests
pnpm test

# Run with coverage
pnpm test:coverage

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“‹ Roadmap

โœ… Completed

  • Voice-enabled characters with ElevenLabs
  • Visual character system with animations
  • Firebase authentication
  • Real-time multiplayer infrastructure
  • CI/CD pipeline
  • Vercel deployment configuration

๐Ÿšง In Progress

  • Complete game logic implementation
  • Mobile responsive design
  • Comprehensive test coverage

๐Ÿ“… Planned

  • AI opponent personalities
  • Tournament mode
  • Leaderboards
  • Educational tutorials
  • Mobile app (React Native)
  • Web3 micro-stakes integration

๐Ÿ”’ Security

  • Environment variables for sensitive data
  • Firebase security rules
  • Input validation
  • Rate limiting (planned)
  • Secure WebSocket connections

๐Ÿ“„ License

MIT License โ€“ Open source for public learning and remixing.

๐Ÿ™ Acknowledgments

  • Gary Stevenson for the original trading game concept
  • ElevenLabs for voice synthesis API
  • Firebase for backend infrastructure
  • Vercel for deployment platform

๐Ÿ“ž Support


Built with โค๏ธ and ๐ŸŽ™๏ธ voices by the community

About

Gamified learning tool to demystify the stock market

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •