void displayEvents(int x, int y) { Console.SetCursorPosition(x, y); Console.Write(match.host.fullName); Console.SetCursorPosition(x + 20, y); Console.Write(match.guest.fullName); y++; for (int i = 0; i < match.eventsHost.Count; i++) { Console.SetCursorPosition(x, y + i); if (match.eventsHost[i] is Goal) { Goal goal = (Goal)match.eventsHost[i]; if (!goal.isFromPenalty) { Console.WriteLine(goal.minute + " " + goal.player.surname); } else if (goal.isFromPenalty) { Console.WriteLine(goal.minute + " (k)" + goal.player.surname); } } else if (match.eventsHost[i] is PenaltyNoGoal) { PenaltyNoGoal penalty = (PenaltyNoGoal)match.eventsHost[i]; Console.WriteLine(penalty.minute + " " + penalty.player.surname + " (/k)"); } } for (int i = 0; i < match.eventsGuest.Count; i++) { Console.SetCursorPosition(x, y + i); if (match.eventsGuest[i] is Goal) { Goal goal = (Goal)match.eventsGuest[i]; if (!goal.isFromPenalty) { Console.WriteLine(goal.minute + " " + goal.player.surname); } else if (goal.isFromPenalty) { Console.WriteLine(goal.minute + " (k)" + goal.player.surname); } } else if (match.eventsGuest[i] is PenaltyNoGoal) { PenaltyNoGoal penalty = (PenaltyNoGoal)match.eventsGuest[i]; Console.WriteLine(penalty.minute + " " + penalty.player.surname + " (/k)"); } } }
/// <summary> /// /// </summary> /// <param name="minute"></param> public void playAction(int minute) { this.minute = minute; actions[minute] = new Action(minute); if (minute == 0) { state = StateOfMatch.playedNow; fillComments(); setStarting11(); calculateSkillsDifference(); calculateChanceOfPenalty(); calculateLevelsDifferenceGoalkeeperExecutorOfPenalty(); actions[minute].comment += rozpoczecieMeczu[generator.Next(rozpoczecieMeczu.Count)] + " "; } if (minute == 45) { actions[minute].comment += rozpoczecie2Polowy[generator.Next(rozpoczecie2Polowy.Count)] + " "; } if (minute >= 0 && minute < 90) { if (generator.Next(100) <= ballPossessionHostGenerally) { actions[minute].ballPossession = EClub.host; attackingTeam = host; defendingTeam = guest; numberOfActionsHost++; if (generator.Next(1000) <= attackForceHostGenerally) { nr = generator.Next(1, 11); Goal goal = new Goal(minute + 1, attackingTeam.squad.players[nr], false); eventsHost.Add(goal); goalsHost.Add(goal); fillComments(); actions[minute].comment += gol[generator.Next(gol.Count)] + " "; } if (generator.Next(chancePenaltyHost) == 0) { nr = generator.Next(1, 11); fillComments(); actions[minute].comment += rzutKarny[generator.Next(rzutKarny.Count)] + " "; if (generator.Next(100) <= penaltyForceHost) { Goal goal = new Goal(minute + 1, attackingTeam.squad.players[attackingTeam.tactics.setPieces], true); eventsHost.Add(goal); goalsHost.Add(goal); actions[minute].comment += rzutKarnyGol[generator.Next(rzutKarnyGol.Count)] + " "; } else { PenaltyNoGoal penalty = new PenaltyNoGoal(minute + 1, attackingTeam.squad.players[attackingTeam.tactics.setPieces]); eventsHost.Add(penalty); actions[minute].comment += rzutKarnyNieGol[generator.Next(rzutKarnyNieGol.Count)] + " "; } } } else { actions[minute].ballPossession = EClub.guest; attackingTeam = guest; defendingTeam = host; numberOfActionsGuest++; if (generator.Next(1000) <= attackForceGuestGenerally) { nr = generator.Next(1, 11); Goal goal = new Goal(minute + 1, attackingTeam.squad.players[nr], false); eventsGuest.Add(goal); goalsGuest.Add(goal); fillComments(); actions[minute].comment += gol[generator.Next(gol.Count)] + " "; } if (generator.Next(chancePenaltyGuest) == 0) { nr = generator.Next(1, 11); fillComments(); actions[minute].comment += rzutKarny[generator.Next(rzutKarny.Count)] + " "; if (generator.Next(100) <= penaltyForceGuest) { Goal goal = new Goal(minute + 1, attackingTeam.squad.players[attackingTeam.tactics.setPieces], true); eventsGuest.Add(goal); goalsGuest.Add(goal); actions[minute].comment += rzutKarnyGol[generator.Next(rzutKarnyGol.Count)] + " "; } else { PenaltyNoGoal penalty = new PenaltyNoGoal(minute + 1, attackingTeam.squad.players[attackingTeam.tactics.setPieces]); eventsGuest.Add(penalty); actions[minute].comment += rzutKarnyNieGol[generator.Next(rzutKarnyNieGol.Count)] + " "; } } } ballPossessionHost = (int)(numberOfActionsHost / (double)(minute + 1) * 100); ballPossessionGuest = 100 - ballPossessionHost; if (numberOfActionsHost > 0) { attackForceHost = (int)(goalsHost.Count / (double)numberOfActionsHost * 100); } if (numberOfActionsGuest > 0) { attackForceGuest = (int)(goalsGuest.Count / (double)numberOfActionsGuest * 100); } result = goalsHost.Count + " - " + goalsGuest.Count; } if (minute == 44) { fillComments(); actions[minute].comment += zakonczeniePolowy[generator.Next(zakonczeniePolowy.Count)] + " "; actions[minute].comment += ballPossession[generator.Next(ballPossession.Count)]; } if (minute == 89) { fillComments(); actions[minute].comment += zakonczenieMeczu[generator.Next(zakonczenieMeczu.Count)] + " "; actions[minute].comment += ballPossession[generator.Next(ballPossession.Count)]; finish(); } }