import { MsgType, PlayerData } from "./msgType_L5R3_GuessingGame";

export default class MsgData {

    _playerList: Array<PlayerData>;
    _time: number = 0;
    _round: number = 0;
    _answerList: Array<any> = [];

    constructor(data?: {
        playerList,
        time,
        round,
        answerList,
    }) {
        this._playerList = data?.playerList || [];
        this._time = data?.time || 0;
        this._round = data?.round || 0;
        this._answerList = data?.answerList || [];
    }

    get PlayerList() {
        return this._playerList;
    }

    addPlayer(val: PlayerData) {
        this._playerList.push(val);
    }



    get Time() {
        return this._time;
    }
    set Time(val: number) {
        this._time = val;
    }

    get Round() {
        return this._round;
    }
    set Round(val: number) {
        this._round = val;
    }


    getAnswerList() {
        return this._answerList;
    }
    addAnswerList(val: { word?: string, uuid: string, index?: number, time: number }) {
        this._answerList.push(val);
    }
    clearAnswerList() {
        this._answerList = [];
    }

    get Msg() {
        let data =
        {
            playerList: this._playerList,
            time: this._time,
            round: this._round,
            answerList: this._answerList,
        }
        return JSON.stringify(data);
    }

}