private void BtnScoreAddReduce_Click(object sender, EventArgs e) { bool exchangeAB = _chkScoreExchangeLR.Checked; if (sender == btnScoreAddA) { Common.g_Game.SetScoreAR(exchangeAB ? true : false, true); } else if (sender == btnScoreAddB) { Common.g_Game.SetScoreAR(exchangeAB ? false : true, true); } else if (sender == btnScoreReduceA) { Common.g_Game.SetScoreAR(exchangeAB ? true : false, false); } else if (sender == btnScoreReduceB) { Common.g_Game.SetScoreAR(exchangeAB ? false : true, false); } else { Debug.Assert(false); return; } Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game); RefreshAll(); Common.NotifyMatchResult(); Common.dbMatchModifyTimeSet(); }
private void OnStatChanged(bool?IsTeamBChanged = null) { // Send stat message. Common.g_Plugin.DataChangedNotify(OVRDataChangedType.emMatchStatistic, -1, -1, -1, Common.g_nMatchID, Common.g_nMatchID, null); //Calculate score if (_chkScoreFromStat.Checked) { bool bScoreChanged = false; if (IsTeamBChanged == null || (bool)IsTeamBChanged) { bScoreChanged |= CalScoreFromStat(false); } if (IsTeamBChanged == null || !(bool)IsTeamBChanged) { bScoreChanged |= CalScoreFromStat(true); } if (bScoreChanged) { //Send score message. Common.g_Plugin.DataChangedNotify(OVRDataChangedType.emMatchResult, -1, -1, -1, Common.g_nMatchID, Common.g_nMatchID, null); //刷新自己的比分 scoreInfoRefresh(); } } //让网络中其他机器刷新 Common.dbMatchModifyTimeSet(); //刷新自己界面的STAT statInfoReferesh(); }
private void btnx_MatchStatus_Click(object sender, EventArgs e) { int nStatusID = 0; if (sender == btnx_Schedule) { nStatusID = Common.STATUS_SCHEDULE; } else if (sender == btnx_StartList) { nStatusID = Common.STATUS_STARTLIST; } else if (sender == btnx_Running) { nStatusID = Common.STATUS_RUNNING; } else if (sender == btnx_Suspend) { nStatusID = Common.STATUS_SUSPEND; } else if (sender == btnx_Unofficial) { nStatusID = Common.STATUS_UNOFFICIAL; } else if (sender == btnx_Official) { nStatusID = Common.STATUS_OFFICIAL; } else if (sender == btnx_Revision) { nStatusID = Common.STATUS_REVISION; } else if (sender == btnx_Canceled) { nStatusID = Common.STATUS_CANCELED; } else { return; } Int32 nResult = OVRDataBaseUtils.ChangeMatchStatus( Common.g_nMatchID, nStatusID, Common.g_DataBaseCon, Common.g_Plugin); //晋级比赛 if (sender == btnx_Official) { //淘汰赛晋级 OVRDataBaseUtils.AutoProgressMatch(Common.g_nMatchID, Common.g_DataBaseCon, Common.g_Plugin); //小组赛计分计算 Common.dbCalGroupResult(Common.g_nMatchID); } Common.dbMatchModifyTimeSet(); RefreshAll(); }
//For timeout Subtitution private void _btnTimeSub_Click(object sender, EventArgs e) { int curSet = Common.g_Game.GetCurSet(); bool exchangeAB = _chkScoreExchangeLR.Checked; bool bResult = false; if (sender == _btnTimeAAdd) { bResult = Common.dbSettingSubtitutionTimeOutCount(true, exchangeAB ? false : true, true, curSet); } else if (sender == _btnTimeAReduce) { bResult = Common.dbSettingSubtitutionTimeOutCount(true, exchangeAB ? false : true, false, curSet); } else if (sender == _btnTimeBAdd) { bResult = Common.dbSettingSubtitutionTimeOutCount(true, exchangeAB ? true : false, true, curSet); } else if (sender == _btnTimeBReduce) { bResult = Common.dbSettingSubtitutionTimeOutCount(true, exchangeAB ? true : false, false, curSet); } else if (sender == _btnSubAAdd) { bResult = Common.dbSettingSubtitutionTimeOutCount(false, exchangeAB ? false : true, true, curSet); } else if (sender == _btnSubAReduce) { bResult = Common.dbSettingSubtitutionTimeOutCount(false, exchangeAB ? false : true, false, curSet); } else if (sender == _btnSubBAdd) { bResult = Common.dbSettingSubtitutionTimeOutCount(false, exchangeAB ? true : false, true, curSet); } else if (sender == _btnSubBReduce) { bResult = Common.dbSettingSubtitutionTimeOutCount(false, exchangeAB ? true : false, false, curSet); } else { Debug.Assert(false); return; } if (!bResult) { MessageBox.Show("修改失败!"); } Common.dbMatchModifyTimeSet(); Common.NotifyMatchResult(); RefreshAll(); }
private void dgvMatchScore_CellEndEdit(object sender, DataGridViewCellEventArgs e) { //没有选中的当前单元格,肯定不会 if (dgvMatchScore.CurrentCell == null) { return; } //判断是否编辑的是IRM if (e.RowIndex >= 1 && e.RowIndex <= 2 && e.ColumnIndex == 1) { //有可能为空 Int32 nIRM_ID = Common.Str2Int(dgvMatchScore.CurrentCell.Tag); if (!Common.dbIRMSet(Common.g_nMatchID, nIRM_ID, (e.RowIndex == 1))) { MessageBox.Show("设置IRM信息失败!"); } Common.dbMatchModifyTimeSet(); Common.NotifyMatchResult(); return; } //是否为编辑值 if (((DataGridView)sender).CurrentCell.Value != null) { String strNewValue = ((DataGridView)sender).CurrentCell.Value.ToString(); //判断是否编辑比分 if (e.RowIndex >= 1 && e.RowIndex <= 2 && e.ColumnIndex >= 3 && e.ColumnIndex <= 7) { Int32 nCurScore = Common.Str2Int(strNewValue); nCurScore = Math.Max(nCurScore, 0); bool bTeamB = (e.RowIndex == 2); Int32 nSet = e.ColumnIndex - 2; Int32 ptsSetOppr = Common.g_Game.GetScoreSet(!bTeamB, nSet); Int32 scoreWin = Common.g_isVB ? 25 : 21; //在第五局如果输入的值大于15分,给予一个提示 if (Common.g_isVB && nCurScore > 15 && nSet == 5 && nCurScore > ptsSetOppr + 2) { if (MessageBox.Show("第5局比分一般不会大于15. 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Common.g_Game.SetScore(nCurScore, bTeamB, nSet); } } else if (!Common.g_isVB && nCurScore > 15 && nSet == 3 && nCurScore > ptsSetOppr + 2) { if (MessageBox.Show("第3局比分一般不会大于15. 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Common.g_Game.SetScore(nCurScore, bTeamB, nSet); } } else if (nCurScore > scoreWin && nCurScore > ptsSetOppr + 2) { if (MessageBox.Show("比分一般不会大于" + scoreWin.ToString() + ". 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Common.g_Game.SetScore(nCurScore, bTeamB, nSet); } } else { Common.g_Game.SetScore(nCurScore, bTeamB, nSet); } Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game); dgvMatchScoreRefresh(); Common.NotifyMatchResult(); return; } //时间 if (e.RowIndex == 3 && e.ColumnIndex >= 3 && e.ColumnIndex <= 8) { int nTime = 0; int nIndex = strNewValue.IndexOf(':'); if (nIndex > 0) { nTime = Common.Str2Int(strNewValue.Substring(0, nIndex)) * 60; nTime += Common.Str2Int(strNewValue.Substring(nIndex + 1, strNewValue.Length - nIndex - 1)); } else { nTime = Common.Str2Int(strNewValue); } if (nTime > 999) { nTime = 999; } if (nTime < 0) { nTime = 0; } if (e.ColumnIndex - 2 == 6) { Common.g_Game.SetTimeMatch(nTime.ToString()); } else if (e.ColumnIndex - 2 < 6 && e.ColumnIndex - 2 > 0) { int nSet = e.ColumnIndex - 2; Common.g_Game.SetTimeSet(nTime.ToString(), nSet); } else { Debug.Assert(false); } Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game); dgvMatchScoreRefresh(); Common.NotifyMatchResult(); return; } } }
private void textBoxStat_KeyUp(object sender, KeyEventArgs e) { ////Esc: 清空输入框,退出 ////Enter:进行判断 if (e.KeyCode == Keys.Escape) { textBoxStat.Text = ""; return; } else if (e.KeyCode != Keys.Return) { return; } ////开始处理 string strN1 = (textBoxStat.Text.Length >= 1) ? textBoxStat.Text.Substring(0, 1) : ""; string strN2 = (textBoxStat.Text.Length >= 2) ? textBoxStat.Text.Substring(1, 1) : ""; string strN3 = (textBoxStat.Text.Length >= 3) ? textBoxStat.Text.Substring(2, 1) : ""; bool bIsTeamB = _tabMain.SelectedTab == _tabHeaderTeamB; strN1 = strN1.ToUpper(); strN2 = strN2.ToUpper(); strN3 = strN3.ToUpper(); if (strN1 == "") { labStatEntryErrMsg.Text = "内容为空,请先输入内容"; return; } if (strN1 == "?" || strN1 == "/") { string strHelp = @" Code Desc. Example 1-10: 队员号码 1-10 q-p: 队员号码 11-20 Esc: 清空输入 A: 整队失败 S: 对方失误 D: 交换操作队 Z: 删除最后一条技术统计 V: 队员上场 V3:3号上场 C: 换人 C32:换人,3号下,2号上 G: ATK 1G+:1号进攻得分 H: BLO 2H-:2号拦网失败 J: SRV K: DIG L: SET ;: RCV + SUC & EXC - FLT ? 显示帮助信息 "; MessageBox.Show(strHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; return; } if (strN1 == "D") //换到另一方技术统计 { _tabMain.SelectedTab = bIsTeamB ? _tabHeaderTeamA : _tabHeaderTeamB; textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; //statInfoReferesh(); Common.dbMatchModifyTimeSet(); return; } else if (strN1 == "A") // A: TEM_FLT { if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), "TEM_FLT", -1, 0, bIsTeamB)) { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } else { labStatEntryErrMsg.Text = string.Format("添加{0}方TEM_FLT失败!", bIsTeamB ? "B" : "A"); } return; } else if (strN1 == "S") // S: OPP_ERR { if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), "OPP_ERR", -1, 0, bIsTeamB)) { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } else { labStatEntryErrMsg.Text = string.Format("添加{0}方OPP_ERR失败!", bIsTeamB ? "B" : "A"); } return; } else if (strN1 == "Z") // Z: 删除最后一条 { string str4 = bIsTeamB ? "CodeB" : "CodeA"; for (int i = dgvActionList.RowCount - 1; i >= 0; i--) { if ((dgvActionList[str4, i] != null) && (dgvActionList[str4, i].Tag != null)) { int nActionID = Common.Str2Int(dgvActionList[str4, i].Tag); if (nActionID <= 0) { labStatEntryErrMsg.Text = "获取最后一条技术统计失败,删除最后技术统计失败!"; } else if (!Common.dbActionListDelete(nActionID)) { labStatEntryErrMsg.Text = "执行删除操作失败,删除最后一条技术统计失败!"; } else { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } return; } } labStatEntryErrMsg.Text = "删除最后一条技术统计失败! 未找到可删除的!"; return; } else if (strN1 == "V") //队员上场 { if (strN2 == "") { labStatEntryErrMsg.Text = "未输入上场队员,无法上场!"; return; } string bibIdInN2 = GetRegBibFromKeyBoard(strN2); if (bibIdInN2 == "") { labStatEntryErrMsg.Text = "上场队员BIB号输入有误,无法上场!"; return; } bool isLiberoInN2; int nRegIdInN2 = GetRegIdFromBib(bibIdInN2, out isLiberoInN2); if (nRegIdInN2 <= 0) { labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的上场队员,无法上场!", bIsTeamB ? "B" : "A", bibIdInN2); return; } if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoInN2 ? "LIB_IN" : "PLY_IN", nRegIdInN2, 0, bIsTeamB)) { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } else { labStatEntryErrMsg.Text = "执行人员上场失败,无法上场!"; } return; } else if (strN1 == "C") //换人 { if (strN2 == "") { labStatEntryErrMsg.Text = "未输入下场队员,无法换人!"; return; } if (strN3 == "") { labStatEntryErrMsg.Text = "未输入上场队员,无法换人!"; return; } string strBibOut = GetRegBibFromKeyBoard(strN2); if (strBibOut == "") { labStatEntryErrMsg.Text = "下场队员BIB号输入有误,无法换人!"; return; } string regBibIn = GetRegBibFromKeyBoard(strN3); if (regBibIn == "") { labStatEntryErrMsg.Text = "上场队员BIB号输入有误,无法换人!"; return; } bool isLiberoOut; int nRegIdOut = GetRegIdFromBib(strBibOut, out isLiberoOut); if (nRegIdOut <= 0) { labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的下场队员,无法换人!", bIsTeamB ? "B" : "A", strBibOut); return; } bool isLiberoIn; int nRegIdIn = GetRegIdFromBib(regBibIn, out isLiberoIn); if (nRegIdIn <= 0) { labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的上场队员,无法换人!", bIsTeamB ? "B" : "A", regBibIn); return; } if (isLiberoOut != isLiberoIn) { labStatEntryErrMsg.Text = "上下场人员身份不一致,无法换人!"; return; } if (!Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoOut ? "LIB_OUT" : "PLY_OUT", nRegIdOut, 0, bIsTeamB)) { labStatEntryErrMsg.Text = "执行人员下场失败,无法换人!"; return; } if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoIn ? "LIB_IN" : "PLY_IN", nRegIdIn, 0, bIsTeamB)) { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } else { labStatEntryErrMsg.Text = "执行人员上场失败,无法换人!"; } return; } //剩下的动作,第一位应为队员BIB号 string strBibInN1 = GetRegBibFromKeyBoard(strN1); if (strBibInN1.Length == 0) { labStatEntryErrMsg.Text = "第一位代码不正确!"; return; } bool isLiberoInN1 = false; int nRegIdInN1 = GetRegIdFromBib(strBibInN1, out isLiberoInN1); if (nRegIdInN1 <= 0) { labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的队员,无法添加技术统计!", bIsTeamB ? "B" : "A", strBibInN1); return; } //判断第二位是否为Acton if (strN2 == "G" || strN2 == "H" || strN2 == "J" || strN2 == "K" || strN2 == "L" || strN2 == ":" || strN2 == ";") { string strErrMsg; string actionCodeInN2 = _AnalyzeKeyCode_StatAction(strN2, strN3, out strErrMsg); if (actionCodeInN2 == null || actionCodeInN2.Length < 1) { labStatEntryErrMsg.Text = strErrMsg; return; } if (!Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), actionCodeInN2, nRegIdInN1, 0, bIsTeamB)) { labStatEntryErrMsg.Text = string.Format("添加技术统计{0}方{1}号队员{2}动作失败!", bIsTeamB ? "B" : "A", strBibInN1, actionCodeInN2); } else { textBoxStat.Text = ""; labStatEntryErrMsg.Text = ""; OnStatChanged(bIsTeamB); } } else { labStatEntryErrMsg.Text = "代码不正确!"; } return; }