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

import android.text.TextUtils;

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

import java.util.Collections;
import java.util.Set;

/**
 * @author ZhuYongKang
 * @description 组三复式实体类
 * @date 2019/10/16
 */
public class MultiBox3 extends BoxSum {

    public int getMinSize() {
        return 2;
    }

    public int getMaxSize() {
        return 10;
    }

    @Override
    public boolean isFull() {
        return mList.size() >= 2;
    }

    @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(num);
                number.setType(BetNumber.CHECKED);
                mList.add(number);
            }
        }
    }

    @Override
    public void random(int... args) {
        int num = args[0];
        clear();
        //第一位
        Set<Integer> set1 = GameUtil.randomList(0, 9, num);
        for (int i : set1) {
            BetNumber number = new BetNumber(String.valueOf(i));
            number.setType(BetNumber.CHECKED);
            mList.add(number);
        }
    }

    @Override
    public void add(BetNumber number) {
        BetNumber bet = new BetNumber(number.getNumber());
        bet.setType(number.getType());
        bet.setRed(number.isRed());
        mList.add(bet);
        Collections.sort(mList, (o1, o2) -> Integer.parseInt(o1.getNumber()) - Integer.parseInt(o2.getNumber()));
    }

}
