示例#1
0
        protected void OnMatchOver(DetectedThrow thrw)
        {
            ConvertAndSaveThrow(thrw, ThrowResult.MatchWon);
            Game.Winner = Game.PlayerOnThrow;

            OnMatchEnd?.Invoke();
        }
示例#2
0
        protected override void OnThrowInternal(DetectedThrow thrw)
        {
            if (IsGameOver(thrw))
            {
                Game.PlayerOnThrow.GameData.SetsWon += 1;
                Game.PlayerOnThrow.GameData.LegsWon += 1;
                OnMatchOver(thrw);
                return;
            }

            if (IsSetOver(thrw))
            {
                OnSetOver(thrw);
                return;
            }

            if (IsLegOver(thrw))
            {
                OnLegOver(thrw);
                return;
            }

            if (IsFault(thrw))
            {
                OnFault(thrw);
                return;
            }

            Game.PlayerOnThrow.GameData.HandPoints += thrw.TotalPoints;
            Game.PlayerOnThrow.GameData.LegPoints  -= thrw.TotalPoints;
            scoreBoard.AddPointsTo(Game.PlayerOnThrow, thrw.TotalPoints * -1);

            OnHandOverDoublePlayersCheck(thrw);
        }
        public Image <Bgr, byte> ProjectionDrawThrow(DetectedThrow thrw)
        {
            var image = ProjectionBackgroundImage.Clone();

            DrawLine(image, thrw.FirstRay.RayPoint, thrw.FirstRay.CamPoint, projectionThrowRayColor, PoiThickness);
            DrawLine(image, thrw.SecondRay.RayPoint, thrw.SecondRay.CamPoint, projectionThrowRayColor, PoiThickness);
            DrawCircle(image, thrw.Poi, PoiRadius, poiColor, PoiThickness);
            return(image);
        }
示例#4
0
 protected void OnFault(DetectedThrow thrw)
 {
     ConvertAndSaveThrow(thrw, ThrowResult.Fault);
     Game.PlayerOnThrow.GameData.LegPoints += Game.PlayerOnThrow.GameData.HandPoints;
     scoreBoard.SetPointsTo(Game.PlayerOnThrow, Game.PlayerOnThrow.GameData.LegPoints);
     ClearPlayerOnThrowHand();
     scoreBoard.CheckPointsHintFor(Game.PlayerOnThrow);
     TogglePlayerOnThrow();
 }
        protected override void OnThrowInternal(DetectedThrow thrw)
        {
            Game.PlayerOnThrow.GameData.HandPoints += thrw.TotalPoints;
            Game.PlayerOnThrow.GameData.LegPoints  += thrw.TotalPoints;

            scoreBoard.AddPointsTo(Game.PlayerOnThrow, thrw.TotalPoints);

            OnHandOverSinglePlayerCheck(thrw);
        }
示例#6
0
        public override void OnThrow(DetectedThrow thrw)
        {
            if (IsOut(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.LegWon);

                dbService.StatisticUpdateAddLegsPlayedForPlayers(Game.Id);
                dbService.StatisticUpdateAddLegsWonForPlayer(PlayerOnThrow, Game.Id);

                foreach (var player in Players)
                {
                    player.LegPoints = writeOffPoints;
                    scoreBoard.SetPointsToClassic(writeOffPoints, player);
                    scoreBoard.CheckPointsHintFor(player);
                }

                ClearThrows();

                TogglePlayerOnThrow();
                return;
            }

            if (IsFault(thrw))
            {
                PlayerOnThrow.LegPoints += PlayerOnThrow.HandPoints;
                scoreBoard.SetPointsToClassic(PlayerOnThrow.LegPoints, PlayerOnThrow);
                ConvertAndSaveThrow(thrw, ThrowResult.Fault);
                ClearThrows();
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);

                TogglePlayerOnThrow();
                return;
            }

            PlayerOnThrow.HandPoints += thrw.TotalPoints;
            PlayerOnThrow.LegPoints  -= thrw.TotalPoints;
            scoreBoard.AddPointsToClassic(thrw.TotalPoints * -1, PlayerOnThrow);

            var dbThrow = ConvertAndSaveThrow(thrw, ThrowResult.Ordinary);

            PlayerOnThrow.HandThrows.Push(dbThrow);

            if (IsHandOver())
            {
                Check180();
                ClearThrows();
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);
                TogglePlayerOnThrow();
            }
            else
            {
                PlayerOnThrow.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(PlayerOnThrow.ThrowNumber);
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);
            }
        }
示例#7
0
        protected void ConvertAndSaveThrow(DetectedThrow detectedThrow,
                                           ThrowResult throwResult = ThrowResult.Ordinary)
        {
            var convertedThrow = new Throw(Game.PlayerOnThrow,
                                           detectedThrow.Sector,
                                           detectedThrow.Type,
                                           throwResult,
                                           (int)Game.PlayerOnThrow.GameData.ThrowNumber,
                                           detectedThrow.TotalPoints,
                                           detectedThrow.Poi,
                                           detectedThrow.ProjectionResolution);

            Game.Throws.Push(convertedThrow);
            Game.PlayerOnThrow.GameData.HandThrows.Add(convertedThrow);
        }
示例#8
0
        protected void OnHandOverSinglePlayerCheck(DetectedThrow thrw)
        {
            ConvertAndSaveThrow(thrw);

            if (IsHandOver())
            {
                Check180();
                ClearPlayerOnThrowHand();
            }
            else
            {
                Game.PlayerOnThrow.GameData.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(Game.PlayerOnThrow.GameData.ThrowNumber);
            }
        }
示例#9
0
        protected Throw ConvertAndSaveThrow(DetectedThrow thrw, ThrowResult throwResult)
        {
            var dbThrow = new Throw(PlayerOnThrow,
                                    Game,
                                    thrw.Sector,
                                    thrw.Type,
                                    throwResult,
                                    PlayerOnThrow.ThrowNumber,
                                    thrw.TotalPoints,
                                    thrw.Poi,
                                    thrw.ProjectionResolution);

            dbService.ThrowSaveNew(dbThrow);
            return(dbThrow);
        }
示例#10
0
        private void OnLegOver(DetectedThrow thrw)
        {
            ConvertAndSaveThrow(thrw, ThrowResult.LegWon);
            Game.PlayerOnThrow.GameData.LegsWon += 1;
            scoreBoard.AddLegsWonTo(Game.PlayerOnThrow);
            ClearPlayerOnThrowHand();

            foreach (var player in Game.Players)
            {
                player.GameData.LegPoints = Game.legPoints;
                scoreBoard.SetPointsTo(player, Game.legPoints);
                scoreBoard.CheckPointsHintFor(player);
            }

            TogglePlayerOnLegAndOnThrow();
        }
        public override void OnThrow(DetectedThrow thrw)
        {
            if (IsLegOver(thrw))
            {
                PlayerOnThrow.LegPoints = writeOffPoints;
                scoreBoard.SetPointsToSinglePlayer(writeOffPoints);

                ConvertAndSaveThrow(thrw, ThrowResult.LegWon);

                dbService.StatisticUpdateAddLegsPlayedForPlayers(Game.Id);
                dbService.StatisticUpdateAddLegsWonForPlayer(PlayerOnThrow, Game.Id);

                ClearPlayerOnThrowHand();
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);
                return;
            }

            if (IsFault(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.Fault);

                OnFault();
                return;
            }

            PlayerOnThrow.HandPoints += thrw.TotalPoints;
            PlayerOnThrow.LegPoints  -= thrw.TotalPoints;
            scoreBoard.AddPointsToSinglePlayer(thrw.TotalPoints * -1);

            var dbThrow = ConvertAndSaveThrow(thrw, ThrowResult.Ordinary);

            PlayerOnThrow.HandThrows.Push(dbThrow);
            if (IsHandOver())
            {
                Check180();
                ClearPlayerOnThrowHand();
            }
            else
            {
                PlayerOnThrow.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(PlayerOnThrow.ThrowNumber);
            }

            scoreBoard.CheckPointsHintFor(PlayerOnThrow);
        }
示例#12
0
        protected void OnHandOverDoublePlayersCheck(DetectedThrow thrw)
        {
            ConvertAndSaveThrow(thrw);

            if (IsHandOver())
            {
                Check180();
                ClearPlayerOnThrowHand();

                scoreBoard.CheckPointsHintFor(Game.PlayerOnThrow);
                TogglePlayerOnThrow();
            }
            else
            {
                Game.PlayerOnThrow.GameData.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(Game.PlayerOnThrow.GameData.ThrowNumber);
                scoreBoard.CheckPointsHintFor(Game.PlayerOnThrow);
            }
        }
        protected override void OnThrowInternal(DetectedThrow thrw)
        {
            Game.PlayerOnThrow.GameData.HandPoints += thrw.TotalPoints;
            Game.PlayerOnThrow.GameData.LegPoints  += thrw.TotalPoints;

            scoreBoard.AddPointsTo(Game.PlayerOnThrow, thrw.TotalPoints);

            ConvertAndSaveThrow(thrw);

            if (IsHandOver())
            {
                Check180();
                ClearPlayerOnThrowHand();
                TogglePlayerOnThrow();
            }
            else
            {
                Game.PlayerOnThrow.GameData.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(Game.PlayerOnThrow.GameData.ThrowNumber);
            }
        }
        public override void OnThrow(DetectedThrow thrw)
        {
            PlayerOnThrow.HandPoints += thrw.TotalPoints;

            scoreBoard.AddPointsTo(PlayerOnThrow, thrw.TotalPoints);

            var dbThrow = ConvertAndSaveThrow(thrw, ThrowResult.Ordinary);

            PlayerOnThrow.HandThrows.Push(dbThrow);

            if (IsHandOver())
            {
                Check180();

                ClearPlayerOnThrowHand();
            }
            else
            {
                PlayerOnThrow.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(PlayerOnThrow.ThrowNumber);
            }
        }
示例#15
0
 public abstract void OnThrow(DetectedThrow thrw);
示例#16
0
        public override void OnThrow(DetectedThrow thrw)
        {
            if (IsGameOver(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.MatchWon);

                dbService.StatisticUpdateAddLegsPlayedForPlayers(Game.Id);
                dbService.StatisticUpdateAddLegsWonForPlayer(PlayerOnThrow, Game.Id);

                dbService.StatisticUpdateAddSetsPlayedForPlayers(Game.Id);
                dbService.StatisticUpdateAddSetsWonForPlayer(PlayerOnThrow, Game.Id);

                InvokeEndMatch();
                return;
            }

            if (IsSetOver(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.SetWon);

                OnSetOver();
                return;
            }

            if (IsLegOver(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.LegWon);

                OnLegOver();
                return;
            }

            if (IsFault(thrw))
            {
                ConvertAndSaveThrow(thrw, ThrowResult.Fault);

                OnFault();
                return;
            }

            PlayerOnThrow.HandPoints += thrw.TotalPoints;
            PlayerOnThrow.LegPoints  -= thrw.TotalPoints;
            scoreBoard.AddPointsToClassic(thrw.TotalPoints * -1, PlayerOnThrow);

            var dbThrow = ConvertAndSaveThrow(thrw, ThrowResult.Ordinary);

            PlayerOnThrow.HandThrows.Push(dbThrow);

            if (IsHandOver())
            {
                Check180();
                ClearPlayerOnThrowHand();
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);
                TogglePlayerOnThrow();
            }
            else
            {
                PlayerOnThrow.ThrowNumber += 1;
                scoreBoard.SetThrowNumber(PlayerOnThrow.ThrowNumber);
                scoreBoard.CheckPointsHintFor(PlayerOnThrow);
            }
        }
示例#17
0
 protected bool IsSetOver(DetectedThrow thrw)
 {
     return(IsLegOver(thrw) && Game.PlayerOnThrow.GameData.LegsWon + 1 == Game.legs);
 }
示例#18
0
 protected bool IsGameOver(DetectedThrow thrw)
 {
     return(IsSetOver(thrw) && Game.PlayerOnThrow.GameData.SetsWon + 1 == Game.sets);
 }
示例#19
0
 protected abstract void OnThrowInternal(DetectedThrow thrw);
示例#20
0
 protected bool IsLegOver(DetectedThrow thrw)
 {
     return(PlayerOnThrow.LegPoints - thrw.TotalPoints == 0 &&
            (thrw.Type == ThrowType.Double || thrw.Type == ThrowType.Bulleye));
 }
 private void OnAnotherThrow(DetectedThrow thrw)
 {
     GameProcessor.OnThrow(thrw);
 }
示例#22
0
 protected bool IsGameOver(DetectedThrow thrw)
 {
     return(IsSetOver(thrw) && PlayerOnThrow.SetsWon + 1 == sets);
 }
示例#23
0
 public virtual void OnThrow(DetectedThrow thrw)
 {
 }
示例#24
0
 protected bool IsSetOver(DetectedThrow thrw)
 {
     return(IsLegOver(thrw) && PlayerOnThrow.LegsWon + 1 == legs);
 }
示例#25
0
 protected bool IsFault(DetectedThrow thrw)
 {
     return(Game.PlayerOnThrow.GameData.LegPoints - thrw.TotalPoints == 1 ||
            Game.PlayerOnThrow.GameData.LegPoints - thrw.TotalPoints < 0 ||
            Game.PlayerOnThrow.GameData.LegPoints - thrw.TotalPoints == 0);
 }
示例#26
0
 protected bool IsFault(DetectedThrow thrw)
 {
     return(PlayerOnThrow.LegPoints - thrw.TotalPoints == 1 ||
            PlayerOnThrow.LegPoints - thrw.TotalPoints < 0 ||
            PlayerOnThrow.LegPoints - thrw.TotalPoints == 0);
 }
示例#27
0
 public void OnThrow(DetectedThrow thrw)
 {
     TakeSnapshot();
     OnThrowInternal(thrw);
 }