Exemple #1
0
        //由外部调用,创建整个赛事模型,利用向导对话框


        //如果返回的无数据,标识创建失败
        public static AxDrawModelEvent CreateModelEvent()
        {
            AxDrawModelEvent modelEvent = new AxDrawModelEvent();
            DialogResult     drResult;

            AxModelWizardFrameForm fmModelEditForm = new AxModelWizardFrameForm();

            fmModelEditForm.ShowDialog();
            drResult = fmModelEditForm.DialogResult;

            if (drResult != DialogResult.OK)
            {
                return(modelEvent);
            }

            modelEvent = fmModelEditForm.m_ModelEvent;

            //把所有比赛实际创建出来


            for (Int32 nStage = 0; nStage < modelEvent.GetStageCnt(); nStage++)
            {
                AxDrawModelStage pModelStage = modelEvent.GetStageObj(nStage);
                for (Int32 nModel = 0; nModel < pModelStage.GetModelCnt(); nModel++)
                {
                    AxDrawModelModelExport pModelExport = pModelStage.GetModelExpObj(nModel);
                    pModelExport.m_matchList = _CreateModelSingle(pModelExport.m_drawInfo);
                }
            }

            modelEvent.CreateMatchNum();

            return(modelEvent);
        }
        public AxDrawModelModelExport GetModelExport(int nStageIdx, int nModelExpIdx)
        {
            AxDrawModelStage pStage = GetStageObj(nStageIdx);

            if (pStage == null)
            {
                return(null);
            }

            if (nModelExpIdx < 0 || nModelExpIdx >= (int)pStage.m_aryModelList.Count)
            {
                Debug.Assert(false);
                return(null);
            }

            return(pStage.m_aryModelList[nModelExpIdx]);
        }
        //创建出只有DrawInfo,没有比赛列表的结构
        public Boolean CreateEventModel()
        {
            m_ModelEvent.RemoveAll();

            //预赛,小组赛
            if (m_eModelUse == EUseEventModel.emModelGroup || m_eModelUse == EUseEventModel.emModelmGtomK || m_eModelUse == EUseEventModel.emModelmGtoK)
            {
                AxDrawModelStage modelStage = new AxDrawModelStage();
                modelStage.m_strStageName = m_StepGroup.GetStageTitle();

                for (Int32 nCyc = 0; nCyc < m_StepGroup.GetGroupCnt(); nCyc++)
                {
                    //每个组除了名字,都一样,所以统一建了一个,每次换名字
                    AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                    modelExport.m_drawInfo.m_bBogol = m_StepGroup.IsUseBogol();
                    modelExport.m_drawInfo.m_bQual  = true;
                    modelExport.m_drawInfo.m_eType  = EDrawModelType.emTypeRoundRobin;
                    modelExport.m_drawInfo.m_nSize  = m_StepGroup.GetPlayerCntPerGroup();
                    modelExport.m_drawInfo.m_nRank  = m_StepGroup.GetQualCntPerGroup();

                    modelExport.m_drawInfo.m_strTitle = m_StepGroup.GetGroupName(nCyc);
                    modelStage.m_aryModelList.Add(modelExport);
                }

                m_ModelEvent.m_aryStageList.Add(modelStage);

                //如果是单循环赛,在这直接加上名次信息,就完事了
                if (m_eModelUse == EUseEventModel.emModelGroup)
                {
                    for (Int32 nCyc = 0; nCyc < modelStage.m_aryModelList[0].m_drawInfo.m_nRank; nCyc++)
                    {
                        for (Int32 nGroup = 0; nGroup < m_StepGroup.GetGroupCnt(); nGroup++)
                        {
                            AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                            playerFrom.m_byStageOrder = 0;
                            playerFrom.m_byModelOrder = (Byte)nGroup;
                            playerFrom.m_byResultRank = (Byte)(nCyc + 1);
                            m_ModelEvent.m_aryEventRank.Add(playerFrom);
                        }
                    }
                }
            }
            else
            if (m_eModelUse == EUseEventModel.emModelmKtoK) //预赛,淘汰赛
            {
                AxDrawModelStage modelStage = new AxDrawModelStage();
                modelStage.m_strStageName = m_StepKnockOut.GetStageTitle();

                for (int nCyc = 0; nCyc < m_StepKnockOut.GetGroupCnt(); nCyc++)
                {
                    //每个组除了名字,都一样,所以统一建了一个,每次换名字
                    AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                    modelExport.m_drawInfo.m_bBogol   = false;
                    modelExport.m_drawInfo.m_bQual    = true;
                    modelExport.m_drawInfo.m_eType    = EDrawModelType.emTypeKonckOut;
                    modelExport.m_drawInfo.m_nSize    = m_StepKnockOut.GetLayerCntPerGroup();
                    modelExport.m_drawInfo.m_nRank    = m_StepKnockOut.GetQualCntPerGroup();
                    modelExport.m_drawInfo.m_strTitle = m_StepKnockOut.GetGroupName(nCyc);
                    modelStage.m_aryModelList.Add(modelExport);
                }

                m_ModelEvent.m_aryStageList.Add(modelStage);
            }
            else
            if (m_eModelUse == EUseEventModel.emModelKnockOut) //预赛,单淘汰赛
            {
                AxDrawModelStage modelStage = new AxDrawModelStage();
                modelStage.m_strStageName = m_StepKnockSingle.GetStageTitle();

                AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                modelExport.m_drawInfo.m_bBogol   = false;
                modelExport.m_drawInfo.m_bQual    = false;
                modelExport.m_drawInfo.m_eType    = EDrawModelType.emTypeKonckOut;
                modelExport.m_drawInfo.m_nSize    = m_StepKnockSingle.GetLayerCntPerGroup();
                modelExport.m_drawInfo.m_nRank    = m_StepKnockSingle.GetQualCntPerGroup();
                modelExport.m_drawInfo.m_strTitle = m_StepKnockSingle.GetStageTitle();

                modelStage.m_aryModelList.Add(modelExport);
                m_ModelEvent.m_aryStageList.Add(modelStage);

                //处理最终排名
                for (int nCyc = 0; nCyc < modelExport.m_drawInfo.m_nRank; nCyc++)
                {
                    AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                    playerFrom.m_byStageOrder = 0;
                    playerFrom.m_byModelOrder = 0;
                    playerFrom.m_byResultRank = (Byte)(nCyc + 1);
                    m_ModelEvent.m_aryEventRank.Add(playerFrom);
                }
            }

            //决赛, 多组To多淘
            if (m_eModelUse == EUseEventModel.emModelmGtomK)
            {
                AxDrawModelStage modelStageKnock = new AxDrawModelStage();
                modelStageKnock.m_strStageName = m_StepKnockFinal.GetStageTitle();

                //创建所有淘汰赛模型
                Int32 nModelCanUseCnt = m_StepKnockFinal.IsModelUse(3) ? 3 : (m_StepKnockFinal.IsModelUse(2) ? 2 : 1);
                for (Int32 nModel = 1; nModel <= nModelCanUseCnt; nModel++)
                {
                    AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                    modelExport.m_drawInfo.m_eType    = EDrawModelType.emTypeKonckOut;
                    modelExport.m_drawInfo.m_nSize    = m_StepKnockFinal.GetModelLayer(nModel);
                    modelExport.m_drawInfo.m_nRank    = m_StepKnockFinal.GetModelSize(nModel);
                    modelExport.m_drawInfo.m_bBogol   = false;
                    modelExport.m_drawInfo.m_strTitle = m_StepKnockFinal.GetModelTitle(nModel);

                    Int32 nRankOrder = 1;

                    //循环把晋级的人填入这个结构, 每组里的第几个人
                    for (Int32 nPlayerIndex = m_StepKnockFinal.GetModelPlayerIndexStart(nModel) - 1;
                         nPlayerIndex < m_StepKnockFinal.GetModelPlayerIndexEnd(nModel);
                         nPlayerIndex++)
                    {
                        //从预赛晋级过来了几个组
                        for (Int32 nGroup = 0; nGroup < m_StepKnockFinal.GetGroupFromCnt(); nGroup++)
                        {
                            //处理所有来源
                            AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                            playerFrom.m_byStageOrder = 0;                              //第1层的
                            playerFrom.m_byModelOrder = (Byte)nGroup;                   //循环这一层的每个模型
                            playerFrom.m_byResultRank = (Byte)(nPlayerIndex + 1);       //在这一组的排序
                            modelExport.m_aryPlayerFrom.Add(playerFrom);

                            //处理整个赛事最后排名
                            AxDrawModelPlayerFrom rankPlayerFrom = new AxDrawModelPlayerFrom();
                            rankPlayerFrom.m_byStageOrder = 1;                  //固定在第二阶段
                            rankPlayerFrom.m_byModelOrder = (Byte)(nModel - 1); //循环每个淘汰赛
                            rankPlayerFrom.m_byResultRank = (Byte)(nRankOrder++);
                            m_ModelEvent.m_aryEventRank.Add(rankPlayerFrom);
                        }
                    }

                    modelStageKnock.m_aryModelList.Add(modelExport);
                }//for nModel

                m_ModelEvent.m_aryStageList.Add(modelStageKnock);
            }
            //多组To单淘
            else if (m_eModelUse == EUseEventModel.emModelmGtoK)
            {
                AxDrawModelStage modelStageKnock = new AxDrawModelStage();
                modelStageKnock.m_strStageName = m_StepKnockSingle.GetStageTitle();

                AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                modelExport.m_drawInfo.m_eType    = EDrawModelType.emTypeKonckOut;
                modelExport.m_drawInfo.m_nSize    = m_StepKnockSingle.GetLayerCntPerGroup();
                modelExport.m_drawInfo.m_nRank    = m_StepKnockSingle.GetQualCntPerGroup();
                modelExport.m_drawInfo.m_bBogol   = false;
                modelExport.m_drawInfo.m_strTitle = m_StepKnockSingle.GetStageTitle();

                //处理所有人来源,以组为轮换顺序加入晋级名单
                for (Int32 nPlayerIdx = 0; nPlayerIdx < m_StepGroup.GetQualCntPerGroup(); nPlayerIdx++)
                {
                    for (Int32 nGroup = 0; nGroup < m_StepGroup.GetGroupCnt(); nGroup++)
                    {
                        AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                        playerFrom.m_byStageOrder = 0;                          //第1层的
                        playerFrom.m_byModelOrder = (Byte)nGroup;               //循环这一层的每个模型
                        playerFrom.m_byResultRank = (Byte)(nPlayerIdx + 1);     //在这一组的排序
                        modelExport.m_aryPlayerFrom.Add(playerFrom);
                    }
                }

                //处理最后排名输出
                for (Int32 nResultIdx = 0; nResultIdx < m_StepKnockSingle.GetQualCntPerGroup(); nResultIdx++)
                {
                    AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                    playerFrom.m_byStageOrder = 1;                      //第2层的
                    playerFrom.m_byModelOrder = 0;                      //循环这一层的每个模型
                    playerFrom.m_byResultRank = (Byte)(nResultIdx + 1); //在这一组的排序
                    m_ModelEvent.m_aryEventRank.Add(playerFrom);
                }

                modelStageKnock.m_aryModelList.Add(modelExport);
                m_ModelEvent.m_aryStageList.Add(modelStageKnock);
            }
            //多淘To淘
            else if (m_eModelUse == EUseEventModel.emModelmKtoK)
            {
                AxDrawModelStage modelStageKnock = new AxDrawModelStage();
                modelStageKnock.m_strStageName = m_StepKnockSingle.GetStageTitle();

                AxDrawModelModelExport modelExport = new AxDrawModelModelExport();
                modelExport.m_drawInfo.m_eType    = EDrawModelType.emTypeKonckOut;
                modelExport.m_drawInfo.m_nSize    = m_StepKnockSingle.GetLayerCntPerGroup();
                modelExport.m_drawInfo.m_nRank    = m_StepKnockSingle.GetQualCntPerGroup();
                modelExport.m_drawInfo.m_bBogol   = false;
                modelExport.m_drawInfo.m_strTitle = m_StepKnockSingle.GetStageTitle();

                //处理所有人来源,以组为轮换顺序加入晋级名单
                for (Int32 nPlayerIdx = 0; nPlayerIdx < m_StepKnockOut.GetQualCntPerGroup(); nPlayerIdx++)
                {
                    for (Int32 nGroup = 0; nGroup < m_StepKnockOut.GetGroupCnt(); nGroup++)
                    {
                        AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                        playerFrom.m_byStageOrder = 0;                          //第1层的
                        playerFrom.m_byModelOrder = (Byte)nGroup;               //循环这一层的每个模型
                        playerFrom.m_byResultRank = (Byte)(nPlayerIdx + 1);     //在这一组的排序
                        modelExport.m_aryPlayerFrom.Add(playerFrom);
                    }
                }

                //处理最后排名输出
                for (Int32 nResultIdx = 0; nResultIdx < m_StepKnockSingle.GetQualCntPerGroup(); nResultIdx++)
                {
                    AxDrawModelPlayerFrom playerFrom = new AxDrawModelPlayerFrom();
                    playerFrom.m_byStageOrder = 1;                      //第2层的
                    playerFrom.m_byModelOrder = 0;                      //只有一个淘汰赛模型
                    playerFrom.m_byResultRank = (Byte)(nResultIdx + 1); //在这一组的排序
                    m_ModelEvent.m_aryEventRank.Add(playerFrom);
                }

                modelStageKnock.m_aryModelList.Add(modelExport);
                m_ModelEvent.m_aryStageList.Add(modelStageKnock);
            }

            return(true);
        }
        //将整个Event中所有比赛编号,按照Event的轮为单位


        public Boolean CreateMatchNum()
        {
            Int32 dwMatchNum = 1; //从1开始


            for (Int32 nStage = 0; nStage < GetStageCnt(); nStage++)
            {
                AxDrawModelStage pStage = GetStageObj(nStage);

                ArrayList aryDwCurMatchIdxInModel = new ArrayList();    //目前Stage中每个Model进行到第几场比赛了,用来在循环中作记忆


                //把个数设为Model个数,并且每个都是先从第一个开始


                for (Int32 nCyc = 0; nCyc < pStage.GetModelCnt(); nCyc++)
                {
                    aryDwCurMatchIdxInModel.Add(0);
                }

                do//填序号,直到每个Model的所有比赛都填了序号
                {
                    //循环每个Model,进行排号,每个Model有一次机会时,把这轮所有的号拍完,
                    //之后释放机会,等下次机会再排下一轮

                    for (Int32 nModel = 0; nModel < pStage.GetModelCnt(); nModel++)
                    {
                        AxDrawModelModelExport pModel = pStage.GetModelExpObj(nModel);

                        //获取阶段中当前模型排号到哪场比赛了

                        Int32 dwCurMatchIdxInModel = (Int32)aryDwCurMatchIdxInModel[nModel];
                        if (dwCurMatchIdxInModel < 0 || dwCurMatchIdxInModel > pModel.GetMatchCnt())
                        {
                            Debug.Assert(false);
                            return(false);
                        }

                        if (dwCurMatchIdxInModel >= pModel.GetMatchCnt())
                        {
                            //如果存的标志大于本Model比赛个数,说明此Model比赛都添加过了

                            continue;
                        }

                        AxDrawModelMatchRow pMatch = pModel.GetMatchObj(dwCurMatchIdxInModel); //得到当前的比赛

                        Int32 byCurRound = Convert.ToInt32(pMatch.m_byteRoundOrder);
                        pMatch.m_dwMatchNum = Convert.ToUInt32(dwMatchNum++);
                        dwCurMatchIdxInModel++;

                        while (dwCurMatchIdxInModel < pModel.GetMatchCnt() &&
                               Convert.ToUInt32(pModel.GetMatchObj(dwCurMatchIdxInModel).m_byteRoundOrder) == byCurRound)
                        {
                            pModel.GetMatchObj(dwCurMatchIdxInModel).m_dwMatchNum = Convert.ToUInt32(dwMatchNum++);
                            dwCurMatchIdxInModel++;
                        }

                        aryDwCurMatchIdxInModel[nModel] = dwCurMatchIdxInModel; //把此Model下次该进行场次排号的Index写入记忆数组
                    }

                    //查找是否还有需要填写的
                    Boolean bNeedFill = false;
                    for (Int32 nCycModel = 0; nCycModel < pStage.GetModelCnt(); nCycModel++)
                    {
                        Int32 dwCurMatchIdx = (Int32)aryDwCurMatchIdxInModel[nCycModel];
                        if (dwCurMatchIdx < pStage.GetModelExpObj(nCycModel).GetMatchCnt())
                        {
                            bNeedFill = true;
                            break;
                        }
                    }

                    if (!bNeedFill)
                    {
                        break; //此Stage填数完成,进入下一个Stage
                    }
                }while (true);
            }//for Stage

            return(true);
        }