public void StartGame(DTO.Player Host)
        {
            int lst = (from l in dc.PlayerLobbies where l.HostPlayer == Host.PlayerId select l.LobbyId).First();
            //       var play = from p in gamelobbies where p.LobbyId.LobbyId == lst select p;
            var lobName = (from p in dc.Lobbies where p.LobbyId == lst select p.LobbyName).First();

            var update = (from l in dc.PlayerLobbies where l.HostPlayer == Host.PlayerId select l).ToList();

            //static
            DTO.PlayerLobby pl = new DTO.PlayerLobby(Host)
            {
                LobbyId = new DTO.Lobby()
                {
                    LobbyId = lst, LobbyName = lobName.ToString()
                }, IsAwaitingForPlayers = true, StartGame = false
            };

            foreach (var item in update)
            {
                item.IsWaitingForPlayers = false;

                item.StartGame = true;
                //static
                if (pl.Player.Count != 4)
                {
                    AddPlayer("hello");
                    pl.Player.Add(new DTO.Player()
                    {
                        PlayerName = "Hello", AlreadExist = false, PlayerId = GenerateID()
                    });
                }
            }

            //static
            gamelobbies.Add(pl);

            var lobby = from d in gamelobbies where d.LobbyId.LobbyId == lst select d;

            foreach (var item in lobby)
            {
                item.IsAwaitingForPlayers = false;
                item.StartGame            = true;
            }

            #region Game init()

            var gamelob = (from p in gamelobbies where p.HostPlayer.PlayerId == Host.PlayerId select p).Single();

            DTO.PlayerLobby plLobby = ConvertToDTOPlayerLobby(Host, lobby);
            NewGame = new DTO.MonopolyEngine.SingleGame(plLobby);
            NewGame.StartGame();

            #endregion

            dc.SubmitChanges();
        }
        public void StartGame(DTO.Player Host)
        {
            var lst = from l in gamelobbies where l.HostPlayer == Host select new { l.LobbyId.LobbyId };

            var update = (from l in dc.PlayerLobbies where l.LobbyId == lst.Single().LobbyId select l).Single();

            update.IsWaitingForPlayers = false;

            var lobby = from d in gamelobbies where d.HostPlayer == Host select d;

            DTO.PlayerLobby plLobby = ConvertToDTOPlayerLobby(Host, lobby);
            newGame = new DTO.MonopolyEngine.SingleGame(plLobby);

            dc.SubmitChanges();
        }
Ejemplo n.º 3
0
        public static void castPlayerDie(GamePlayer P, SingleGame S)
        {
            if (S.publicState.CurrentPhase != TurnState.EndPhase)
            {
                if (P.MyPlayer.PlayerId == S.publicState.ActivePlayer.PlayerId && S.publicState.DieCast == false)
                {
                    S.publicState.lastDieRoll = DiceRoll();
                    S.publicState.DieCast     = true;
                    int locVal = 0;
                    if (P.IsPrison)
                    {
                        if (S.publicState.lastDieRoll == null)
                        {
                            toJail(P);
                        }
                        else if (S.publicState.lastDieRoll[0] == S.publicState.lastDieRoll[1])
                        {
                            foreach (int value in S.publicState.lastDieRoll)
                            {
                                locVal = locVal + value;
                            }

                            updateLocation(P, locVal);
                        }
                        else
                        {
                            P.PrisonTime++;
                        }
                    }
                    else
                    {
                        if (S.publicState.lastDieRoll != null)
                        {
                            foreach (int value in S.publicState.lastDieRoll)
                            {
                                locVal = locVal + value;
                            }

                            updateLocation(P, locVal);
                        }
                        else
                        {
                            toJail(P);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public static void castPlayerDie(GamePlayer P, SingleGame S)
 {
     if (P.MyPlayer.PlayerId == S.publicState.ActivePlayer.PlayerId && S.publicState.DieCast == false)
     {
         S.publicState.lastDieRoll = DiceRoll();
         S.publicState.DieCast     = true;
         int locVal = 0;
         if (S.publicState.lastDieRoll != null)
         {
             foreach (int value in S.publicState.lastDieRoll)
             {
                 locVal = locVal + value;
             }
             updateLocation(P, locVal);
         }
         else
         {
             toJail(P);
         }
     }
 }
Ejemplo n.º 5
0
        //Start game
        #region GameStart()

        //Start the game
        public void StartGame(DTO.Player Host)
        {
            //select the lobbyid from the playerlobby which hostplayer is Host
            int lst = (from l in dc.PlayerLobbies where l.HostPlayer == Host.PlayerId select l.LobbyId).First();
            //select the lobbyname of the lobby with the same name as lst
            var lobName = (from p in dc.Lobbies where p.LobbyId == lst select p.LobbyName).First();
            //select all playerlobbies from the database whose hostplayer id is the same as the Host's playerID
            var update = (from l in dc.PlayerLobbies where l.HostPlayer == Host.PlayerId select l).ToList();

            //Make a static playerlobby to test it all
            DTO.PlayerLobby pl = new DTO.PlayerLobby(Host)
            {
                LobbyId = new DTO.Lobby()
                {
                    LobbyId = lst, LobbyName = lobName.ToString()
                }, IsAwaitingForPlayers = true, StartGame = false
            };

            foreach (var item in update)
            {
                //the lobby isn't awaiting for players anymore
                item.IsWaitingForPlayers = false;
                //the game is started
                item.StartGame = true;


                //static to see if the count is fout
                while (pl.Player.Count != 4)
                {
                    //add static players until player count is four
                    AddPlayer("hello");
                    pl.Player.Add(new DTO.Player()
                    {
                        PlayerName = "Hello", AlreadExist = false, PlayerId = GenerateID()
                    });
                }
            }

            //static add the playerlobby pl
            gamelobbies.Add(pl);
            //select the lobbyid from the gamelobby
            var lobby = from d in gamelobbies where d.LobbyId.LobbyId == lst select d;

            foreach (var item in lobby)
            {
                //set the bools right
                item.IsAwaitingForPlayers = false;
                item.StartGame            = true;
            }

            //intitiates the game
            #region Game init()
            //get the gamelobby
            //var gamelob = (from p in gamelobbies where p.HostPlayer.PlayerId == Host.PlayerId select p).First();
            //make a playerlobby of the host and the lobby
            DTO.PlayerLobby plLobby = ConvertToDTOPlayerLobby(Host, lobby);
            NewGame = new DTO.MonopolyEngine.SingleGame();
            //Update the players of the game
            NewGame.UpdatePlayers(plLobby);
            //stat the game
            NewGame.StartGame();

            #endregion

            dc.SubmitChanges();
        }