public Game( GameViewModel Game ) : base() { //Use width and height from GameViewModel this.width = Game.width; this.height = Game.height; //Boxes and Turns should be empty in a new game. Ignore them. this.Boxes = new Collection<Box>(); this.Turns = new Collection<Turn>(); this.Players = new Dictionary<int, Player>(); this.GenerateBoxList(); }
public async Task CreateNewCustomGame( TokenViewModel Token, GameViewModel Game ) { try { var User = await this.VerifyToken( Token ); if ( User != null ) { //Create New Game Game game = new Game(Game); //Add Current User to Game game.AddPlayer(new Player(User.Profile)); //Save Game db.Games.Add(game); await db.SaveChangesAsync(); //Send Game back to client. Clients.Caller.newGame(game); } else { Clients.Caller.error( "Unauthorized Access." ); } } catch ( Exception error ) { Clients.Caller.error( "Exception Occurred: " + error.Message ); } }
public async Task PlayTurn( TokenViewModel Token, GameViewModel Game, TurnViewModel Turn ) { try { var User = await this.VerifyToken( Token ); if ( User != null ) { //todo Create a New Game } else { Clients.Caller.error( "Unauthorized Access." ); } } catch ( Exception error ) { Clients.Caller.error( "Exception Occurred: " + error.Message ); } }