game24_net

Crates.iogame24_net
lib.rsgame24_net
version0.2.2
created_at2025-12-31 09:05:16.933219+00
updated_at2026-01-08 07:25:37.105213+00
descriptionA multiplayer, real-time '24 Game' built in Rust with TCP server/client. Fully plain-text terminal compatible; no ANSI colors or emojis.
homepage
repository
max_upload_size
id2014308
size51,114
(c3qu)

documentation

README

24 Point Network Game (Rust TUI)

A multiplayer, terminal-based implementation of the classic 24 Game logic puzzle, written in Rust. This project features a TCP client-server architecture, allowing multiple players to compete simultaneously in real-time using a clean Text User Interface (TUI).

🎮 Game Overview

The objective is simple: given four randomly generated numbers, use arithmetic operations to calculate the value 24.

Players compete in a shared lobby. The first player to submit a valid expression that equals 24 wins the round and gains a point.

🚀 Features

  • Multiplayer: Support for multiple clients connecting to a central server.
  • Real-time TUI: Split-screen interface showing game status, live chat/logs, and an interactive input field.
  • Smart Input: Custom keyboard shortcuts for complex math operations (like auto-parentheses).
  • Rate Limiting: Prevents spamming to ensure fair play.
  • No Penalty Mode: Incorrect answers do not deduct points, encouraging experimentation.

📜 Game Rules

  1. The Cards: Each round, the server generates 4 random numbers (integers between 1 and 10).
  2. The Goal: Construct a mathematical expression that equals exactly 24.
  3. Valid Operators:
  • Addition (+)

  • Subtraction (-)

  • Multiplication (*)

  • Division (/)

  • Exponentiation/Power (^)

  • Parentheses () for grouping.

  1. Constraints:
  • You must use all four numbers provided.

  • You must use each number exactly once.

  • You can use the operators as many times as needed.

  1. Winning a Round: The first player to submit a correct expression gets +1 point. The round ends immediately, and the next set of numbers is generated.
  2. Game Over: The game ends after a set number of rounds (default: 10). The player with the highest score wins.

⌨️ Controls & Input

The input system is designed for speed and convenience in a terminal environment.

Key / Input Action
Number Keys Input numbers (0-9)
Operators Input +, -, *, /
. (Dot) Auto-Bracket: Wraps your entire current expression in parentheses (...) and moves the cursor to the end.
(Up Arrow) Power: Inserts the exponentiation symbol ^.
Delete or PageUp Power: Insert (.
PageDown Power: Insert ).
Enter Submit your answer or command.
Esc Quit the game client.

Commands

Type these into the input bar:

  • /start - Start the game (if currently waiting).
  • /pass - Vote to skip the current difficult puzzle.
  • /score - Check your current score.
  • /players - List all connected players and their scores.
  • /help - Show the help menu.

🛠️ Installation & Usage

Prerequisites

1. Build the Project

cargo build --release

2. Run the Server

Start the game server. You can specify the number of rounds and the port.

# Syntax: cargo run -- server [rounds] [IP:Port]
# Example (Start 10 rounds on default port):
cargo run -- server

# Example (Start 20 rounds on specific port):
cargo run -- server 20 0.0.0.0:7878

3. Run the Client(s)

Connect to the server. Open a new terminal window for each player.

# Syntax: cargo run -- client <Nickname> <IP:Port>
cargo run -- client Alice 127.0.0.1:7878
cargo run -- client Bob 127.0.0.1:7878

🧩 Example Gameplay

Server gives numbers: 3, 3, 8, 8

Player Input:

8 / ( 3 - 8 / 3 )

Result:

  • Correct! The player wins the round.

Using Special Controls: If you have typed 2+2 and want to multiply the result by 6:

  1. Current input: 2+2
  2. Press . (Dot) -> Becomes (2+2)
  3. Type *6 -> Becomes (2+2)*6 -> 24.

📝 License

This project is open-source. Feel free to fork and modify!

Commit count: 0

cargo fmt