Skip to content

krisfur/taurijack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Blackjack Tauri

A desktop blackjack game built with Next.js and Tauri, featuring a modern UI and full game logic.

Next.js React TypeScript Tauri Rust Tailwind CSS

Game logic based on the Node.JS version made before.

screenshot

๐ŸŽฎ Features

  • Complete Blackjack Game: Full implementation of blackjack rules including hitting, standing, and dealer AI
  • Modern UI: Clean, responsive interface with Tailwind CSS
  • Keyboard Shortcuts: Quick actions with D (Deal), H (Hit), S (Stand)
  • Visual Feedback: Card animations and winner indicators
  • Desktop Native: Runs as a native desktop application using Tauri

๐Ÿ› ๏ธ Tech Stack

  • Frontend: Next.js 15 with React 19 and TypeScript
  • Styling: Tailwind CSS
  • Desktop Framework: Tauri 1.x (Rust backend)
  • Game Logic: Custom TypeScript implementation

๐Ÿ“‹ Prerequisites

Before running this project, make sure you have the following installed:

Required Software

  • Node.js (v18 or higher)
  • npm or yarn
  • Rust (latest stable version)
  • Cargo (comes with Rust)

System Dependencies (Linux)

On Arch Linux, you'll need:

sudo pacman -S webkit2gtk

On other Linux distributions, install the equivalent webkit2gtk package.

๐Ÿš€ Getting Started

1. Clone the Repository

git clone <your-repo-url>
cd taurijack

2. Install Dependencies

npm install

3. Run the Development Server

Option A: Web Development (Next.js only)

npm run dev

This starts the Next.js development server at http://localhost:3000

Option B: Desktop App (Tauri)

npm run tauri:dev

This builds and runs the desktop application with hot reload.

4. Build for Production

Web Build

npm run build
npm start

Desktop App Build

npm run tauri:build

This creates platform-specific installers in src-tauri/target/release/bundle/

๐ŸŽฏ How to Play

  1. Start a Game: Click "Deal" or press D to begin
  2. Hit: Click "Hit" or press H to draw another card
  3. Stand: Click "Stand" or press S to end your turn
  4. Win Conditions:
    • Get 21 (Blackjack!)
    • Have a higher total than the dealer without going over 21
    • Dealer busts (goes over 21)

Game Rules

  • Dealer must hit on 16 and stand on 17
  • Aces are worth 1 or 11 (automatically optimized)
  • Face cards (J, Q, K) are worth 10
  • Number cards are worth their face value

๐Ÿ“ Project Structure

taurijack/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/                 # Next.js app directory
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx        # Main game page
โ”‚   โ”‚   โ””โ”€โ”€ globals.css     # Global styles
โ”‚   โ”œโ”€โ”€ components/         # React components
โ”‚   โ”‚   โ”œโ”€โ”€ BlackjackGame.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Card.tsx
โ”‚   โ”‚   โ””โ”€โ”€ Hand.tsx
โ”‚   โ”œโ”€โ”€ hooks/              # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ useBlackjack.ts
โ”‚   โ””โ”€โ”€ lib/                # Game logic
โ”‚       โ””โ”€โ”€ blackjack.ts
โ”œโ”€โ”€ src-tauri/              # Tauri backend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ main.rs
โ”‚   โ”‚   โ””โ”€โ”€ lib.rs
โ”‚   โ”œโ”€โ”€ Cargo.toml
โ”‚   โ””โ”€โ”€ tauri.conf.json
โ”œโ”€โ”€ public/                 # Static assets
โ””โ”€โ”€ package.json

๐Ÿ”ง Development

Available Scripts

  • npm run dev - Start Next.js development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint
  • npm run tauri:dev - Start Tauri development
  • npm run tauri:build - Build Tauri app for distribution

Key Components

  • BlackjackGame: Main game component with UI and controls
  • useBlackjack: Custom hook managing game state and actions
  • blackjack.ts: Core game logic (deck, hands, scoring)
  • Card & Hand: Reusable UI components for displaying cards

๐ŸŽจ Customization

Styling

The app uses Tailwind CSS. Modify src/app/globals.css for global styles or update component classes for specific styling.

Game Logic

Game rules and logic are in src/lib/blackjack.ts. You can modify:

  • Deck creation and shuffling
  • Scoring rules
  • Dealer behavior
  • Win conditions

Tauri Configuration

Desktop app settings are in src-tauri/tauri.conf.json:

  • Window size and properties
  • App permissions
  • Build settings
  • Bundle configuration

๐Ÿ› Troubleshooting

Common Issues

"webkit2gtk-4.1 not found"

  • This project uses Tauri 1.x which works with webkit2gtk-4.0
  • Make sure you have webkit2gtk installed on your system

Build Errors

  • Ensure Rust and Cargo are up to date: rustup update
  • Clean and rebuild: cargo clean && npm run tauri:dev

Port Already in Use

  • If port 3000 is busy, change it in next.config.ts or kill the existing process

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Enjoy playing Blackjack! ๐Ÿƒ