进一步完善服务器功能,添加远程命令系统,踢人系统

This commit is contained in:
2025-08-15 13:20:01 +08:00
parent ea42a1563d
commit 4bc5673726
99 changed files with 24189 additions and 552 deletions

View File

@@ -32,6 +32,10 @@ class ConsoleCommandsAPI:
"lsplayer": self.cmd_list_players, # 列出所有玩家
"playerinfo": self.cmd_player_info, # 查看玩家信息
"resetland": self.cmd_reset_land, # 重置玩家土地
"repasswd": self.cmd_reset_password, # 重置玩家密码
"rename": self.cmd_rename_player, # 重命名玩家昵称
"refarmname": self.cmd_rename_farm, # 重命名农场名称
"ban": self.cmd_ban_player, # 踢出玩家
"weather": self.cmd_weather, # 设置天气
"help": self.cmd_help, # 显示帮助信息
"stop": self.cmd_stop, # 停止服务器
@@ -392,6 +396,175 @@ class ConsoleCommandsAPI:
else:
print(" 当前无在线客户端")
def cmd_reset_password(self, args: List[str]):
"""重置玩家密码命令: /repasswd QQ号"""
if len(args) != 1:
print("❌ 用法: /repasswd <QQ号>")
return
qq_number = args[0]
# 加载玩家数据
player_data = self.server.load_player_data(qq_number)
if not player_data:
print(f"❌ 玩家 {qq_number} 不存在")
return
# 重置密码为123456
old_password = player_data.get("玩家密码", "未设置")
player_data["玩家密码"] = "123456"
# 保存数据
success = self.server.save_player_data(qq_number, player_data)
if success:
print(f"✅ 已重置玩家 {qq_number} 的密码")
print(f" 新密码: 123456")
else:
print(f"❌ 重置玩家 {qq_number} 密码失败")
def cmd_rename_player(self, args: List[str]):
"""重命名玩家昵称命令: /rename QQ号 新昵称"""
if len(args) != 2:
print("❌ 用法: /rename <QQ号> <新昵称>")
return
qq_number, new_nickname = args
# 加载玩家数据
player_data = self.server.load_player_data(qq_number)
if not player_data:
print(f"❌ 玩家 {qq_number} 不存在")
return
# 修改玩家昵称
old_nickname = player_data.get("玩家昵称", "未设置")
player_data["玩家昵称"] = new_nickname
# 保存数据
success = self.server.save_player_data(qq_number, player_data)
if success:
print(f"✅ 已重命名玩家 {qq_number} 的昵称")
print(f" 原昵称: {old_nickname} → 新昵称: {new_nickname}")
else:
print(f"❌ 重命名玩家 {qq_number} 昵称失败")
def cmd_rename_farm(self, args: List[str]):
"""重命名农场名称命令: /refarmname QQ号 新农场名称"""
if len(args) != 2:
print("❌ 用法: /refarmname <QQ号> <新农场名称>")
return
qq_number, new_farm_name = args
# 加载玩家数据
player_data = self.server.load_player_data(qq_number)
if not player_data:
print(f"❌ 玩家 {qq_number} 不存在")
return
# 修改农场名称
old_farm_name = player_data.get("农场名称", "未设置")
player_data["农场名称"] = new_farm_name
# 保存数据
success = self.server.save_player_data(qq_number, player_data)
if success:
print(f"✅ 已重命名玩家 {qq_number} 的农场名称")
print(f" 原农场名: {old_farm_name} → 新农场名: {new_farm_name}")
else:
print(f"❌ 重命名玩家 {qq_number} 农场名称失败")
def cmd_ban_player(self, args: List[str]):
"""踢出玩家命令: /ban QQ号 [时长] [原因]"""
if len(args) < 1 or len(args) > 3:
print("❌ 用法: /ban <QQ号> [时长(秒)] [原因]")
print(" 时长默认为0秒(立即可重新登录),原因默认为'您已被管理员踢出服务器'")
return
qq_number = args[0]
ban_duration = 0 # 默认0秒
ban_reason = "您已被管理员踢出服务器" # 默认原因
# 解析时长参数
if len(args) >= 2:
try:
ban_duration = int(args[1])
if ban_duration < 0:
print("❌ 踢出时长不能为负数")
return
except ValueError:
print("❌ 踢出时长必须是整数(秒)")
return
# 解析原因参数
if len(args) >= 3:
ban_reason = args[2]
# 加载玩家数据
player_data = self.server.load_player_data(qq_number)
if not player_data:
print(f"❌ 玩家 {qq_number} 不存在")
return
# 计算禁止登录时间
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
ban_end_time = ""
if ban_duration > 0:
from datetime import timedelta
end_datetime = datetime.now() + timedelta(seconds=ban_duration)
ban_end_time = end_datetime.strftime("%Y-%m-%d %H:%M:%S")
# 设置禁用系统
if "禁用系统" not in player_data:
player_data["禁用系统"] = {}
player_data["禁用系统"] = {
"是否被禁止登录": ban_duration > 0,
"禁止登录原因": ban_reason,
"禁止登录开始": current_time,
"禁止登录截止": ban_end_time
}
# 保存数据
success = self.server.save_player_data(qq_number, player_data)
if not success:
print(f"❌ 保存玩家 {qq_number} 数据失败")
return
# 如果玩家在线,强制下线
kicked_online = False
if hasattr(self.server, 'user_data'):
for client_id, user_info in self.server.user_data.items():
if user_info.get("username") == qq_number and user_info.get("logged_in", False):
# 发送踢出消息
kick_message = {
"type": "kick_notification",
"reason": ban_reason,
"duration": ban_duration
}
self.server.send_data(client_id, kick_message)
# 断开连接
if hasattr(self.server, 'disconnect_client'):
self.server.disconnect_client(client_id)
kicked_online = True
break
# 输出结果
if ban_duration > 0:
print(f"✅ 已踢出玩家 {qq_number},禁止登录 {ban_duration}")
print(f" 踢出原因: {ban_reason}")
print(f" 禁止登录至: {ban_end_time}")
else:
print(f"✅ 已踢出玩家 {qq_number},可立即重新登录")
print(f" 踢出原因: {ban_reason}")
if kicked_online:
print(f" 玩家已在线,已强制下线")
else:
print(f" 玩家当前不在线")
def cmd_help(self, args: List[str]):
"""显示帮助信息"""
print("🌱 萌芽农场服务器控制台命令帮助")
@@ -404,6 +577,10 @@ class ConsoleCommandsAPI:
print(" /lsplayer - 列出所有已注册玩家")
print(" /playerinfo <QQ号> - 查看玩家详细信息")
print(" /resetland <QQ号> - 重置玩家土地状态")
print(" /repasswd <QQ号> - 重置玩家密码为123456")
print(" /rename <QQ号> <新昵称> - 重命名玩家昵称")
print(" /refarmname <QQ号> <新农场名> - 重命名农场名称")
print(" /ban <QQ号> [时长] [原因] - 踢出玩家(时长秒,原因可选)")
print("")
print("游戏控制命令:")
print(" /weather <类型> - 控制全服天气")

View File

@@ -31,6 +31,7 @@ class QQMailAPI:
self.smtp_server = 'smtp.qq.com'
self.smtp_port = 465 # SSL端口
# 发送纯文本邮件
def send_text_email(self, receiver_email, subject, content, cc_emails=None):
"""
发送纯文本邮件
@@ -65,6 +66,7 @@ class QQMailAPI:
print(f"邮件发送失败:{str(e)}")
return False
# 发送HTML格式邮件可带附件
def send_html_email(self, receiver_email, subject, html_content, cc_emails=None, attachments=None):
"""
发送HTML格式邮件可带附件
@@ -115,6 +117,8 @@ class QQMailAPI:
return False
class EmailVerification:
#生成指定长度的随机验证码
@staticmethod
def generate_verification_code(length=6):
"""
@@ -130,6 +134,7 @@ class EmailVerification:
chars = string.ascii_uppercase + string.digits
return ''.join(random.choice(chars) for _ in range(length))
#发送验证码邮件到QQ邮箱
@staticmethod
def send_verification_email(qq_number, verification_code, email_type="register"):
"""
@@ -192,6 +197,7 @@ class EmailVerification:
except Exception as e:
return False, f"发送验证码失败: {str(e)}"
#保存验证码到MongoDB优先或缓存文件备用
@staticmethod
def save_verification_code(qq_number, verification_code, expiry_time=300, code_type="register"):
"""
@@ -266,6 +272,7 @@ class EmailVerification:
print(f"保存验证码失败: {str(e)}")
return False
#验证用户输入的验证码优先使用MongoDB
@staticmethod
def verify_code(qq_number, input_code, code_type="register"):
"""
@@ -366,6 +373,7 @@ class EmailVerification:
print(f"[验证码系统-JSON] QQ {qq_number} 验证失败: 验证码不匹配")
return False, "验证码错误"
#清理过期的验证码和已使用的验证码优先使用MongoDB
@staticmethod
def clean_expired_codes():
"""
@@ -435,6 +443,7 @@ class EmailVerification:
except Exception as e:
print(f"清理验证码失败: {str(e)}")
#获取验证码状态优先使用MongoDB
@staticmethod
def get_verification_status(qq_number):
"""

View File

@@ -14,6 +14,30 @@ from datetime import datetime, timedelta
from bson import ObjectId
class SMYMongoDBAPI:
# ===================== 配置系统常量 =====================
#游戏配置JSON文档id
CONFIG_IDS = {
"daily_checkin": "687cce278e77ba00a7414ba2",#每日签到配置
"lucky_draw": "687cd52e8e77ba00a7414ba3",#幸运抽奖配置
"new_player": "687cdbd78e77ba00a7414ba4",#新玩家配置
"wisdom_tree": "687cdfbe8e77ba00a7414ba5",#智慧树配置
"online_gift": "687ce7678e77ba00a7414ba6",#在线礼包配置
"scare_crow": "687cea258e77ba00a7414ba8",# 稻草人系统配置
"item": "687cf17c8e77ba00a7414baa",# 道具系统配置
"pet": "687cf59b8e77ba00a7414bab",# 宠物系统配置
"stamina": "687cefba8e77ba00a7414ba9",# 体力值系统配置
"crop_data": "687cfb3d8e77ba00a7414bac",# 作物系统配置
"initial_player_data": "687e2f3f8e77ba00a7414bb0",# 初始玩家数据配置
"verification_codes": "687e35078e77ba00a7414bb1",# 验证码配置
"game_tips": "687e40008e77ba00a7414bb2",# 游戏小提示配置
}
# ===================== 配置系统常量 =====================
#初始化MongoDB API
def __init__(self, environment: str = "test"):
"""
初始化MongoDB API
@@ -51,6 +75,7 @@ class SMYMongoDBAPI:
# 连接数据库
self.connect()
# 连接到MongoDB数据库
def connect(self) -> bool:
"""
连接到MongoDB数据库
@@ -93,6 +118,7 @@ class SMYMongoDBAPI:
self.connected = False
return False
# 断开数据库连接
def disconnect(self):
"""断开数据库连接"""
if self.client:
@@ -100,10 +126,12 @@ class SMYMongoDBAPI:
self.connected = False
self.logger.info("已断开MongoDB连接")
# 检查数据库连接状态
def is_connected(self) -> bool:
"""检查是否已连接到数据库"""
return self.connected and self.client is not None
# 获取集合对象
def get_collection(self, collection_name: str):
"""
获取集合对象
@@ -120,6 +148,7 @@ class SMYMongoDBAPI:
# ========================= 游戏配置管理 =========================
# 获取游戏配置通过ObjectId
def _get_config_by_id(self, object_id: str, config_name: str) -> Optional[Dict[str, Any]]:
"""
通用方法根据ObjectId获取配置
@@ -139,11 +168,13 @@ class SMYMongoDBAPI:
result = collection.find_one({"_id": oid})
if result:
# 移除MongoDB的_id字段updated_at字段
# 移除MongoDB的_id字段updated_at字段和config_type字段
if "_id" in result:
del result["_id"]
if "updated_at" in result:
del result["updated_at"]
if "config_type" in result:
del result["config_type"]
self.logger.info(f"成功获取{config_name}")
return result
@@ -155,6 +186,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取{config_name}失败: {e}")
return None
# 更新游戏配置通过ObjectId
def _update_config_by_id(self, object_id: str, config_data: Dict[str, Any], config_name: str) -> bool:
"""
通用方法根据ObjectId更新配置
@@ -179,10 +211,14 @@ class SMYMongoDBAPI:
**config_data
}
result = collection.replace_one({"_id": oid}, update_data)
# 使用upsert=True来创建或更新文档
result = collection.replace_one({"_id": oid}, update_data, upsert=True)
if result.acknowledged and result.matched_count > 0:
self.logger.info(f"成功更新{config_name}")
if result.acknowledged:
if result.matched_count > 0:
self.logger.info(f"成功更新{config_name}")
elif result.upserted_id:
self.logger.info(f"成功创建{config_name}")
return True
else:
self.logger.error(f"更新{config_name}失败")
@@ -192,6 +228,7 @@ class SMYMongoDBAPI:
self.logger.error(f"更新{config_name}异常: {e}")
return False
# 获取游戏配置通过config_type
def get_game_config(self, config_type: str) -> Optional[Dict[str, Any]]:
"""
获取游戏配置通过config_type
@@ -225,6 +262,8 @@ class SMYMongoDBAPI:
except Exception as e:
self.logger.error(f"获取游戏配置失败 [{config_type}]: {e}")
return None
# 更新游戏配置通过config_type
def set_game_config(self, config_type: str, config_data: Dict[str, Any]) -> bool:
"""
设置游戏配置
@@ -260,23 +299,10 @@ class SMYMongoDBAPI:
except Exception as e:
self.logger.error(f"设置游戏配置异常 [{config_type}]: {e}")
return False
# ========================= 游戏配置管理 =========================
# ===================== 配置系统常量 =====================
CONFIG_IDS = {
"daily_checkin": "687cce278e77ba00a7414ba2",
"lucky_draw": "687cd52e8e77ba00a7414ba3",
"new_player": "687cdbd78e77ba00a7414ba4",
"wisdom_tree": "687cdfbe8e77ba00a7414ba5",
"online_gift": "687ce7678e77ba00a7414ba6",
"scare_crow": "687cea258e77ba00a7414ba8",
"item": "687cf17c8e77ba00a7414baa",
"pet": "687cf59b8e77ba00a7414bab",
"stamina": "687cefba8e77ba00a7414ba9",
"crop_data": "687cfb3d8e77ba00a7414bac",
"initial_player_data": "687e2f3f8e77ba00a7414bb0",
"verification_codes": "687e35078e77ba00a7414bb1"
}
#=====================每日签到系统======================
def get_daily_checkin_config(self) -> Optional[Dict[str, Any]]:
@@ -399,6 +425,18 @@ class SMYMongoDBAPI:
#=====================初始玩家数据模板系统======================
#=====================游戏小提示系统======================
def get_game_tips_config(self) -> Optional[Dict[str, Any]]:
"""获取游戏小提示配置"""
return self._get_config_by_id(self.CONFIG_IDS["game_tips"], "游戏小提示配置")
def update_game_tips_config(self, config_data: Dict[str, Any]) -> bool:
"""更新游戏小提示配置"""
return self._update_config_by_id(self.CONFIG_IDS["game_tips"], config_data, "游戏小提示配置")
#=====================游戏小提示系统======================
#批量更新离线玩家的作物生长(优化版本,支持完整的加速效果计算)
def batch_update_offline_players_crops(self, growth_multiplier: float = 1.0, exclude_online_players: List[str] = None) -> int:
"""
批量更新离线玩家的作物生长(优化版本,支持完整的加速效果计算)
@@ -531,6 +569,7 @@ class SMYMongoDBAPI:
self.logger.error(f"批量更新离线玩家作物失败: {e}")
return 0
#检查玩家是否在新玩家奖励期内注册后3天内享受10倍生长速度
def _is_new_player_bonus_active(self, register_time_str: str) -> bool:
"""
检查玩家是否在新玩家奖励期内注册后3天内享受10倍生长速度
@@ -562,13 +601,10 @@ class SMYMongoDBAPI:
except ValueError as e:
self.logger.warning(f"解析注册时间格式错误: {register_time_str}, 错误: {str(e)}")
return False
# 注意get_offline_players_with_crops 方法已被移除
# 现在使用优化的 batch_update_offline_players_crops 方法直接在 MongoDB 中处理查询和更新
#=====================玩家数据管理======================
# ========================= 验证码系统 =========================
# 保存验证码到MongoDB
def save_verification_code(self, qq_number: str, verification_code: str,
expiry_time: int = 300, code_type: str = "register") -> bool:
"""
@@ -617,8 +653,8 @@ class SMYMongoDBAPI:
self.logger.error(f"保存验证码异常 [QQ {qq_number}]: {e}")
return False
def verify_verification_code(self, qq_number: str, input_code: str,
code_type: str = "register") -> tuple[bool, str]:
#验证用户输入的验证码
def verify_verification_code(self, qq_number: str, input_code: str, code_type: str = "register") -> tuple[bool, str]:
"""
验证用户输入的验证码
@@ -671,6 +707,7 @@ class SMYMongoDBAPI:
self.logger.error(f"验证验证码异常 [QQ {qq_number}]: {e}")
return False, "验证码验证失败"
#清理过期的验证码和已使用的验证码
def clean_expired_verification_codes(self) -> int:
"""
清理过期的验证码和已使用的验证码
@@ -708,10 +745,12 @@ class SMYMongoDBAPI:
self.logger.error(f"清理验证码异常: {e}")
return 0
#=====================验证码系统======================
# ========================= 验证码系统 =========================
# ========================= 通用数据库操作 =========================
#========================玩家数据管理==========================
#获取玩家数据
def get_player_data(self, account_id: str) -> Optional[Dict[str, Any]]:
"""获取玩家数据
@@ -746,6 +785,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取玩家数据失败 [{account_id}]: {e}")
return None
#保存玩家数据
def save_player_data(self, account_id: str, player_data: Dict[str, Any]) -> bool:
"""保存玩家数据
@@ -780,6 +820,7 @@ class SMYMongoDBAPI:
self.logger.error(f"保存玩家数据异常 [{account_id}]: {e}")
return False
#删除玩家数据
def delete_player_data(self, account_id: str) -> bool:
"""删除玩家数据
@@ -806,6 +847,7 @@ class SMYMongoDBAPI:
self.logger.error(f"删除玩家数据异常 [{account_id}]: {e}")
return False
#获取所有玩家的基本信息
def get_all_players_basic_info(self, projection: Dict[str, int] = None) -> List[Dict[str, Any]]:
"""获取所有玩家的基本信息(优化版本,用于排行榜等)
@@ -848,6 +890,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取玩家基本信息失败: {e}")
return []
#根据条件获取玩家数据
def get_players_by_condition(self, condition: Dict[str, Any],
projection: Dict[str, int] = None,
limit: int = 0) -> List[Dict[str, Any]]:
@@ -886,6 +929,7 @@ class SMYMongoDBAPI:
self.logger.error(f"根据条件获取玩家数据失败: {e}")
return []
#获取长时间离线的玩家
def get_offline_players(self, offline_days: int = 3) -> List[Dict[str, Any]]:
"""获取长时间离线的玩家(用于杂草生长等)
@@ -931,6 +975,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取离线玩家失败: {e}")
return []
#检查玩家是否离线超过指定天数
def _is_player_offline_by_time(self, last_login_str: str, offline_days: int) -> bool:
"""检查玩家是否离线超过指定天数"""
try:
@@ -949,6 +994,7 @@ class SMYMongoDBAPI:
except Exception:
return False
#递归转换数据中的datetime对象为字符串
def _convert_datetime_to_string(self, data: Any) -> Any:
"""
递归转换数据中的datetime对象为字符串
@@ -970,6 +1016,7 @@ class SMYMongoDBAPI:
else:
return data
#统计玩家总数
def count_total_players(self) -> int:
"""统计玩家总数
@@ -987,6 +1034,7 @@ class SMYMongoDBAPI:
self.logger.error(f"统计玩家总数失败: {e}")
return 0
#更新玩家的特定字段
def update_player_field(self, account_id: str, field_updates: Dict[str, Any]) -> bool:
"""更新玩家的特定字段
@@ -1019,153 +1067,11 @@ class SMYMongoDBAPI:
except Exception as e:
self.logger.error(f"更新玩家字段异常 [{account_id}]: {e}")
return False
#=====================玩家数据管理======================
#========================玩家数据管理==========================
# ========================= 验证码系统 =========================
def save_verification_code(self, qq_number: str, verification_code: str,
expiry_time: int = 300, code_type: str = "register") -> bool:
"""
保存验证码到MongoDB
Args:
qq_number: QQ号
verification_code: 验证码
expiry_time: 过期时间默认5分钟
code_type: 验证码类型,"register""reset_password"
Returns:
bool: 保存成功返回True否则返回False
"""
try:
import time
from datetime import datetime, timedelta
collection = self.get_collection("verification_codes")
# 计算过期时间
expire_at = datetime.now() + timedelta(seconds=expiry_time)
# 验证码文档
verification_doc = {
"qq_number": qq_number,
"code": verification_code,
"code_type": code_type,
"created_at": datetime.now(),
"expire_at": expire_at,
"used": False
}
# 使用upsert更新或插入覆盖同一QQ号的旧验证码
query = {"qq_number": qq_number, "code_type": code_type}
result = collection.replace_one(query, verification_doc, upsert=True)
if result.acknowledged:
self.logger.info(f"成功保存验证码: QQ {qq_number}, 类型 {code_type}")
return True
else:
self.logger.error(f"保存验证码失败: QQ {qq_number}")
return False
except Exception as e:
self.logger.error(f"保存验证码异常 [QQ {qq_number}]: {e}")
return False
def verify_verification_code(self, qq_number: str, input_code: str,
code_type: str = "register") -> tuple:
"""
验证用户输入的验证码
Args:
qq_number: QQ号
input_code: 用户输入的验证码
code_type: 验证码类型,"register""reset_password"
Returns:
tuple: (验证成功, 消息)
"""
try:
from datetime import datetime
collection = self.get_collection("verification_codes")
# 查找验证码
query = {"qq_number": qq_number, "code_type": code_type}
code_doc = collection.find_one(query)
if not code_doc:
return False, "验证码不存在,请重新获取"
# 检查是否已使用
if code_doc.get("used", False):
return False, "验证码已使用,请重新获取"
# 检查是否过期
if datetime.now() > code_doc.get("expire_at", datetime.now()):
return False, "验证码已过期,请重新获取"
# 验证码码
if input_code.upper() != code_doc.get("code", "").upper():
return False, "验证码错误,请重新输入"
# 标记为已使用
update_result = collection.update_one(
query,
{"$set": {"used": True, "used_at": datetime.now()}}
)
if update_result.acknowledged:
self.logger.info(f"验证码验证成功: QQ {qq_number}, 类型 {code_type}")
return True, "验证码验证成功"
else:
self.logger.error(f"标记验证码已使用失败: QQ {qq_number}")
return False, "验证码验证失败"
except Exception as e:
self.logger.error(f"验证验证码异常 [QQ {qq_number}]: {e}")
return False, "验证码验证失败"
def clean_expired_verification_codes(self) -> int:
"""
清理过期的验证码和已使用的验证码
Returns:
int: 清理的验证码数量
"""
try:
from datetime import datetime, timedelta
collection = self.get_collection("verification_codes")
current_time = datetime.now()
one_hour_ago = current_time - timedelta(hours=1)
# 删除条件:过期的验证码 或 已使用超过1小时的验证码
delete_query = {
"$or": [
{"expire_at": {"$lt": current_time}}, # 过期的
{"used": True, "used_at": {"$lt": one_hour_ago}} # 已使用超过1小时的
]
}
result = collection.delete_many(delete_query)
if result.acknowledged:
deleted_count = result.deleted_count
self.logger.info(f"清理验证码完成: 删除了 {deleted_count} 个验证码")
return deleted_count
else:
self.logger.error("清理验证码失败")
return 0
except Exception as e:
self.logger.error(f"清理验证码异常: {e}")
return 0
#=====================验证码系统======================
# ========================= 通用数据库操作 =========================
#插入文档
def insert_document(self, collection_name: str, document: Dict[str, Any]) -> Optional[str]:
"""
插入文档
@@ -1191,6 +1097,7 @@ class SMYMongoDBAPI:
self.logger.error(f"插入文档失败 [{collection_name}]: {e}")
return None
#查找文档
def find_documents(self, collection_name: str, query: Dict[str, Any] = None,
limit: int = 0) -> List[Dict[str, Any]]:
"""
@@ -1220,6 +1127,9 @@ class SMYMongoDBAPI:
for doc in documents:
if "_id" in doc:
doc["_id"] = str(doc["_id"])
# 如果是gameconfig集合移除config_type字段以防止客户端报错
if collection_name == "gameconfig" and "config_type" in doc:
del doc["config_type"]
# 转换datetime对象为字符串
documents = [self._convert_datetime_to_string(doc) for doc in documents]
@@ -1230,6 +1140,7 @@ class SMYMongoDBAPI:
self.logger.error(f"查找文档失败 [{collection_name}]: {e}")
return []
#更新文档
def update_document(self, collection_name: str, query: Dict[str, Any],
update: Dict[str, Any]) -> bool:
"""
@@ -1253,6 +1164,7 @@ class SMYMongoDBAPI:
self.logger.error(f"更新文档失败 [{collection_name}]: {e}")
return False
#删除文档
def delete_document(self, collection_name: str, query: Dict[str, Any]) -> bool:
"""
删除文档
@@ -1273,9 +1185,12 @@ class SMYMongoDBAPI:
except Exception as e:
self.logger.error(f"删除文档失败 [{collection_name}]: {e}")
return False
# ========================= 通用数据库操作 =========================
# ========================= 聊天消息管理 =========================
#保存聊天消息到MongoDB按天存储
def save_chat_message(self, username: str, player_name: str, content: str) -> bool:
"""
保存聊天消息到MongoDB按天存储
@@ -1341,6 +1256,7 @@ class SMYMongoDBAPI:
self.logger.error(f"保存聊天消息异常: {e}")
return False
#获取聊天历史消息从按天存储的chat集合
def get_chat_history(self, days: int = 3, limit: int = 500) -> List[Dict[str, Any]]:
"""
获取聊天历史消息从按天存储的chat集合
@@ -1399,6 +1315,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取聊天历史失败: {e}")
return []
#获取最新的聊天消息从按天存储的chat集合
def get_latest_chat_message(self) -> Optional[Dict[str, Any]]:
"""
获取最新的聊天消息从按天存储的chat集合
@@ -1439,6 +1356,7 @@ class SMYMongoDBAPI:
self.logger.error(f"获取最新聊天消息失败: {e}")
return None
#删除旧的聊天消息从按天存储的chat集合
def clean_old_chat_messages(self, keep_days: int = 30) -> int:
"""
清理旧的聊天消息从按天存储的chat集合

507
Server/SpecialFarm.py Normal file
View File

@@ -0,0 +1,507 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
特殊农场管理系统
作者: AI Assistant
功能: 管理特殊农场的自动种植和维护
"""
import time
import random
import logging
from datetime import datetime
from SMYMongoDBAPI import SMYMongoDBAPI
from bson import ObjectId
#杂交农场666-种植杂交树1杂交树2-每天0点种植
#花卉农场520-随机种植各种花卉-星期一,星期三,星期五,星期日零点种植
#瓜果农场333-随机种植各种瓜果-星期二,星期四,星期六零点种植
#小麦谷222-全屏种植小麦-每天0点种植
#稻香111-全屏种植稻谷-每天0点种植
#幸运农场888-随机种植1-80个幸运草和幸运花-星期一零点种植
class SpecialFarmManager:
#初始化特殊农场管理器
def __init__(self, environment=None):
"""
初始化特殊农场管理器
Args:
environment: 环境类型,"test""production"如果为None则自动检测
"""
# 如果没有指定环境使用与TCPGameServer相同的环境检测逻辑
if environment is None:
import os
if os.path.exists('/.dockerenv') or os.environ.get('PRODUCTION', '').lower() == 'true':
environment = "production"
else:
environment = "test"
self.environment = environment
self.mongo_api = SMYMongoDBAPI(environment)
# 设置日志
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('special_farm.log', encoding='utf-8'),
logging.StreamHandler()
]
)
self.logger = logging.getLogger(__name__)
# 特殊农场配置
self.special_farms = {
"杂交农场": {
"object_id": "689b4b9286cf953f2f4e56ee",
"crops": ["杂交树1", "杂交树2"],
"description": "专门种植杂交树的特殊农场"
},
"花卉农场": {
"object_id": "689bec6286cf953f2f4e56f1",
"crops": ["郁金香", "牵牛花", "百合花", "栀子花", "玫瑰花", "向日葵", "藏红花", "幸运花"],
"description": "盛产各种美丽花卉的特殊农场",
"plant_type": "random_flowers" # 标记为随机花卉种植类型
},
"瓜果农场": {
"object_id": "689bf73886cf953f2f4e56fa",
"crops": ["西瓜", "南瓜", "哈密瓜", "葫芦", "黄瓜", "龙果", "菠萝", "芒果"],
"description": "盛产各种瓜果的农场",
"plant_type": "random_fruits" # 标记为随机瓜果种植类型
},
"小麦谷": {
"object_id": "689bf9a886cf953f2f4e56fd",
"crops": ["小麦"],
"description": "盛产小麦的农场",
"plant_type": "single_wheat" # 标记为单一小麦种植类型
},
"稻香": {
"object_id": "689bf9ac86cf953f2f4e56fe",
"crops": ["稻谷"],
"description": "盛产稻谷的农场",
"plant_type": "single_rice" # 标记为单一稻谷种植类型
},
"幸运农场": {
"object_id": "689c027886cf953f2f4e56ff",
"crops": ["幸运草", "幸运花"],
"description": "盛产幸运草和幸运花的农场",
"plant_type": "random_lucky" # 标记为随机幸运植物种植类型
}
}
self.logger.info(f"特殊农场管理器初始化完成 - 环境: {environment}")
#获取作物系统数据
def get_crop_data(self):
"""
获取作物配置数据
Returns:
dict: 作物配置数据
"""
try:
crop_config = self.mongo_api.get_crop_data_config()
if crop_config:
# 移除MongoDB相关字段
if "_id" in crop_config:
del crop_config["_id"]
if "config_type" in crop_config:
del crop_config["config_type"]
if "updated_at" in crop_config:
del crop_config["updated_at"]
return crop_config
else:
self.logger.error("无法获取作物配置数据")
return {}
except Exception as e:
self.logger.error(f"获取作物配置数据时出错: {str(e)}")
return {}
#通过文档ID获取农场数据
def get_player_data_by_object_id(self, object_id):
"""
通过ObjectId获取玩家数据
Args:
object_id: MongoDB文档ID
Returns:
dict: 玩家数据如果未找到返回None
"""
try:
collection = self.mongo_api.get_collection("playerdata")
oid = ObjectId(object_id)
player_data = collection.find_one({"_id": oid})
if player_data:
self.logger.info(f"成功获取玩家数据: {player_data.get('玩家昵称', 'Unknown')}")
return player_data
else:
self.logger.warning(f"未找到ObjectId为 {object_id} 的玩家数据")
return None
except Exception as e:
self.logger.error(f"获取玩家数据时出错: {str(e)}")
return None
#通过文档ID保存农场数据
def save_player_data_by_object_id(self, object_id, player_data):
"""
通过ObjectId保存玩家数据
Args:
object_id: MongoDB文档ID
player_data: 玩家数据
Returns:
bool: 是否保存成功
"""
try:
collection = self.mongo_api.get_collection("playerdata")
oid = ObjectId(object_id)
# 更新最后登录时间
player_data["最后登录时间"] = datetime.now().strftime("%Y年%m月%d%H时%M分%S秒")
result = collection.replace_one({"_id": oid}, player_data)
if result.acknowledged and result.matched_count > 0:
self.logger.info(f"成功保存玩家数据: {player_data.get('玩家昵称', 'Unknown')}")
return True
else:
self.logger.error(f"保存玩家数据失败: ObjectId {object_id}")
return False
except Exception as e:
self.logger.error(f"保存玩家数据时出错: {str(e)}")
return False
#在指定农场种植作物
def plant_crops_in_farm(self, farm_name):
"""
为指定特殊农场种植作物
Args:
farm_name: 农场名称
Returns:
bool: 是否种植成功
"""
if farm_name not in self.special_farms:
self.logger.error(f"未知的特殊农场: {farm_name}")
return False
farm_config = self.special_farms[farm_name]
object_id = farm_config["object_id"]
available_crops = farm_config["crops"]
# 获取玩家数据
player_data = self.get_player_data_by_object_id(object_id)
if not player_data:
return False
# 获取作物配置
crop_data = self.get_crop_data()
if not crop_data:
self.logger.error("无法获取作物配置,跳过种植")
return False
# 检查作物是否存在
for crop_name in available_crops:
if crop_name not in crop_data:
self.logger.error(f"作物 {crop_name} 不存在于作物配置中")
return False
# 获取农场土地
farm_lands = player_data.get("农场土地", [])
if not farm_lands:
self.logger.error(f"农场 {farm_name} 没有土地数据")
return False
planted_count = 0
plant_type = farm_config.get("plant_type", "normal")
# 遍历所有土地,先开垦再种植作物
for i, land in enumerate(farm_lands):
# 根据农场类型选择作物
if plant_type == "random_flowers":
# 花卉农场:随机种植各种花卉,种满所有土地
crop_name = random.choice(available_crops)
should_plant = True # 100%种植率,种满所有土地
elif plant_type == "random_fruits":
# 瓜果农场:随机种植各种瓜果,种满所有土地
crop_name = random.choice(available_crops)
should_plant = True # 100%种植率,种满所有土地
elif plant_type == "single_wheat":
# 小麦谷:全屏种植小麦,种满所有土地
crop_name = "小麦"
should_plant = True # 100%种植率,种满所有土地
elif plant_type == "single_rice":
# 稻香:全屏种植稻谷,种满所有土地
crop_name = "稻谷"
should_plant = True # 100%种植率,种满所有土地
elif plant_type == "random_lucky":
# 幸运农场随机种植1-80个幸运草和幸运花
crop_name = random.choice(available_crops)
# 随机决定是否种植确保总数在1-80之间
target_plants = random.randint(1, min(80, len(farm_lands)))
should_plant = planted_count < target_plants
else:
# 普通农场:按原逻辑随机选择
crop_name = random.choice(available_crops)
should_plant = True
if should_plant:
crop_info = crop_data[crop_name]
# 更新土地数据(先开垦,再种植)
land.update({
"is_diged": True, # 确保土地已开垦
"is_planted": True,
"crop_type": crop_name,
"grow_time": 0, # 立即成熟
"max_grow_time": crop_info.get("生长时间", 21600),
"is_dead": False,
"已浇水": True,
"已施肥": True,
"土地等级": 0
})
# 清除施肥时间戳
if "施肥时间" in land:
del land["施肥时间"]
planted_count += 1
else:
# 留空的土地:只开垦不种植
land.update({
"is_diged": True,
"is_planted": False,
"crop_type": "",
"grow_time": 0,
"max_grow_time": 3,
"is_dead": False,
"已浇水": False,
"已施肥": False,
"土地等级": 0
})
# 清除施肥时间戳
if "施肥时间" in land:
del land["施肥时间"]
# 保存玩家数据
if self.save_player_data_by_object_id(object_id, player_data):
self.logger.info(f"成功为 {farm_name} 种植了 {planted_count} 块土地的作物")
return True
else:
self.logger.error(f"保存 {farm_name} 数据失败")
return False
#每日维护任务
def daily_maintenance(self):
"""
每日维护任务
"""
from datetime import datetime
self.logger.info("开始执行特殊农场维护任务...")
success_count = 0
total_farms = 0
current_time = datetime.now()
current_weekday = current_time.weekday() # 0=Monday, 1=Tuesday, ..., 6=Sunday
current_time_str = current_time.strftime("%Y-%m-%d %H:%M:%S")
for farm_name in self.special_farms.keys():
# 检查农场是否需要在今天维护
should_maintain = True
if farm_name == "瓜果农场":
# 瓜果农场只在星期二(1)、四(3)、六(5)维护
if current_weekday not in [1, 3, 5]:
should_maintain = False
self.logger.info(f"瓜果农场今日({['周一','周二','周三','周四','周五','周六','周日'][current_weekday]})不需要维护")
elif farm_name == "幸运农场":
# 幸运农场只在星期一(0)维护
if current_weekday != 0:
should_maintain = False
self.logger.info(f"幸运农场今日({['周一','周二','周三','周四','周五','周六','周日'][current_weekday]})不需要维护")
if should_maintain:
total_farms += 1
try:
if self.plant_crops_in_farm(farm_name):
success_count += 1
self.logger.info(f"农场 {farm_name} 维护完成")
# 更新维护时间记录
try:
farm_config = self.special_farms[farm_name]
object_id = farm_config["object_id"]
player_data = self.get_player_data_by_object_id(object_id)
if player_data:
player_data["特殊农场最后维护时间"] = current_time_str
self.save_player_data_by_object_id(object_id, player_data)
except Exception as record_error:
self.logger.error(f"更新 {farm_name} 维护时间记录失败: {str(record_error)}")
else:
self.logger.error(f"农场 {farm_name} 维护失败")
except Exception as e:
self.logger.error(f"维护农场 {farm_name} 时出错: {str(e)}")
self.logger.info(f"维护任务完成: {success_count}/{total_farms} 个农场维护成功")
#启动定时任务调度器(后台线程模式)
def start_scheduler(self):
"""
启动定时任务调度器(后台线程模式)
"""
import threading
self.logger.info("特殊农场定时任务调度器已启动")
self.logger.info("维护任务将在每天凌晨0点执行")
# 检查是否需要立即执行维护任务
self._check_and_run_initial_maintenance()
# 在后台线程中运行调度循环
def scheduler_loop():
last_maintenance_date = None
while True:
try:
now = datetime.now()
current_date = now.strftime("%Y-%m-%d")
# 检查是否到了零点且今天还没有执行过维护
if (now.hour == 0 and now.minute == 0 and
last_maintenance_date != current_date):
self.logger.info("零点维护时间到,开始执行维护任务...")
self.daily_maintenance()
last_maintenance_date = current_date
time.sleep(60) # 每分钟检查一次
except Exception as e:
self.logger.error(f"调度器运行时出错: {str(e)}")
time.sleep(60)
# 启动后台线程
scheduler_thread = threading.Thread(target=scheduler_loop, daemon=True)
scheduler_thread.start()
self.logger.info("特殊农场调度器已在后台线程启动")
#检查是否需要执行初始维护任务
def _check_and_run_initial_maintenance(self):
"""
检查是否需要执行初始维护任务
避免服务器重启时重复执行
"""
try:
from datetime import datetime, timedelta
# 检查今天是否已经执行过维护任务
current_time = datetime.now()
today = current_time.strftime("%Y-%m-%d")
current_weekday = current_time.weekday() # 0=Monday, 1=Tuesday, ..., 6=Sunday
# 获取特殊农场数据,检查最后维护时间
for farm_name, farm_config in self.special_farms.items():
object_id = farm_config["object_id"]
player_data = self.get_player_data_by_object_id(object_id)
# 检查农场是否需要在今天维护
should_maintain = True
if farm_name == "瓜果农场":
# 瓜果农场只在星期二(1)、四(3)、六(5)维护
if current_weekday not in [1, 3, 5]:
should_maintain = False
self.logger.info(f"瓜果农场今日({['周一','周二','周三','周四','周五','周六','周日'][current_weekday]})不需要维护")
elif farm_name == "幸运农场":
# 幸运农场只在星期一(0)维护
if current_weekday != 0:
should_maintain = False
self.logger.info(f"幸运农场今日({['周一','周二','周三','周四','周五','周六','周日'][current_weekday]})不需要维护")
if should_maintain and player_data:
last_maintenance = player_data.get("特殊农场最后维护时间", "")
# 如果今天还没有维护过,则执行维护
if not last_maintenance or not last_maintenance.startswith(today):
self.logger.info(f"检测到 {farm_name} 今日尚未维护,执行维护任务...")
if self.plant_crops_in_farm(farm_name):
# 更新维护时间记录
player_data["特殊农场最后维护时间"] = current_time.strftime("%Y-%m-%d %H:%M:%S")
self.save_player_data_by_object_id(object_id, player_data)
else:
self.logger.info(f"{farm_name} 今日已维护过,跳过初始维护")
except Exception as e:
self.logger.error(f"检查初始维护任务时出错: {str(e)}")
# 如果检查失败,执行一次维护作为备用
self.logger.info("执行备用维护任务...")
self.daily_maintenance()
#停止定时任务调度器
def stop_scheduler(self):
"""
停止定时任务调度器
"""
try:
# 设置停止标志(如果需要的话)
self.logger.info("特殊农场定时任务调度器已停止")
except Exception as e:
self.logger.error(f"停止定时任务调度器时出错: {str(e)}")
#手动执行维护任务
def manual_maintenance(self, farm_name=None):
"""
手动执行维护任务
Args:
farm_name: 指定农场名称如果为None则维护所有农场
"""
if farm_name:
if farm_name in self.special_farms:
self.logger.info(f"手动维护农场: {farm_name}")
return self.plant_crops_in_farm(farm_name)
else:
self.logger.error(f"未知的农场名称: {farm_name}")
return False
else:
self.logger.info("手动维护所有特殊农场")
self.daily_maintenance()
return True
def main():
"""
主函数
"""
import sys
# 检查命令行参数
environment = "production"
if len(sys.argv) > 1:
if sys.argv[1] in ["test", "production"]:
environment = sys.argv[1]
else:
print("使用方法: python SpecialFarm.py [test|production]")
sys.exit(1)
# 创建特殊农场管理器
manager = SpecialFarmManager(environment)
# 检查是否为手动模式
if len(sys.argv) > 2 and sys.argv[2] == "manual":
# 手动执行维护
farm_name = sys.argv[3] if len(sys.argv) > 3 else None
manager.manual_maintenance(farm_name)
else:
# 启动定时任务
manager.start_scheduler()
if __name__ == "__main__":
main()

View File

@@ -12,6 +12,8 @@ import random
from SMYMongoDBAPI import SMYMongoDBAPI #导入MongoDB数据库模块
from QQEmailSendAPI import EmailVerification#导入QQ邮箱发送模块
from ConsoleCommandsAPI import ConsoleCommandsAPI #导入控制台命令API模块
from SpecialFarm import SpecialFarmManager #导入特殊农场管理系统
from WSRemoteCmdApi import WSRemoteCmdApi #导入WebSocket远程命令API
"""
萌芽农场TCP游戏服务器
@@ -24,7 +26,7 @@ from ConsoleCommandsAPI import ConsoleCommandsAPI #导入控制台命令API模
server_host: str = "0.0.0.0"
server_port: int = 7070
buffer_size: int = 4096
server_version: str = "2.0.1"
server_version: str = "2.2.0"
class TCPGameServer(TCPServer):
@@ -65,6 +67,15 @@ class TCPGameServer(TCPServer):
self.log('INFO', f"萌芽农场TCP游戏服务器初始化完成 - 版本: {server_version}", 'SERVER')
# 清理配置缓存,确保使用最新的配置数据
self._clear_config_cache()
# 初始化特殊农场管理系统
self._init_special_farm_manager()
# 初始化WebSocket远程命令API
self._init_websocket_remote_api()
# 启动定时器
self.start_crop_growth_timer()
self.start_weed_growth_timer()
@@ -111,6 +122,47 @@ class TCPGameServer(TCPServer):
self.weed_growth_probability = 0.3 # 每个空地长杂草的概率30%
self.last_weed_check_time = time.time() # 上次检查杂草的时间
#初始化特殊农场管理系统
def _init_special_farm_manager(self):
"""初始化特殊农场管理系统"""
try:
# 使用自动环境检测,确保与游戏服务器环境一致
self.special_farm_manager = SpecialFarmManager()
# 启动特殊农场定时任务
self.special_farm_manager.start_scheduler()
self.log('INFO', f"特殊农场管理系统初始化完成 - 环境: {self.special_farm_manager.environment}", 'SERVER')
except Exception as e:
self.log('ERROR', f"特殊农场管理系统初始化失败: {str(e)}", 'SERVER')
self.special_farm_manager = None
#初始化WebSocket远程命令API
def _init_websocket_remote_api(self):
"""初始化WebSocket远程命令API服务器"""
try:
# 创建WebSocket远程命令API实例
ws_host = "0.0.0.0"
ws_port = 7071
auth_key = "mengya2024" # 可以从配置文件读取
self.ws_remote_api = WSRemoteCmdApi(
game_server=self,
host=ws_host,
port=ws_port,
auth_key=auth_key
)
# 启动WebSocket服务器
self.ws_remote_api.start_server()
self.log('INFO', f"WebSocket远程命令API初始化完成 - ws://{ws_host}:{ws_port}", 'SERVER')
except Exception as e:
self.log('ERROR', f"WebSocket远程命令API初始化失败: {str(e)}", 'SERVER')
self.ws_remote_api = None
#设置游戏服务器日志配置
def _setup_game_server_logging(self):
"""设置游戏服务器日志配置,禁用父类重复输出"""
@@ -230,6 +282,28 @@ class TCPGameServer(TCPServer):
self.offline_crop_timer = None
self.log('INFO', "离线作物更新定时器已停止", 'SERVER')
# 停止特殊农场管理系统
if hasattr(self, 'special_farm_manager') and self.special_farm_manager:
try:
# 停止特殊农场定时任务
self.special_farm_manager.stop_scheduler()
# 清理特殊农场管理器引用
self.special_farm_manager = None
self.log('INFO', "特殊农场管理系统已停止", 'SERVER')
except Exception as e:
self.log('ERROR', f"停止特殊农场管理系统时出错: {str(e)}", 'SERVER')
# 停止WebSocket远程命令API服务器
if hasattr(self, 'ws_remote_api') and self.ws_remote_api:
try:
self.ws_remote_api.stop_server()
self.ws_remote_api = None
self.log('INFO', "WebSocket远程命令API服务器已停止", 'SERVER')
except Exception as e:
self.log('ERROR', f"停止WebSocket远程命令API服务器时出错: {str(e)}", 'SERVER')
# 显示服务器统计信息
stats = self.get_server_stats()
self.log('INFO', f"服务器统计 - 在线玩家: {stats['online_players']}, 总连接: {stats['total_connections']}", 'SERVER')
@@ -252,14 +326,6 @@ class TCPGameServer(TCPServer):
self._update_player_logout_time(client_id, username)
self.log('INFO', f"用户 {username} 登出", 'SERVER')
# 广播用户离开消息
self.broadcast({
"type": "user_left",
"user_id": client_id,
"timestamp": time.time(),
"remaining_users": len(self.clients) - 1
}, exclude=[client_id])
# 清理用户数据
if client_id in self.user_data:
# 清理偷菜免被发现计数器
@@ -267,8 +333,20 @@ class TCPGameServer(TCPServer):
del self.user_data[client_id]
self.log('INFO', f"用户 {username} 已离开游戏", 'SERVER')
super()._remove_client(client_id)
# 先调用父类方法移除客户端,避免递归调用
super()._remove_client(client_id)
# 在客户端已移除后再广播用户离开消息,避免向已断开的客户端发送消息
self.broadcast({
"type": "user_left",
"user_id": client_id,
"timestamp": time.time(),
"remaining_users": len(self.clients)
})
else:
# 如果客户端不在列表中,直接调用父类方法
super()._remove_client(client_id)
#==========================客户端连接管理==========================
@@ -364,6 +442,12 @@ class TCPGameServer(TCPServer):
return player_data, username, None
#加载作物配置数据(优化版本)
def _clear_config_cache(self):
"""清理配置缓存,强制重新加载"""
self.crop_data_cache = None
self.crop_data_cache_time = 0
self.log('INFO', "配置缓存已清理", 'SERVER')
def _load_crop_data(self):
"""加载作物配置数据从MongoDB带缓存优化"""
current_time = time.time()
@@ -468,20 +552,34 @@ class TCPGameServer(TCPServer):
self.log('WARNING', 'MongoDB未配置或不可用无法更新离线玩家作物', 'SERVER')
return
# 获取当前在线玩家列表
online_players = []
# 获取需要排除的玩家列表(在线玩家 + 被访问的玩家)
exclude_players = []
# 添加在线玩家
for client_id, user_info in self.user_data.items():
if user_info.get("logged_in", False) and user_info.get("username"):
online_players.append(user_info["username"])
exclude_players.append(user_info["username"])
# 直接调用优化后的批量更新方法,传入在线玩家列表进行排除
# 添加被访问的玩家(避免访问模式下的重复更新)
visited_players = set()
for client_id, user_info in self.user_data.items():
if (user_info.get("logged_in", False) and
user_info.get("visiting_mode", False) and
user_info.get("visiting_target")):
visited_players.add(user_info["visiting_target"])
# 将被访问的玩家也加入排除列表
exclude_players.extend(list(visited_players))
# 直接调用优化后的批量更新方法,传入排除玩家列表
# 离线更新间隔为60秒所以每次更新应该增长60秒
updated_count = self.mongo_api.batch_update_offline_players_crops(
growth_multiplier=1.0,
exclude_online_players=online_players
growth_multiplier=60.0,
exclude_online_players=exclude_players
)
if updated_count > 0:
self.log('INFO', f"成功更新了 {updated_count} 个离线玩家的作物生长", 'SERVER')
self.log('INFO', f"成功更新了 {updated_count} 个离线玩家的作物生长(排除了 {len(exclude_players)} 个在线/被访问玩家)", 'SERVER')
else:
self.log('DEBUG', "没有离线玩家的作物需要更新", 'SERVER')
@@ -496,26 +594,37 @@ class TCPGameServer(TCPServer):
#作物生长更新系统
def update_crops_growth(self):
"""更新所有玩家的作物生长"""
# 更新在线玩家的作物
# 收集所有需要更新的玩家(在线玩家 + 被访问的玩家)
players_to_update = set()
# 添加在线玩家
for client_id, user_info in self.user_data.items():
if not user_info.get("logged_in", False):
continue
username = user_info.get("username")
if not username:
continue
if user_info.get("logged_in", False) and user_info.get("username"):
players_to_update.add(user_info.get("username"))
# 添加被访问的玩家(即使他们不在线)
for client_id, user_info in self.user_data.items():
if user_info.get("logged_in", False) and user_info.get("visiting_mode", False):
visiting_target = user_info.get("visiting_target", "")
if visiting_target:
players_to_update.add(visiting_target)
# 更新所有需要更新的玩家的作物
for username in players_to_update:
try:
player_data = self.load_player_data(username)
if not player_data:
continue
if self.update_player_crops(player_data, username):
self.save_player_data(username, player_data)
self._push_crop_update_to_player(username, player_data)
# 确保数据保存成功后才推送更新
if self.save_player_data(username, player_data):
self._push_crop_update_to_player(username, player_data)
else:
self.log('ERROR', f"保存玩家 {username} 数据失败,跳过推送更新", 'SERVER')
except Exception as e:
self.log('ERROR', f"更新在线玩家 {username} 作物时出错: {str(e)}", 'SERVER')
self.log('ERROR', f"更新玩家 {username} 作物时出错: {str(e)}", 'SERVER')
#更新单个玩家的作物
def update_player_crops(self, player_data, account_id):
@@ -593,6 +702,9 @@ class TCPGameServer(TCPServer):
self._send_visiting_update(client_id, visiting_target)
else:
self._send_normal_update(client_id, player_data)
# 检查是否有其他玩家正在访问这个玩家的农场
self._push_update_to_visitors(account_id, player_data)
#根据用户名查找客户端ID
def _find_client_by_username(self, username):
@@ -629,6 +741,31 @@ class TCPGameServer(TCPServer):
"is_visiting": False
}
self.send_data(client_id, update_message)
#向正在访问某个玩家农场的其他玩家推送更新
def _push_update_to_visitors(self, target_username, target_player_data):
"""向正在访问某个玩家农场的其他玩家推送更新"""
for visitor_client_id, visitor_info in self.user_data.items():
if not visitor_info.get("logged_in", False):
continue
visiting_mode = visitor_info.get("visiting_mode", False)
visiting_target = visitor_info.get("visiting_target", "")
# 如果这个玩家正在访问目标玩家的农场,发送更新
if visiting_mode and visiting_target == target_username:
target_client_id = self._find_client_by_username(target_username)
update_message = {
"type": "crop_update",
"农场土地": target_player_data.get("农场土地", []),
"timestamp": time.time(),
"is_visiting": True,
"visited_player": target_username,
"target_online": target_client_id is not None
}
self.send_data(visitor_client_id, update_message)
self.log('DEBUG', f"向访问者 {visitor_info.get('username', 'unknown')} 推送 {target_username} 的农场更新", 'SERVER')
#================================作物系统管理=========================================
@@ -709,6 +846,8 @@ class TCPGameServer(TCPServer):
return self._handle_item_config_request(client_id)
elif message_type == "request_pet_config":#请求宠物配置数据
return self._handle_pet_config_request(client_id)
elif message_type == "request_game_tips_config":#请求游戏小提示配置数据
return self._handle_game_tips_config_request(client_id)
elif message_type == "visit_player":#拜访其他玩家农场
return self._handle_visit_player_request(client_id, message)
elif message_type == "return_my_farm":#返回我的农场
@@ -769,7 +908,15 @@ class TCPGameServer(TCPServer):
return self._handle_pet_battle_result(client_id, message)
elif message_type == "today_divination":#今日占卜
return self._handle_today_divination(client_id, message)
elif message_type == "give_money":#送金币
return self._handle_give_money_request(client_id, message)
elif message_type == "sync_bag_data":#同步背包数据
return self._handle_sync_bag_data(client_id, message)
#---------------------------------------------------------------------------
# 管理员操作相关
elif message_type == "kick_player":#踢出玩家
return self._handle_kick_player(client_id, message)
elif message_type == "message":#处理聊天消息(暂未实现)
return self._handle_chat_message(client_id, message)
@@ -833,6 +980,60 @@ class TCPGameServer(TCPServer):
player_data = self.load_player_data(username)
if player_data and player_data.get("玩家密码") == password:
# 检查禁用系统
ban_system = player_data.get("禁用系统", {})
is_banned = ban_system.get("是否被禁止登录", False)
if is_banned:
# 检查禁止登录是否已过期
ban_end_time = ban_system.get("禁止登录截止", "")
if ban_end_time:
try:
end_datetime = datetime.datetime.strptime(ban_end_time, "%Y-%m-%d %H:%M:%S")
current_datetime = datetime.datetime.now()
if current_datetime >= end_datetime:
# 禁止登录已过期,解除禁止
player_data["禁用系统"] = {
"是否被禁止登录": False,
"禁止登录原因": "",
"禁止登录开始": "",
"禁止登录截止": ""
}
self.save_player_data(username, player_data)
self.log('INFO', f"用户 {username} 禁止登录已过期,自动解除", 'SERVER')
else:
# 仍在禁止期内
ban_reason = ban_system.get("禁止登录原因", "您已被管理员禁止登录")
self.log('WARNING', f"用户 {username} 登录失败: 账号被禁止登录", 'SERVER')
response = {
"type": "login_response",
"status": "banned",
"message": ban_reason,
"ban_end_time": ban_end_time
}
return self.send_data(client_id, response)
except Exception as e:
self.log('ERROR', f"解析禁止登录时间出错: {e}", 'SERVER')
# 如果解析出错,仍然禁止登录
ban_reason = ban_system.get("禁止登录原因", "您已被管理员禁止登录")
response = {
"type": "login_response",
"status": "banned",
"message": ban_reason
}
return self.send_data(client_id, response)
else:
# 永久禁止或没有截止时间
ban_reason = ban_system.get("禁止登录原因", "您已被管理员禁止登录")
self.log('WARNING', f"用户 {username} 登录失败: 账号被永久禁止登录", 'SERVER')
response = {
"type": "login_response",
"status": "banned",
"message": ban_reason
}
return self.send_data(client_id, response)
# 登录成功
self.log('INFO', f"用户 {username} 登录成功", 'SERVER')
@@ -2441,6 +2642,25 @@ class TCPGameServer(TCPServer):
self.log('ERROR', f"从MongoDB加载宠物配置失败: {str(e)}", 'SERVER')
return {}
def _load_game_tips_config(self):
"""从MongoDB加载游戏小提示配置数据"""
try:
if not hasattr(self, 'mongo_api') or not self.mongo_api:
self.log('ERROR', 'MongoDB未配置或不可用无法加载游戏小提示配置数据', 'SERVER')
return {}
config = self.mongo_api.get_game_tips_config()
if config:
self.log('INFO', "成功从MongoDB加载游戏小提示配置", 'SERVER')
return config
else:
self.log('ERROR', "MongoDB中未找到游戏小提示配置", 'SERVER')
return {}
except Exception as e:
self.log('ERROR', f"从MongoDB加载游戏小提示配置失败: {str(e)}", 'SERVER')
return {}
# 将巡逻宠物ID转换为完整宠物数据
def _convert_patrol_pets_to_full_data(self, player_data):
"""将存储的巡逻宠物ID转换为完整的宠物数据"""
@@ -5228,8 +5448,27 @@ class TCPGameServer(TCPServer):
"success": False,
"message": "无法读取宠物配置数据"
})
#==========================道具配置数据处理==========================
#处理客户端请求游戏小提示配置数据
def _handle_game_tips_config_request(self, client_id):
"""处理客户端请求游戏小提示配置数据"""
game_tips_config = self._load_game_tips_config()
if game_tips_config:
self.log('INFO', f"向客户端 {client_id} 发送游戏小提示配置数据", 'SERVER')
return self.send_data(client_id, {
"type": "game_tips_config_response",
"success": True,
"game_tips_config": game_tips_config
})
else:
return self.send_data(client_id, {
"type": "game_tips_config_response",
"success": False,
"message": "无法读取游戏小提示配置数据"
})
#==========================升级土地处理==========================
@@ -6325,10 +6564,19 @@ class TCPGameServer(TCPServer):
"点赞数": target_player_data.get("点赞系统", {}).get("总点赞数", 0), # 添加点赞数
"最后登录时间": target_player_data.get("最后登录时间", "未知"),
"总游玩时间": target_player_data.get("总游玩时间", "0时0分0秒"),
"total_likes": target_player_data.get("total_likes", 0)
"total_likes": target_player_data.get("total_likes", 0),
"访问系统": target_player_data.get("访问系统", {
"总访问人数": 0,
"今日访问人数": 0,
"访问记录": {}
}) # 添加访问系统数据
}
current_username = self.user_data[client_id]["username"]
# 更新被访问玩家的访问系统数据
self._update_visit_system(target_username, current_username)
self.log('INFO', f"玩家 {current_username} 访问了玩家 {target_username} 的农场", 'SERVER')
# 记录玩家的访问状态
@@ -6344,6 +6592,229 @@ class TCPGameServer(TCPServer):
})
#==========================访问其他玩家农场处理==========================
#==========================访问系统处理==========================
def _update_visit_system(self, target_username, visitor_username):
"""更新被访问玩家的访问系统数据"""
try:
# 加载被访问玩家的数据
target_player_data = self.load_player_data(target_username)
if not target_player_data:
self.log('ERROR', f"无法加载被访问玩家 {target_username} 的数据", 'SERVER')
return
# 获取访问者的昵称
visitor_player_data = self.load_player_data(visitor_username)
visitor_nickname = visitor_player_data.get("玩家昵称", visitor_username) if visitor_player_data else visitor_username
# 初始化访问系统(如果不存在)
if "访问系统" not in target_player_data:
target_player_data["访问系统"] = {
"总访问人数": 0,
"今日访问人数": 0,
"访问记录": {}
}
visit_system = target_player_data["访问系统"]
# 获取今日日期
from datetime import datetime
today = datetime.now().strftime("%Y-%m-%d")
# 更新总访问人数
visit_system["总访问人数"] = visit_system.get("总访问人数", 0) + 1
# 检查是否需要重置今日访问人数(新的一天)
last_visit_date = visit_system.get("最后访问日期", "")
if last_visit_date != today:
visit_system["今日访问人数"] = 0
visit_system["最后访问日期"] = today
# 更新今日访问人数
visit_system["今日访问人数"] = visit_system.get("今日访问人数", 0) + 1
# 更新访问记录
if "访问记录" not in visit_system:
visit_system["访问记录"] = {}
if today not in visit_system["访问记录"]:
visit_system["访问记录"][today] = []
# 添加访问者昵称到今日访问记录(避免重复)
if visitor_nickname not in visit_system["访问记录"][today]:
visit_system["访问记录"][today].append(visitor_nickname)
# 保存更新后的数据
if self.save_player_data(target_username, target_player_data):
self.log('INFO', f"成功更新玩家 {target_username} 的访问系统数据,访问者: {visitor_nickname}", 'SERVER')
else:
self.log('ERROR', f"保存玩家 {target_username} 的访问系统数据失败", 'SERVER')
except Exception as e:
self.log('ERROR', f"更新访问系统数据时出错: {e}", 'SERVER')
def _reset_daily_visit_count(self):
"""重置所有玩家的今日访问人数(凌晨调用)"""
try:
# 获取所有玩家的基本信息
if hasattr(self, 'mongo_api') and self.mongo_api:
players_info = self.mongo_api.get_all_players_basic_info()
from datetime import datetime
today = datetime.now().strftime("%Y-%m-%d")
reset_count = 0
for player_info in players_info:
username = player_info.get("玩家账号")
if username:
player_data = self.load_player_data(username)
if player_data and "访问系统" in player_data:
visit_system = player_data["访问系统"]
last_visit_date = visit_system.get("最后访问日期", "")
# 如果不是今天,重置今日访问人数
if last_visit_date != today:
visit_system["今日访问人数"] = 0
visit_system["最后访问日期"] = today
if self.save_player_data(username, player_data):
reset_count += 1
self.log('INFO', f"成功重置了 {reset_count} 个玩家的今日访问人数", 'SERVER')
except Exception as e:
self.log('ERROR', f"重置今日访问人数时出错: {e}", 'SERVER')
def _handle_give_money_request(self, client_id, message):
"""处理送金币请求"""
try:
# 获取发送者信息
sender_info = self.user_data.get(client_id)
if not sender_info or not sender_info.get("logged_in", False):
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "请先登录"
})
return
sender_username = sender_info.get("username")
target_username = message.get("target_username", "")
amount = message.get("amount", 0)
# 验证参数
if not target_username:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "目标玩家用户名不能为空"
})
return
if amount != 500:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "每次只能送500金币"
})
return
if sender_username == target_username:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "不能给自己送金币"
})
return
# 加载发送者数据
sender_data = self.load_player_data(sender_username)
if not sender_data:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "无法加载发送者数据"
})
return
# 检查发送者金币是否足够
sender_money = sender_data.get("钱币", 0)
if sender_money < amount:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": f"您的金币不足,当前拥有{sender_money}金币"
})
return
# 加载接收者数据
target_data = self.load_player_data(target_username)
if not target_data:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "目标玩家不存在"
})
return
# 执行金币转移
sender_data["钱币"] = sender_money - amount
target_data["钱币"] = target_data.get("钱币", 0) + amount
# 记录送金币日志
from datetime import datetime
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log_message = f"[{current_time}] {sender_username} 送给 {target_username} {amount}金币"
self.log('INFO', log_message, 'GIVE_MONEY')
# 保存数据
if self.save_player_data(sender_username, sender_data) and self.save_player_data(target_username, target_data):
# 获取目标玩家昵称
target_nickname = target_data.get("玩家昵称", target_username)
# 发送成功响应
self.send_data(client_id, {
"type": "give_money_response",
"success": True,
"message": f"成功送给 {target_nickname} {amount}金币!",
"updated_data": {
"钱币": sender_data["钱币"]
},
"target_updated_data": {
"钱币": target_data["钱币"]
}
})
# 如果目标玩家在线,通知他们收到金币
target_client_id = None
for cid, user_info in self.user_data.items():
if user_info.get("username") == target_username and user_info.get("logged_in", False):
target_client_id = cid
break
if target_client_id:
sender_nickname = sender_data.get("玩家昵称", sender_username)
self.send_data(target_client_id, {
"type": "money_received_notification",
"sender_nickname": sender_nickname,
"amount": amount,
"new_money": target_data["钱币"]
})
else:
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "数据保存失败,请重试"
})
except Exception as e:
self.log('ERROR', f"处理送金币请求失败: {str(e)}", 'GIVE_MONEY')
self.send_data(client_id, {
"type": "give_money_response",
"success": False,
"message": "服务器内部错误"
})
#==========================访问系统处理==========================
@@ -8232,6 +8703,63 @@ class TCPGameServer(TCPServer):
"success": False,
"message": message
})
#处理背包数据同步消息
def _handle_sync_bag_data(self, client_id, message):
"""处理背包数据同步请求"""
username = self.user_data.get(client_id, {}).get("username")
if not username:
return self.send_data(client_id, {
"type": "sync_bag_data_response",
"success": False,
"message": "用户未登录"
})
# 从数据库加载最新的玩家数据
player_data = self.load_player_data(username)
if not player_data:
return self.send_data(client_id, {
"type": "sync_bag_data_response",
"success": False,
"message": "玩家数据加载失败"
})
# 提取所有背包数据
bag_data = {
"道具背包": player_data.get("道具背包", []),
"宠物背包": player_data.get("宠物背包", []),
"种子仓库": player_data.get("种子仓库", []),
"作物仓库": player_data.get("作物仓库", [])
}
self.log('INFO', f"用户 {username} 请求同步背包数据", 'SERVER')
return self.send_data(client_id, {
"type": "sync_bag_data_response",
"success": True,
"message": "背包数据同步成功",
"bag_data": bag_data
})
def _handle_kick_player(self, client_id, message):
"""处理踢出玩家消息(服务器内部使用)"""
# 这个函数主要用于接收来自控制台命令的踢出消息
# 实际的踢出逻辑在 ConsoleCommandsAPI 中处理
reason = message.get("reason", "您已被管理员踢出服务器")
duration = message.get("duration", 0)
# 发送踢出通知给客户端
response = {
"type": "kick_notification",
"reason": reason,
"duration": duration,
"message": reason
}
self.log('INFO', f"向客户端 {client_id} 发送踢出通知: {reason}", 'SERVER')
return self.send_data(client_id, response)
# ================================账户设置处理方法================================
@@ -9914,6 +10442,7 @@ if __name__ == "__main__":
print("👋 感谢使用萌芽农场服务器!")
print("=" * 60)
sys.exit(0)
except Exception as e:
print(f"\n❌ 服务器启动失败: {str(e)}")
print("🔧 请检查配置并重试")

254
Server/WSRemoteCmdApi.py Normal file
View File

@@ -0,0 +1,254 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
WebSocket协议的服务器远程命令API
作者: AI Assistant
功能: 提供基于WebSocket的远程控制台命令执行功能
"""
import asyncio
import websockets
import json
import threading
import time
from typing import Dict, Any, Optional
from ConsoleCommandsAPI import ConsoleCommandsAPI
class WSRemoteCmdApi:
"""WebSocket远程命令API服务器"""
def __init__(self, game_server, host="0.0.0.0", port=7071, auth_key="mengya2024"):
"""
初始化WebSocket远程命令API服务器
Args:
game_server: 游戏服务器实例
host: WebSocket服务器监听地址
port: WebSocket服务器监听端口
auth_key: 认证密钥
"""
self.game_server = game_server
self.host = host
self.port = port
self.auth_key = auth_key
self.server = None
self.clients = {} # 存储已连接的客户端
self.console_api = ConsoleCommandsAPI(game_server)
self.running = False
async def register_client(self, websocket, path=None):
"""注册新的客户端连接"""
client_id = f"{websocket.remote_address[0]}:{websocket.remote_address[1]}_{int(time.time())}"
self.clients[client_id] = {
"websocket": websocket,
"authenticated": False,
"connect_time": time.time()
}
try:
# 发送欢迎消息
await self.send_message(websocket, {
"type": "welcome",
"message": "欢迎连接到萌芽农场远程控制台",
"server_version": getattr(self.game_server, 'server_version', '2.2.0'),
"require_auth": True
})
# 处理客户端消息
async for message in websocket:
await self.handle_message(client_id, message)
except websockets.exceptions.ConnectionClosed:
pass
except Exception as e:
print(f"❌ 客户端 {client_id} 连接处理出错: {str(e)}")
finally:
# 清理客户端连接
if client_id in self.clients:
del self.clients[client_id]
print(f"🔌 客户端 {client_id} 已断开连接")
async def handle_message(self, client_id: str, message: str):
"""处理客户端消息"""
try:
data = json.loads(message)
message_type = data.get("type", "")
if message_type == "auth":
await self.handle_auth(client_id, data)
elif message_type == "command":
await self.handle_command(client_id, data)
elif message_type == "ping":
await self.handle_ping(client_id, data)
else:
await self.send_error(client_id, f"未知消息类型: {message_type}")
except json.JSONDecodeError:
await self.send_error(client_id, "无效的JSON格式")
except Exception as e:
await self.send_error(client_id, f"处理消息时出错: {str(e)}")
async def handle_auth(self, client_id: str, data: Dict[str, Any]):
"""处理客户端认证"""
if client_id not in self.clients:
return
provided_key = data.get("auth_key", "")
if provided_key == self.auth_key:
self.clients[client_id]["authenticated"] = True
await self.send_message(self.clients[client_id]["websocket"], {
"type": "auth_result",
"success": True,
"message": "认证成功,欢迎使用远程控制台"
})
print(f"✅ 客户端 {client_id} 认证成功")
else:
await self.send_message(self.clients[client_id]["websocket"], {
"type": "auth_result",
"success": False,
"message": "认证失败,密钥错误"
})
print(f"❌ 客户端 {client_id} 认证失败")
async def handle_command(self, client_id: str, data: Dict[str, Any]):
"""处理控制台命令"""
if client_id not in self.clients:
return
# 检查是否已认证
if not self.clients[client_id]["authenticated"]:
await self.send_error(client_id, "请先进行认证")
return
command = data.get("command", "").strip()
if not command:
await self.send_error(client_id, "命令不能为空")
return
# 执行命令并捕获输出
try:
# 重定向标准输出来捕获命令执行结果
import io
import sys
old_stdout = sys.stdout
sys.stdout = captured_output = io.StringIO()
# 执行命令
success = self.console_api.process_command(command)
# 恢复标准输出
sys.stdout = old_stdout
output = captured_output.getvalue()
# 发送执行结果
await self.send_message(self.clients[client_id]["websocket"], {
"type": "command_result",
"command": command,
"success": success,
"output": output if output else ("命令执行成功" if success else "命令执行失败")
})
print(f"📝 客户端 {client_id} 执行命令: {command} - {'成功' if success else '失败'}")
except Exception as e:
await self.send_error(client_id, f"执行命令时出错: {str(e)}")
async def handle_ping(self, client_id: str, data: Dict[str, Any]):
"""处理ping请求"""
if client_id not in self.clients:
return
await self.send_message(self.clients[client_id]["websocket"], {
"type": "pong",
"timestamp": time.time()
})
async def send_message(self, websocket, data: Dict[str, Any]):
"""发送消息到客户端"""
try:
message = json.dumps(data, ensure_ascii=False)
await websocket.send(message)
except Exception as e:
print(f"❌ 发送消息失败: {str(e)}")
async def send_error(self, client_id: str, error_message: str):
"""发送错误消息到客户端"""
if client_id in self.clients:
await self.send_message(self.clients[client_id]["websocket"], {
"type": "error",
"message": error_message
})
def start_server(self):
"""启动WebSocket服务器"""
if self.running:
return
async def run_server_async():
try:
self.server = await websockets.serve(
self.register_client,
self.host,
self.port
)
self.running = True
print(f"🌐 WebSocket远程控制台服务器已启动: ws://{self.host}:{self.port}")
print(f"🔑 认证密钥: {self.auth_key}")
# 保持服务器运行
await self.server.wait_closed()
except Exception as e:
print(f"❌ WebSocket服务器启动失败: {str(e)}")
self.running = False
def run_server():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(run_server_async())
except Exception as e:
print(f"❌ WebSocket服务器线程异常: {str(e)}")
self.running = False
# 在新线程中运行WebSocket服务器
server_thread = threading.Thread(target=run_server, daemon=True)
server_thread.start()
def stop_server(self):
"""停止WebSocket服务器"""
if not self.running:
return
self.running = False
# 关闭所有客户端连接
for client_id, client_info in list(self.clients.items()):
try:
asyncio.create_task(client_info["websocket"].close())
except:
pass
self.clients.clear()
if self.server:
try:
self.server.close()
except:
pass
print("🌐 WebSocket远程控制台服务器已停止")
def get_status(self) -> Dict[str, Any]:
"""获取服务器状态"""
return {
"running": self.running,
"host": self.host,
"port": self.port,
"connected_clients": len(self.clients),
"authenticated_clients": len([c for c in self.clients.values() if c["authenticated"]])
}

Binary file not shown.

Binary file not shown.

1071
Server/crop_data_debug.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
2025-08-15 13:15:48,010 [INFO] 服务器监控器启动
2025-08-15 13:15:48,010 [INFO] 正在启动服务器...
2025-08-15 13:15:48,406 [INFO] [SERVER] ============================================================
2025-08-15 13:15:48,420 [INFO] [SERVER] Traceback (most recent call last):
2025-08-15 13:15:48,420 [ERROR] 检测到严重错误: Traceback (most recent call last):
2025-08-15 13:15:48,422 [INFO] [SERVER] File "E:\Godot\Godot项目\比较完成的作品\萌芽农场\Server\TCPGameServer.py", line 10395, in <module>
2025-08-15 13:15:48,423 [INFO] [SERVER] print(f"\U0001f331 萌芽农场游戏服务器 v{server_version} \U0001f331")
2025-08-15 13:15:48,423 [INFO] [SERVER] ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,423 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 47, in write
2025-08-15 13:15:48,423 [INFO] [SERVER] self.__convertor.write(text)
2025-08-15 13:15:48,423 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:15:48,423 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 177, in write
2025-08-15 13:15:48,423 [INFO] [SERVER] self.write_and_convert(text)
2025-08-15 13:15:48,423 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:15:48,424 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
2025-08-15 13:15:48,424 [INFO] [SERVER] self.write_plain_text(text, cursor, len(text))
2025-08-15 13:15:48,424 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,424 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
2025-08-15 13:15:48,424 [INFO] [SERVER] self.wrapped.write(text[start:end])
2025-08-15 13:15:48,424 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,424 [INFO] [SERVER] UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f331' in position 0: illegal multibyte sequence
2025-08-15 13:15:48,424 [INFO] [SERVER] During handling of the above exception, another exception occurred:
2025-08-15 13:15:48,424 [INFO] [SERVER] Traceback (most recent call last):
2025-08-15 13:15:48,424 [ERROR] 检测到严重错误: Traceback (most recent call last):
2025-08-15 13:15:48,424 [INFO] [SERVER] File "E:\Godot\Godot项目\比较完成的作品\萌芽农场\Server\TCPGameServer.py", line 10447, in <module>
2025-08-15 13:15:48,424 [INFO] [SERVER] print(f"\n\u274c 服务器启动失败: {str(e)}")
2025-08-15 13:15:48,424 [INFO] [SERVER] ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,425 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 47, in write
2025-08-15 13:15:48,425 [INFO] [SERVER] self.__convertor.write(text)
2025-08-15 13:15:48,425 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:15:48,425 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 177, in write
2025-08-15 13:15:48,425 [INFO] [SERVER] self.write_and_convert(text)
2025-08-15 13:15:48,425 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:15:48,425 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
2025-08-15 13:15:48,425 [INFO] [SERVER] self.write_plain_text(text, cursor, len(text))
2025-08-15 13:15:48,425 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,425 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
2025-08-15 13:15:48,425 [INFO] [SERVER] self.wrapped.write(text[start:end])
2025-08-15 13:15:48,425 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
2025-08-15 13:15:48,425 [INFO] [SERVER] UnicodeEncodeError: 'gbk' codec can't encode character '\u274c' in position 2: illegal multibyte sequence
2025-08-15 13:15:53,015 [ERROR] 服务器启动失败
2025-08-15 13:15:53,015 [ERROR] 初始启动失败,退出监控
2025-08-15 13:17:34,183 [INFO] 服务器监控器启动
2025-08-15 13:17:34,183 [INFO] 正在启动服务器...
2025-08-15 13:17:34,623 [INFO] [SERVER] ============================================================
2025-08-15 13:17:34,623 [INFO] [SERVER] [ERROR] 服务器启动失败: 'gbk' codec can't encode character '\U0001f331' in position 0: illegal multibyte sequence
2025-08-15 13:17:34,628 [INFO] [SERVER] Traceback (most recent call last):
2025-08-15 13:17:34,628 [ERROR] 检测到严重错误: Traceback (most recent call last):
2025-08-15 13:17:34,628 [INFO] [SERVER] File "E:\Godot\Godot项目\比较完成的作品\萌芽农场\Server\TCPGameServer.py", line 10395, in <module>
2025-08-15 13:17:34,628 [INFO] [SERVER] print(f"\U0001f331 萌芽农场游戏服务器 v{server_version} \U0001f331")
2025-08-15 13:17:34,629 [INFO] [SERVER] ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,629 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 47, in write
2025-08-15 13:17:34,629 [INFO] [SERVER] self.__convertor.write(text)
2025-08-15 13:17:34,629 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:17:34,629 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 177, in write
2025-08-15 13:17:34,629 [INFO] [SERVER] self.write_and_convert(text)
2025-08-15 13:17:34,629 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:17:34,630 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
2025-08-15 13:17:34,630 [INFO] [SERVER] self.write_plain_text(text, cursor, len(text))
2025-08-15 13:17:34,630 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,630 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
2025-08-15 13:17:34,630 [INFO] [SERVER] self.wrapped.write(text[start:end])
2025-08-15 13:17:34,630 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,630 [INFO] [SERVER] UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f331' in position 0: illegal multibyte sequence
2025-08-15 13:17:34,630 [INFO] [SERVER] During handling of the above exception, another exception occurred:
2025-08-15 13:17:34,630 [INFO] [SERVER] Traceback (most recent call last):
2025-08-15 13:17:34,631 [ERROR] 检测到严重错误: Traceback (most recent call last):
2025-08-15 13:17:34,631 [INFO] [SERVER] File "E:\Godot\Godot项目\比较完成的作品\萌芽农场\Server\TCPGameServer.py", line 10448, in <module>
2025-08-15 13:17:34,631 [INFO] [SERVER] print("\U0001f527 请检查配置并重试")
2025-08-15 13:17:34,631 [INFO] [SERVER] ~~~~~^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,631 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 47, in write
2025-08-15 13:17:34,631 [INFO] [SERVER] self.__convertor.write(text)
2025-08-15 13:17:34,632 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:17:34,632 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 177, in write
2025-08-15 13:17:34,632 [INFO] [SERVER] self.write_and_convert(text)
2025-08-15 13:17:34,632 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
2025-08-15 13:17:34,632 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
2025-08-15 13:17:34,632 [INFO] [SERVER] self.write_plain_text(text, cursor, len(text))
2025-08-15 13:17:34,632 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,632 [INFO] [SERVER] File "E:\ProgramLanguage\Python\python313\Lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
2025-08-15 13:17:34,633 [INFO] [SERVER] self.wrapped.write(text[start:end])
2025-08-15 13:17:34,633 [INFO] [SERVER] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
2025-08-15 13:17:34,633 [INFO] [SERVER] UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f527' in position 0: illegal multibyte sequence
2025-08-15 13:17:39,187 [ERROR] 服务器启动失败
2025-08-15 13:17:39,187 [ERROR] 初始启动失败,退出监控

View File

@@ -1,5 +1,7 @@
# Game Server Dependencies
colorama>=0.4.6 # For colored terminal output
pymongo>=4.6.0 # MongoDB driver for Python
schedule>=1.2.0 # Task scheduling for special farm management
websockets>=11.0.3 # WebSocket server for remote console API
# Email Requirements
# Standard library dependencies are not listed (socket, threading, json, etc.)

0
Server/special_farm.log Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
{
"切换模式":"顺序",//可选,顺序,随机,倒序
"切换速度":5,
"游戏小提示":
[
"按住wsad可以移动游戏画面",
"使用鼠标滚轮来缩放游戏画面",
"移动端双指缩放游戏画面",
"不要一上来就花光你的初始资金",
"钱币是目前游戏唯一货币",
"每隔一小时体力值+1",
"不要忘记领取你的新手礼包!",
"记得使用一键截图来分享你的农场",
"新注册用户可享受三天10倍速作物生长",
"偷别人菜时不要忘了给别人浇水哦",
"你能分得清小麦和稻谷吗",
"凌晨刷新体力值",
"面板左上角有刷新按钮,可以刷新面板",
"小心偷菜被巡逻宠物发现",
"访问特殊农场来获得一些特殊的作物"
]
}

View File

@@ -0,0 +1,84 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
游戏小提示配置数据导入脚本
将游戏小提示配置数据导入到MongoDB数据库中
"""
import sys
import os
# 添加当前目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from SMYMongoDBAPI import SMYMongoDBAPI
def import_game_tips_config():
"""导入游戏小提示配置数据到MongoDB"""
# 游戏小提示配置数据
game_tips_config = {
"切换模式": "顺序", # 可选:顺序,随机,倒序
"切换速度": 5,
"游戏小提示": [
"按住wsad可以移动游戏画面",
"使用鼠标滚轮来缩放游戏画面",
"移动端双指缩放游戏画面",
"不要一上来就花光你的初始资金",
"钱币是目前游戏唯一货币",
"每隔一小时体力值+1",
"不要忘记领取你的新手礼包!",
"记得使用一键截图来分享你的农场",
"新注册用户可享受三天10倍速作物生长",
"偷别人菜时不要忘了给别人浇水哦",
"你能分得清小麦和稻谷吗",
"凌晨刷新体力值",
"面板左上角有刷新按钮,可以刷新面板",
"小心偷菜被巡逻宠物发现",
"访问特殊农场来获得一些特殊的作物"
]
}
try:
# 创建MongoDB API实例
mongo_api = SMYMongoDBAPI()
# 连接到数据库
if not mongo_api.connect():
print("错误无法连接到MongoDB数据库")
return False
print("成功连接到MongoDB数据库")
# 更新游戏小提示配置
result = mongo_api.update_game_tips_config(game_tips_config)
if result:
print("成功导入游戏小提示配置数据到MongoDB")
print(f"配置内容:")
print(f" 切换模式: {game_tips_config['切换模式']}")
print(f" 切换速度: {game_tips_config['切换速度']}")
print(f" 游戏小提示数量: {len(game_tips_config['游戏小提示'])}")
return True
else:
print("错误:导入游戏小提示配置数据失败")
return False
except Exception as e:
print(f"导入过程中发生错误: {str(e)}")
return False
finally:
# 断开数据库连接
if 'mongo_api' in locals():
mongo_api.disconnect()
print("已断开MongoDB数据库连接")
if __name__ == "__main__":
print("开始导入游戏小提示配置数据...")
success = import_game_tips_config()
if success:
print("\n导入完成!")
else:
print("\n导入失败!")
sys.exit(1)

View File

@@ -0,0 +1,132 @@
{
"type": "item_config_response",
"success": true,
"item_config": {
"精准采集-镰刀": {
"花费": 100,
"描述": "可以在收获作物时必定掉落该作物的种子",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/紫水晶镰刀.webp"
},
"时运-镰刀": {
"花费": 100,
"描述": "可以在收获作物时掉落更多的作物的收获物",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/红宝石镰刀.webp"
},
"农家肥": {
"花费": 100,
"描述": "施肥道具可以在30分钟内2倍速作物生长",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/农家肥.webp"
},
"金坷垃": {
"花费": 100,
"描述": "施肥道具可以在5分钟内5倍速作物的生长",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/金坷垃2.webp"
},
"水壶": {
"花费": 100,
"描述": "(浇水道具)直接让作物生长进度+1%",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/铁质洒水壶.webp"
},
"水桶": {
"花费": 100,
"描述": "(浇水道具)让作物生长进度+2%",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/木质水桶2.webp"
},
"杀虫剂": {
"花费": 100,
"描述": "杀虫,暂时没什么用",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/杀虫剂.webp"
},
"除草剂": {
"花费": 100,
"描述": "除草",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/除草剂.webp"
},
"生长素": {
"花费": 100,
"描述": "时运可以10分钟内3倍速作物生长而且作物生长速度+3%",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/生长素.webp"
},
"铲子": {
"花费": 100,
"描述": "铲除作物",
"类型": "作物道具",
"道具图片": "res://assets/道具图片/附魔铁铲.webp"
},
"不死图腾": {
"花费": 100,
"描述": "让宠物死亡复活一次",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/不死图腾.webp"
},
"荆棘护甲": {
"花费": 100,
"描述": "宠物收到伤害时反弹伤害给敌人",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/荆棘护甲.webp"
},
"狂暴药水": {
"花费": 100,
"描述": "宠物血量低于某个值,进入狂暴模式",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/狂暴药水.webp"
},
"援军令牌": {
"花费": 100,
"描述": "血量低于某个值,召唤一堆宠物仆从帮助你战斗",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/援军令牌.webp"
},
"金刚图腾": {
"花费": 100,
"描述": "更改宠物元素为金元素",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/金元素图腾.webp"
},
"灵木图腾": {
"花费": 100,
"描述": "更改宠物元素为木元素",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/木元素图腾.webp"
},
"潮汐图腾": {
"花费": 100,
"描述": "更改宠物元素为水元素",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/水元素图腾.webp"
},
"烈焰图腾": {
"花费": 100,
"描述": "更改宠物元素为火元素",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/火元素图腾.webp"
},
"敦岩图腾": {
"花费": 100,
"描述": "更改宠物元素为土元素",
"类型": "宠物道具",
"道具图片": "res://assets/道具图片/土元素图腾.webp"
},
"小额经验卡": {
"花费": 100,
"描述": "让玩家立即获得500经验值",
"类型": "农场道具",
"道具图片": "res://assets/道具图片/小额经验卡.webp"
},
"小额金币卡": {
"花费": 100,
"描述": "让玩家立即获得500金币",
"类型": "农场道具",
"道具图片": "res://assets/道具图片/小额金币卡.webp"
}
}
}

View File

@@ -0,0 +1,155 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
特殊农场系统性能监控脚本
用于监控特殊农场系统的资源使用情况
"""
import psutil
import time
import threading
from datetime import datetime
class SpecialFarmMonitor:
def __init__(self):
self.monitoring = False
self.monitor_thread = None
self.stats = {
'cpu_usage': [],
'memory_usage': [],
'thread_count': [],
'start_time': None
}
def start_monitoring(self, duration=60):
"""开始监控指定时间(秒)"""
if self.monitoring:
print("监控已在运行中")
return
self.monitoring = True
self.stats['start_time'] = datetime.now()
def monitor_loop():
print(f"开始监控特殊农场系统性能 - {self.stats['start_time']}")
print(f"监控时长: {duration}")
print("=" * 50)
start_time = time.time()
while self.monitoring and (time.time() - start_time) < duration:
try:
# 获取当前进程信息
process = psutil.Process()
# CPU使用率
cpu_percent = process.cpu_percent()
self.stats['cpu_usage'].append(cpu_percent)
# 内存使用情况
memory_info = process.memory_info()
memory_mb = memory_info.rss / 1024 / 1024
self.stats['memory_usage'].append(memory_mb)
# 线程数量
thread_count = process.num_threads()
self.stats['thread_count'].append(thread_count)
# 实时显示
elapsed = int(time.time() - start_time)
print(f"\r[{elapsed:3d}s] CPU: {cpu_percent:5.1f}% | 内存: {memory_mb:6.1f}MB | 线程: {thread_count:2d}", end="", flush=True)
time.sleep(1)
except Exception as e:
print(f"\n监控出错: {str(e)}")
break
self.monitoring = False
print("\n" + "=" * 50)
self._print_summary()
self.monitor_thread = threading.Thread(target=monitor_loop, daemon=True)
self.monitor_thread.start()
def stop_monitoring(self):
"""停止监控"""
self.monitoring = False
if self.monitor_thread:
self.monitor_thread.join(timeout=2)
def _print_summary(self):
"""打印监控摘要"""
if not self.stats['cpu_usage']:
print("没有收集到监控数据")
return
print("监控摘要:")
print(f"监控时间: {self.stats['start_time']} - {datetime.now()}")
print(f"数据点数: {len(self.stats['cpu_usage'])}")
# CPU统计
cpu_avg = sum(self.stats['cpu_usage']) / len(self.stats['cpu_usage'])
cpu_max = max(self.stats['cpu_usage'])
print(f"CPU使用率 - 平均: {cpu_avg:.1f}%, 最高: {cpu_max:.1f}%")
# 内存统计
mem_avg = sum(self.stats['memory_usage']) / len(self.stats['memory_usage'])
mem_max = max(self.stats['memory_usage'])
print(f"内存使用量 - 平均: {mem_avg:.1f}MB, 最高: {mem_max:.1f}MB")
# 线程统计
thread_avg = sum(self.stats['thread_count']) / len(self.stats['thread_count'])
thread_max = max(self.stats['thread_count'])
print(f"线程数量 - 平均: {thread_avg:.1f}, 最高: {thread_max}")
# 性能评估
print("\n性能评估:")
if cpu_avg < 1.0:
print("✓ CPU使用率很低性能良好")
elif cpu_avg < 5.0:
print("✓ CPU使用率正常")
else:
print("⚠ CPU使用率较高可能需要优化")
if mem_avg < 50:
print("✓ 内存使用量很低")
elif mem_avg < 100:
print("✓ 内存使用量正常")
else:
print("⚠ 内存使用量较高")
if thread_max <= 10:
print("✓ 线程数量合理")
else:
print("⚠ 线程数量较多,注意资源管理")
def main():
"""主函数"""
print("特殊农场系统性能监控工具")
print("使用说明:")
print("1. 启动游戏服务器")
print("2. 运行此监控脚本")
print("3. 观察特殊农场系统的资源使用情况")
print()
monitor = SpecialFarmMonitor()
try:
# 监控60秒
monitor.start_monitoring(60)
# 等待监控完成
while monitor.monitoring:
time.sleep(1)
print("\n监控完成")
except KeyboardInterrupt:
print("\n用户中断监控")
monitor.stop_monitoring()
except Exception as e:
print(f"\n监控过程中出错: {str(e)}")
monitor.stop_monitoring()
if __name__ == "__main__":
main()

View File

View File

@@ -0,0 +1,147 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
测试发送给客户端的数据结构
模拟服务器发送给客户端的数据格式
"""
import json
from SMYMongoDBAPI import SMYMongoDBAPI
def test_client_data_format():
"""测试发送给客户端的数据格式"""
print("=== 测试客户端数据格式 ===")
try:
# 初始化MongoDB API
mongo_api = SMYMongoDBAPI("test")
if not mongo_api.is_connected():
print("❌ MongoDB连接失败")
return
print("✅ MongoDB连接成功")
# 模拟_load_crop_data方法
print("\n=== 测试作物数据 ===")
crop_data = mongo_api.get_crop_data_config()
if crop_data:
# 模拟服务器发送的crop_data_message
crop_data_message = {
"type": "crop_data_response",
"success": True,
"crop_data": crop_data
}
print(f"作物数据类型: {type(crop_data)}")
print(f"作物数据键数量: {len(crop_data)}")
# 检查是否有config_type字段
if 'config_type' in crop_data:
print(f"⚠️ 作物数据包含config_type: {crop_data['config_type']}")
else:
print("✅ 作物数据不包含config_type字段")
# 检查前几个作物的数据结构
crop_count = 0
for crop_name, crop_info in crop_data.items():
if crop_name not in ['_id', 'config_type'] and crop_count < 3:
print(f"\n作物 {crop_name}:")
print(f" 数据类型: {type(crop_info)}")
if isinstance(crop_info, dict):
# 检查关键字段
key_fields = ['能否购买', '品质', '等级', '作物名称']
for key in key_fields:
if key in crop_info:
value = crop_info[key]
print(f" {key}: {value} (类型: {type(value)})")
# 特别检查能否购买字段
if key == '能否购买':
if isinstance(value, str):
print(f" ⚠️ '能否购买'字段是字符串这会导致Godot报错!")
elif isinstance(value, bool):
print(f"'能否购买'字段是布尔值,正确")
elif isinstance(crop_info, str):
print(f" ⚠️ 整个作物数据是字符串: '{crop_info[:50]}...'")
print(f" 这会导致Godot调用.get()方法时报错!")
crop_count += 1
# 保存作物数据到文件以便检查
with open('crop_data_debug.json', 'w', encoding='utf-8') as f:
json.dump(crop_data_message, f, ensure_ascii=False, indent=2, default=str)
print(f"\n✅ 作物数据已保存到 crop_data_debug.json")
# 测试道具数据
print("\n=== 测试道具数据 ===")
item_config = mongo_api.get_item_config()
if item_config:
# 模拟服务器发送的item_config_message
item_config_message = {
"type": "item_config_response",
"success": True,
"item_config": item_config
}
print(f"道具数据类型: {type(item_config)}")
# 检查是否有config_type字段
if 'config_type' in item_config:
print(f"⚠️ 道具数据包含config_type: {item_config['config_type']}")
else:
print("✅ 道具数据不包含config_type字段")
# 保存道具数据到文件
with open('item_config_debug.json', 'w', encoding='utf-8') as f:
json.dump(item_config_message, f, ensure_ascii=False, indent=2, default=str)
print(f"✅ 道具数据已保存到 item_config_debug.json")
# 检查JSON序列化后的数据
print("\n=== 测试JSON序列化 ===")
if crop_data:
try:
# 模拟服务器发送数据时的JSON序列化过程
json_str = json.dumps(crop_data_message, ensure_ascii=False, default=str)
# 模拟客户端接收数据时的JSON反序列化过程
received_data = json.loads(json_str)
print("✅ JSON序列化/反序列化成功")
# 检查反序列化后的数据结构
received_crop_data = received_data.get('crop_data', {})
# 检查第一个作物的数据
for crop_name, crop_info in received_crop_data.items():
if crop_name not in ['_id', 'config_type']:
print(f"\n反序列化后的作物 {crop_name}:")
print(f" 数据类型: {type(crop_info)}")
if isinstance(crop_info, dict):
if '能否购买' in crop_info:
value = crop_info['能否购买']
print(f" 能否购买: {value} (类型: {type(value)})")
elif isinstance(crop_info, str):
print(f" ⚠️ 反序列化后变成字符串: '{crop_info[:50]}...'")
break
except Exception as e:
print(f"❌ JSON序列化/反序列化失败: {e}")
except Exception as e:
print(f"❌ 测试过程中出错: {e}")
import traceback
traceback.print_exc()
finally:
if 'mongo_api' in locals():
mongo_api.disconnect()
print("\n✅ 数据库连接已关闭")
if __name__ == "__main__":
test_client_data_format()

View File

@@ -0,0 +1,208 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
完整的游戏小提示配置系统测试
测试从数据库导入到服务端处理的完整流程
"""
import sys
import os
import socket
import json
import time
import threading
# 添加当前目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from SMYMongoDBAPI import SMYMongoDBAPI
from TCPGameServer import TCPGameServer
def test_database_operations():
"""测试数据库操作"""
print("=== 测试数据库操作 ===\n")
try:
mongo_api = SMYMongoDBAPI()
if not mongo_api.connect():
print("❌ 无法连接到MongoDB数据库")
return False
print("✓ 成功连接到MongoDB数据库")
# 测试获取配置
config = mongo_api.get_game_tips_config()
if config:
print("✓ 成功获取游戏小提示配置")
print(f" 切换模式: {config.get('切换模式', 'N/A')}")
print(f" 切换速度: {config.get('切换速度', 'N/A')}")
print(f" 小提示数量: {len(config.get('游戏小提示', []))}")
return True
else:
print("❌ 无法获取游戏小提示配置")
return False
except Exception as e:
print(f"❌ 数据库测试失败: {str(e)}")
return False
finally:
if 'mongo_api' in locals():
mongo_api.disconnect()
def test_server_loading():
"""测试服务器加载配置"""
print("\n=== 测试服务器加载配置 ===\n")
try:
server = TCPGameServer()
server.mongo_api = SMYMongoDBAPI()
if not server.mongo_api.connect():
print("❌ 服务器无法连接到MongoDB")
return False
print("✓ 服务器成功连接到MongoDB")
# 测试服务器加载配置
config = server._load_game_tips_config()
if config:
print("✓ 服务器成功加载游戏小提示配置")
print(f" 切换模式: {config.get('切换模式', 'N/A')}")
print(f" 切换速度: {config.get('切换速度', 'N/A')}")
print(f" 小提示数量: {len(config.get('游戏小提示', []))}")
return True
else:
print("❌ 服务器无法加载游戏小提示配置")
return False
except Exception as e:
print(f"❌ 服务器测试失败: {str(e)}")
return False
finally:
if 'server' in locals() and hasattr(server, 'mongo_api') and server.mongo_api:
server.mongo_api.disconnect()
def test_client_server_communication():
"""测试客户端-服务端通信"""
print("\n=== 测试客户端-服务端通信 ===\n")
# 启动服务器(在后台线程中)
server = None
server_thread = None
try:
print("启动测试服务器...")
server = TCPGameServer()
# 在后台线程中启动服务器
def run_server():
try:
server.start_server()
except Exception as e:
print(f"服务器启动失败: {e}")
server_thread = threading.Thread(target=run_server, daemon=True)
server_thread.start()
# 等待服务器启动
time.sleep(2)
# 创建客户端连接
print("创建客户端连接...")
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.settimeout(5)
try:
client_socket.connect(('localhost', 12345))
print("✓ 客户端成功连接到服务器")
# 发送游戏小提示配置请求
request = {
"type": "request_game_tips_config"
}
message = json.dumps(request, ensure_ascii=False)
client_socket.send(message.encode('utf-8'))
print("✓ 已发送游戏小提示配置请求")
# 接收响应
response_data = client_socket.recv(4096)
if response_data:
response = json.loads(response_data.decode('utf-8'))
print("✓ 收到服务器响应")
if response.get("type") == "game_tips_config_response":
success = response.get("success", False)
if success:
config = response.get("game_tips_config", {})
print("✓ 成功获取游戏小提示配置")
print(f" 切换模式: {config.get('切换模式', 'N/A')}")
print(f" 切换速度: {config.get('切换速度', 'N/A')}")
print(f" 小提示数量: {len(config.get('游戏小提示', []))}")
return True
else:
message = response.get("message", "未知错误")
print(f"❌ 服务器返回失败: {message}")
return False
else:
print(f"❌ 收到意外的响应类型: {response.get('type')}")
return False
else:
print("❌ 未收到服务器响应")
return False
except socket.timeout:
print("❌ 客户端连接超时")
return False
except ConnectionRefusedError:
print("❌ 无法连接到服务器")
return False
finally:
client_socket.close()
except Exception as e:
print(f"❌ 通信测试失败: {str(e)}")
return False
finally:
# 停止服务器
if server:
try:
server.stop_server()
except:
pass
def main():
"""主测试函数"""
print("开始完整的游戏小提示配置系统测试...\n")
# 执行各项测试
db_success = test_database_operations()
server_success = test_server_loading()
comm_success = test_client_server_communication()
# 输出测试结果
print("\n" + "="*50)
print("测试结果汇总")
print("="*50)
print(f"数据库操作测试: {'✓ 通过' if db_success else '❌ 失败'}")
print(f"服务器加载测试: {'✓ 通过' if server_success else '❌ 失败'}")
print(f"客户端通信测试: {'✓ 通过' if comm_success else '❌ 失败'}")
if db_success and server_success and comm_success:
print("\n🎉 所有测试通过!游戏小提示配置系统完全正常工作。")
print("\n系统功能说明:")
print("1. ✓ 配置数据已成功导入MongoDB数据库")
print("2. ✓ 服务端能正确加载和处理配置数据")
print("3. ✓ 客户端能成功请求并接收配置数据")
print("4. ✓ 支持顺序、倒序、随机三种切换模式")
print("5. ✓ 支持自定义切换速度")
print("\n现在客户端可以从服务端获取游戏小提示配置,")
print("并根据配置的切换模式和速度显示小提示。")
return True
else:
print("\n❌ 部分测试失败,请检查系统配置。")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)

View File

@@ -0,0 +1,138 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
数据库文档结构测试脚本
用于检查MongoDB中gameconfig集合的文档结构
"""
import json
from SMYMongoDBAPI import SMYMongoDBAPI
def test_database_documents():
"""测试数据库文档结构"""
print("=== 数据库文档结构测试 ===")
try:
# 初始化MongoDB API
mongo_api = SMYMongoDBAPI("test")
if not mongo_api.is_connected():
print("❌ MongoDB连接失败")
return
print("✅ MongoDB连接成功")
# 获取gameconfig集合
collection = mongo_api.get_collection("gameconfig")
print("\n=== 检查gameconfig集合中的所有文档 ===")
# 查找所有文档
documents = list(collection.find({}))
print(f"找到 {len(documents)} 个文档")
for i, doc in enumerate(documents):
print(f"\n--- 文档 {i+1} ---")
print(f"_id: {doc.get('_id')}")
print(f"config_type: {doc.get('config_type', '未找到')}")
# 检查是否有config_type字段
if 'config_type' in doc:
print(f"⚠️ 发现config_type字段: {doc['config_type']}")
else:
print("✅ 没有config_type字段")
# 显示文档的所有键
print(f"文档键: {list(doc.keys())}")
# 如果是作物配置,检查具体内容
if doc.get('config_type') == '作物数据配置':
print("\n=== 作物数据配置详细检查 ===")
# 检查作物数据结构
for key, value in doc.items():
if key not in ['_id', 'config_type']:
print(f"作物 {key}: {type(value)}")
if isinstance(value, dict):
# 检查作物的具体字段
crop_keys = list(value.keys())
print(f" 作物字段: {crop_keys}")
# 检查是否有字符串类型的字段被误认为是字典
for crop_key, crop_value in value.items():
if isinstance(crop_value, str) and crop_key in ['能否购买', '品质', '等级']:
print(f" ⚠️ 字段 {crop_key} 是字符串类型: '{crop_value}'")
elif isinstance(value, str):
print(f" ⚠️ 整个作物数据是字符串: '{value[:100]}...'")
print("\n=== 测试API方法返回的数据 ===")
# 测试get_crop_data_config方法
print("\n--- 测试get_crop_data_config ---")
crop_data = mongo_api.get_crop_data_config()
if crop_data:
print(f"返回数据类型: {type(crop_data)}")
print(f"返回数据键: {list(crop_data.keys()) if isinstance(crop_data, dict) else 'N/A'}")
# 检查是否还有config_type字段
if 'config_type' in crop_data:
print(f"⚠️ API返回的数据仍包含config_type: {crop_data['config_type']}")
else:
print("✅ API返回的数据不包含config_type字段")
# 检查第一个作物的数据结构
for crop_name, crop_info in crop_data.items():
if crop_name not in ['_id', 'config_type']:
print(f"\n作物 {crop_name}:")
print(f" 类型: {type(crop_info)}")
if isinstance(crop_info, dict):
print(f" 字段: {list(crop_info.keys())}")
# 检查关键字段
for key in ['能否购买', '品质', '等级']:
if key in crop_info:
value = crop_info[key]
print(f" {key}: {value} (类型: {type(value)})")
elif isinstance(crop_info, str):
print(f" ⚠️ 作物数据是字符串: '{crop_info[:50]}...'")
break # 只检查第一个作物
else:
print("❌ get_crop_data_config返回空数据")
# 测试get_item_config方法
print("\n--- 测试get_item_config ---")
item_data = mongo_api.get_item_config()
if item_data:
print(f"道具配置数据类型: {type(item_data)}")
if 'config_type' in item_data:
print(f"⚠️ 道具配置仍包含config_type: {item_data['config_type']}")
else:
print("✅ 道具配置不包含config_type字段")
# 测试find_documents方法
print("\n--- 测试find_documents方法 ---")
all_configs = mongo_api.find_documents("gameconfig", {})
if all_configs:
print(f"find_documents返回 {len(all_configs)} 个文档")
for doc in all_configs:
if 'config_type' in doc:
print(f"⚠️ find_documents返回的文档仍包含config_type: {doc['config_type']}")
else:
print(f"✅ 文档ID {doc.get('_id')} 不包含config_type字段")
except Exception as e:
print(f"❌ 测试过程中出错: {e}")
import traceback
traceback.print_exc()
finally:
if 'mongo_api' in locals():
mongo_api.disconnect()
print("\n✅ 数据库连接已关闭")
if __name__ == "__main__":
test_database_documents()

View File

View File

@@ -0,0 +1,117 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
测试游戏小提示配置功能
验证服务端能否正确加载和返回游戏小提示配置数据
"""
import sys
import os
# 添加当前目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from SMYMongoDBAPI import SMYMongoDBAPI
from TCPGameServer import TCPGameServer
def test_mongo_api():
"""测试MongoDB API的游戏小提示配置功能"""
print("=== 测试MongoDB API ===\n")
try:
# 创建MongoDB API实例
mongo_api = SMYMongoDBAPI()
# 连接到数据库
if not mongo_api.connect():
print("错误无法连接到MongoDB数据库")
return False
print("成功连接到MongoDB数据库")
# 获取游戏小提示配置
config = mongo_api.get_game_tips_config()
if config:
print("成功获取游戏小提示配置:")
print(f" 切换模式: {config.get('切换模式', 'N/A')}")
print(f" 切换速度: {config.get('切换速度', 'N/A')}")
tips = config.get('游戏小提示', [])
print(f" 游戏小提示数量: {len(tips)}")
print(" 前3条小提示:")
for i, tip in enumerate(tips[:3]):
print(f" {i+1}. {tip}")
return True
else:
print("错误:无法获取游戏小提示配置")
return False
except Exception as e:
print(f"测试过程中发生错误: {str(e)}")
return False
finally:
# 断开数据库连接
if 'mongo_api' in locals():
mongo_api.disconnect()
print("已断开MongoDB数据库连接")
def test_game_server():
"""测试游戏服务器的游戏小提示配置加载功能"""
print("\n=== 测试游戏服务器 ===\n")
try:
# 创建游戏服务器实例(不启动网络服务)
server = TCPGameServer()
# 初始化MongoDB连接
server.mongo_api = SMYMongoDBAPI()
if not server.mongo_api.connect():
print("错误服务器无法连接到MongoDB数据库")
return False
print("服务器成功连接到MongoDB数据库")
# 测试加载游戏小提示配置
config = server._load_game_tips_config()
if config:
print("服务器成功加载游戏小提示配置:")
print(f" 切换模式: {config.get('切换模式', 'N/A')}")
print(f" 切换速度: {config.get('切换速度', 'N/A')}")
tips = config.get('游戏小提示', [])
print(f" 游戏小提示数量: {len(tips)}")
print(" 前3条小提示:")
for i, tip in enumerate(tips[:3]):
print(f" {i+1}. {tip}")
return True
else:
print("错误:服务器无法加载游戏小提示配置")
return False
except Exception as e:
print(f"测试过程中发生错误: {str(e)}")
return False
finally:
# 断开数据库连接
if 'server' in locals() and hasattr(server, 'mongo_api') and server.mongo_api:
server.mongo_api.disconnect()
print("服务器已断开MongoDB数据库连接")
if __name__ == "__main__":
print("开始测试游戏小提示配置功能...\n")
# 测试MongoDB API
mongo_success = test_mongo_api()
# 测试游戏服务器
server_success = test_game_server()
print("\n=== 测试结果 ===\n")
print(f"MongoDB API测试: {'✓ 通过' if mongo_success else '✗ 失败'}")
print(f"游戏服务器测试: {'✓ 通过' if server_success else '✗ 失败'}")
if mongo_success and server_success:
print("\n🎉 所有测试通过!游戏小提示配置功能正常工作。")
else:
print("\n❌ 部分测试失败,请检查配置。")
sys.exit(1)

View File

@@ -0,0 +1,242 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
游戏小提示配置系统集成测试
测试完整的配置流程:数据库 -> 服务端 -> 客户端请求 -> 配置应用
"""
import sys
import os
import time
import threading
import socket
import json
# 添加当前目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from SMYMongoDBAPI import SMYMongoDBAPI
from TCPGameServer import TCPGameServer
def test_database_config():
"""测试数据库配置"""
print("=== 测试数据库配置 ===")
try:
# 连接数据库
mongo_api = SMYMongoDBAPI(environment="test")
if not mongo_api.is_connected():
print("❌ 数据库连接失败")
return False
# 获取游戏小提示配置
config = mongo_api.get_game_tips_config()
if config:
print("✓ 成功获取游戏小提示配置:")
print(f" 切换模式: {config.get('切换模式', '未设置')}")
print(f" 切换速度: {config.get('切换速度', '未设置')}")
print(f" 游戏小提示数量: {len(config.get('游戏小提示', []))}")
tips = config.get('游戏小提示', [])
if tips:
print(" 前3条小提示:")
for i, tip in enumerate(tips[:3], 1):
print(f" {i}. {tip}")
mongo_api.disconnect()
return True
else:
print("❌ 未找到游戏小提示配置")
mongo_api.disconnect()
return False
except Exception as e:
print(f"❌ 数据库测试失败: {e}")
return False
def test_server_config_loading():
"""测试服务端配置加载"""
print("\n=== 测试服务端配置加载 ===")
try:
# 初始化游戏服务器
server = TCPGameServer(server_host="localhost", server_port=0)
if not server.mongo_api or not server.mongo_api.is_connected():
print("❌ 服务器MongoDB连接失败")
return False
print("✓ 服务器成功连接到MongoDB数据库")
# 测试配置加载
config = server._load_game_tips_config()
if config:
print("✓ 服务器成功加载游戏小提示配置:")
print(f" 切换模式: {config.get('切换模式', '未设置')}")
print(f" 切换速度: {config.get('切换速度', '未设置')}")
print(f" 游戏小提示数量: {len(config.get('游戏小提示', []))}")
tips = config.get('游戏小提示', [])
if tips:
print(" 前3条小提示:")
for i, tip in enumerate(tips[:3], 1):
print(f" {i}. {tip}")
server.mongo_api.disconnect()
print("✓ 服务器已断开MongoDB数据库连接")
return True
else:
print("❌ 服务器加载游戏小提示配置失败")
server.mongo_api.disconnect()
return False
except Exception as e:
print(f"❌ 服务端测试失败: {e}")
return False
def test_client_server_communication():
"""测试客户端-服务端通信"""
print("\n=== 测试客户端-服务端通信 ===")
server = None
client_socket = None
try:
# 启动服务器(使用固定端口进行测试)
test_port = 17070
server = TCPGameServer(server_host="localhost", server_port=test_port)
if not server.mongo_api or not server.mongo_api.is_connected():
print("❌ 服务器MongoDB连接失败")
return False
# 在新线程中启动服务器
server_thread = threading.Thread(target=server.start, daemon=True)
server_thread.start()
# 等待服务器启动
time.sleep(1)
# 获取服务器端口
server_port = test_port
print(f"✓ 服务器已启动,端口: {server_port}")
# 创建客户端连接
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.settimeout(5)
client_socket.connect(("localhost", server_port))
print("✓ 客户端已连接到服务器")
# 发送游戏小提示配置请求
request = {
"type": "request_game_tips_config"
}
request_data = json.dumps(request).encode('utf-8')
client_socket.send(len(request_data).to_bytes(4, byteorder='big'))
client_socket.send(request_data)
print("✓ 已发送游戏小提示配置请求")
# 接收响应
response_length_bytes = client_socket.recv(4)
if len(response_length_bytes) != 4:
print("❌ 接收响应长度失败")
return False
response_length = int.from_bytes(response_length_bytes, byteorder='big')
response_data = b''
while len(response_data) < response_length:
chunk = client_socket.recv(response_length - len(response_data))
if not chunk:
break
response_data += chunk
if len(response_data) != response_length:
print("❌ 接收响应数据不完整")
return False
# 解析响应
response = json.loads(response_data.decode('utf-8'))
print("✓ 已接收服务器响应")
# 验证响应
if response.get("type") == "game_tips_config_response":
if response.get("success"):
config = response.get("game_tips_config", {})
print("✓ 成功接收游戏小提示配置:")
print(f" 切换模式: {config.get('切换模式', '未设置')}")
print(f" 切换速度: {config.get('切换速度', '未设置')}")
print(f" 游戏小提示数量: {len(config.get('游戏小提示', []))}")
tips = config.get('游戏小提示', [])
if tips:
print(" 前3条小提示:")
for i, tip in enumerate(tips[:3], 1):
print(f" {i}. {tip}")
return True
else:
message = response.get("message", "未知错误")
print(f"❌ 服务器返回失败: {message}")
return False
else:
print(f"❌ 收到意外的响应类型: {response.get('type')}")
return False
except Exception as e:
print(f"❌ 客户端-服务端通信测试失败: {e}")
return False
finally:
# 清理资源
if client_socket:
try:
client_socket.close()
except:
pass
if server and server.mongo_api:
try:
server.mongo_api.disconnect()
except:
pass
def main():
"""主测试函数"""
print("🚀 开始游戏小提示配置系统集成测试\n")
# 测试结果
results = {
"数据库配置": test_database_config(),
"服务端配置加载": test_server_config_loading(),
"客户端-服务端通信": test_client_server_communication()
}
print("\n=== 测试结果 ===\n")
all_passed = True
for test_name, result in results.items():
status = "✓ 通过" if result else "❌ 失败"
print(f"{test_name}测试: {status}")
if not result:
all_passed = False
if all_passed:
print("\n🎉 所有测试通过!游戏小提示配置系统完全正常工作。")
print("\n📋 系统功能确认:")
print(" ✓ 数据库配置存储和读取正常")
print(" ✓ 服务端配置加载正常")
print(" ✓ 客户端-服务端通信正常")
print(" ✓ 配置数据传输完整")
print("\n🎮 客户端现在应该能够正确使用数据库中的游戏小提示配置!")
else:
print("\n❌ 部分测试失败,请检查相关组件。")
return all_passed
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,151 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
特殊农场管理系统测试脚本
作者: AI Assistant
功能: 测试特殊农场的种植功能
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from SpecialFarm import SpecialFarmManager
def test_special_farm():
"""
测试特殊农场功能
"""
print("=" * 50)
print("特殊农场管理系统测试")
print("=" * 50)
try:
# 创建管理器(使用测试环境)
print("1. 初始化特殊农场管理器...")
manager = SpecialFarmManager("test")
print("✓ 管理器初始化成功")
# 测试数据库连接
print("\n2. 测试数据库连接...")
if manager.mongo_api.is_connected():
print("✓ 数据库连接成功")
else:
print("✗ 数据库连接失败")
return False
# 测试获取作物配置
print("\n3. 测试获取作物配置...")
crop_data = manager.get_crop_data()
if crop_data:
print(f"✓ 成功获取作物配置,共 {len(crop_data)} 种作物")
# 检查杂交树是否存在
if "杂交树1" in crop_data and "杂交树2" in crop_data:
print("✓ 杂交树1和杂交树2配置存在")
print(f" - 杂交树1: {crop_data['杂交树1']['作物名称']}")
print(f" - 杂交树2: {crop_data['杂交树2']['作物名称']}")
else:
print("✗ 杂交树配置不存在")
return False
else:
print("✗ 获取作物配置失败")
return False
# 测试获取杂交农场数据
print("\n4. 测试获取杂交农场数据...")
farm_config = manager.special_farms["杂交农场"]
object_id = farm_config["object_id"]
player_data = manager.get_player_data_by_object_id(object_id)
if player_data:
print(f"✓ 成功获取杂交农场数据")
print(f" - 农场名称: {player_data.get('农场名称', 'Unknown')}")
print(f" - 玩家昵称: {player_data.get('玩家昵称', 'Unknown')}")
print(f" - 土地数量: {len(player_data.get('农场土地', []))}")
# 统计土地状态
farm_lands = player_data.get("农场土地", [])
digged_count = sum(1 for land in farm_lands if land.get("is_diged", False))
planted_count = sum(1 for land in farm_lands if land.get("is_planted", False))
print(f" - 已开垦土地: {digged_count}")
print(f" - 已种植土地: {planted_count}")
else:
print("✗ 获取杂交农场数据失败")
return False
# 测试种植功能
print("\n5. 测试杂交农场种植功能...")
if manager.plant_crops_in_farm("杂交农场"):
print("✓ 杂交农场种植成功")
# 重新获取数据验证种植结果
updated_data = manager.get_player_data_by_object_id(object_id)
if updated_data:
farm_lands = updated_data.get("农场土地", [])
planted_count = sum(1 for land in farm_lands if land.get("is_planted", False))
# 统计种植的作物类型
crop_types = {}
for land in farm_lands:
if land.get("is_planted", False):
crop_type = land.get("crop_type", "")
crop_types[crop_type] = crop_types.get(crop_type, 0) + 1
print(f" - 种植后已种植土地: {planted_count}")
print(f" - 作物分布:")
for crop_type, count in crop_types.items():
print(f" * {crop_type}: {count}")
else:
print("✗ 杂交农场种植失败")
return False
print("\n" + "=" * 50)
print("✓ 所有测试通过!特殊农场管理系统工作正常")
print("=" * 50)
return True
except Exception as e:
print(f"\n✗ 测试过程中出错: {str(e)}")
import traceback
traceback.print_exc()
return False
def test_manual_maintenance():
"""
测试手动维护功能
"""
print("\n" + "=" * 50)
print("测试手动维护功能")
print("=" * 50)
try:
manager = SpecialFarmManager("test")
print("执行手动维护...")
if manager.manual_maintenance("杂交农场"):
print("✓ 手动维护成功")
else:
print("✗ 手动维护失败")
except Exception as e:
print(f"✗ 手动维护测试出错: {str(e)}")
if __name__ == "__main__":
# 运行基础测试
success = test_special_farm()
if success:
# 运行手动维护测试
test_manual_maintenance()
print("\n" + "=" * 50)
print("使用说明:")
print("1. 自动模式: python SpecialFarm.py [test|production]")
print("2. 手动模式: python SpecialFarm.py [test|production] manual [农场名称]")
print("3. 日志文件: special_farm.log")
print("=" * 50)
else:
print("\n测试失败,请检查配置和数据库连接")
sys.exit(1)

View File

@@ -0,0 +1,143 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简化的访问模式实时更新功能测试
"""
import sys
import os
print("开始测试访问模式下的实时更新功能...")
try:
# 测试导入
print("正在导入模块...")
# 检查文件是否存在
if os.path.exists('TCPGameServer.py'):
print("✓ TCPGameServer.py 文件存在")
else:
print("❌ TCPGameServer.py 文件不存在")
sys.exit(1)
if os.path.exists('SMYMongoDBAPI.py'):
print("✓ SMYMongoDBAPI.py 文件存在")
else:
print("❌ SMYMongoDBAPI.py 文件不存在")
sys.exit(1)
# 尝试导入
from TCPGameServer import TCPGameServer
print("✓ 成功导入 TCPGameServer")
# 检查关键方法是否存在
server = TCPGameServer()
if hasattr(server, '_push_update_to_visitors'):
print("✓ _push_update_to_visitors 方法存在")
else:
print("❌ _push_update_to_visitors 方法不存在")
if hasattr(server, 'update_crops_growth'):
print("✓ update_crops_growth 方法存在")
else:
print("❌ update_crops_growth 方法不存在")
if hasattr(server, '_push_crop_update_to_player'):
print("✓ _push_crop_update_to_player 方法存在")
else:
print("❌ _push_crop_update_to_player 方法不存在")
print("\n=== 功能验证 ===")
# 模拟用户数据
server.user_data = {
"client_a": {
"logged_in": True,
"username": "user_a",
"visiting_mode": False,
"visiting_target": ""
},
"client_b": {
"logged_in": True,
"username": "user_b",
"visiting_mode": True,
"visiting_target": "user_a"
}
}
# 测试 update_crops_growth 方法是否能正确收集需要更新的玩家
print("测试作物生长更新逻辑...")
# 重写 load_player_data 方法以避免数据库依赖
def mock_load_player_data(username):
return {
"农场土地": [
{
"is_planted": True,
"crop_type": "番茄",
"grow_time": 300,
"max_grow_time": 600
}
]
}
def mock_save_player_data(username, data):
pass
def mock_update_player_crops(data, username):
return True
def mock_push_crop_update_to_player(username, data):
print(f" 推送作物更新给: {username}")
server.load_player_data = mock_load_player_data
server.save_player_data = mock_save_player_data
server.update_player_crops = mock_update_player_crops
server._push_crop_update_to_player = mock_push_crop_update_to_player
# 调用作物生长更新
print("调用 update_crops_growth...")
server.update_crops_growth()
print("\n=== 测试访问者推送功能 ===")
# 重写 send_data 方法
def mock_send_data(client_id, data):
print(f"{client_id} 发送消息: {data.get('type', 'unknown')}")
if data.get('type') == 'crop_update':
print(f" - 是否访问模式: {data.get('is_visiting', False)}")
print(f" - 被访问玩家: {data.get('visited_player', 'N/A')}")
def mock_find_client_by_username(username):
if username == "user_a":
return "client_a"
return None
server.send_data = mock_send_data
server._find_client_by_username = mock_find_client_by_username
# 测试向访问者推送更新
target_player_data = {
"农场土地": [
{
"is_planted": True,
"crop_type": "番茄",
"grow_time": 400,
"max_grow_time": 600
}
]
}
print("调用 _push_update_to_visitors...")
server._push_update_to_visitors("user_a", target_player_data)
print("\n🎉 所有功能验证通过!访问模式下的实时更新功能已正确实现。")
except Exception as e:
print(f"❌ 测试过程中出现错误: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
print("\n测试完成!")

View File

@@ -0,0 +1,559 @@
# DisplayServer API 参考文档
## 类简介
**继承**Object
DisplayServer 是用于低阶窗口管理的服务器接口。所有与窗口管理相关的内容都由 DisplayServer显示服务器处理。
> **无头模式**:如果使用 `--headless` 命令行参数启动引擎,就会禁用所有渲染和窗口管理功能,此时 DisplayServer 的大多数函数都会返回虚设值。
---
## 方法列表
### 🔔 系统交互
#### `void beep()`
发出系统提示音。
#### `void enable_for_stealing_focus(process_id: int)`
允许指定进程获取焦点。
#### `void force_process_and_drop_events()`
强制处理并丢弃所有事件。
---
### 📋 剪贴板操作
#### `String clipboard_get()`
获取剪贴板文本内容。
#### `Image clipboard_get_image()`
获取剪贴板图像内容。
#### `String clipboard_get_primary()`
获取主剪贴板文本内容(仅限 Linux
#### `bool clipboard_has()`
检查剪贴板是否有内容。
#### `bool clipboard_has_image()`
检查剪贴板是否有图像。
#### `void clipboard_set(clipboard: String)`
设置剪贴板文本内容。
#### `void clipboard_set_primary(clipboard_primary: String)`
设置主剪贴板文本内容(仅限 Linux
---
### 🖱️ 鼠标和光标
#### `CursorShape cursor_get_shape()`
获取当前光标形状。
#### `void cursor_set_custom_image(cursor: Resource, shape: CursorShape = 0, hotspot: Vector2 = Vector2(0, 0))`
设置自定义光标图像。
#### `void cursor_set_shape(shape: CursorShape)`
设置光标形状。
#### `BitField[MouseButtonMask] mouse_get_button_state()`
获取鼠标按键状态。
#### `MouseMode mouse_get_mode()`
获取鼠标模式。
#### `Vector2i mouse_get_position()`
获取鼠标位置。
#### `void mouse_set_mode(mouse_mode: MouseMode)`
设置鼠标模式。
#### `void warp_mouse(position: Vector2i)`
将鼠标光标移动到指定位置。
---
### 💬 对话框
#### `Error dialog_input_text(title: String, description: String, existing_text: String, callback: Callable)`
显示文本输入对话框。
#### `Error dialog_show(title: String, description: String, buttons: PackedStringArray, callback: Callable)`
显示系统对话框。
#### `Error file_dialog_show(title: String, current_directory: String, filename: String, show_hidden: bool, mode: FileDialogMode, filters: PackedStringArray, callback: Callable)`
显示文件选择对话框。
#### `Error file_dialog_with_options_show(title: String, current_directory: String, root: String, filename: String, show_hidden: bool, mode: FileDialogMode, filters: PackedStringArray, options: Array[Dictionary], callback: Callable)`
显示带扩展选项的文件选择对话框。
---
### 🎨 主题和颜色
#### `Color get_accent_color()`
获取系统强调色。
#### `Color get_base_color()`
获取系统基础色。
#### `bool is_dark_mode()`
检查系统是否为深色模式。
#### `bool is_dark_mode_supported()`
检查系统是否支持深色模式。
#### `void set_system_theme_change_callback(callable: Callable)`
设置系统主题变化时的回调。
---
### 📱 显示和屏幕
#### `Array[Rect2] get_display_cutouts()`
获取显示器刘海信息。
#### `Rect2i get_display_safe_area()`
获取显示器安全区域。
#### `int get_keyboard_focus_screen()`
获取键盘焦点所在屏幕。
#### `String get_name()`
获取显示服务器名称。
#### `int get_primary_screen()`
获取主屏幕索引。
#### `int get_screen_count()`
获取屏幕数量。
#### `int get_screen_from_rect(rect: Rect2)`
根据矩形位置获取屏幕索引。
#### `bool get_swap_cancel_ok()`
获取是否交换确定取消按钮。
#### `int get_window_at_screen_position(position: Vector2i)`
获取指定屏幕位置的窗口ID。
#### `PackedInt32Array get_window_list()`
获取所有窗口ID列表。
---
### 🖥️ 屏幕操作
#### `int screen_get_dpi(screen: int = -1)`
获取屏幕DPI。
#### `Image screen_get_image(screen: int = -1)`
获取屏幕截图。
#### `Image screen_get_image_rect(rect: Rect2i)`
获取屏幕指定区域截图。
#### `float screen_get_max_scale()`
获取所有屏幕的最大缩放系数。
#### `ScreenOrientation screen_get_orientation(screen: int = -1)`
获取屏幕朝向。
#### `Color screen_get_pixel(position: Vector2i)`
获取指定位置的像素颜色。
#### `Vector2i screen_get_position(screen: int = -1)`
获取屏幕位置。
#### `float screen_get_refresh_rate(screen: int = -1)`
获取屏幕刷新率。
#### `float screen_get_scale(screen: int = -1)`
获取屏幕缩放系数。
#### `Vector2i screen_get_size(screen: int = -1)`
获取屏幕大小。
#### `Rect2i screen_get_usable_rect(screen: int = -1)`
获取屏幕可用区域。
#### `bool screen_is_kept_on()`
检查屏幕是否保持开启。
#### `void screen_set_keep_on(enable: bool)`
设置屏幕保持开启。
#### `void screen_set_orientation(orientation: ScreenOrientation, screen: int = -1)`
设置屏幕朝向。
---
### 🖼️ 图标设置
#### `void set_icon(image: Image)`
设置窗口图标。
#### `void set_native_icon(filename: String)`
使用原生格式设置窗口图标。
---
### 💾 输出管理
#### `bool has_additional_outputs()`
检查是否有额外输出设备。
#### `void register_additional_output(object: Object)`
注册额外输出设备。
#### `void unregister_additional_output(object: Object)`
取消注册额外输出设备。
---
### ⚡ 功能检测
#### `bool has_feature(feature: Feature)`
检查是否支持指定功能。
#### `bool has_hardware_keyboard()`
检查是否有硬件键盘。
#### `bool is_touchscreen_available()`
检查是否支持触屏。
#### `bool is_window_transparency_available()`
检查是否支持窗口透明。
---
### ⌨️ 键盘
#### `int keyboard_get_current_layout()`
获取当前键盘布局。
#### `Key keyboard_get_keycode_from_physical(keycode: Key)`
从物理按键获取键码。
#### `Key keyboard_get_label_from_physical(keycode: Key)`
从物理按键获取标签。
#### `int keyboard_get_layout_count()`
获取键盘布局数量。
#### `String keyboard_get_layout_language(index: int)`
获取键盘布局语言。
#### `String keyboard_get_layout_name(index: int)`
获取键盘布局名称。
#### `void keyboard_set_current_layout(index: int)`
设置当前键盘布局。
---
### 📝 输入法
#### `Vector2i ime_get_selection()`
获取输入法选中范围。
#### `String ime_get_text()`
获取输入法文本。
---
### 🎯 状态指示器
#### `int create_status_indicator(icon: Texture2D, tooltip: String, callback: Callable)`
创建状态指示器。
#### `void delete_status_indicator(id: int)`
删除状态指示器。
#### `Rect2 status_indicator_get_rect(id: int)`
获取状态指示器位置。
#### `void status_indicator_set_callback(id: int, callback: Callable)`
设置状态指示器回调。
#### `void status_indicator_set_icon(id: int, icon: Texture2D)`
设置状态指示器图标。
#### `void status_indicator_set_menu(id: int, menu_rid: RID)`
设置状态指示器菜单。
#### `void status_indicator_set_tooltip(id: int, tooltip: String)`
设置状态指示器提示文本。
---
### 📱 数位板
#### `String tablet_get_current_driver()`
获取当前数位板驱动。
#### `int tablet_get_driver_count()`
获取数位板驱动数量。
#### `String tablet_get_driver_name(idx: int)`
获取数位板驱动名称。
#### `void tablet_set_current_driver(name: String)`
设置数位板驱动。
---
### 🗣️ 文本转语音
#### `Array[Dictionary] tts_get_voices()`
获取语音列表。
#### `PackedStringArray tts_get_voices_for_language(language: String)`
获取指定语言的语音列表。
#### `bool tts_is_paused()`
检查是否暂停。
#### `bool tts_is_speaking()`
检查是否正在朗读。
#### `void tts_pause()`
暂停朗读。
#### `void tts_resume()`
恢复朗读。
#### `void tts_set_utterance_callback(event: TTSUtteranceEvent, callable: Callable)`
设置朗读事件回调。
#### `void tts_speak(text: String, voice: String, volume: int = 50, pitch: float = 1.0, rate: float = 1.0, utterance_id: int = 0, interrupt: bool = false)`
开始朗读文本。
#### `void tts_stop()`
停止朗读。
---
### ⌨️ 虚拟键盘
#### `int virtual_keyboard_get_height()`
获取虚拟键盘高度。
#### `void virtual_keyboard_hide()`
隐藏虚拟键盘。
#### `void virtual_keyboard_show(existing_text: String, position: Rect2 = Rect2(0, 0, 0, 0), type: VirtualKeyboardType = 0, max_length: int = -1, cursor_start: int = -1, cursor_end: int = -1)`
显示虚拟键盘。
---
### 🪟 窗口管理
#### `bool window_can_draw(window_id: int = 0)`
检查窗口是否可绘制。
#### `int window_get_active_popup()`
获取活动弹出窗口ID。
#### `int window_get_attached_instance_id(window_id: int = 0)`
获取窗口附加的实例ID。
#### `int window_get_current_screen(window_id: int = 0)`
获取窗口所在屏幕。
#### `bool window_get_flag(flag: WindowFlags, window_id: int = 0)`
获取窗口标志。
#### `Vector2i window_get_max_size(window_id: int = 0)`
获取窗口最大尺寸。
#### `Vector2i window_get_min_size(window_id: int = 0)`
获取窗口最小尺寸。
#### `WindowMode window_get_mode(window_id: int = 0)`
获取窗口模式。
#### `int window_get_native_handle(handle_type: HandleType, window_id: int = 0)`
获取窗口原生句柄。
#### `Rect2i window_get_popup_safe_rect(window: int)`
获取弹出窗口安全区域。
#### `Vector2i window_get_position(window_id: int = 0)`
获取窗口位置。
#### `Vector2i window_get_position_with_decorations(window_id: int = 0)`
获取窗口位置(含边框)。
#### `Vector3i window_get_safe_title_margins(window_id: int = 0)`
获取标题栏安全边距。
#### `Vector2i window_get_size(window_id: int = 0)`
获取窗口大小。
#### `Vector2i window_get_size_with_decorations(window_id: int = 0)`
获取窗口大小(含边框)。
#### `Vector2i window_get_title_size(title: String, window_id: int = 0)`
获取标题栏大小。
#### `VSyncMode window_get_vsync_mode(window_id: int = 0)`
获取垂直同步模式。
#### `bool window_is_focused(window_id: int = 0)`
检查窗口是否有焦点。
#### `bool window_is_maximize_allowed(window_id: int = 0)`
检查窗口是否可最大化。
#### `bool window_maximize_on_title_dbl_click()`
检查双击标题栏是否最大化。
#### `bool window_minimize_on_title_dbl_click()`
检查双击标题栏是否最小化。
#### `void window_move_to_foreground(window_id: int = 0)`
将窗口移到前台。
#### `void window_request_attention(window_id: int = 0)`
请求窗口注意。
#### `void window_set_current_screen(screen: int, window_id: int = 0)`
设置窗口所在屏幕。
#### `void window_set_drop_files_callback(callback: Callable, window_id: int = 0)`
设置文件拖放回调。
#### `void window_set_exclusive(window_id: int, exclusive: bool)`
设置窗口独占模式。
#### `void window_set_flag(flag: WindowFlags, enabled: bool, window_id: int = 0)`
设置窗口标志。
#### `void window_set_ime_active(active: bool, window_id: int = 0)`
设置输入法是否激活。
#### `void window_set_ime_position(position: Vector2i, window_id: int = 0)`
设置输入法位置。
#### `void window_set_input_event_callback(callback: Callable, window_id: int = 0)`
设置输入事件回调。
#### `void window_set_input_text_callback(callback: Callable, window_id: int = 0)`
设置文本输入回调。
#### `void window_set_max_size(max_size: Vector2i, window_id: int = 0)`
设置窗口最大尺寸。
#### `void window_set_min_size(min_size: Vector2i, window_id: int = 0)`
设置窗口最小尺寸。
#### `void window_set_mode(mode: WindowMode, window_id: int = 0)`
设置窗口模式。
#### `void window_set_mouse_passthrough(region: PackedVector2Array, window_id: int = 0)`
设置鼠标穿透区域。
#### `void window_set_popup_safe_rect(window: int, rect: Rect2i)`
设置弹出窗口安全区域。
#### `void window_set_position(position: Vector2i, window_id: int = 0)`
设置窗口位置。
#### `void window_set_rect_changed_callback(callback: Callable, window_id: int = 0)`
设置窗口位置大小变化回调。
#### `void window_set_size(size: Vector2i, window_id: int = 0)`
设置窗口大小。
#### `void window_set_title(title: String, window_id: int = 0)`
设置窗口标题。
#### `void window_set_transient(window_id: int, parent_window_id: int)`
设置窗口为瞬态。
#### `void window_set_vsync_mode(vsync_mode: VSyncMode, window_id: int = 0)`
设置垂直同步模式。
#### `void window_set_window_buttons_offset(offset: Vector2i, window_id: int = 0)`
设置窗口按钮偏移。
#### `void window_set_window_event_callback(callback: Callable, window_id: int = 0)`
设置窗口事件回调。
#### `void window_start_drag(window_id: int = 0)`
开始拖拽窗口。
#### `void window_start_resize(edge: WindowResizeEdge, window_id: int = 0)`
开始调整窗口大小。
---
### 📞 帮助系统
#### `void help_set_search_callbacks(search_callback: Callable, action_callback: Callable)`
设置帮助系统搜索回调。
#### `void show_emoji_and_symbol_picker()`
显示表情符号选择器。
---
### ⚙️ 事件处理
#### `void process_events()`
处理事件。
---
## 常量
- `SCREEN_WITH_MOUSE_FOCUS = -4`:鼠标焦点所在屏幕
- `SCREEN_WITH_KEYBOARD_FOCUS = -3`:键盘焦点所在屏幕
- `SCREEN_PRIMARY = -2`:主屏幕
- `SCREEN_OF_MAIN_WINDOW = -1`:主窗口所在屏幕
- `MAIN_WINDOW_ID = 0`主窗口ID
- `INVALID_WINDOW_ID = -1`无效窗口ID
---
## 枚举
### Feature
系统功能支持检测枚举,包含多种功能如子窗口、触屏、鼠标、剪贴板、虚拟键盘等支持检测。
### MouseMode
鼠标模式枚举:可见、隐藏、捕获、限制等模式。
### ScreenOrientation
屏幕朝向枚举:横屏、竖屏及其反向,以及传感器自动模式。
### VirtualKeyboardType
虚拟键盘类型默认、多行、数字、小数、电话、邮箱、密码、URL等。
### CursorShape
光标形状枚举:箭头、工字形、指向手形等多种光标样式。
### WindowFlags
窗口标志枚举:控制窗口的各种行为和外观属性。
### WindowMode
窗口模式枚举:窗口、最小化、最大化、全屏等模式。
### HandleType
句柄类型枚举:用于获取不同类型的原生窗口句柄。
### VSyncMode
垂直同步模式枚举:控制画面撕裂和帧率同步。
### TTSUtteranceEvent
语音朗读事件枚举:开始、结束、取消、边界等事件。
---
> **注意**:此文档已排除所有已弃用的方法。某些功能可能仅在特定平台上可用,请参考原始文档中的平台支持说明。

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,144 @@
# 游戏小提示配置系统实现说明
## 概述
本系统成功将游戏小提示配置从客户端硬编码迁移到服务端数据库管理,实现了动态配置和灵活的显示模式。
## 系统架构
### 1. 数据库层 (MongoDB)
- **配置ID**: `687e40008e77ba00a7414bb2`
- **集合**: `gameconfig`
- **配置结构**:
```json
{
"切换模式": "顺序", // 可选:顺序、随机、倒序
"切换速度": 5, // 切换间隔(秒)
"游戏小提示": [ // 小提示内容数组
"按住wsad可以移动游戏画面",
"使用鼠标滚轮来缩放游戏画面",
// ... 更多小提示
]
}
```
### 2. 服务端层 (Python)
#### SMYMongoDBAPI.py 新增功能
- `get_game_tips_config()`: 获取游戏小提示配置
- `update_game_tips_config()`: 更新游戏小提示配置
- 配置ID: `CONFIG_IDS["game_tips"]`
#### TCPGameServer.py 新增功能
- `_load_game_tips_config()`: 从数据库加载配置
- `_handle_game_tips_config_request()`: 处理客户端配置请求
- 消息路由: `request_game_tips_config` → `_handle_game_tips_config_request`
### 3. 客户端层 (GDScript)
#### TCPNetworkManager.gd 新增功能
- `sendGetGameTipsConfig()`: 发送配置请求
- 消息处理: `game_tips_config_response` → `main_game._handle_game_tips_config_response`
#### MainGame.gd 新增功能
- `game_tips_config`: 存储服务端配置
- `current_tip_index`: 顺序/倒序模式的索引
- `_handle_game_tips_config_response()`: 处理服务端响应
- `_random_small_game_tips()`: 重构为支持多种切换模式
## 功能特性
### 1. 切换模式
- **顺序模式**: 按配置顺序依次显示小提示
- **倒序模式**: 按配置倒序依次显示小提示
- **随机模式**: 随机选择小提示显示
### 2. 动态配置
- 服务端可随时更新小提示内容
- 客户端启动时自动获取最新配置
- 支持热更新(无需重启游戏)
### 3. 容错机制
- 服务端配置不可用时使用本地默认配置
- 配置为空时显示默认欢迎信息
- 网络异常时优雅降级
## 部署文件
### 1. 配置导入脚本
- `import_game_tips_config.py`: 将配置数据导入MongoDB
- 包含15条游戏小提示
- 默认配置顺序模式5秒切换间隔
### 2. 测试脚本
- `test_game_tips_config.py`: 基础功能测试
- `test_complete_game_tips_system.py`: 完整系统测试
## 使用方法
### 1. 初始化配置
```bash
cd Server
python import_game_tips_config.py
```
### 2. 测试系统
```bash
python test_game_tips_config.py
```
### 3. 客户端集成
游戏启动时会自动请求服务端配置:
```gdscript
# 在MainGame.gd中已集成
tcp_network_manager_panel.sendGetGameTipsConfig()
```
## 配置管理
### 1. 查看当前配置
```python
from SMYMongoDBAPI import SMYMongoDBAPI
api = SMYMongoDBAPI()
api.connect()
config = api.get_game_tips_config()
print(config)
```
### 2. 更新配置
```python
new_config = {
"切换模式": "随机",
"切换速度": 3,
"游戏小提示": ["新的小提示1", "新的小提示2"]
}
api.update_game_tips_config(new_config)
```
## 测试结果
**数据库操作测试**: 通过
**服务器加载测试**: 通过
**配置导入功能**: 通过
**客户端集成**: 完成
## 技术优势
1. **集中管理**: 所有小提示内容统一在服务端管理
2. **动态更新**: 无需客户端更新即可修改小提示
3. **灵活配置**: 支持多种显示模式和自定义切换速度
4. **高可用性**: 完善的容错机制确保系统稳定性
5. **易于维护**: 清晰的代码结构和完整的测试覆盖
## 后续扩展
1. **多语言支持**: 可扩展为支持多语言的小提示
2. **个性化配置**: 可为不同用户群体配置不同的小提示
3. **统计分析**: 可添加小提示显示统计和用户反馈
4. **管理界面**: 可开发Web管理界面方便运营人员管理
---
**实现完成时间**: 2024年12月
**版本**: 1.0
**状态**: 已完成并测试通过

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
"访问系统":{
"总访问人数":0,
"今日访问人数":0,
"访问记录":{
"2025-07-21":["树萌芽","柚大青"],
"2025-07-1":["树萌芽","柚大青","大萌芽"],
}
}

View File

@@ -0,0 +1,968 @@
{
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "小麦谷",
"玩家昵称": "小麦谷",
"玩家账号": "222",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产小麦的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "稻草人1",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "这里是花谷",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "一个盛产各种奇异花卉的地方",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "星期一,三,五,七零点种植",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "欢迎参观!",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,968 @@
{
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "幸运农场",
"玩家昵称": "幸运农场",
"玩家账号": "111",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产幸运草和幸运花的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "稻草人1",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "这里是花谷",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "一个盛产各种奇异花卉的地方",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "星期一,三,五,七零点种植",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "欢迎参观!",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,971 @@
{
"_id": {
"$oid": "689b4b9286cf953f2f4e56ee"
},
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "杂交农场",
"玩家昵称": "杂交农场",
"玩家账号": "666",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产杂交果实的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "第一句话",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "第二句话",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "第三句话",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "第四句话",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,968 @@
{
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "瓜果农场",
"玩家昵称": "瓜果农场",
"玩家账号": "333",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产各种瓜果的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "稻草人1",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "这里是花谷",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "一个盛产各种奇异花卉的地方",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "星期一,三,五,七零点种植",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "欢迎参观!",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,968 @@
{
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "稻香",
"玩家昵称": "稻香",
"玩家账号": "111",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产稻谷的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "稻草人1",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "这里是花谷",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "一个盛产各种奇异花卉的地方",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "星期一,三,五,七零点种植",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "欢迎参观!",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,968 @@
{
"经验值": 0,
"等级": 1,
"钱币": 0,
"农场名称": "花谷",
"玩家昵称": "花谷",
"玩家账号": "520",
"玩家密码": "tyh@19900420",
"最后登录时间": "2025年07月20日17时19分16秒",
"总游玩时间": "0时0分0秒",
"注册时间": "2025年05月21日15时00分00秒",
"个人简介": "盛产各种花卉的农场",
"农场土地": [
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": true,
"is_planted": false,
"max_grow_time": 3,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
},
{
"crop_type": "",
"grow_time": 0,
"is_dead": false,
"is_diged": false,
"is_planted": false,
"max_grow_time": 5,
"已浇水": false,
"已施肥": false,
"土地等级": 0
}
],
"种子仓库": [],
"作物仓库": [],
"道具背包": [],
"宠物背包": [],
"巡逻宠物": [],
"出战宠物": [],
"稻草人配置": {
"已拥有稻草人类型": [
"稻草人1"
],
"稻草人展示类型": "稻草人1",
"稻草人昵称": "稻草人",
"稻草人说的话": {
"第一句话": {
"内容": "这里是花谷",
"颜色": "52dceeff"
},
"第二句话": {
"内容": "一个盛产各种奇异花卉的地方",
"颜色": "80d5ffff"
},
"第三句话": {
"内容": "星期一,三,五,七零点种植",
"颜色": "ac52ffff"
},
"第四句话": {
"内容": "欢迎参观!",
"颜色": "f881ffff"
}
},
"稻草人昵称颜色": "b38282ff"
},
"智慧树配置": {
"距离上一次杀虫时间": 1753004237,
"距离上一次除草时间": 1753004237,
"智慧树显示的话": "",
"等级": 1,
"当前经验值": 0,
"最大经验值": 100,
"最大生命值": 100,
"当前生命值": 100,
"高度": 20
},
"签到历史": {},
"在线礼包": {
"当前日期": "2025-07-20",
"今日在线时长": 0,
"已领取礼包": [],
"登录时间": 1753003043.7163484
},
"点赞系统": {
"今日剩余点赞次数": 10,
"点赞上次刷新时间": "2025-07-20",
"总点赞数": 0
},
"新手礼包": {
"已领取": false,
"领取时间": "2025-07-12 23:02:25"
},
"体力系统": {
"当前体力值": 20,
"最大体力值": 20,
"上次刷新时间": "2025-07-20",
"上次恢复时间": 1753003043.7066433
},
"小卖部配置": {
"商品列表": [],
"格子数": 10
},
"游戏设置": {
"背景音乐音量": 1,
"天气显示": true
}
}

View File

@@ -0,0 +1,218 @@
# 特殊农场管理系统
## 概述
特殊农场管理系统是一个自动化的农场维护工具,用于管理游戏中的特殊农场,为玩家提供特殊的不可购买作物。系统支持定时任务和手动维护两种模式。
## 功能特性
### 1. 自动定时维护
- **执行时间**: 每天凌晨0点自动执行
- **维护内容**: 为特殊农场种植指定的作物
- **日志记录**: 详细记录维护过程和结果
### 2. 手动维护模式
- 支持即时手动维护指定农场
- 可用于测试和紧急维护
### 3. 多环境支持
- **测试环境**: 用于开发和测试
- **生产环境**: 用于正式运行
## 当前支持的特殊农场
### 杂交农场
- **农场ID**: `689b4b9286cf953f2f4e56ee`
- **种植作物**: 0号杂交树、1号杂交树
- **种植方式**: 随机全屏种植
- **土地要求**: 仅在已开垦的土地上种植
- **作物状态**: 自动设置为已浇水、已施肥、立即成熟
## 使用方法
### 方法一:使用启动脚本(推荐)
```bash
# Windows
start_special_farm.bat
# 然后选择运行模式:
# 1. 测试环境
# 2. 生产环境
# 3. 手动维护模式
```
### 方法二:直接命令行
#### 自动模式(定时任务)
```bash
# 测试环境
python SpecialFarm.py test
# 生产环境
python SpecialFarm.py production
```
#### 手动维护模式
```bash
# 手动维护杂交农场(测试环境)
python SpecialFarm.py test manual 杂交农场
# 手动维护杂交农场(生产环境)
python SpecialFarm.py production manual 杂交农场
```
### 方法三:运行测试
```bash
# 运行完整测试
python test_special_farm.py
```
## 系统架构
### 核心组件
1. **SpecialFarmManager**: 主管理类
- 负责农场配置管理
- 处理定时任务调度
- 执行种植逻辑
2. **MongoDB集成**:
- 使用 `SMYMongoDBAPI` 进行数据库操作
- 支持玩家数据和作物配置的读写
3. **定时任务**:
- 使用 `schedule` 库实现定时功能
- 支持每日凌晨0点自动执行
### 数据结构
#### 农场配置
```python
special_farms = {
"杂交农场": {
"object_id": "689b4b9286cf953f2f4e56ee",
"crop_types": ["杂交树1", "杂交树2"]
}
}
```
#### 作物种植逻辑
- 随机选择配置的作物类型
- 仅在已开垦(`is_diged=True`)的土地上种植
- 自动设置作物状态:
- `is_planted=True`
- `is_watered=True`
- `is_fertilized=True`
- `growth_time=0`(立即成熟)
## 日志系统
### 日志文件
- **文件名**: `special_farm.log`
- **位置**: 与脚本同目录
- **格式**: `时间 - 级别 - 模块 - 消息`
### 日志级别
- **INFO**: 正常操作信息
- **WARNING**: 警告信息
- **ERROR**: 错误信息
### 示例日志
```
2024-01-15 00:00:01,123 - INFO - __main__ - 开始执行每日特殊农场维护任务...
2024-01-15 00:00:02,456 - INFO - __main__ - 成功为 杂交农场 种植了 40 块土地的作物
2024-01-15 00:00:02,789 - INFO - __main__ - 每日维护任务完成: 1/1 个农场维护成功
```
## 依赖要求
### Python包
```
schedule>=1.2.0
pymongo>=4.0.0
```
### 系统要求
- Python 3.7+
- MongoDB数据库连接
- 有效的游戏数据库配置
## 扩展指南
### 添加新的特殊农场
1. **在数据库中创建农场数据**
-`playerdata` 集合中添加新的农场文档
- 记录文档的 `ObjectId`
2. **更新农场配置**
```python
# 在 SpecialFarm.py 中的 special_farms 字典添加
"新农场名称": {
"object_id": "新农场的ObjectId",
"crop_types": ["作物类型1", "作物类型2"]
}
```
3. **测试新农场**
```bash
python SpecialFarm.py test manual 新农场名称
```
### 自定义种植逻辑
可以在 `plant_crops_in_farm` 方法中修改种植逻辑:
- 改变作物选择算法
- 调整作物生长参数
- 添加特殊种植条件
## 故障排除
### 常见问题
1. **数据库连接失败**
- 检查MongoDB服务是否运行
- 验证数据库连接配置
2. **农场数据不存在**
- 确认农场ObjectId是否正确
- 检查数据库中是否存在对应文档
3. **作物配置错误**
- 验证作物类型名称是否正确
- 检查作物配置数据是否完整
### 调试模式
运行测试脚本获取详细信息:
```bash
python test_special_farm.py
```
## 安全注意事项
1. **生产环境使用**
- 确保在生产环境中使用正确的数据库配置
- 定期备份重要数据
2. **权限管理**
- 确保脚本有足够的数据库读写权限
- 限制对生产数据库的访问
3. **监控和告警**
- 定期检查日志文件
- 设置维护任务失败的告警机制
## 版本历史
- **v1.0.0**: 初始版本,支持杂交农场的自动维护
- 实现定时任务功能
- 支持手动维护模式
- 完整的日志系统
- 测试和生产环境分离
---
**作者**: AI Assistant
**创建时间**: 2024年
**最后更新**: 2024年

52
Server/test_websocket.py Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
测试WebSocket远程命令API
"""
import asyncio
import websockets
import json
async def test_client():
"""测试WebSocket客户端"""
uri = "ws://localhost:7071"
try:
async with websockets.connect(uri) as websocket:
print(f"✅ 已连接到 {uri}")
# 接收欢迎消息
welcome_msg = await websocket.recv()
print(f"收到欢迎消息: {welcome_msg}")
# 发送认证请求
auth_data = {
"type": "auth",
"auth_key": "mengya2024"
}
await websocket.send(json.dumps(auth_data))
print("已发送认证请求")
# 接收认证结果
auth_result = await websocket.recv()
print(f"认证结果: {auth_result}")
# 发送测试命令
command_data = {
"type": "command",
"command": "help"
}
await websocket.send(json.dumps(command_data))
print("已发送help命令")
# 接收命令结果
command_result = await websocket.recv()
print(f"命令结果: {command_result}")
except Exception as e:
print(f"❌ 连接失败: {e}")
if __name__ == "__main__":
print("开始测试WebSocket连接...")
asyncio.run(test_client())

View File

@@ -0,0 +1,199 @@
# 特殊农场系统优化说明
## 概述
特殊农场系统已经过全面优化,解决了服务器重启时间重置和性能问题。现在系统更加稳定、高效,不会影响游戏服务器的正常运行。
## 主要优化内容
### 1. 解决服务器重启时间重置问题
**问题**: 之前每次服务器重启都会立即执行维护任务,导致重复种植。
**解决方案**:
- 添加维护时间记录功能
- 服务器启动时检查当日是否已执行维护
- 只有当天未维护过才会执行维护任务
- 确保每天只执行一次维护,无论服务器重启多少次
### 2. 性能优化
**CPU使用优化**:
- 调度器检查间隔从1分钟优化到5分钟
- 减少不必要的CPU占用
- 后台线程使用守护模式,不阻塞主进程
**内存管理优化**:
- 改进资源清理机制
- 服务器停止时正确释放特殊农场系统资源
- 避免内存泄漏
### 3. 稳定性改进
**错误处理**:
- 增强异常处理机制
- 添加详细的日志记录
- 系统出错时自动恢复
**资源管理**:
- 正确的启动和停止流程
- 线程安全的操作
- 避免资源竞争
## 系统工作原理
### 定时任务调度
```
启动服务器 → 初始化特殊农场管理器 → 检查当日维护状态
如果未维护 → 执行维护任务 → 记录维护时间
如果已维护 → 跳过维护任务
启动后台调度器 → 每天凌晨0点自动维护
```
### 维护任务内容
1. **土地开垦**: 确保所有土地都处于已开垦状态
2. **作物种植**: 随机种植杂交树1或杂交树2
3. **状态设置**: 设置作物为立即成熟状态
4. **记录更新**: 更新维护时间记录
## 使用方法
### 正常启动
特殊农场系统已集成到游戏服务器中,无需单独启动:
```bash
cd Server
python TCPGameServer.py
```
### 手动维护
如果需要手动执行维护任务:
```bash
# 维护所有特殊农场
python SpecialFarm.py test manual
# 维护指定农场
python SpecialFarm.py test manual 杂交农场
```
### 性能监控
使用性能监控工具检查系统资源使用:
```bash
python monitor_special_farm.py
```
### 测试优化效果
运行测试脚本验证优化效果:
```bash
python test_special_farm_optimization.py
```
## 配置说明
### 特殊农场配置
`SpecialFarm.py` 中的 `special_farms` 字典:
```python
self.special_farms = {
"杂交农场": {
"object_id": "689b4b9286cf953f2f4e56ee",
"crops": ["杂交树1", "杂交树2"],
"description": "专门种植杂交树的特殊农场"
}
}
```
### 调度器配置
- **维护时间**: 每天凌晨0点
- **检查间隔**: 5分钟
- **运行模式**: 后台守护线程
## 性能指标
### 优化前 vs 优化后
| 指标 | 优化前 | 优化后 | 改进 |
|------|--------|--------|------|
| CPU检查间隔 | 1分钟 | 5分钟 | 减少80%检查频率 |
| 重启重复执行 | 是 | 否 | 避免重复维护 |
| 资源清理 | 不完整 | 完整 | 防止内存泄漏 |
| 错误恢复 | 基础 | 增强 | 提高稳定性 |
### 预期性能表现
- **CPU使用率**: < 1%(正常运行时)
- **内存使用**: < 50MB额外占用
- **线程数**: +1后台调度线程
- **启动时间**: < 1秒
## 故障排除
### 常见问题
1. **特殊农场未自动维护**
- 检查MongoDB连接是否正常
- 查看日志文件 `special_farm.log`
- 确认特殊农场配置正确
2. **服务器启动缓慢**
- 检查MongoDB连接速度
- 查看是否有网络问题
- 考虑使用本地MongoDB
3. **内存使用过高**
- 运行性能监控工具
- 检查是否有内存泄漏
- 重启服务器释放资源
### 日志文件
- **特殊农场日志**: `special_farm.log`
- **服务器日志**: 控制台输出
- **MongoDB日志**: MongoDB服务器日志
## 维护建议
### 定期检查
1. **每周检查**:
- 查看 `special_farm.log` 日志
- 确认维护任务正常执行
- 检查特殊农场作物状态
2. **每月检查**:
- 运行性能监控工具
- 清理过期日志文件
- 检查MongoDB数据库状态
### 备份建议
- 定期备份MongoDB数据库
- 保存特殊农场配置文件
- 记录重要的配置变更
## 技术支持
如果遇到问题,请提供以下信息:
1. 错误日志内容
2. 服务器运行环境
3. MongoDB版本和配置
4. 问题复现步骤
---
**注意**: 此优化版本向后兼容,不会影响现有的游戏数据和功能。