Esempio n. 1
0
 public void GetSheet()
 {
     Console.WriteLine($"BingoHub: Requesting sheet for {Id}");
     int[] sheet = BingoService.GetBingoSheet(Context);
     Console.WriteLine("BingoHub: Sending sheet");
     Clients.Caller.SendAsync("Sheet", sheet);
 }
Esempio n. 2
0
 public async void BanUser(string session, string key)
 {
     if (key == CallerKey)
     {
         BingoService.BanUser(session);
     }
 }
Esempio n. 3
0
 public void ValidatePlayerCardboard(Position corn, List <PositionCardboard[, ]> cardboards)
 {
     for (int i = 0; i < cardboards.Count; i++)
     {
         BingoService.ValidateCardboard(corn, cardboards[i]);
         System.Threading.Thread.Sleep(20);
     }
 }
Esempio n. 4
0
        public async void NextRound(string key)
        {
            Console.WriteLine("BingoHub: Requesting next round");
            await Clients.All.SendAsync("StartingNewRound");

            await Task.Delay(10000);

            BingoService.Continue();
        }
Esempio n. 5
0
 public void NewGame(string key)
 {
     if (key == CallerKey)
     {
         Console.WriteLine("BingoHub: Requesting new game");
         BingoService.NewGame();
         Clients.All.SendAsync("StartingNewGame");
     }
 }
Esempio n. 6
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ServiceManager.Instance.Add(typeof(IDialogService), new BingoDialogService());
            IBingoManager client = new BingoService();
            Shell         shell  = new Shell();
            MainPresenter main   = new MainPresenter();

            shell.DataContext = main;
            shell.Show();
        }
Esempio n. 7
0
 public bool ValidatePlayerGame(List <PositionCardboard[, ]> cardboards, int[,] mode)
 {
     foreach (PositionCardboard[,] cardboard in cardboards)
     {
         if (BingoService.ValidateGame(cardboard, mode))
         {
             return(true);
         }
         System.Threading.Thread.Sleep(20);
     }
     return(false);
 }
Esempio n. 8
0
        private void btnGivemeCard_Click(object sender, RoutedEventArgs e)
        {
            BingoService bs = new BingoService(75);

            txtCard.Text = "";
            PositionCardboard[,] cardboard = bs.DealCardboard();

            bool win   = bs.ValidateGame(cardboard, Modes.Corner);
            int  count = 0;

            while (!win && count < 75)
            {
                System.Threading.Thread.Sleep(50);
                Position p = bs.CallPosition();
                bs.ValidateCardboard(p, cardboard);
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (cardboard[j, i].Marked)
                        {
                            Console.BackgroundColor = ConsoleColor.Red;
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write(cardboard[j, i]);
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.Write(cardboard[j, i]);
                        }
                    }
                }
                win = bs.ValidateGame(cardboard, Modes.Corner);
                count++;
            }
            if (win)
            {
                txtStatus.Text = "You Win!!!";
            }
            else
            {
                txtStatus.Text = "Loser";
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            AppLogic appLogic = new AppLogic();

            Console.WriteLine("Nombre del Jugador: ");
            string name   = Console.ReadLine();
            Player player = new Player(name);

            Console.WriteLine("\nInserte la cantidad de fichas: ");
            int          size = int.Parse(Console.ReadLine());
            BingoService bs   = new BingoService(size);

            Console.WriteLine("\nSeleccione el modo de juego: ");
            Console.WriteLine(" 1  - Carton lleno");
            Console.WriteLine(" 2  - 4 esquinas");
            Console.WriteLine(" 3  - H");
            Console.WriteLine(" 4  - X");
            Console.WriteLine(" 5  - 0");
            Console.WriteLine(" 6  - U");
            Console.WriteLine(" 7  - P");
            Console.WriteLine(" 8  - A");
            Console.WriteLine(" 9  - E");
            Console.WriteLine(" 10 - W");
            Console.WriteLine(" 11 - R");
            int modeId = int.Parse(Console.ReadLine());

            int[,] mode = appLogic.SelectMode(modeId);

            Console.WriteLine("\nNumero de cartones: ");
            int numberOfCardboards = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfCardboards; i++)
            {
                player.AddCarboard(bs.DealCardboard());
                System.Threading.Thread.Sleep(20);
            }

            appLogic.PrintPlayerCardboards(player.Cardboards);

            bool win   = appLogic.ValidatePlayerGame(player.Cardboards, mode);
            int  count = 0;

            while (!win && count < size)
            {
                System.Threading.Thread.Sleep(20);
                Position p = bs.CallPosition();
                appLogic.PrintPosition(p);
                appLogic.ValidatePlayerCardboard(p, player.Cardboards);
                appLogic.PrintPlayerCardboards(player.Cardboards);
                win = appLogic.ValidatePlayerGame(player.Cardboards, mode);
                count++;
            }

            Console.WriteLine("--------------------------------------");

            if (win)
            {
                Console.WriteLine($"{player.PlayerName} has ganado!!");
            }
            else
            {
                Console.WriteLine($"{player.PlayerName} has perdido :(");
            }
        }