示例#1
0
        public ActionResult Create()
        {
            var game = new Game();
            context.Insert(game);

            return RedirectToAction("Index", "Game", new { gameId = game.Id });
        }
示例#2
0
文件: Game.cs 项目: JustynaJuza/Magic
 // Constructor with number of players.
 public GameViewModel(Game game, int playerCount)
     : this(game)
 {
     PlayerCapacity = playerCount;
 }
示例#3
0
 private void UpdateUserStatuses(Game game)
 {
     if (game.Observers != null)
     {
         foreach (var observer in game.Observers)
         {
             var user = context.Users.Find(observer.Id);
             user.Status = UserStatus.Observing;
             context.InsertOrUpdate(user, true);
         }
     }
     foreach (var player in game.Players)
     {
         player.User.Status = UserStatus.Playing;
         player.User.Games.Add(new GamePlayerStatus()
         {
             GameId = game.Id,
             UserId = player.User.Id,
             User = player.User,
             Status = GameStatus.InProgress
         });
         context.InsertOrUpdate(player.User);
     }
 }
示例#4
0
文件: Game.cs 项目: JustynaJuza/Magic
 public GameViewModel(Game game)
     : this()
 {
     Id = game.Id;
     IsPrivate = game.IsPrivate;
     PlayerCapacity = game.PlayerCapacity;
     TimePlayed = game.TimePlayed.ToTotalHoursString();
     Players = new List<PlayerViewModel>();
     foreach (var player in game.Players)
     {
         Players.Add((PlayerViewModel)player.Player.GetViewModel());
     }
     Observers = game.Observers.ToList();
 }