예제 #1
0
        public int GetBidValue(MatadorsJackStraight jackStraight, bool schneider = false, bool schwarz = false)
        {
            if (Type == GameType.Null)
            {
                return(GetNullBaseValue());
            }
            int mult = jackStraight.Play;

            if (Option.HasFlag(GameOption.Hand))
            {
                mult++;
            }
            if (Option.HasFlag(GameOption.Ouvert))
            {
                mult++;
            }
            if (Option.HasFlag(GameOption.Schneider))
            {
                mult++;
            }
            if (Option.HasFlag(GameOption.Schwarz))
            {
                mult++;
            }
            if (schneider)
            {
                mult++;
            }
            if (schwarz)
            {
                mult++;
            }
            return(mult * GetGrandOrColorBaseValue());
        }
예제 #2
0
        public GameValue GetGameValue(MatadorsJackStraight spitzen, List <Card> stitches, List <Card> skat, int bidValue, bool giveUp)
        {
            int  score;
            bool schneider           = false;
            bool schwarz             = false;
            bool gamePlayerSchneider = false;
            bool gamePlayerSchwarz   = false;

            if (Type != GameType.Null)
            {
                score     = Card.GetScore(stitches, skat);
                schneider = score >= 90;
                schwarz   = stitches.Count == 30;
                if (!giveUp)
                {
                    if (stitches.Count == 0)
                    {
                        gamePlayerSchwarz = true;
                    }
                    gamePlayerSchneider = score <= 30;
                }
            }
            var gameValue = new GameValue();
            // check if bid value is exceeded considering schneider and schwarz
            var gameBidValue = GetBidValue(spitzen, schneider, schwarz);

            if (gameBidValue < bidValue)
            {
                int baseValue;
                if (Type == GameType.Null)
                {
                    baseValue = GetNullBaseValue();
                }
                else
                {
                    baseValue = GetGrandOrColorBaseValue();
                }
                gameValue.Score = baseValue;
                int factor = 1;
                while (gameValue.Score < bidValue)
                {
                    gameValue.Score += baseValue;
                    factor++;
                }
                var calc = factor == 1 ? $"{baseValue}" : $"{factor} x {baseValue}";
                gameValue.BidExceeded = true;
                gameValue.IsWinner    = false;
                gameValue.Score      *= -2;
                gameValue.Description = $"Das Spiel wurde überreizt mit {bidValue}. {GetGameAndOptionText()} : {calc} x -2 = {gameValue.Score}.";
            }
            else
            {
                string calc;
                string game;
                int    baseValue;
                int    factor = 1;
                if (Type == GameType.Null)
                {
                    baseValue       = GetNullBaseValue();
                    gameValue.Score = baseValue;
                    game            = GetGameAndOptionText();
                }
                else
                {
                    var with = spitzen.With ? "Mit" : "Ohne";
                    game   = $"{with} {spitzen.Count} spielt {spitzen.Play} ";
                    factor = spitzen.Play;
                    if (Option.HasFlag(GameOption.Hand))
                    {
                        factor++;
                        game += $"Hand {factor} ";
                    }
                    if (Option.HasFlag(GameOption.Ouvert))
                    {
                        factor++;
                        game += $"Ouvert {factor} ";
                    }
                    if (schneider || gamePlayerSchneider)
                    {
                        factor++;
                        game += $"Schneider {factor} ";
                    }
                    if (Option.HasFlag(GameOption.Schneider))
                    {
                        factor++;
                        if (!schneider && !gamePlayerSchneider)
                        {
                            game += "Schneider ";
                        }
                        game += $"Angesagt {factor} ";
                    }
                    if (schwarz || gamePlayerSchwarz)
                    {
                        factor++;
                        game += $"Schwarz {factor} ";
                    }
                    if (Option.HasFlag(GameOption.Schwarz))
                    {
                        factor++;
                        if (!schwarz && !gamePlayerSchwarz)
                        {
                            game += "Schwarz ";
                        }
                        game += $"Angesagt {factor} ";
                    }
                    game     += $"{GetGameText()} ";
                    baseValue = GetGrandOrColorBaseValue();
                }
                gameValue.Score = factor * baseValue;
                calc            = $"{factor} x {baseValue}";
                if (!IsWinner(stitches, skat))
                {
                    gameValue.Score      *= -2;
                    gameValue.IsWinner    = false;
                    gameValue.Description = $"{game}: {calc} x -2 = {gameValue.Score}.";
                }
                else
                {
                    gameValue.Description = $"{game}: {calc} = {gameValue.Score}.";
                }
            }
            return(gameValue);
        }