public GameSetup(int playUntilPoints, int expectedNumberOfPlayers, GameMode gameMode, string password, TypeOfDeck typeOfDeck) { Id = Guid.NewGuid().ToString(); PlayUntilPoints = playUntilPoints; ExpectedNumberOfPlayers = expectedNumberOfPlayers; GameMode = gameMode; Password = password; TypeOfDeck = typeOfDeck; }
public async Task UpdateGame(string gameId, int playUntilPoints, int expectedNumberOfPlayers, GameMode gameMode, TypeOfDeck typeOfDeck, string password) { var game = _games.FirstOrDefault(x => x.GameSetup.Id == gameId); if (game == null) { return; } if (game.GameStarted) { return; } var user = _users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId); if (user == null) { return; } if (game.Players.First().User != user) { return; } game.GameSetup.Password = password; game.GameSetup.ExpectedNumberOfPlayers = expectedNumberOfPlayers; game.GameSetup.GameMode = gameMode; game.GameSetup.PlayUntilPoints = playUntilPoints; game.GameSetup.TypeOfDeck = typeOfDeck; await GameUpdated(game); await UpdateAllGames(); }
public async Task CreateGame(int playUntilPoints, int expectedNumberOfPlayers, GameMode gameMode, TypeOfDeck typeOfDeck, string password) { await CleanupUserFromGames(); var user = _users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId); var gameSetup = new GameSetup(playUntilPoints, expectedNumberOfPlayers, gameMode, password, typeOfDeck); var game = new Game(gameSetup); game.Players.Add(new Player(user)); _games.Add(game); await GameUpdated(game); await UpdateAllGames(); await SendMessageToAllChat("Server", $"User {user.Name} has created new game", TypeOfMessage.Server); }
public Card(CardColor color, CardNumber number, TypeOfDeck typeOfDeck) { Color = color; Number = number; ImageUrl = $"/images/{(int)typeOfDeck}/{(int)color}/{(int)number}.jpg"; }