# 创建跟踪游戏统计信息的Game_Stats类

import json


class Game_Stats():
    """跟踪游戏统计信息的类"""
    def __init__(self, ai_settings):
        self.ai_settings = ai_settings
        self.reset_stats()
        # 游戏刚启动时处于活动状态
        self.game_active = False

        # 在任何情况情况下都不应重置最高得分,加载历史最高分
        self.high_score = 0
        with open('Max_score.json', encoding='UTF-8') as file:
            self.high_score = json.load(file)

    def reset_stats(self):
        """初始化在游戏运行期间可能变化的统计信息"""
        self.ships_left = self.ai_settings.ship_limit
        self.score = 0  # 每次有新的分数都应该重置
        self.level = 1  # 设置游戏等级