Beispiel #1
0
        /// <summary>
        ///     Create a new instance (in memory and database) of <see cref="T:Business.EliminationStep" /> with specified param
        /// </summary>
        /// <param name="phase">Phase linked to this new step</param>
        /// <param name="teamList">Team involved in this new step</param>
        /// <param name="matchSetting">Set setting match for new Elimination phase</param>
        /// <param name="firstStep">Set first step for elimination step</param>
        /// <returns>EliminationStep's instance</returns>
        public static IEliminationStep Create(IPhase phase, IList <ITeam> teamList, IMatchSetting matchSetting,
                                              EliminationType firstStep)
        {
            if (phase == null)
            {
                throw new ArgumentNullException(nameof(phase));
            }
            if (teamList == null)
            {
                throw new ArgumentNullException(nameof(teamList));
            }
            if (matchSetting == null)
            {
                throw new ArgumentNullException(nameof(matchSetting));
            }

            var requiredTeam = (ushort)firstStep * 2;

            if (teamList.Count != requiredTeam)
            {
                throw new ArgumentException(
                          $"La première étape de la phase éliminatoire ne correspond pas au nombre équipe fourni. Nombre d'équipe requise:{requiredTeam}. Nombre d'équipe:{teamList.Count}");
            }

            var result = new EliminationStep(phase, teamList, matchSetting)
            {
                Type = firstStep
            };

            return(result);
        }
Beispiel #2
0
        protected GameStep(IPhase phase, IList <ITeam> teamList, IMatchSetting currentMatchSetting)
            : this()
        {
            if (teamList == null)
            {
                throw new ArgumentNullException(nameof(teamList));
            }

            FlippingContainer.Instance.ComposeParts(this);

            foreach (var team in teamList)
            {
                var count = teamList.Count(item => item == team);
                if (count != 1)
                {
                    throw new ArgumentException(
                              $"La liste des équipes ne peut pas contenir plus deux fois la même équipe. Equipe:{team.Id}. Count:{count}.");
                }
            }

            Phase               = phase ?? throw new ArgumentNullException(nameof(phase));
            TeamList            = teamList;
            CurrentMatchSetting = currentMatchSetting;
            MatchList           = new List <IMatch>();
        }
Beispiel #3
0
        /// <summary>
        ///     Create a new instance (in memory and database) of <see cref="T:Business.Match" /> with specified param
        /// </summary>
        /// <param name="team1">First team involved in match</param>
        /// <param name="team2">Second team involved in match</param>
        /// <param name="gameStep">Game step linked</param>
        /// <param name="setting">Set setting for new match</param>
        /// <returns>Match's instance</returns>
        public IMatch Create(IGameStep gameStep, ITeam team1, ITeam team2, IMatchSetting setting)
        {
            if (team1 == null)
            {
                throw new ArgumentNullException(nameof(team1));
            }
            if (team2 == null)
            {
                throw new ArgumentNullException(nameof(team2));
            }
            if (gameStep == null)
            {
                throw new ArgumentNullException(nameof(gameStep));
            }
            if (team1.Id == team2.Id)
            {
                throw new ArgumentException("Les deux équipes d'un même match ne peuvent pas être identique.");
            }
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            IMatch result = new Match
            {
                Team1      = team1,
                Team2      = team2,
                TeamScore1 = 0,
                TeamScore2 = 0,
                MatchState = MatchState.Planned,
                GameStep   = gameStep,
                Setting    = setting
            };

            team1.AddMatch(result);
            team2.AddMatch(result);

            return(result);
        }
Beispiel #4
0
 protected EliminationStep(IPhase phase, IList <ITeam> teamList, IMatchSetting currentMatchSetting)
     : base(phase, teamList, currentMatchSetting)
 {
 }
Beispiel #5
0
 /// <summary>
 ///     Instance a new EliminationStepSetting with specified param
 /// </summary>
 /// <param name="matchSetting">Set match setting for qualification step</param>
 /// <param name="firstStep">Set the first step for elimination step</param>
 public EliminationStepSetting(IMatchSetting matchSetting, EliminationType firstStep)
     : base(matchSetting)
 {
     FirstStep = firstStep;
 }
Beispiel #6
0
        internal static IMatch CreateMatch(string gameStepId, string team1Id, string team2Id, IMatchSetting matchSetting)
        {
            var gameStep = CreateMock <IGameStep>(gameStepId);
            var team1    = CreateMock <ITeam>(team1Id);
            var team2    = CreateMock <ITeam>(team2Id);

            return(new MatchFactory().Create(gameStep.Object, team1.Object, team2.Object, matchSetting));
        }
 public IMatch Create(IGameStep gameStep, ITeam team1, ITeam team2, IMatchSetting setting)
 {
     return(Mock.Object.Create(gameStep, team1, team2, setting));
 }
Beispiel #8
0
 protected QualificationStep(IPhase phase, IList <ITeam> teamList, IMatchSetting matchSetting)
     : base(phase, teamList, matchSetting)
 {
 }
Beispiel #9
0
 /// <summary>
 ///     Instance a new StepSetting with specified param
 /// </summary>
 /// <param name="matchSetting">Set match setting for  step</param>
 protected StepSetting(IMatchSetting matchSetting)
     : this()
 {
     MatchSetting = matchSetting ?? throw new ArgumentNullException(nameof(matchSetting));
 }