public void CheckAllTournament(int day) { foreach (var tournamentConfig in ConfigData.TournamentDict.Values) { if (tournamentConfig.ApplyDate == day) { DbTournamentData tourdata = GetTournamentData(tournamentConfig.Id); tourdata.Pids = PeopleBook.GetRandNPeople(tournamentConfig.PlayerCount, tournamentConfig.MinLevel, tournamentConfig.MaxLevel); if (tourdata.Engage) { tourdata.Pids[MathTool.GetRandom(tournamentConfig.PlayerCount)] = -1; //player } tourdata.Results = new MatchResult[tournamentConfig.MaxLevel]; } if (tournamentConfig.BeginDate <= day && tournamentConfig.EndDate >= day) { foreach (int mid in TournamentBook.GetTournamentMatchIds(tournamentConfig.Id)) { TournamentMatchConfig tournamentMatchConfig = ConfigData.GetTournamentMatchConfig(mid); if (tournamentMatchConfig.Date == day && Tournaments[tournamentConfig.Id].Results[tournamentMatchConfig.Offset].Winner == 0) { Tournaments[tournamentConfig.Id].CheckMatch(tournamentMatchConfig.Offset, true); } } } if (tournamentConfig.EndDate == day) { Tournaments[tournamentConfig.Id].Award(); } } }
private void TourLeague4_Paint(object sender, PaintEventArgs e) { if (show) { Font font = new Font("宋体", 11 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel); TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid); foreach (int mid in TournamentBook.GetTournamentMatchIds(tid)) { TournamentMatchConfig tournamentMatchConfig = ConfigData.GetTournamentMatchConfig(mid); Image head = MatchManager.GetHeadImage(tourData.Pids[tournamentMatchConfig.LeftValue]); if (head != null) { e.Graphics.DrawImage(head, 10 + (36 - headSize) / 2, gridSize * tournamentMatchConfig.Offset + 10 + (36 - headSize) / 2, headSize, headSize); } Brush nbrush = new SolidBrush(MatchManager.GetNameColor(tourData.Results[tournamentMatchConfig.Offset].Winner, tourData.Pids[tournamentMatchConfig.LeftValue])); e.Graphics.DrawString(MatchManager.GetPlayerName(tourData.Pids[tournamentMatchConfig.LeftValue]), font, nbrush, 50, gridSize * tournamentMatchConfig.Offset + 25); nbrush.Dispose(); head = MatchManager.GetHeadImage(tourData.Pids[tournamentMatchConfig.RightValue]); if (head != null) { e.Graphics.DrawImage(head, 210 + (36 - headSize) / 2, gridSize * tournamentMatchConfig.Offset + 10 + (36 - headSize) / 2, headSize, headSize); } nbrush = new SolidBrush(MatchManager.GetNameColor(tourData.Results[tournamentMatchConfig.Offset].Winner, tourData.Pids[tournamentMatchConfig.RightValue])); e.Graphics.DrawString(MatchManager.GetPlayerName(tourData.Pids[tournamentMatchConfig.RightValue]), font, nbrush, 250, gridSize * tournamentMatchConfig.Offset + 25); nbrush.Dispose(); if (tourData.Results[tournamentMatchConfig.Offset].Winner != 0) { e.Graphics.DrawString(tourData.Results[tournamentMatchConfig.Offset].Winner == tourData.Pids[tournamentMatchConfig.LeftValue] ? "胜" : "负", font, Brushes.White, 143, gridSize * tournamentMatchConfig.Offset + 25); } } List <int[]> ranks = tourData.GetRanks(); Brush brush = new SolidBrush(Color.FromArgb(15, 15, 15)); e.Graphics.FillRectangle(brush, 340, 53, 165, 200); brush.Dispose(); e.Graphics.DrawRectangle(Pens.Gray, 340, 53, 165, tournamentConfig.PlayerCount * 50); e.Graphics.DrawLine(Pens.Gray, 400, 53, 400, 53 + tournamentConfig.PlayerCount * 50); for (int i = 0; i < tournamentConfig.PlayerCount - 1; i++) { e.Graphics.DrawLine(Pens.Gray, 340, 103 + 50 * i, 505, 103 + 50 * i); } for (int i = 0; i < tournamentConfig.PlayerCount; i++) { Image head = MatchManager.GetHeadImage(ranks[i][0]); if (head != null) { e.Graphics.DrawImage(head, 350, 50 * i + 60, 36, 36); e.Graphics.DrawString(string.Format("{0}战 {1}胜 {2}分", ranks[i][1], ranks[i][2], ranks[i][3]), font, Brushes.White, 410, 50 * i + 75); } } font.Dispose(); } }