From 9a6c3bae5aa67900c9d63550ac03c5e229841b3b Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Mon, 2 Mar 2026 11:17:51 +0000 Subject: [PATCH] Add README.md --- README.en.md | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..59c4ee2 --- /dev/null +++ b/README.en.md @@ -0,0 +1,145 @@ +# Cloud Compute Book / Warzone Multiplayer Battle Game + +This project contains two implemented local network multiplayer battle games: a C++ version and a Go version. + +## Project Overview + +This is a small-scale game project supporting multiple players battling on the same local network. Players can move on the map, pick up weapons, and attack opponents with the goal of eliminating other players. The game includes a complete account and statistics system with persistent player data storage. + +## Project Structure + +``` +warzone/ +├── c++/ # C++ Implementation (v3.0 Monolithic Prototype) +│ ├── client.cpp # Client program +│ ├── server.cpp # Server program +│ ├── database.h # Database operations and password hashing +│ ├── protocol.h # Network protocol and game parameter definitions +│ ├── Makefile # Build configuration +│ └── README.md # C++ version documentation +│ +└── go/ # Go Language Implementation (TUI Multiplayer Battle Demo) + ├── cmd/ + │ ├── client/ # Client program + │ └── server/ # Server program + ├── internal/ + │ ├── client/ # Client core logic + │ │ ├── backend.go + │ │ ├── net_backend.go + │ │ └── tui/ # Terminal UI implementation + │ ├── proto/ # Protocol definitions + │ └── server/ # Server core logic and storage + ├── game.db # SQLite database file + ├── go.mod + └── README.md # Go version documentation +``` + +## Key Features + +### General Features + +- **Multiplayer Online**: Supports multiple players battling on the same local network +- **Account System**: Player registration and login with persistent data storage +- **Statistics System**: Tracks player wins, kills, deaths, and other metrics +- **Real-time State Synchronization**: Server broadcasts game state to all clients + +### Gameplay Mechanics + +- **Movement Control**: Players move on the map using arrow keys +- **Weapon System**: Weapons spawn randomly on the map; picking them up grants attack capabilities +- **Combat System**: Players can attack opponents within their field of view +- **Health System**: Each player has a health value that decreases when attacked + +## C++ Version (v3.0) + +### Compilation and Execution + +```bash +cd warzone/c++ +make +``` + +### Starting the Server + +```bash +./server [port] +# Default port: 8888 +``` + +### Starting the Client + +```bash +./client [server IP] [port] +# Default connection: localhost:8888 +``` + +### Controls + +- **Arrow Keys**: Move +- **Spacebar**: Attack +- **Q**: View statistics +- **ESC**: Exit game + +### Configurable Parameters + +Modify the following parameters in `protocol.h`: + +- `MAX_PLAYERS`: Maximum number of players +- `MAP_W / MAP_H`: Map dimensions +- `MAX_HEALTH`: Maximum health +- `ATTACK_DAMAGE`: Normal attack damage +- `POWER_DAMAGE`: Powerful attack damage +- `ATTACK_RANGE`: Attack range +- `HEARTBEAT_INTERVAL`: Heartbeat interval +- `HEARTBEAT_TIMEOUT`: Heartbeat timeout + +## Go Version (TUI) + +### Compilation and Execution + +```bash +cd warzone/go +go build ./cmd/server +go build ./cmd/client +``` + +### Starting the Server + +```bash +./server +# Default listens on :8888 +``` + +### Starting the Client + +```bash +./client +# After startup, enter server address and username +``` + +### Controls + +- **Arrow Keys**: Move +- **Tab**: Select opponent to challenge +- **Enter**: Confirm challenge +- **Esc**: Exit + +## Technical Highlights + +### C++ Version + +- Implements network communication using raw sockets +- Uses SQLite for data storage +- Heartbeat mechanism to detect player online status +- Mutex locks to protect shared game state + +### Go Version + +- Uses TUI library for terminal interface +- JSON-based communication protocol +- SQLite for storing player data +- Heartbeat monitoring with automatic disconnection handling + +## License + +This project is intended solely for learning and research purposes. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ff5e65 --- /dev/null +++ b/README.md @@ -0,0 +1,147 @@ + + +# Cloud Comute Book / Warzone 多人对战游戏 + +本项目包含两个实现的局域网多人对战游戏: C++ 版本和 Go 版本。 + +## 项目简介 + +这是一个支持多人在同一局域网内对战的小型游戏项目。玩家可以在地图上移动、拾取武器、攻击对手,目标是击败其他玩家。游戏包含完整的账号与战绩系统,支持玩家数据持久化存储。 + +## 项目结构 + +``` +warzone/ +├── c++/ # C++ 实现 (v3.0 单体原型) +│ ├── client.cpp # 客户端程序 +│ ├── server.cpp # 服务器程序 +│ ├── database.h # 数据库操作与密码哈希 +│ ├── protocol.h # 网络协议与游戏参数定义 +│ ├── Makefile # 编译配置 +│ └── README.md # C++ 版本说明 +│ +└── go/ # Go 语言实现 (TUI 多人对战演示) + ├── cmd/ + │ ├── client/ # 客户端程序 + │ └── server/ # 服务器程序 + ├── internal/ + │ ├── client/ # 客户端核心逻辑 + │ │ ├── backend.go + │ │ ├── net_backend.go + │ │ └── tui/ # 终端 UI 实现 + │ ├── proto/ # 协议定义 + │ └── server/ # 服务器核心逻辑与存储 + ├── game.db # SQLite 数据库文件 + ├── go.mod + └── README.md # Go 版本说明 +``` + +## 主要功能 + +### 通用功能 + +- **多人联机**:支持多玩家在同一局域网内对战 +- **账号系统**:玩家注册与登录,数据持久化存储 +- **战绩系统**:记录玩家胜负、击杀、死亡等数据 +- **实时状态同步**:服务器广播游戏状态给所有客户端 + +### 游戏玩法 + +- **移动控制**:玩家通过方向键在地图上移动 +- **武器系统**:地图上随机生成武器,拾取后获得攻击能力 +- **对战机制**:玩家可对视野内的对手发起攻击 +- **生命值系统**:每位玩家有生命值,被攻击后扣血 + +## C++ 版本 (v3.0) + +### 编译与运行 + +```bash +cd warzone/c++ +make +``` + +### 启动服务器 + +```bash +./server [端口号] +# 默认端口 8888 +``` + +### 启动客户端 + +```bash +./client [服务器IP] [端口号] +# 默认连接 localhost:8888 +``` + +### 操作说明 + +- **方向键**:移动 +- **空格键**:攻击 +- **Q**:查看战绩 +- **ESC**:退出游戏 + +### 可调参数 + +在 `protocol.h` 中可修改以下参数: + +- `MAX_PLAYERS`:最大玩家数 +- `MAP_W / MAP_H`:地图尺寸 +- `MAX_HEALTH`:最大生命值 +- `ATTACK_DAMAGE`:普通攻击伤害 +- `POWER_DAMAGE`:强力攻击伤害 +- `ATTACK_RANGE`:攻击范围 +- `HEARTBEAT_INTERVAL`:心跳间隔 +- `HEARTBEAT_TIMEOUT`:心跳超时时间 + +## Go 版本 (TUI) + +### 编译与运行 + +```bash +cd warzone/go +go build ./cmd/server +go build ./cmd/client +``` + +### 启动服务器 + +```bash +./server +# 默认监听 :8888 +``` + +### 启动客户端 + +```bash +./client +# 启动后输入服务器地址和用户名 +``` + +### 操作说明 + +- **方向键**:移动 +- **Tab**:选择挑战对手 +- **Enter**:确认挑战 +- **Esc**:退出 + +## 技术特点 + +### C++ 版本 + +- 使用原始套接字实现网络通信 +- SQLite 作为数据存储 +- 心跳机制检测玩家在线状态 +- 互斥锁保护共享游戏状态 + +### Go 版本 + +- 使用 TUI 库实现终端界面 +- JSON 协议通信 +- SQLite 存储玩家数据 +- 心跳监控与自动断连 + +## 许可证 + +本项目仅供学习与研究使用。 \ No newline at end of file -- Gitee