protected void OnMatchOver(DetectedThrow thrw) { ConvertAndSaveThrow(thrw, ThrowResult.MatchWon); Game.Winner = Game.PlayerOnThrow; OnMatchEnd?.Invoke(); }
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); }
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); }
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); } }
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); }
protected void OnHandOverSinglePlayerCheck(DetectedThrow thrw) { ConvertAndSaveThrow(thrw); if (IsHandOver()) { Check180(); ClearPlayerOnThrowHand(); } else { Game.PlayerOnThrow.GameData.ThrowNumber += 1; scoreBoard.SetThrowNumber(Game.PlayerOnThrow.GameData.ThrowNumber); } }
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); }
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); }
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); } }
public abstract void OnThrow(DetectedThrow thrw);
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); } }
protected bool IsSetOver(DetectedThrow thrw) { return(IsLegOver(thrw) && Game.PlayerOnThrow.GameData.LegsWon + 1 == Game.legs); }
protected bool IsGameOver(DetectedThrow thrw) { return(IsSetOver(thrw) && Game.PlayerOnThrow.GameData.SetsWon + 1 == Game.sets); }
protected abstract void OnThrowInternal(DetectedThrow thrw);
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); }
protected bool IsGameOver(DetectedThrow thrw) { return(IsSetOver(thrw) && PlayerOnThrow.SetsWon + 1 == sets); }
public virtual void OnThrow(DetectedThrow thrw) { }
protected bool IsSetOver(DetectedThrow thrw) { return(IsLegOver(thrw) && PlayerOnThrow.LegsWon + 1 == legs); }
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); }
protected bool IsFault(DetectedThrow thrw) { return(PlayerOnThrow.LegPoints - thrw.TotalPoints == 1 || PlayerOnThrow.LegPoints - thrw.TotalPoints < 0 || PlayerOnThrow.LegPoints - thrw.TotalPoints == 0); }
public void OnThrow(DetectedThrow thrw) { TakeSnapshot(); OnThrowInternal(thrw); }