예제 #1
0
        /// <summary>
        /// 勝者を取得します。
        /// 試合が行われていなくても、対戦相手が BYE の場合は勝者とみなします。
        /// Not Played の場合は BYE を勝者とします。
        /// </summary>
        /// <returns>勝者。</returns>
        public Opponent GetWinner()
        {
            if (this.GameResult.GameStatus == GameStatus.NotPlayed)
            {
                return(Opponent.CreateBye());
            }

            if (this.Opponents.Any(o => o.IsBye))
            {
                return(this.Opponents.FirstOrDefault(o => !o.IsBye)?.Clone());
            }

            if (!this.IsDone)
            {
                return(null);
            }

            var opponent = this.Opponents
                           .Where(o => o.EntryNumber == this.GameResult.EntryNumberOfWinner)
                           .FirstOrDefault();

            return(opponent?.Clone());
        }
예제 #2
0
        /// <summary>
        /// 対戦者の割り当てを解除します。
        /// </summary>
        /// <param name="opponent">対戦者。</param>
        public void UnassignOpponent(Opponent opponent)
        {
            if (this.IsDone)
            {
                throw new InvalidOperationException("すでに試合結果が入力されているため、選手の割り当てを解除できません。");
            }

            var removeOpponent = this.Opponents.FirstOrDefault(o => o.DrawNumber == opponent.DrawNumber);

            removeOpponent.UpdateOpponent(
                playerClassification: null,
                entryNumber: null,
                seedNumber: null,
                teamCodes: null,
                teamAbbreviatedNames: null,
                playerCodes: null,
                playerNames: null,
                fromGameNumber: null);

            if (this.Opponents.Count(o => o.IsAssigned) < maxOpponentsCount)
            {
                this.GameResult.NotReadied();
            }
        }