#!/bin/bash
# OnlineRpg 自动演示脚本

echo "=========================================="
echo "  OnlineRpg 游戏演示"
echo "=========================================="
echo ""

# 检查服务器是否运行
if ! pgrep -x "server" > /dev/null; then
    echo "❌ 服务器未运行！"
    echo "请先运行: ./build/bin/server"
    exit 1
fi

echo "✅ 服务器已运行"
echo ""

# 演示1：注册新用户
echo "【演示1】注册新用户..."
echo "---"
(
echo "1"          # 选择注册
echo "player1"    # 用户名
echo "pass123"    # 密码
sleep 1
echo "3"          # 退出
) | timeout 5 ./build/bin/client 2>&1 | grep -E "(Registration|Select|username|password)" || true
echo ""
sleep 1

# 演示2：登录并创建角色
echo "【演示2】登录并创建战士角色..."
echo "---"
(
echo "2"          # 选择登录
echo "player1"    # 用户名
echo "pass123"    # 密码
sleep 1
echo "1"          # 选择战士
echo "勇敢的战士"  # 角色名
sleep 1
echo "5"          # 登出
) | timeout 10 ./build/bin/client 2>&1 | grep -E "(Login|Character|class|Lobby)" || true
echo ""

echo "=========================================="
echo "  演示完成！"
echo "=========================================="
echo ""
echo "💡 提示："
echo "1. 服务器运行中: ./build/bin/server"
echo "2. 启动客户端: ./build/bin/client"
echo "3. 查看详细指南: cat 如何运行和游戏.md"
echo ""
echo "🎮 现在你可以手动运行客户端开始游戏了！"
