Esempio n. 1
0
 public static void AddSamplePlayersToDb(MafiaContext _context)
 {
     //_context.Rooms.Add(new Models.Room { RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960") });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4955"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Romas", Role = "Mafia"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4956"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Kapitomas", Role = "Mafia"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4957"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Adomas", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4958"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Omas", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4954"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Tomas", Role = "Mafia"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4959"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "Rudas", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4950"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "szudas", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4953"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "yolo", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4952"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "trysdu", Role = "Civil"
     });
     _context.Players.Add(new Models.Player {
         PlayerId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4951"), RoomId = new Guid("49a20b2e-f469-4614-1649-08d7f90d4960"), IsAlive = true, Name = "keturi", Role = "Civil"
     });
     _context.SaveChanges();
 }
Esempio n. 2
0
 public static void AddGameSessionToDb(MafiaContext _context)
 {
     _context.GameSessions.Add(new Models.GameSession()
     {
         GameSessionId = new Guid("49a20b2e - f469 - 4614 - 1649 - 08d7f90d4954"),
         RoomId        = new Guid("49a20b2e - f469 - 4614 - 1649 - 08d7f90d4960"),
         GameTime      = TimeSpan.FromMinutes(1),
         VoteTime      = TimeSpan.FromMinutes(1)
     });
     _context.SaveChanges();
 }
Esempio n. 3
0
        public void UpdateRoomParameters(MafiaContext _context, Class classResponder)
        {
            Guid roomId = new Guid("b7afd4f1-9221-482e-966b-5456ae190100");
            var  room   = _context.Rooms
                          .Where(x => x.RoomId == roomId)
                          .FirstOrDefault();

            room.Name        = classResponder.name;
            room.MafiaAmount = classResponder.mafiaAmount;
            room.CivilAmount = classResponder.civilAmount;
            _context.SaveChanges();
        }
Esempio n. 4
0
        public void KillPlayer(MafiaContext _context)
        {
            var votedPlayerId = _context.Votes
                                .GroupBy(x => x.VotedPlayerId)
                                .OrderByDescending(z => z.Count())
                                .Take(1)
                                .Select(t => t.Key)
                                .FirstOrDefault();

            _context.Players
            .Where(x => x.PlayerId == votedPlayerId)
            .FirstOrDefault()
            .IsAlive = false;
            var votes = _context.Votes.ToList();

            _context.Votes.RemoveRange(votes);
            _context.SaveChanges();
        }