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

import android.text.TextUtils;

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

import java.util.Random;

/**
 * @author ZhuYongKang
 * @description 3D猜奇偶玩法
 * @date 2019/10/14
 */
public class GuessOE extends BoxSum{

    @Override
    public String toBetString() {
        StringBuilder builder = new StringBuilder();
        for (BetNumber number : mList) {
            builder.append(number.getNumber().equals("偶") ? "4" : "5");
            builder.append("|");
        }
        return builder.toString();
    }

    @Override
    public void parseBetData(String betData) {
        if (!TextUtils.isEmpty(betData)) {
            LogTool.logD("betData = " + betData);
            String[] nums = betData.split("\\|");
            BetNumber number = new BetNumber(nums[0].equals("4") ? "偶" : "奇");
            number.setType(BetNumber.CHECKED);
            mList.add(number);
        }
    }

    @Override
    public void random(int... args) {
        clear();
        Random rand = new Random();
        int anInt = rand.nextInt(2);
        if (anInt == 0) {
            BetNumber number = new BetNumber("偶");
            number.setType(BetNumber.CHECKED);
            mList.add(number);
        } else {
            BetNumber number = new BetNumber("奇");
            number.setType(BetNumber.CHECKED);
            mList.add(number);
        }
    }

}
