Skip to content

deafwave/typescript-websocket-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Usage Example

  1. pnpm i
  2. terminal 1 pnpm run server
  3. terminal 2 pnpm run demo

Overview

This system consists of two types of clients:

🏦 Mule Client

  • Purpose: Stores and manages large amounts of gold
  • Behavior: Requests gold dumps from farmers when the mule has over 100M gold
  • Features:
    • Automatically sends dump requests when gold exceeds 100M
    • Listens for farmer responses
    • Tracks gold received from farmers
    • Simulates gold accumulation over time

🌾 Farmer Client

  • Purpose: Farms gold and responds to mule dump requests

  • Behavior:

    • βœ… Above 100M gold: Responds "On my way!" and dumps excess gold to mule
    • ❌ Below 100M gold: Responds "Ignoring - don't have that kind of money"
  • Features:

    • Automatically detects mule dump requests in chat
    • Responds based on current gold amount
    • Simulates farming activities and gold generation
    • Dumps 80-95% of excess gold (above 100M) to mule

    How It Works

  1. Mule Detection: When mule gold exceeds 100M, it sends a message like:

    🚨 ATTENTION FARMERS: Mule requesting gold dump! I have 150,000,000 gp. Please dump your gold if you're above 100M! πŸ’°
    
  2. Farmer Response: Farmers automatically detect this message and respond based on their gold:

    • Rich Farmer (>100M): "On my way to dump gold! πŸƒβ€β™‚οΈπŸ’°"
    • Poor Farmer (<100M): "Sorry, ignoring - I don't have that kind of money πŸ˜…"
  3. Gold Transfer: Rich farmers simulate going to the mule and dumping their excess gold, keeping around 100M for continued farming.

Example Interaction

[Mule] 🚨 ATTENTION FARMERS: Mule requesting gold dump! I have 150,000,000 gp. Please dump your gold if you're above 100M! πŸ’°
[RichFarmer] On my way to dump gold! πŸƒβ€β™‚οΈπŸ’°
[PoorFarmer] Sorry, ignoring - I don't have that kind of money πŸ˜…
[RichFarmer] Dumped 75,000,000 gp to mule! Keeping 105,000,000 gp for farming πŸ’°βœ…
[Mule] Thanks RichFarmer! Received 75,000,000 gp. Mule total now: 225,000,000 gp

Features

  • Realistic Simulation: Random delays, varied responses, and realistic gold amounts
  • Smart Detection: Farmers automatically detect mule requests in chat
  • Threshold-Based Logic: 100M gold threshold for dump decisions
  • Activity Simulation: Both clients simulate their respective activities
  • Graceful Shutdown: Proper cleanup with Ctrl+C

Customization

You can customize:

  • Gold thresholds (currently 100M)
  • Response messages
  • Activity intervals
  • Gold generation amounts
  • Server URL and usernames

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published