Beispiel #1
0
        public void SaveCurrentGame(MultiplayerGameModel model)
        {
            List <MultiplayerGameModel> hostGamesList = ReadMultiplayerGameFromFile(model.HostPlayer.UserName, false);

            hostGamesList.Add(model);
            SaveMultiplayerGameToFile(hostGamesList);
        }
        /// <summary>
        /// Setting up a new Tic-Tac-Toe game board
        /// </summary>
        private void New_Game()
        {
            PlayerDisplayName_textbox.IsEnabled = true;                                         // Enabels the users DisplayName input

            mpGame = new MultiplayerGameModel();                                                // new instance of my GameModel

            gameLogic.PrepareTheGameboardSymbols(mpGame.GameboardFildsArray, 9, true);          // Creates a new instance of GameSymbolTypes[9] and Explicitly sets all GameSymbolTypes to 'Free'.

            gameLogic.SetAllButtonsContent(Gameboard.Children.Cast <Button>().ToList());        // Clears all 'Content' and changes background color on all buttons inside 'Gameboard'.

            mpGame.HasGameEnded = false;                                                        // resets the gamestatus
        }
Beispiel #3
0
 public GameLogic(string userName, string msg)
 {
     MultiplayerGame = new MultiplayerGameModel()
     {
         HostPlayer = new PlayerModel()
         {
             UserName  = userName,
             ImagePath = imgDict[0],
             NumberOfTryGuessLetter = 0,
             Points       = 0,
             UserInput    = "",
             Word         = GetRandomWord(),
             WrongLetters = ""
         }
     };
 }
Beispiel #4
0
        public MultiplayerGameModel GetHostGameByUserName(string hostUserName, string userName)
        {
            MultiplayerGameModel gameToJoin = ReadMultiplayerGameFromFile(hostUserName, true).FirstOrDefault();

            if (gameToJoin == null)
            {
                return(null);
            }

            MultiplayerGameModel model = gameToJoin;

            model.RivalPlayer = new PlayerModel()
            {
                UserName = userName, Points = 0, Word = gameToJoin.HostPlayer.Word, UserInput = "", WrongLetters = "", NumberOfTryGuessLetter = 0, ImagePath = gameToJoin.HostPlayer.ImagePath
            };
            SaveCurrentGame(model);

            return(model);
        }
Beispiel #5
0
 public MultiplayerGameModel SetMultiplayerGameModelForNewTurn(MultiplayerGameModel model, string userName)
 {
     if (model.HostPlayer.UserName == userName)
     {
         model.RivalPlayer = ReadMultiplayerGameFromFile(userName, true).FirstOrDefault().RivalPlayer;
         if (model.RivalPlayer == null)
         {
             return(model);
         }
         model.HostPlayer = SetPlayerModel(model.HostPlayer);
         SaveCurrentGame(model);
     }
     if (model.RivalPlayer.UserName == userName)
     {
         model.HostPlayer  = ReadMultiplayerGameFromFile(model.HostPlayer.UserName, true).FirstOrDefault().HostPlayer;
         model.RivalPlayer = SetPlayerModel(model.RivalPlayer);
         SaveCurrentGame(model);
     }
     return(model);
 }