package com.genlot.ninglottery.game.qlc.bean;

import android.text.TextUtils;

import com.genlot.ninglottery.game.bet.BetNumber;
import com.genlot.ninglottery.game.qlc.QlcConfig;
import com.genlot.ninglottery.toolkit.GameUtil;
import com.genlot.ninglottery.toolkit.LogTool;
import com.genlot.ninglottery.toolkit.StringTool;

import java.util.Set;

/**
 * @author ZhuYongKang
 * @description 7乐彩复式
 * @date 2019/9/11
 */
public class Multi7lc extends Bet7lc {
    @Override
    public boolean isFull() {
        return mRedList.size() >= QlcConfig.MULTI_RED_MIN;
    }

    /**
     * @return  1|2|3|4|5|6|7|8|
     */
    @Override
    public String toBetString() {
        StringBuilder builder = new StringBuilder();
        for (BetNumber number : mRedList) {
            builder.append(number.getNumber()).append("|");
        }
        return builder.toString();
    }

    @Override
    public void parseBetData(String betData) {
        if (!TextUtils.isEmpty(betData)) {
            LogTool.logD("betData = " + betData);
            String[] nums = betData.split("\\|");
            for (String num : nums) {
                BetNumber number = new BetNumber(StringTool.format2(Integer.parseInt(num)));
                number.setType(BetNumber.CHECKED);
                mRedList.add(number);
            }
        }
    }

    @Override
    public void random(int... args) {
        int num = args[0];
        clear();
        //红球
        Set<Integer> redSet = GameUtil.randomList(1, 30, num);
        for (int i : redSet) {
            BetNumber number = new BetNumber(StringTool.format2(i));
            number.setType(BetNumber.CHECKED);
            mRedList.add(number);
        }
    }

}
