#ifndef PINGPONG_GAME_H
#define PINGPONG_GAME_H

#include <godot_cpp/classes/node2d.hpp>
#include <godot_cpp/classes/label.hpp>

namespace godot {

class PingPongGame : public Node2D {
    GDCLASS(PingPongGame, Node2D)

private:
    int left_score = 0;
    int right_score = 0;
    int max_score = 5;

    Label *left_score_label = nullptr;
    Label *right_score_label = nullptr;

    void update_score_display();

protected:
    static void _bind_methods();

public:
    PingPongGame();
    ~PingPongGame();

    void _ready() override;

    // 得分处理
    void _on_ball_scored(int which);

    // 重置整局游戏
    void reset_game();

    // 属性 getter/setter
    void set_left_score(int p_score);
    int get_left_score() const;

    void set_right_score(int p_score);
    int get_right_score() const;

    void set_max_score(int p_score);
    int get_max_score() const;

    // 信号: game_over(int winner) — 0=左边赢, 1=右边赢
};

}

#endif // PINGPONG_GAME_H
