コード例 #1
0
        public async Task TaskUpdateGameList()
        {
            await GameHistoryModel.UpdateGameList();

            CustomListViewRecords.Clear();
            if (GameHistoryModel.GamesList != null && GameHistoryModel.GamesList.Count > 0)
            {
                for (int i = 0; i < GameHistoryModel.GamesList.Count; i++)
                {
                    if (GameHistoryModel.GamesList[i].GameState == GameStateEnum.END)
                    {
                        CustomListViewRecords.Add(new GameListElement(GameHistoryModel.GamesList[i]));
                    }
                }
            }
            if (CustomListViewRecords.Count == 0)
            {
                IsCustomListViewVisible           = false;
                IsGameListViewEmptyMessageVisible = true;
            }
            else
            {
                IsCustomListViewVisible           = true;
                IsGameListViewEmptyMessageVisible = false;
            }
        }
コード例 #2
0
        public async void LoadSelectedGame(GameListElement selectedItem)
        {
            if (SelectionMode == 1)
            {
                SelectionMode = 0;
                await GameHistoryModel.GetSelectedGameData(selectedItem.IdGame);

                GameField = new Views.GameField(Game, GameStateInfo, Navigation);
                await Navigation.PushAsync(GameField);

                GameHistoryModel.IsGameStarted = false;
                UpdateGameList();
            }
        }
コード例 #3
0
 public static void writeLine(GameHistoryModel mdl, string path)
 {
     File.WriteAllText(path, mdl.FormatLineForRecordsList);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: youngDevelopman/BlackJack
        static void Main(string[] args)
        {
            Database.SetInitializer <GameHistoryContext>(null);

            Game currentGame;
            GameHistoryContext gameHistoryContext = new GameHistoryContext();

            Console.WriteLine("Do you want to start a new game?");
            Console.WriteLine("Y/N");
            string     input = Console.ReadLine();
            ConsoleKey continueConfirm;

            if (input == "Y" || input == "y")
            {
                // New game registration
                currentGame = new Game();
                HelpMethods.GiveCardsOnStartup(currentGame);
                bool   isContinue = true;
                Player winner     = null;

                while (isContinue)
                {
                    HelpMethods.DisplayCount(currentGame);
                    if (currentGame.Player.Count <= 21)
                    {
                        Console.WriteLine("Do you want to continue this round?");

                        continueConfirm = Console.ReadKey(true).Key;
                        Console.WriteLine();

                        if (continueConfirm == ConsoleKey.Y)
                        {
                            isContinue = true;
                            HelpMethods.GiveCardToPlayer(currentGame.Player);
                        }
                        else
                        {
                            isContinue = false;
                        }
                    }
                    else
                    {
                        HelpMethods.GiveDealerCards(currentGame.Dealer);
                        winner     = HelpMethods.DetectWinner(currentGame);
                        isContinue = false;
                    }
                }

                if (winner == null)
                {
                    HelpMethods.GiveDealerCards(currentGame.Dealer);
                    winner = HelpMethods.DetectWinner(currentGame);
                }

                Console.WriteLine("{0} have won ", winner.Name);

                GameHistoryModel gameHistoryModel = new GameHistoryModel()
                {
                    WinnerCount = winner.Count,
                    WinnerId    = winner.Id,
                    WinnerName  = winner.Name,
                };

                gameHistoryContext.GameHistory.Add(gameHistoryModel);
                gameHistoryContext.SaveChanges();
            }
            else
            {
                Console.WriteLine("Game has ended.");
            }

            Console.ReadKey();
        }
コード例 #5
0
 public GameHistoryDisplayData(INavigation Navigation)
 {
     this.Navigation  = Navigation;
     GameHistoryModel = new GameHistoryModel();
 }