Ejemplo n.º 1
0
 public Match(Team team1, Team team2, int firstLegScore1, int firstLegScore2)
     : this(team1, team2, false, true)
 {
     this.firstLegScore1 = firstLegScore1;
     this.firstLegScore2 = firstLegScore2;
     isSecondLeg = true;
 }
Ejemplo n.º 2
0
        private static void PrintPlayerStats(Team team)
        {
            Console.WriteLine("{0,-18}  G  A  P+ P- D+ D- S+ S- Sb I+ I- T+ T- B+ B- G+ G- R", team.Name);
            Console.WriteLine("-------------------------------------------------------------------------");

            foreach (var player in team.Squad)
            {
                Console.Write("{0,-4}{1,-14} ", player.Position, player.Name);
                Console.Write("{0,2} {1,2} {2,2} {3,2} {4,2} {5,2} {6,2} {7,2} {8,2} ",
                    player.Goals, player.Assists, player.PassesCompleted, player.PassesFailed,
                    player.DribblesCompleted, player.DribblesFailed, player.ShotsOnTarget, player.ShotsMissed, player.ShotsBlocked);

                Console.Write("{0,2} {1,2} {2,2} {3,2} {4,2} {5,2} {6,2} {7,2} ",
                    player.PassesIntercepted, player.PassesAllowed, player.TacklesCompleted, player.TacklesFailed,
                    player.ShotsPrevented, player.ShotsAllowed, player.ShotsSaved, player.ShotsNotSaved);

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write("{0,2}", player.FinalRating);
                Console.ResetColor();

                Console.WriteLine();
            }

            Console.WriteLine();
        }
Ejemplo n.º 3
0
 public MatchResult(Team team1, Team team2, Team winner, int score1, int score2, int penaltyScore1, int penaltyScore2,
     IEnumerable<IMatchEvent> events)
 {
     Team1 = team1;
     Team2 = team2;
     Winner = winner;
     Score1 = score1;
     Score2 = score2;
     PenaltyScore1 = penaltyScore1;
     PenaltyScore2 = penaltyScore2;
     Events = events;
 }
Ejemplo n.º 4
0
        public Player(int id, string name, Team team, Position position, int defensiveSkills, int offensiveSkills, int form)
        {
            Id = id;
            Name = name;
            Team = team;
            Position = position;

            DefensiveSkills = defensiveSkills;
            OffensiveSkills = offensiveSkills;
            Form = form;

            Rating = InitialRating;
        }
Ejemplo n.º 5
0
        public Team CreateTeam(string name)
        {
            Club club = world.Clubs.First(c => c.Name == name);
            var team = new Team(club.Name, club.Strategy);

            var clubPlayers = world.Players.Where(p => p.ClubId == club.Id);

            foreach (var player in clubPlayers)
            {
                team.AddSquadPlayer(0, player.Name, Position.FromCode(player.Position), player.Defending, player.Attacking, player.Form);
            }

            return team;
        }
Ejemplo n.º 6
0
        public Match(Team team1, Team team2, bool isNeutralGround, bool isExtraTimeRequired)
        {
            Team1 = team1;
            Team2 = team2;
            IsNeutralGround = isNeutralGround;
            this.isExtraTimeRequired = isExtraTimeRequired;

            team1.Opponent = team2;
            team2.Opponent = team1;

            Length = 90;
            Minute = 1;
            ExtendedLength = 0;
            ExtendedMinute = 0;
        }
Ejemplo n.º 7
0
 private void IncreaseScore(Team team)
 {
     if (team == Team1)
     {
         Score1 += 1;
     }
     else
     {
         Score2 += 1;
     }
 }
Ejemplo n.º 8
0
        public void OnExtraPenaltyKick(Team team, bool isScored)
        {
            if (team == Team1)
            {
                PenaltyScore1 += isScored ? 1 : 0;
                PenaltyRoundsPlayed1++;
            }
            else
            {
                PenaltyScore2 += isScored ? 1 : 0;
                PenaltyRoundsPlayed2++;
            }

            events.Add(new PenaltyKickEvent(team == Team1, 120, 0, isScored));
        }
        private void PrintStatistics(IEnumerable<MatchResult> results, Team homeTeam)
        {
            Console.WriteLine();

            Console.WriteLine("Total games: {0}", results.Count());

            int wins = results.Count(m => m.Score1 > m.Score2);
            int draws = results.Count(m => m.Score1 == m.Score2);
            int losses = results.Count(m => m.Score1 < m.Score2);

            Console.WriteLine("Wins: {0}%, Draws: {1}%, Losses: {2}%",
                100 * wins / results.Count(),
                100 * draws / results.Count(),
                100 * losses / results.Count());

            int maxScore = results.Max(m => m.Score1 + m.Score2);
            var matchWithMaxScore = results.First(m => m.Score1 + m.Score2 == maxScore);
            Console.WriteLine("Max score: {0}:{1}", matchWithMaxScore.Score1, matchWithMaxScore.Score2);

            int homeGoals = results.Sum(m => m.Score1);
            int awayGoals = results.Sum(m => m.Score2);
            int totalGoals = results.Sum(m => m.Score1 + m.Score2);
            Console.WriteLine("Home goals:  {0,6} {1,8}", homeGoals, (float)homeGoals / results.Count());
            Console.WriteLine("Away goals:  {0,6} {1,8}", awayGoals, (float)awayGoals / results.Count());
            Console.WriteLine("Total goals: {0,6} {1,8}", totalGoals, (float)totalGoals / results.Count());

            Console.WriteLine();
            Console.WriteLine("No goals:    {0,4}", results.Count(m => m.Score1 + m.Score2 == 0));
            Console.WriteLine("Max 1 goal:  {0,4}", results.Count(m => m.Score1 + m.Score2 <= 1));
            Console.WriteLine("Max 2 goals: {0,4}", results.Count(m => m.Score1 + m.Score2 <= 2));
            Console.WriteLine("Max 3 goals: {0,4}", results.Count(m => m.Score1 + m.Score2 <= 3));
            Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("Results counts:");

            var matchesByScore = results.OrderBy(m => m.Score2).OrderBy(m => m.Score1 + m.Score2).ToArray();
            int count = 0;
            MatchResult previous = null;

            for (int i = 0; i < matchesByScore.Length; i++)
            {
                var current = matchesByScore[i];

                if (previous == null || (current.Score1 == previous.Score1 && current.Score2 == previous.Score2))
                {
                    count++;
                }
                else
                {
                    Console.WriteLine("{0}:{1} {2,5}% {3,5}", previous.Score1, previous.Score2, 100 * count / results.Count(), count);
                    count = 1;
                }

                previous = current;
            }

            Console.ReadLine();
            Console.WriteLine();
            Console.WriteLine("Goals by position (home only):");

            var positions = Enum.GetValues(typeof(PositionCode)).Cast<PositionCode>();

            foreach (var position in positions)
            {
                int goals = results.Sum(m => m.Events.OfType<GoalEvent>().Count(e =>
                    e.Scorer.Team == homeTeam && e.Scorer.Position.Code == position));
                Console.WriteLine("{0,3} {1,5}% {2,5}", position, 100 * goals / homeGoals, goals);
            }
        }
Ejemplo n.º 10
0
 public Team AttackingTeam(Team team1, Team team2, bool isNeutralGround)
 {
     double firstTeamChance = isNeutralGround ? 0.5 : 0.6;
     return random.Decide(firstTeamChance) ? team1 : team2;
 }