Example #1
0
 public bool IsValid()
 {
     if (!Validator.TryValidateObject(Account, Context, Results, true))
     {
         foreach (var error in Results)
         {
             ColorEngine.Red();
             Console.WriteLine(error.ErrorMessage);
         }
         return(false);
     }
     return(true);
 }
Example #2
0
        public Task <ColorPalette[]> GetColorPalettesAsync(ColorExtractionModel model)
        {
            var engine = new ColorEngine(new List <IColorPaletteFactory>()
            {
                new AnalogousPaletteFactory(),
                new Analogous2SeedsPaletteFactory()
            });

            using (var imageStream = new MemoryStream(model.Image))
            {
                return(Task.FromResult(engine.GetSuggestedPalettes(imageStream,
                                                                   accentAndTBContrastThreshold: model.accentAndTBContrastThreshold,
                                                                   tbContrastThreshold: model.tbContrastThreshold,
                                                                   hlAndFhlContrastThreshold: model.hlAndFhlContrastThreshold
                                                                   ).ToArray()));
            }
        }
Example #3
0
        public void TryToGuess()
        {
            ColorEngine.White();
            Console.WriteLine($"Try to guess a number from 0 to {MaxValue}. You have {Attempts} attempts");

            var history = new PlayerHistory();

            while (Attempts > 0 && !IsWon)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Enter the estimated number");
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Write(">>> ");

                if (int.TryParse(Console.ReadLine(), out int estimatedNumber))
                {
                    if (estimatedNumber > MaxValue || estimatedNumber < MinValue)
                    {
                        ColorEngine.Red();
                        Console.WriteLine("Out of range");
                        continue;
                    }
                    Attempts--;
                    ColorEngine.White();

                    switch (estimatedNumber.CompareTo(ExpectedNumber))
                    {
                    case (int)Equality.Bigger:
                    {
                        history.AddAction($"Entered number Bigger({estimatedNumber}) than expected({ExpectedNumber})");
                        Console.WriteLine($"\tYour entered number BIGGER than expected. You have {Attempts} attempts");
                        break;
                    }

                    case (int)Equality.Less:
                    {
                        history.AddAction($"Entered number({estimatedNumber}) LESS than expected({ExpectedNumber})");
                        Console.WriteLine($"\tYour entered number LESS than expected. You have {Attempts} attempts");
                        break;
                    }

                    case (int)Equality.Equals:
                    {
                        IsWon = true;
                        history.AddAction($"You Won!!");
                        Console.WriteLine("\tCongratulations, you won!");
                        break;
                    }

                    default:
                        break;
                    }
                }
                else
                {
                    ColorEngine.Red();
                    Console.WriteLine("YOU'VE GOT TO ENTER A N_U_M_B_E_R");
                }
            }
            if (!IsWon)
            {
                Console.WriteLine($"Expected number is: {ExpectedNumber}. You loose");
                history.AddAction($"Loooooseee :=(");
            }
            Console.WriteLine();

            TheGame.DataBase.AddHistoryToCurrentAccount(history);
        }