Ejemplo n.º 1
0
        public void GameMaker()
        {
            if (HttpContext.Session.GetInt32("GameId") != null)
            {
                return;
            }
            GameState newGame = new GameState();

            newGame.p1Turn     = false;
            newGame.p2Turn     = false;
            newGame.turnNumber = 1;
            // SET PLAYER POPULATIONS
            newGame.p1Population = 100;
            newGame.p2Population = 100;
            dbContext.Add(newGame);
            dbContext.SaveChanges();
            HttpContext.Session.SetInt32("GameId", newGame.GameId);
            System.Console.WriteLine(newGame.GameId);
            System.Console.WriteLine("***************************************************************************");
        }
Ejemplo n.º 2
0
        // Make sure to put in DbContext stuf. I will forget.
        public RedirectToActionResult LoginProcess(string Name)
        {
            // get list of active players
            List <Player> ActivePlayers = dbContext.Players.Where(p => p.IsActive == true).ToList();
            Player        newPlayer     = new Player();

            //We can't have more than 2 active players
            if (ActivePlayers.Count > 2)
            {
                System.Console.WriteLine("We can't handle this!");
                return(RedirectToAction("EndGame"));
            }
            // Set player state to player 1 or player 2
            if (ActivePlayers.Count > 0 && ActivePlayers.Count < 2)
            {
                newPlayer.PlayerState = 2;
            }
            else
            {
                newPlayer.PlayerState = 1;
            }
            // Build rest of DBEntry
            newPlayer.IsActive = true;
            newPlayer.Name     = Name;
            HttpContext.Session.SetInt32("PlayerState", newPlayer.PlayerState);
            newPlayer.CreatedAt = DateTime.Now;
            newPlayer.UpdatedAt = DateTime.Now;
            // newPlayer.PlayerState
            dbContext.Add(newPlayer);
            // create debugger instance
            LightYearDebugger CombatLog = new LightYearDebugger();

            CombatLog.P1_Total_Ship_Kills = 0;
            CombatLog.P2_Total_Ship_Kills = 0;
            CombatLog.P1_Total_Pop_Lost   = 0;
            CombatLog.P2_Total_Pop_Lost   = 0;
            CombatLog.Total_Ships_Lost    = 0;
            CombatLog.Total_Pop_Lost      = 0;
            dbContext.Add(CombatLog);
            HttpContext.Session.SetInt32("CombatLogId", CombatLog.LightYearDebuggerId);
            Console.WriteLine(")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))");
            Console.WriteLine($"CombatLog ID: {HttpContext.Session.GetInt32("CombatLogId")}");
            Console.WriteLine(")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))");
            dbContext.SaveChanges();
            return(RedirectToAction("Lobby", "Home"));
        }