public override Boolean GetModelExport(AxDrawModelMatchList drawModelModel) { drawModelModel.RemoveAll(); if (m_oGroup.GetPlayerCnt() < 1) { return(false); } Int32 nRoundCnt = m_oGroup.GetRoundCount(); for (Int32 nCycRound = 0; nCycRound < nRoundCnt; nCycRound++) { stRrRound pRound = m_oGroup.GetRoundObj(nCycRound); Int32 nMatchCnt = pRound.GetMatchCount(); for (Int32 nCycMatch = 0; nCycMatch < nMatchCnt; nCycMatch++) { stRrMatch pMatch = pRound.GetMatchObj(nCycMatch); AxDrawModelMatchRow MatchRow = new AxDrawModelMatchRow(); MatchRow.m_nLeftFromLineOrIndex = pMatch.m_byPlayerL; MatchRow.m_nRightFromLineOrIndex = pMatch.m_byPlayerR; MatchRow.m_byteRoundOrder = (Byte)(nCycRound + 1); MatchRow.m_byteMatchOrder = (Byte)(nCycMatch + 1); MatchRow.m_emLayerCode = EDrawModelLayerCode.emLayerRound_RoundRobin; drawModelModel.m_aryMatchRow.Add(MatchRow); } } return(true); }
public void CreateMatchNum() { for (Int32 nCyc = 0; nCyc < m_aryMatchRow.Count; nCyc++) { AxDrawModelMatchRow pMatchRow = m_aryMatchRow[nCyc]; pMatchRow.m_dwMatchNum = (UInt32)(nCyc + 1); } }
public override String GetDumpStr() { String StrOut; String strMsg; // 1. 打印内部结构 { strMsg = String.Format("我们共有{0:D}个人 \r\n", m_oGroup.GetPlayerCnt()); StrOut = strMsg; for (Int32 nRound = 0; nRound < m_oGroup.GetRoundCount(); nRound++) { stRrRound pRound = m_oGroup.GetRoundObj(nRound); strMsg = String.Format("第{0:D}轮: \r\n", nRound + 1); StrOut += strMsg; for (Int32 nMatch = 0; nMatch < pRound.GetMatchCount(); nMatch++) { stRrMatch pMatch = pRound.GetMatchObj(nMatch); strMsg = String.Format("Match[{0:D}-{1:D} {2:D} vs {3:D} ] ", nRound + 1, nMatch + 1, pMatch.m_byPlayerL, pMatch.m_byPlayerR); StrOut += strMsg; } StrOut += "\r\n"; } StrOut += "\r\n"; } // 2.打印输出结构 { AxDrawModelMatchList aryMatch = new AxDrawModelMatchList(); GetModelExport(aryMatch); for (Int32 nCycRow = 0; nCycRow < (Int32)aryMatch.m_aryMatchRow.Count; nCycRow++) { AxDrawModelMatchRow pMatchRow = aryMatch.m_aryMatchRow[nCycRow]; strMsg = String.Format("{0:D} 第{1:D}轮-第{2:D}场", nCycRow + 1, pMatchRow.m_byteRoundOrder, pMatchRow.m_byteMatchOrder); //pMatchRow->nLeftFromLineOrIndex, pMatchRow->nLeftFromLineOrIndex, //pMatchRow->GetVsDesc() ); StrOut += strMsg; StrOut += "\r\n"; } StrOut += "\r\n"; } return(StrOut); }
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); }
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()); }
//将整个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); }