/**
 * @description 签到数据
 * @author 邹勇 薛鸿潇
 */
export class SignData {
    /** 标志位：是否需要刷新数据 */
    public init_data: boolean = false;

    /** 签到配置 */
    public c_sign = [];

    // 假数据 当前签到天数
    private _cur_sign_day = 3;
    set cur_sign_day(value: number) {
        this._cur_sign_day = value;
        this.init_data = true;
    }
    get cur_sign_day(): number {
        return this._cur_sign_day;
    }

    // 假数据 能够签到
    private _can_sign = 1;
    set can_sign(value: number) {
        this._can_sign = value;
        this.init_data = true;
    }
    get can_sign(): number {
        return this._can_sign;
    }

    /** 签到列表数据 */
    public list_data = [];
    /** 初始化列表数据 */
    public initListData() {
        if (!this.c_sign.length) this.c_sign = this.getSignConfig();
        let list_data = [];
        for (let i = 0; i < 30;) {
            let item_data = [];
            for (let j = 0; j < 3; j++) {
                let data = this.c_sign[i];
                item_data.push(data);
                i++;
            }
            list_data.push(item_data);
        }
        this.list_data = list_data;
    }

    /** 客户端造的假配置 */
    private getSignConfig() {
        let c_sign = [];
        for (let i = 0; i < 30; i++) {
            const id = i + 1;
            let data: any = {};
            data.id = id;
            data.reward_type = i % 3;
            data.count = id;
            data.login_day = id;
            data.video_limit = 0;
            c_sign.push(data);
        }
        return c_sign;
    }
    
    /**
     * 获取奖励状态
     * @param login_day 登陆日 
     * @returns 状态123
     */
    public getStateByDay(login_day: number) {
        let _state = g.enum.rewardState.none;
        if (login_day < this.cur_sign_day) {
            _state = g.enum.rewardState.none;
        } else if (login_day == this.cur_sign_day) {
            if (!this.can_sign) {
                _state = g.enum.rewardState.none;
            } else {
                _state = g.enum.rewardState.unlock;
            }
        } else {
            _state = g.enum.rewardState.lock;
        }
        return _state;
    }
}