//обработка события конца забега public void HandleFinishEvent(Score score) { timer1.Enabled = false; bets.Clear(); UpdateInfo(); UpdateScoreInfo(score); groupBox1.Enabled = true ; }
//конструктор public GameController(List<Bug> bugs,List<Gambler> gamers) { this.bugs = new List<Bug>(bugs); this.gamers =new List<Gambler>( gamers ); r = new Random(); RaceCount = 0; score = new Score(); totalizator = new Totalizator(bugs); foreach(var bug in bugs) { bug.finish += BugFinishedEventHandle; checkAllBugsHasFinished += bug.RaiseEventIfFinished; } }
public void RegisterRace(Score score) { this.score = score; }
//обновление информаии о результате зебега private void UpdateScoreInfo(Score score) { listBox2.Items.Add(string.Format("{0} выиграл забег номер {1}", score.WinnerBug.Name, controller.RaceCount)); foreach (var bug in score.BugsPlaces.Keys) { listBox2.Items.Add(string.Format("{0} прибыл {1}-м", bug.Name, score.BugsPlaces[bug])); } foreach (var gambler in score.GamblersPrizes.Keys) { if (score.GamblersPrizes[gambler] > 0) listBox2.Items.Add(string.Format("{0} выиграл {1} р.", gambler.Name, score.GamblersPrizes[gambler])); else listBox2.Items.Add(string.Format("{0} проиграл", gambler.Name)); } }