package com.genlot.nativesdk.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

public class GameTicket implements Parcelable {
    /**
     * 特征码
     */
    public String mFeatureCode;
    private final int MAX_BET_SIZE = 5;//单票最大注数
    public int mGameID = 0;//游戏ID
    public int mValid = 0;//票有效性，0－投注机注销，1-冲正，2-中心注销，3-有效，4－投注机兑奖，5－中心兑奖，6－弃奖
    public int mBets = 0;//投注注数
    public int mBitOfNumber = 0;//号码位数
    public String mOperatorID;//操作员ID
    public int mIsMixPlayType = 0;//是否混合玩法
    public String mMemberID;//会员卡号
    public String mGameName;//游戏名称
    public String mVerifyCode;//验票码
    public int mMultiIssue = 0;//投注的多期期数
    public long mFeatureKey = 0;//特征码key
    public long mGameIssue = 0;//游戏期号
    public long mTicketSN = 0;//票流水号
    public long mFrontSN = 0;//终端流水号
    public long mBettingTime = 0;//投注时间
    public long mSaleIssue = 0;//销售期号
    public long mCancelTime = 0;//注销时间
    public long mCancelTermID = 0;//注销的终端编号
    public long mTerminalID = 0;//终端编号
    public long mInitPlayType = 0;//初始玩法类型
    public double mBettingMoney = 0.00f;//投注金额
    public int[] mBettingMode;//投注方式
    public int[] mMultiTimes;//投注倍数
    public int[] mNumOfBet;//单注号码个数
    public int[] mPlayType;//投注玩法类型
    public int[] mBetDataLength;//投注号码内容长度
    public String[] mPlayTypeString;//投注玩法名称
    public int[][] mNumSP;//特殊玩法包号个数
    public int[][] mGameBetData;//第一个投注号码
    public int[][] mExtraBetData;//投注号码
    public String[] gameBetDataString;//投注的号码
    public String mWelfareFundTipsString;//公益金提示语


    public GameTicket() {
        mBettingMode = new int[MAX_BET_SIZE];
        mMultiTimes = new int[MAX_BET_SIZE];
        mNumOfBet = new int[MAX_BET_SIZE];
        mNumSP = new int[MAX_BET_SIZE][10];
        mGameBetData = new int[MAX_BET_SIZE][256];
        mExtraBetData = new int[MAX_BET_SIZE][256];
        mPlayType = new int[MAX_BET_SIZE];
        mBetDataLength = new int[MAX_BET_SIZE];
        mPlayTypeString = new String[MAX_BET_SIZE];
        gameBetDataString = new String[MAX_BET_SIZE];
        clearTicket();
    }

    public void clearTicket() {
        mGameID = 0;
        mValid = 0;
        mBets = 0;
        mBitOfNumber = 0;
        mOperatorID = "";
        mIsMixPlayType = 0;
        mMemberID = "";
        mGameName = "";
        mMultiIssue = 0;
        mGameIssue = 0;
        mTicketSN = 0;
        mFrontSN = 0;
        mBettingTime = 0;
        mSaleIssue = 0;
        mCancelTime = 0;
        mCancelTermID = 0;
        mTerminalID = 0;
        mInitPlayType = 0;
        mBettingMoney = 0.00f;
        Arrays.fill(mBettingMode, 0);
        Arrays.fill(mMultiTimes, 0);
        Arrays.fill(mNumOfBet, 0);
        Arrays.fill(mPlayType, 0);
        Arrays.fill(mBetDataLength, 0);
        Arrays.fill(mPlayTypeString, "");
        Arrays.fill(gameBetDataString, "");
        for (int i = 0; i < MAX_BET_SIZE; i++) {
            Arrays.fill(mNumSP[i], 0);
            Arrays.fill(mGameBetData[i], -1);
            Arrays.fill(mExtraBetData[i], -1);
        }
    }

    public static final Creator<GameTicket> CREATOR = new Creator<GameTicket>() {
        @Override
        public GameTicket createFromParcel(Parcel source) {
            GameTicket ticket = new GameTicket();
            ticket.mGameID = source.readInt();
            ticket.mValid = source.readInt();
            ticket.mBets = source.readInt();
            ticket.mBitOfNumber = source.readInt();
            ticket.mOperatorID = source.readString();
            ticket.mIsMixPlayType = source.readInt();
            ticket.mMemberID = source.readString();
            ticket.mGameName = source.readString();
            ticket.mFeatureCode = source.readString();
            ticket.mVerifyCode = source.readString();
            ticket.mMultiIssue = source.readInt();
            ticket.mGameIssue = source.readLong();
            ticket.mTicketSN = source.readLong();
            ticket.mFrontSN = source.readLong();
            ticket.mBettingTime = source.readLong();
            ticket.mSaleIssue = source.readLong();
            ticket.mCancelTime = source.readLong();
            ticket.mCancelTermID = source.readLong();
            ticket.mTerminalID = source.readLong();
            ticket.mInitPlayType = source.readLong();
            ticket.mBettingMoney = source.readDouble();
            source.readIntArray(ticket.mBettingMode);
            source.readIntArray(ticket.mMultiTimes);
            source.readIntArray(ticket.mNumOfBet);
            source.readIntArray(ticket.mPlayType);
            source.readIntArray(ticket.mBetDataLength);
            source.readStringArray(ticket.mPlayTypeString);
            source.readStringArray(ticket.gameBetDataString);
            for (int i = 0; i < ticket.mNumSP.length; i++) {
                source.readIntArray(ticket.mNumSP[i]);
            }
            for (int i = 0; i < ticket.mGameBetData.length; i++) {
                source.readIntArray(ticket.mGameBetData[i]);
            }
            for (int i = 0; i < ticket.mExtraBetData.length; i++) {
                source.readIntArray(ticket.mExtraBetData[i]);
            }
            ticket.mWelfareFundTipsString = source.readString();
            return ticket;
        }

        @Override
        public GameTicket[] newArray(int size) {
            return new GameTicket[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeInt(mGameID);
        parcel.writeInt(mValid);
        parcel.writeInt(mBets);
        parcel.writeInt(mBitOfNumber);
        parcel.writeString(mOperatorID);
        parcel.writeInt(mIsMixPlayType);
        parcel.writeString(mMemberID);
        parcel.writeString(mGameName);
        parcel.writeString(mFeatureCode);
        parcel.writeString(mVerifyCode);
        parcel.writeInt(mMultiIssue);
        parcel.writeLong(mGameIssue);
        parcel.writeLong(mTicketSN);
        parcel.writeLong(mFrontSN);
        parcel.writeLong(mBettingTime);
        parcel.writeLong(mSaleIssue);
        parcel.writeLong(mCancelTime);
        parcel.writeLong(mCancelTermID);
        parcel.writeLong(mTerminalID);
        parcel.writeLong(mInitPlayType);
        parcel.writeDouble(mBettingMoney);
        parcel.writeIntArray(mBettingMode);
        parcel.writeIntArray(mMultiTimes);
        parcel.writeIntArray(mNumOfBet);
        parcel.writeIntArray(mPlayType);
        parcel.writeIntArray(mBetDataLength);
        parcel.writeStringArray(mPlayTypeString);
        parcel.writeStringArray(gameBetDataString);
        for (int i = 0; i < mNumSP.length; i++) {
            parcel.writeIntArray(mNumSP[i]);
        }
        for (int i = 0; i < mGameBetData.length; i++) {
            parcel.writeIntArray(mGameBetData[i]);
        }
        for (int i = 0; i < mExtraBetData.length; i++) {
            parcel.writeIntArray(mExtraBetData[i]);
        }
        parcel.writeString(mWelfareFundTipsString);
    }
}
