示例#1
0
        public override void ApplyResult(MatchResult result)
        {
            base.ApplyResult(result);

            CurrentStage.ApplyResult(result);

            if (CurrentStage.IsFinished)
            {
                var previousStage = CurrentStage;
                CurrentStageIndex += 1;

                if (CurrentStageIndex == Stages.Count)
                {
                    Phase = TournamentPhase.Finished;

                    PromotedTeams.AddRange(previousStage.PromotedTeams);
                    PromotionPlayOffTeams.AddRange(previousStage.Teams.Except(PromotedTeams).ToArray());
                }
                else
                {
                    CurrentStage.Activate(previousStage.PromotedTeams);
                    NextSchedulingDate = World.Date;
                }
            }
        }
示例#2
0
 public bool IsMatchingResult(MatchResult result)
 {
     return
         (FirstLegResult == null && result.Date == FirstLegDate &&
             result.Team1 == Team1 && result.Team2 == Team2) ||
         (FirstLegResult != null && SecondLegResult == null && result.Date == SecondLegDate &&
             result.Team1 == Team2 && result.Team2 == Team1);
 }
        public override void ApplyResult(MatchResult result)
        {
            var tie = Ties.First(t => t.IsMatchingResult(result));
            tie.AddResult(result);

            if (Ties.All(t => t.HasWinner))
            {
                Phase = TournamentPhase.Finished;
            }
        }
        public override void ApplyResult(MatchResult result)
        {
            PromoteTeam(result.Winner);
            PlayedCount += 1;

            if (PlayedCount == TeamCount / 2)
            {
                Phase = TournamentPhase.Finished;
            }
        }
        public void ApplyResult(MatchResult result)
        {
            PlayerMatchStats matchStats = result.PlayersStats.FirstOrDefault(s => s.Player == Player);

            if (matchStats != null)
            {
                Played += 1;
                Goals += matchStats.Goals;
                Assists += matchStats.Assists;

                AverageRating = (AverageRating * (Played - 1) + matchStats.Rating) / Played;
            }
        }
示例#6
0
 public void AddResult(MatchResult result)
 {
     if (IsMatchingResult(result))
     {
         if (result.Date == FirstLegDate)
         {
             FirstLegResult = result;
         }
         else
         {
             SecondLegResult = result;
             Winner = result.Winner;
             Loser = Winner == Team1 ? Team2 : Team1;
         }
     }
 }
示例#7
0
        public bool TryApplyResult(MatchResult result)
        {
            var stats1 = TeamStats.FirstOrDefault(s => s.Team == result.Team1);
            var stats2 = TeamStats.FirstOrDefault(s => s.Team == result.Team2);

            if (stats1 != null && stats2 != null)
            {
                stats1.ApplyResult(result);
                stats2.ApplyResult(result);

                return true;
            }
            else
            {
                return false;
            }
        }
        public void ApplyResult(MatchResult result)
        {
            if (result.Team1 == Team || result.Team2 == Team)
            {
                Played += 1;

                if (!PlayerStats.Any())
                {
                    PlayerStats.AddRange(Team.Players.Select(p => new PlayerTournamentStats(TournamentSeason, p)).ToList());
                }

                foreach (var playerStats in PlayerStats)
                {
                    playerStats.ApplyResult(result);
                }
            }
        }
        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;
        }
示例#10
0
        public override void ApplyResult(MatchResult result)
        {
            foreach (var group in Groups)
            {
                if (group.TryApplyResult(result))
                {
                    if (group.IsCompleted)
                    {
                        foreach (var teamStats in group.Standings.Take(GroupPromotedCount))
                        {
                            PromoteTeam(teamStats.Team);
                        }

                        if (Groups.All(g => g.IsCompleted))
                        {
                            Phase = TournamentPhase.Finished;
                        }
                    }

                    break;
                }
            }
        }
示例#11
0
 public abstract void ApplyResult(MatchResult result);
示例#12
0
        public override void ApplyResult(MatchResult result)
        {
            base.ApplyResult(result);

            GetStatsFor(result.Team1).ApplyResult(result);
            GetStatsFor(result.Team2).ApplyResult(result);

            if (Phase == TournamentPhase.InProgress)
            {
                int roundsToPlay = (TeamStats.Count - 1) * (HasReturnRound ? 2 : 1);

                if (TeamStats.All(s => s.Played == roundsToPlay))
                {
                    Phase = TournamentPhase.Finished;

                    PromotedTeams.AddRange(AutomaticPromotionZone);
                    RelegatedTeams.AddRange(AutomaticRelegationZone);
                    PromotionPlayOffTeams.AddRange(PlayOffPromotionZone);
                    RelegationPlayOffTeams.AddRange(PlayOffRelegationZone);
                }
            }
        }
示例#13
0
 public virtual void ApplyResult(MatchResult result)
 {
     TeamTournamentStats.First(s => s.Team == result.Team1).ApplyResult(result);
     TeamTournamentStats.First(s => s.Team == result.Team2).ApplyResult(result);
 }