Skip to content

A real-time strategy game where you build and manage a village, expand your territory, and survive as long as possible. Manage resources, construct buildings, recruit units, and expand your influence across a hexagonal map.

Notifications You must be signed in to change notification settings

mm-webx/ai-generated-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Village Strategy Game

A real-time strategy game where you build and manage a village, expand your territory, and survive as long as possible. Manage resources, construct buildings, recruit units, and expand your influence across a hexagonal map.

๐ŸŽฎ How to Play

Objective

Build and expand your village while managing resources. Avoid starvation by maintaining positive food production. The longer you survive, the higher your score!

Getting Started

  1. Start the game: Click on your village (the tile with a house icon in the center) to open the village panel
  2. Build your first building: Start with a Farm to increase food production
  3. Manage resources: Keep an eye on your resource production rates (hold Shift while hovering over resources)
  4. Expand your territory: Click on visible tiles adjacent to your owned tiles to claim them
  5. Upgrade tiles: Click on owned tiles to upgrade them and increase their production bonuses

Resources

The game features six types of resources:

  • Food ๐ŸŽ - Essential for survival. Each person consumes 1 food per minute. Base production: +5/min
  • Wood ๐Ÿชต - Used for construction and upgrades. Base production: +3/min
  • Stone โ›๏ธ - Required for advanced buildings and upgrades. Base production: +1/min
  • Diamond ๐Ÿ’Ž - Rare resource for high-tier upgrades. Obtained from special tiles and buildings
  • Technology ๐Ÿ”ฌ - Research points for advancement. Generated by libraries and military buildings
  • Power โš”๏ธ - Military strength. Required to claim new tiles and villages. Generated by military units

Buildings

Build and upgrade buildings in your village to boost resource production:

  • Farm ๐ŸŒพ - Increases food production (+2/m per level)
  • Lumbermill ๐ŸŒฒ - Increases wood production (+1.5/m per level)
  • Quarry ๐Ÿ”จ - Increases stone production (+1/m per level)
  • Mine ๐Ÿ’Ž - Increases diamond production (+0.5/m per level)
  • Library ๐Ÿ“š - Increases technology production (+0.3/m per level)
  • Home ๐Ÿ  - Increases population limit (+5 per level)
  • Barracks โš”๏ธ - Train warriors and generate technology (+1/m per level)
  • Archer Guild ๐Ÿน - Train archers and generate technology (+1/m per level)
  • Mage Tower โœจ - Train mages and generate technology (+1/m per level)

Units

Recruit military units to generate power and technology:

  • Warrior โš”๏ธ - Generates 1 power and 1 research point
  • Archer ๐Ÿน - Generates 3 power and 2 research points
  • Mage โœจ - Generates 5 power and 3 research points

Guild Masters

Hire specialized masters to boost resource production by 2% per master:

  • Master Farmer ๐ŸŒพ - Boosts food production
  • Master Lumberjack ๐ŸŒฒ - Boosts wood production
  • Master Stonemason ๐Ÿ”จ - Boosts stone production
  • Master Miner ๐Ÿ’Ž - Boosts diamond production
  • Master Scholar ๐Ÿ“š - Boosts technology production

Map & Territory

  • Hexagonal Map: Explore and expand across a hexagonal grid
  • Claim Tiles: Click on visible tiles adjacent to your territory to claim them
  • Upgrade Tiles: Click on owned tiles to upgrade them (up to level 100)
  • Claim Villages: Conquer AI villages to expand your influence (requires significant power)
  • Tile Types: Different terrain types provide different resource bonuses

Game Controls

Keyboard Shortcuts

  • ` (Backtick) - Toggle pause/play
  • 1 - Set speed to 1x
  • 2 - Set speed to 5x
  • 3 - Set speed to 20x

Mouse Controls

  • Click - Interact with tiles (claim, upgrade, open village panel)
  • Drag - Pan the map
  • Scroll - Zoom in/out (or use zoom controls)

UI Controls

  • Time Display - Click to open dropdown menu with reset and test options
  • Speed Controls - Adjust game speed (1x, 5x, 20x)
  • Pause Button - Pause/resume the game
  • Resource Display - Hover to see details, hold Shift for production breakdown

Tips & Strategy

  1. Start with Farms: Food is critical - build farms early to avoid starvation
  2. Manage Population: Build homes to increase population limit, but remember each person consumes food
  3. Balance Production: Don't focus on just one resource - you'll need all of them
  4. Upgrade Strategically: Tile upgrades increase production bonuses significantly
  5. Build Military: Power is required to claim new tiles and villages
  6. Use Speed Controls: Speed up time when waiting for resources or building completion
  7. Watch Production Rates: Hold Shift over resources to see detailed production breakdown
  8. Plan Building Queue: You have limited building job slots - plan your construction carefully

Game Over

The game ends when:

  • Food reaches 0
  • Food production is 0 or negative
  • No farms are being built that could increase food production

Your final score is calculated based on:

  • Village level
  • Experience gained
  • Building levels
  • Units recruited
  • Guild masters hired
  • Resources spent
  • Penalty: Game time (surviving longer reduces score)

Auto-Save

Your game progress is automatically saved to browser localStorage every 10 seconds. Refresh the page to continue where you left off!


๐Ÿ› ๏ธ Technical Details

Tech Stack

  • Framework: Next.js 16.0.1 (App Router)
  • Language: TypeScript 5
  • UI Library: React 19.2.0
  • Styling: Tailwind CSS 4
  • UI Components: Radix UI (Dropdown Menu, Separator, Tabs, Tooltip)
  • Icons: Lucide React
  • State Management: React Context API
  • Storage: Browser localStorage

Project Structure

โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ””โ”€โ”€ TimeControl.tsx      # Time control component
โ”‚   โ”œโ”€โ”€ page.tsx                 # Main game page
โ”‚   โ””โ”€โ”€ layout.tsx               # App layout
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ game/
โ”‚   โ”‚   โ”œโ”€โ”€ building-jobs-display.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ control-buttons.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ population-display.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ resource-config.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ resource-display.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ resource-list.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ tile-info-panel.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ time-display.tsx
โ”‚   โ”‚   โ””โ”€โ”€ types.ts
โ”‚   โ”œโ”€โ”€ game-board/
โ”‚   โ”‚   โ”œโ”€โ”€ GameBoard.tsx        # Main game board component
โ”‚   โ”‚   โ”œโ”€โ”€ HexMap.tsx           # Hexagonal map renderer
โ”‚   โ”‚   โ”œโ”€โ”€ HexTile.tsx          # Individual tile component
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts             # Map-related types
โ”‚   โ”‚   โ”œโ”€โ”€ utils.ts             # Map utilities and calculations
โ”‚   โ”‚   โ””โ”€โ”€ zoom-controls.tsx    # Zoom controls
โ”‚   โ”œโ”€โ”€ game-header.tsx          # Main game state provider
โ”‚   โ”œโ”€โ”€ village/
โ”‚   โ”‚   โ”œโ”€โ”€ building-card.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ building-list.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ guild-masters-panel.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ recruitment-panel.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts             # Game entity definitions
โ”‚   โ”‚   โ””โ”€โ”€ village-upgrade-panel.tsx
โ”‚   โ””โ”€โ”€ ui/                      # Reusable UI components
โ””โ”€โ”€ lib/
    โ””โ”€โ”€ utils.ts                  # Utility functions

Key Features Implementation

Game State Management

  • Centralized state via TimeControlContext in game-header.tsx
  • Auto-save to localStorage every 10 seconds
  • State persistence across page refreshes

Time System

  • Game time advances based on speed multiplier (1x, 5x, 20x)
  • Building timers use game time, accelerating with speed
  • Real-time updates for UI responsiveness

Building System

  • Queue-based building with limited job slots
  • Building timers show remaining game time
  • Buildings provide resource bonuses based on level

Map System

  • Hexagonal coordinate system (q, r)
  • Deterministic tile generation
  • Tile visibility system (owned, visible, hidden)
  • Tile upgrade system (levels 1-100)

Resource System

  • Base production from village
  • Tile bonuses from owned tiles
  • Building bonuses from constructed buildings
  • Population consumption for food
  • Speed multiplier affects all production

Development

Prerequisites

  • Node.js 18+
  • npm/pnpm/yarn

Installation

npm install
# or
pnpm install

Development Server

npm run dev
# or
pnpm dev

Open http://localhost:3000 to view the game.

Build

npm run build
npm start

Linting

npm run lint

Browser Compatibility

  • Modern browsers with ES6+ support
  • localStorage support required for save functionality
  • Recommended: Chrome, Firefox, Safari, Edge (latest versions)

License

Private project - All rights reserved

About

A real-time strategy game where you build and manage a village, expand your territory, and survive as long as possible. Manage resources, construct buildings, recruit units, and expand your influence across a hexagonal map.

Resources

Stars

Watchers

Forks