Пример #1
0
        public Fixture[] CreateFixtures(TournamentSeason tournamentSeason)
        {
            var firstLeg = new Fixture(tournamentSeason, FirstLegDate, Team1, Team2, false, false);
            var secondLeg = new Fixture(SecondLegDate, firstLeg);

            return new Fixture[] { firstLeg, secondLeg };
        }
Пример #2
0
 public MatchResult(Fixture fixture, Team winner, int score1, int score2, int penaltyScore1, int penaltyScore2,
     IEnumerable<Goal> goals,
     IEnumerable<PlayerMatchStats> playersStats1,
     IEnumerable<PlayerMatchStats> playersStats2)
 {
     TournamentSeasonId = fixture.TournamentSeasonId;
     Date = fixture.Date;
     Team1 = fixture.Team1;
     Team2 = fixture.Team2;
     Team1Name = fixture.Team1Name;
     Team2Name = fixture.Team2Name;
     Winner = winner;
     Score1 = score1;
     Score2 = score2;
     PenaltyScore1 = penaltyScore1;
     PenaltyScore2 = penaltyScore2;
     Goals = goals.ToList();
     PlayersStats1 = playersStats1.ToList();
     PlayersStats2 = playersStats2.ToList();
 }
        public MatchResult Play(Fixture fixture)
        {
            allPlayers = Enumerable.Union(fixture.Team1.Players, fixture.Team2.Players).ToArray();

            MatchSimulator.Domain.Team team1 = ConvertTeamForMatchSimulator(fixture.Team1);
            MatchSimulator.Domain.Team team2 = ConvertTeamForMatchSimulator(fixture.Team2);

            MatchSimulator.Domain.Match match;

            if (fixture.IsSecondLeg)
            {
                var firstLegResult = fixture.FirstLeg.Result;
                match = new MatchSimulator.Domain.Match(team1, team2, firstLegResult.Score1, firstLegResult.Score2);
            }
            else
            {
                match = new MatchSimulator.Domain.Match(team1, team2, fixture.IsNeutralGround, fixture.RequiresExtraTime);
            }

            var simulator = new MatchSimulator.Domain.Simulator(MatchSimulator.Domain.MatchRandomizer.Current);
            var simulatorResult = simulator.Play(match);

            var goals = simulatorResult.Goals.Select(g =>
                new Goal(g.IsForFirstTeam, g.Minute, g.Extended, MapPlayer(g.Scorer))).ToArray();

            Team winner = null;

            if (simulatorResult.Winner != null)
            {
                winner = simulatorResult.Winner == team1 ? fixture.Team1 : fixture.Team2;
            }

            var playersStats1 = team1.Squad.Select(p => new PlayerMatchStats(MapPlayer(p), p.FinalRating, p.Goals, p.Assists)).ToArray();
            var playersStats2 = team2.Squad.Select(p => new PlayerMatchStats(MapPlayer(p), p.FinalRating, p.Goals, p.Assists)).ToArray();

            var result = new MatchResult(fixture, winner, simulatorResult.Score1, simulatorResult.Score2,
                simulatorResult.PenaltyScore1, simulatorResult.PenaltyScore2,
                goals, playersStats1, playersStats2);

            return result;
        }
Пример #4
0
 public Fixture(DateTime date, Fixture firstLeg)
     : this(firstLeg.World, firstLeg.TournamentSeasonId, date, firstLeg.Team2, firstLeg.Team1, false, true)
 {
     FirstLeg = firstLeg;
 }