Ejemplo n.º 1
0
        //这个淘汰赛有多少层
        public Int32 GetLayerCount()
        {
            if (GetPyramidCount() < 1)
            {
                return(0);
            }

            stKoPyramid pMainPyramid = GetPyramidObj(0);

            return(pMainPyramid.GetLayerCount());
        }
Ejemplo n.º 2
0
        public override Boolean GetModelExport(AxDrawModelMatchList drawModelModel)
        {
            drawModelModel.RemoveAll();
            Int32 nPyramidCnt = m_oEvent.GetPyramidCount();

            if (nPyramidCnt < 1)
            {
                return(false);
            }

            //填入源信息时底层的需要排序位置
            Int32 nPosIndex = 0;        //来自人员的顺序ID
            //AryKoStartPos aryPos;	//来自人员序列
            ArrayList aryPos = new ArrayList();

            GetStartPos(m_oEvent.GetLayerCount(), aryPos);

            //1. 先循环一次,把所有比赛加入队列, 这样我们内存的结构里,就有了Match的RowNumber
            for (Int32 nPyramid = 0; nPyramid < nPyramidCnt; nPyramid++)
            {
                stKoPyramid pPrramid  = m_oEvent.GetPyramidObj(nPyramid);
                Int32       nLayerCnt = pPrramid.GetLayerCount();

                for (Int32 nLayer = nLayerCnt - 1; nLayer >= 0; nLayer--)
                {
                    stKoLayer pLayer   = pPrramid.GetLayerObj(nLayer);
                    Int32     nNodeCnt = pLayer.GetNodeCount();

                    for (Int32 nNode = 0; nNode < nNodeCnt; nNode++)
                    {
                        stKoMatchNode pNode = pLayer.GetNodeObj(nNode);

                        AxDrawModelMatchRow matchInfo = new AxDrawModelMatchRow();
                        matchInfo.m_byteRoundOrder = (Byte)(nLayerCnt - nLayer + nPyramid * 10);
                        matchInfo.m_strMatchDesc   = String.Format("{0:D}-{1:D}-{2:D}", nPyramid + 1, nLayer + 1, nNode + 1);

                        //将此场比赛添加到列表后,会返还行号,正好填给内存中的塔
                        drawModelModel.m_aryMatchRow.Add(matchInfo);
                        Int32 nCurNodeRowInMatchList = drawModelModel.m_aryMatchRow.Count - 1;
                        pNode.m_nRowTemp = nCurNodeRowInMatchList;
                    }
                }
            }

            //2.再循环一次,把目标和源填入
            for (Int32 nPyramid = 0; nPyramid < nPyramidCnt; nPyramid++)
            {
                stKoPyramid pPyramid  = m_oEvent.GetPyramidObj(nPyramid);
                Int32       nLayerCnt = pPyramid.GetLayerCount();

                for (Int32 nLayer = 0; nLayer < nLayerCnt; nLayer++)
                {
                    stKoLayer pLayer   = pPyramid.GetLayerObj(nLayer);
                    Int32     nNodeCnt = pLayer.GetNodeCount();

                    for (Int32 nNode = 0; nNode < nNodeCnt; nNode++)
                    {
                        stKoMatchNode       pNode            = pLayer.GetNodeObj(nNode);
                        AxDrawModelMatchRow pMatchInfoInList = drawModelModel.m_aryMatchRow[pNode.m_nRowTemp];


                        //1.轮次信息
                        {
                            if (nPyramid == 0) //第一个塔里的结构就是从金牌赛往下顺
                            {
                                switch (nLayer)
                                {
                                case 8: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_512to256; break;

                                case 7: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_256to128; break;

                                case 6: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_128to64; break;

                                case 5: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_64to32; break;

                                case 4: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_32to16; break;

                                case 3: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_16to8; break;

                                case 2: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_8to4; break;

                                case 1: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_4to2; break;

                                case 0: pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_2to1; break;

                                default: break;
                                }
                            }
                            else if (nPyramid == 1) //第二个塔里只能有铜牌赛
                            {
                                pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_34to3;
                            }
                            else if (nPyramid == 2) //第三个塔是5-8名
                            {
                                if (nLayer == 0)
                                {
                                    pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_56to5;
                                }
                                else
                                {
                                    pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_58to56;
                                }
                            }
                            else if (nPyramid == 3) //第四个塔是7,8名
                            {
                                pMatchInfoInList.m_emLayerCode = EDrawModelLayerCode.emLayerRound_78to7;
                            }
                        }

                        //2. 跳跃信息
                        pMatchInfoInList.m_eWinGotoKind  = pNode.m_oJumpWin.m_byJumpKind;
                        pMatchInfoInList.m_eLostGotoKind = pNode.m_oJumpLost.m_byJumpKind;

                        if (pNode.m_oJumpWin.IsJumpPos()) //是跳跃到位置,那么在金字塔中找到那Node, Node里肯定有行号,把目标行号拿到即可
                        {
                            stKoMatchNode pNodeWinGoto = m_oEvent.GetMatchObj(pNode.m_oJumpWin);
                            pMatchInfoInList.m_byWinGotoLineOrRank = pNodeWinGoto.m_nRowTemp;
                        }
                        else // 不是跳到位置,那要么是Rank,或者是Out
                        {
                            pMatchInfoInList.m_byWinGotoLineOrRank = pNode.m_oJumpWin.m_byPyramindIndexOrRank;
                        }

                        if (pNode.m_oJumpLost.IsJumpPos())
                        {
                            stKoMatchNode pNodeLostGoto = m_oEvent.GetMatchObj(pNode.m_oJumpLost);
                            pMatchInfoInList.m_byLostGotoLineOrRank = pNodeLostGoto.m_nRowTemp;
                        }
                        else
                        {
                            pMatchInfoInList.m_byLostGotoLineOrRank = pNode.m_oJumpLost.m_byPyramindIndexOrRank;
                        }


                        //3. 来源信息
                        stKoJumpInfo JumpThisInfo = new stKoJumpInfo();
                        JumpThisInfo.SetJumpToPointer((Byte)nPyramid, (Byte)nLayer, (Byte)nNode, false); //本Node的Jump坐标
                        {
                            //左来源
                            stKoJumpInfo jumpFromLeft = m_oEvent.GetMatchPlayerFrom(JumpThisInfo, true);
                            if (jumpFromLeft.IsJumpAsPointer()) //从其他地方来的
                            {
                                stKoMatchNode pNodeLeftFrom = m_oEvent.GetMatchObj(jumpFromLeft);
                                pMatchInfoInList.m_eLeftFromKind        = jumpFromLeft.m_byIsWin ? EKnockOutFromKind.emKoFromWin : EKnockOutFromKind.emKoFromLost;
                                pMatchInfoInList.m_nLeftFromLineOrIndex = pNodeLeftFrom.m_nRowTemp;
                            }
                            else //最底层的
                            {
                                pMatchInfoInList.m_eLeftFromKind        = EKnockOutFromKind.emKoFromInit;
                                pMatchInfoInList.m_nLeftFromLineOrIndex = Convert.ToInt32(aryPos[nPosIndex++]);
                            }

                            //右来源
                            stKoJumpInfo jumpFromRight = m_oEvent.GetMatchPlayerFrom(JumpThisInfo, false);
                            if (jumpFromRight.IsJumpAsPointer())
                            {
                                stKoMatchNode pNodeRightFrom = m_oEvent.GetMatchObj(jumpFromRight);
                                pMatchInfoInList.m_eRightFromKind        = jumpFromRight.m_byIsWin ? EKnockOutFromKind.emKoFromWin : EKnockOutFromKind.emKoFromLost;
                                pMatchInfoInList.m_nRightFromLineOrIndex = pNodeRightFrom.m_nRowTemp;
                            }
                            else
                            {
                                pMatchInfoInList.m_eRightFromKind        = EKnockOutFromKind.emKoFromInit;
                                pMatchInfoInList.m_nRightFromLineOrIndex = Convert.ToInt32(aryPos[nPosIndex++]);
                            }
                        }
                    } //For Node
                }     //For layer
            }         //For Pyramid

            return(true);
        }
Ejemplo n.º 3
0
        public override String GetDumpStr()
        {
            StringBuilder strOut = new StringBuilder();
            String        strMsg = "";

            // 1. 打印内部结构
            {
                strMsg = String.Format("\r\n我们有{0:D}人比赛,产生{1:D}人名次,主塔{2:D}层,最多供{3:D}人比赛,\r\n", GetPlayerCnt(), GetPlayerResultCnt(), m_oEvent.GetLayerCount(), m_oEvent.GetMaxPlayerCount());
                strOut.Append(strMsg);

                Int32 PyramidCnt = m_oEvent.GetPyramidCount();

                for (Int32 nPyramid = 0; nPyramid < PyramidCnt; nPyramid++)
                {
                    stKoPyramid pPyramid = m_oEvent.GetPyramidObj(nPyramid);
                    strMsg = String.Format("塔{0:D} \r\n", nPyramid + 1);
                    strOut.Append(strMsg);

                    for (Int32 nLayer = 0; nLayer < pPyramid.GetLayerCount(); nLayer++)
                    {
                        stKoLayer pLayer = pPyramid.GetLayerObj(nLayer);
                        strMsg = String.Format("第{0:D}层: ", nLayer + 1);
                        strOut.Append(strMsg);

                        for (Int32 nNode = 0; nNode < pLayer.GetNodeCount(); nNode++)
                        {
                            stKoMatchNode pNode = pLayer.GetNodeObj(nNode);

                            strMsg = String.Format("Node[{0:D}-{1:D}-{2:D} W:'{3:D}' L:'{4:D}' ] ", nPyramid + 1, nLayer + 1, nNode + 1,
                                                   pNode.m_oJumpWin.GetDesc(), pNode.m_oJumpLost.GetDesc());
                            strOut.Append(strMsg);
                        }

                        strOut.Append("\r\n");
                    }

                    strOut.Append("\r\n");
                }

                strOut.Append("\r\n");
            }

            // 2. 打印输出表
            AxDrawModelMatchList aryMatch = new AxDrawModelMatchList();

            GetModelExport(aryMatch);

            for (Int32 nCyc = 0; nCyc < aryMatch.m_aryMatchRow.Count; nCyc++)
            {
                AxDrawModelMatchRow pMatchInfo = aryMatch.m_aryMatchRow[nCyc];

                String strLeftFromDesc = "";
                {
                    if (pMatchInfo.m_eLeftFromKind == EKnockOutFromKind.emKoFromInit)
                    {
                        if (pMatchInfo.m_nLeftFromLineOrIndex == -1)
                        {
                            strLeftFromDesc = "BYE";
                        }
                        else
                        {
                            strLeftFromDesc = String.Format("源{0:D}", pMatchInfo.m_nLeftFromLineOrIndex + 1);
                        }
                    }
                    else if (pMatchInfo.m_eLeftFromKind == EKnockOutFromKind.emKoFromWin)
                    {
                        strLeftFromDesc = String.Format("{0:D}行Win", pMatchInfo.m_nLeftFromLineOrIndex);
                    }
                    else if (pMatchInfo.m_eLeftFromKind == EKnockOutFromKind.emKoFromLost)
                    {
                        strLeftFromDesc = String.Format("{0:D}行Lost", pMatchInfo.m_nLeftFromLineOrIndex);
                    }
                }

                String strRightFromDesc = "";
                {
                    if (pMatchInfo.m_eRightFromKind == EKnockOutFromKind.emKoFromInit)
                    {
                        if (pMatchInfo.m_nRightFromLineOrIndex == -1)
                        {
                            strRightFromDesc = "BYE";
                        }
                        else
                        {
                            strRightFromDesc = String.Format("源{0:D}", pMatchInfo.m_nRightFromLineOrIndex + 1);
                        }
                    }
                    else if (pMatchInfo.m_eRightFromKind == EKnockOutFromKind.emKoFromWin)
                    {
                        strRightFromDesc = String.Format("{0:D}行Win", pMatchInfo.m_nRightFromLineOrIndex);
                    }
                    else if (pMatchInfo.m_eRightFromKind == EKnockOutFromKind.emKoFromLost)
                    {
                        strRightFromDesc = String.Format("{0:D}行Lost", pMatchInfo.m_nRightFromLineOrIndex);
                    }
                }

                String strWinToDesc = "";
                {
                    if (pMatchInfo.m_eWinGotoKind == EKnockOutJumpKind.emkoJumpLeft)
                    {
                        strWinToDesc = String.Format("{0:D}行左", pMatchInfo.m_byWinGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eWinGotoKind == EKnockOutJumpKind.emkoJumpRight)
                    {
                        strWinToDesc = String.Format("{0:D}行右", pMatchInfo.m_byWinGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eWinGotoKind == EKnockOutJumpKind.emkoJumpRank)
                    {
                        strWinToDesc = String.Format("第{0:D}名", pMatchInfo.m_byWinGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eWinGotoKind == EKnockOutJumpKind.emkoJumpOut)
                    {
                        strWinToDesc = "淘汰";
                    }
                }

                String strLostToDesc = "";
                {
                    if (pMatchInfo.m_eLostGotoKind == EKnockOutJumpKind.emkoJumpLeft)
                    {
                        strLostToDesc = String.Format("{0:D}行左", pMatchInfo.m_byLostGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eLostGotoKind == EKnockOutJumpKind.emkoJumpRight)
                    {
                        strLostToDesc = String.Format("{0:D}行右", pMatchInfo.m_byLostGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eLostGotoKind == EKnockOutJumpKind.emkoJumpRank)
                    {
                        strLostToDesc = String.Format("第{0:D}名", pMatchInfo.m_byLostGotoLineOrRank);
                    }
                    else if (pMatchInfo.m_eLostGotoKind == EKnockOutJumpKind.emkoJumpOut)
                    {
                        strLostToDesc = "淘汰";
                    }
                }

                strMsg = String.Format("{0:D} {1} Round{2}:{3}. WinTo:{4}, LostTo:{5}, LeftFrom:{6}, RightFrom:{7} \r\n",
                                       nCyc, pMatchInfo.m_strMatchDesc, pMatchInfo.m_byteRoundOrder, pMatchInfo.GetRoundDesc(),
                                       strWinToDesc, strLostToDesc, strLeftFromDesc, strRightFromDesc);

                strOut.Append(strMsg);
            }

            strOut.Append("\r\n");

            return(strOut.ToString());
        }
Ejemplo n.º 4
0
        //一个节点左边运动员来自哪
        public stKoJumpInfo GetMatchPlayerFrom(stKoJumpInfo jumpInfo, Boolean bIsFromLeft)
        {
            stKoJumpInfo jumpInfoRet = new stKoJumpInfo();

            int nPyramidCnt = GetPyramidCount();

            for (int nPyramid = 0; nPyramid < nPyramidCnt; nPyramid++)
            {
                stKoPyramid pPyramid = GetPyramidObj(nPyramid);
                if (pPyramid == null)
                {
                    return(null);
                }

                int nLayerCnt = pPyramid.GetLayerCount();

                for (Int32 nLayer = 0; nLayer < nLayerCnt; nLayer++)
                {
                    stKoLayer pLayer = pPyramid.GetLayerObj(nLayer);
                    if (pLayer == null)
                    {
                        return(null);
                    }

                    int nNodeCnt = pLayer.GetNodeCount();

                    for (int nNode = 0; nNode < nNodeCnt; nNode++)
                    {
                        stKoMatchNode pNode = pLayer.GetNodeObj(nNode);
                        if (pNode == null)
                        {
                            return(null);
                        }

                        if (pNode.m_oJumpWin.IsJumpPos())
                        {
                            if (pNode.m_oJumpWin.m_byPyramindIndexOrRank == jumpInfo.m_byPyramindIndexOrRank &&
                                pNode.m_oJumpWin.m_byLayerIndex == jumpInfo.m_byLayerIndex &&
                                pNode.m_oJumpWin.m_byNodeIndex == jumpInfo.m_byNodeIndex &&
                                pNode.m_oJumpWin.IsJumpLeft() == bIsFromLeft)
                            {
                                jumpInfoRet.SetJumpToPointer((Byte)nPyramid, (Byte)nLayer, (Byte)nNode, true);
                                return(jumpInfoRet);
                            }
                        }

                        if (pNode.m_oJumpLost.IsJumpPos())
                        {
                            if (pNode.m_oJumpLost.m_byPyramindIndexOrRank == jumpInfo.m_byPyramindIndexOrRank &&
                                pNode.m_oJumpLost.m_byLayerIndex == jumpInfo.m_byLayerIndex &&
                                pNode.m_oJumpLost.m_byNodeIndex == jumpInfo.m_byNodeIndex &&
                                pNode.m_oJumpLost.IsJumpLeft() == bIsFromLeft)
                            {
                                jumpInfoRet.SetJumpToPointer((Byte)nPyramid, (Byte)nLayer, (Byte)nNode, false);
                                return(jumpInfoRet);
                            }
                        }
                    }
                }
            }

            return(jumpInfoRet);
        }