Skip to content

Aviator Game Client The Aviator Game Client is a real-time online betting game built with React, TypeScript, and Redux. Players bet on a virtual airplane's flight duration, aiming to cash out before it crashes. The game features real-time multipliers, WebSocket communication, and a robust betting system, providing an engaging and interactive gaming

Notifications You must be signed in to change notification settings

IsoDevMate/AVIATOR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

Overview

The Aviator game is a popular online betting game that operates on a web socket for real-time interaction. Players place bets on a virtual airplane that takes off and flies away. The goal is to cash out before the plane "flies away" (crashes), with the multiplier increasing as the plane ascends.

Untitled.video.-.Made.with.Clipchamp.mp4

###Here are the key diagrams for our architecture:

Usecase diagrams:

image

Betting System: image

Server generated Flight-phase: image

Cahing out: Cahing out: image

Result processing: image

Key Components

  1. User Interface (UI)
  2. Betting System
  3. Real-Time Multiplier
  4. WebSocket Communication
  5. Leaderboard and Chat
  6. Payment and Withdrawal System

1. User Interface (UI)

The UI is designed to be intuitive and engaging. Key elements include:

  • Betting Panel: Allows users to place bets. Users can input the amount they wish to bet and confirm it.
  • Auto Bet: An option for users to set automatic bets for consecutive rounds.
  • Cash Out Button: Allows users to cash out their bets at any time before the plane crashes.
  • Multiplier Display: Shows the current multiplier value as the plane ascends.
  • Leaderboard: Displays the top bets and their respective multipliers.
  • Chat Window: Allows users to interact with each other and possibly receive tips or strategies.

2. Betting System

The betting system is the core of the game. Here’s how it works:

  • Bet Placement: Users place bets using the betting panel. The minimum and maximum bet amounts are predefined.
  • Bet Confirmation: Once a bet is placed, it is confirmed and deducted from the user's balance.
  • Bet Tracking: The system tracks all active bets and their respective multipliers.

3. Real-Time Multiplier

The multiplier starts at 1x and increases as the plane ascends. Key points:

  • Random Crash Point: The plane crashes at a random point, determined by a provably fair algorithm to ensure fairness.
  • Multiplier Increase: The multiplier increases over time, and users can cash out at any point before the crash.
  • Cash Out: If a user cashes out before the crash, their bet is multiplied by the current multiplier. If the plane crashes before they cash out, they lose their bet.

4. WebSocket Communication

WebSocket is used for real-time communication between the client and the server. This ensures that:

  • Real-Time Updates: The multiplier value, bet status, and other game events are updated in real-time.
  • Low Latency: Minimizes delay in bet placement, cash out, and multiplier updates.
  • Scalability: Handles multiple users simultaneously without significant performance degradation.

5. Leaderboard and Chat

The leaderboard and chat enhance the social aspect of the game:

  • Leaderboard: Displays the top bets and their multipliers, encouraging competition among users.
  • Chat Window: Allows users to communicate with each other, share strategies, and provide tips. This can also be used for customer support, as seen in the screenshots where users are asking for help.

6. Payment and Withdrawal System

The payment system handles deposits, bets, and withdrawals:

  • Deposits: Users can deposit funds into their accounts to place bets.
  • Withdrawals: Users can withdraw their winnings. The system ensures secure and timely transactions.
  • Balance Management: Keeps track of the user's balance, deducting bets and adding winnings in real-time.

System Flow

  1. User Registration/Login: Users register or log in to their accounts.
  2. Deposit Funds: Users deposit funds into their accounts.
  3. Place Bets: Users place bets using the betting panel.
  4. Game Starts: The plane takes off, and the multiplier starts increasing.
  5. Real-Time Updates: The multiplier value is updated in real-time via WebSocket.
  6. Cash Out: Users can cash out at any time before the plane crashes.
  7. Game Ends: The plane crashes at a random point. Users who cashed out before the crash win their bet multiplied by the current multiplier. Those who didn’t lose their bet.
  8. Withdraw Winnings: Users can withdraw their winnings from their accounts.

Conclusion

The Aviator game is a dynamic and engaging betting game that leverages real-time communication via WebSocket to provide an immersive experience. The combination of a user-friendly interface, a robust betting system, and social features like the leaderboard and chat makes it a popular choice among online gamers.

By understanding these components, developers can design and implement similar systems, ensuring a seamless and fair gaming experience for users. # Aviator Game System Design

Core Game Mechanics

Game Loop

  1. Round Initialization

    • Each round starts with a betting phase (visible in screenshots where users can place bets)
    • Players can place bets using the UI (showing bet amounts in KES currency)
    • Minimum bet appears to be 10.00 KES
    • Maximum bet shown is 20,000.00 KES
  2. Flight Phase

    • An airplane starts flying on a curved trajectory
    • A multiplier value increases as the plane flies higher (e.g., 1.39x, 2.88x seen in screenshots)
    • Players must cash out before the plane "flies away" (crashes)
    • The multiplier determines the payout (bet amount × multiplier)
  3. Crash Event

    • Round ends when plane crashes ("FLEW AWAY!" message appears)
    • Final multiplier is displayed (e.g., 2.88x in screenshot)
    • Winners and losers are determined
    • Payouts are calculated and distributed

Technical Architecture

Frontend Components

  1. Real-time Display

    • Animated airplane on curved trajectory
    • Live multiplier counter (e.g., "1.39x")
    • Betting interface with quick-select amounts
    • Previous results history (showing multipliers like 1.90x, 1.29x, 8.37x, etc.)
  2. User Interface Elements

    • All Bets/My Bets/Top tabs for bet viewing
    • Live bet placement panels
    • Auto-bet functionality
    • Tournament information banner
    • Balance display (showing KES currency)

Backend Systems

  1. WebSocket Server

    • Maintains real-time connections with all players
    • Broadcasts game state updates (multiplier changes)
    • Handles bet placements and cashouts
    • Manages game rounds and state transitions
  2. Game Logic

    • Random crash point generation
    • Multiplier calculation and progression
    • Bet validation and processing
    • Winner determination
    • Payout calculation
  3. Tournament System

    • "xTournament: Collect Highest Multiplier" feature
    • Tracks player performance
    • Manages tournament rules and rewards

Data Models

  1. Player Data
interface Player {
    id: string;          // Masked as "2***6" in UI
    balance: number;     // In KES
    activeBets: Bet[];
    tournamentStats: TournamentStats;
}
  1. Bet Data
interface Bet {
    id: string;
    playerId: string;
    amount: number;      // In KES
    placedAt: timestamp;
    cashoutMultiplier?: number;
    status: 'active' | 'won' | 'lost';
}
  1. Round Data
interface Round {
    id: string;
    startTime: timestamp;
    crashPoint: number;
    participants: Bet[];
    status: 'betting' | 'flying' | 'crashed';
    finalMultiplier: number;
}

Real-time Communication Flow

  1. Round Start:
// Server -> Client
{
    type: 'ROUND_START',
    data: {
        roundId: string,
        startTime: timestamp,
        bettingPhase: boolean
    }
}
  1. Multiplier Updates:
// Server -> Client
{
    type: 'MULTIPLIER_UPDATE',
    data: {
        multiplier: number,
        timestamp: timestamp
    }
}
  1. Crash Event:
// Server -> Client
{
    type: 'CRASH',
    data: {
        finalMultiplier: number,
        winners: Array<{playerId: string, payout: number}>,
        nextRoundStart: timestamp
    }
}

Security Considerations

  1. Bet Validation

    • Maximum and minimum bet limits
    • Balance verification
    • Duplicate bet prevention
    • Rate limiting on bet placement
  2. Anti-Cheat Measures

    • Server-side crash point generation
    • Timestamp validation
    • Client-server state synchronization
    • Automated betting detection
  3. Fair Play

    • Provably fair algorithms for crash points
    • Transparent multiplier calculation
    • Historical results verification
    • Licensed operation verification

Scalability Considerations

  1. Connection Management

    • WebSocket connection pooling
    • Load balancing for multiple game instances
    • Connection state recovery
    • Heartbeat monitoring
  2. Performance Optimization

    • Efficient state broadcasting
    • Batch updates for non-critical data
    • Connection throttling during high load
    • Cache frequently accessed data welll be using the following tech stack also ensure temp rary data not to be sent to the database to increase peformnce and save architecture/cpu involve ment nodejs with typescript option sqlite drizzle orm auth via google startegy paypal sdks for payouts remember we are using websockets
  3. Add the authentication flow with Google?

  4. Implement the PayPal payout system?

  5. Add more game logic for betting and crash points?

  6. Create the frontend React components aslo using rtk query another thing i would like is the betting game logic addd as much logic as possible mulitple error handlers etc make sure all the gamelogic in the description above i mean alll in a very elaborate mannner is implemented in the best and perfect most way/manner

About

Aviator Game Client The Aviator Game Client is a real-time online betting game built with React, TypeScript, and Redux. Players bet on a virtual airplane's flight duration, aiming to cash out before it crashes. The game features real-time multipliers, WebSocket communication, and a robust betting system, providing an engaging and interactive gaming

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages