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

import com.genlot.ninglottery.game.bet.BetNumber;
import com.genlot.ninglottery.game.bet.IBetBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhuYongKang
 * @description 3D游戏基类
 * @date 2019/9/2
 */
public abstract class BetD3 implements IBetBean {

    public List<BetNumber> mList1;
    public List<BetNumber> mList2;
    public List<BetNumber> mList3;

    public BetD3() {
        mList1 = new ArrayList<>();
        mList2 = new ArrayList<>();
        mList3 = new ArrayList<>();
    }

    @Override
    public void clear() {
        mList1.clear();
        mList2.clear();
        mList3.clear();
    }

    @Override
    public List<BetNumber> getAllNumberList() {
        List<BetNumber> list = new ArrayList<>();
        list.addAll(mList1);
        list.addAll(mList2);
        list.addAll(mList3);
        return list;
    }

    public void add(BetNumber number, int index) {
        BetNumber bet = new BetNumber(number.getNumber());
        bet.setType(number.getType());
        bet.setRed(number.isRed());
        if (index == 0) {
            mList1.add(bet);
        } else if (index == 1) {
            mList2.add(bet);
        } else if (index == 2) {
            mList3.add(bet);
        }
    }

    public void remove(BetNumber number, int index) {
        if (index == 0) {
            for (BetNumber bet : mList1) {
                if (bet.getNumber().equals(number.getNumber())) {
                    mList1.remove(bet);
                    break;
                }
            }
        } else if (index == 1) {
            for (BetNumber bet : mList2) {
                if (bet.getNumber().equals(number.getNumber()) ) {
                    mList2.remove(bet);
                    break;
                }
            }
        } else if (index == 2) {
            for (BetNumber bet : mList3) {
                if (bet.getNumber().equals(number.getNumber())) {
                    mList3.remove(bet);
                    break;
                }
            }
        }
    }

}
