public StartGameErrorDialog(StartGameResult startGameResult) { InitializeComponent(); Translator.TranslateForm(this); switch (startGameResult) { case StartGameResult.EarlyGameExit: mainInstruction.Text = Translator.GetText("EarlyGameExitMainInstruction"); subTitle.Text = Translator.GetText("EarlyGameExitSubtitle"); instruction.Text = Translator.GetText("EarlyGameExitInstruction1") + "\n\n" + Translator.GetText("EarlyGameExitInstruction2") + "\n\n" + Translator.GetText("EarlyGameExitInstruction3"); break; case StartGameResult.Failure: mainInstruction.Text = Translator.GetText("FailureMainInstruction"); subTitle.Text = Translator.GetText("FailureSubtitle"); instruction.Text = Translator.GetText("FailureInstruction1") + "\n\n" + Translator.GetText("FailureInstruction2") + "\n\n" + Translator.GetText("FailureInstruction3"); break; case StartGameResult.PermissionsNeeded: mainInstruction.Text = Translator.GetText("PermissionsNeededMainInstruction"); subTitle.Text = Translator.GetText("PermissionsNeededSubtitle"); instruction.Text = Translator.GetText("PermissionsNeededInstruction1") + "\n\n" + Translator.GetText("PermissionsNeededInstruction2") + "\n\n" + Translator.GetText("PermissionsNeededInstruction3"); break; case StartGameResult.ProfileNotFound: mainInstruction.Text = Translator.GetText("ProfileMissingMainInstruction"); subTitle.Text = Translator.GetText("ProfileMissingSubtitle"); instruction.Text = Translator.GetText("ProfileMissingInstruction1"); break; } }
private void HandleGameStart(StartGameResult startGameResult) { this.Activate(); if (startGameResult == StartGameResult.Success) { return; } using (var dialog = new StartGameErrorDialog(startGameResult)) { dialog.ShowDialog(); } }
public StartGameResult StartGame(Guid playerId) { var player = _playerRepository.GetById(playerId); if (player == null) { throw new NullReferenceException($"Отсутствует пользователь с id = {playerId}"); } var gameTable = _gameTableRepository.GetByOwner(player); if (gameTable == null) { throw new Exception($"Игрок с Id = {playerId} не является создателем игрового стола"); } gameTable.StartNewGame(player); var result = new StartGameResult() { GameTableId = gameTable.Id, MoverId = gameTable.CurrentMover.Id, PlayerCards = new List <PlayerCardsInfo>() }; foreach (var item in gameTable.Players) { var playerCards = gameTable.GetPlayerCards(item.Player.Id); var playerCardsItem = new PlayerCardsInfo() { PlayerId = item.Player.Id, CardsCount = playerCards.Count, Cards = playerCards.Select(c => new PlayingCardDto() { Id = c.Id, Rank = (int)c.Rank, Suit = (int)c.Suit }).ToList() }; result.PlayerCards.Add(playerCardsItem); } return(result); }
private async Task NotifyGameStarted(StartGameResult startGameResult) { foreach (var item in startGameResult.PlayerCards.Where(pc => pc.PlayerId != Context.User.GetUserId())) { if (_userConnectionIdStore.TryGetValue(item.PlayerId, out var connectionId)) { await Clients.Client(connectionId).OnGameStarted(new OnGameStartedParams() { MoverId = startGameResult.MoverId, PlayerCardsInfo = startGameResult.PlayerCards.Select(pc => new PlayerCardsInfoDto() { Cards = item.PlayerId == pc.PlayerId ? pc.Cards : null, CardsCount = pc.CardsCount, PlayerId = pc.PlayerId }).ToList() }); } } }
public StartGameErrorDialog(StartGameResult startGameResult) { InitializeComponent(); Translator.TranslateForm(this); switch (startGameResult) { case StartGameResult.EarlyGameExit: mainInstruction.Text = Translator.GetText("EarlyGameExitMainInstruction"); subTitle.Text = Translator.GetText("EarlyGameExitSubtitle"); instruction.Text = Translator.GetText("EarlyGameExitInstruction1") + "\n\n" + Translator.GetText("EarlyGameExitInstruction2") + "\n\n" + Translator.GetText("EarlyGameExitInstruction3"); break; case StartGameResult.Failure: mainInstruction.Text = Translator.GetText("FailureMainInstruction"); subTitle.Text = Translator.GetText("FailureSubtitle"); instruction.Text = Translator.GetText("FailureInstruction1") + "\n\n" + Translator.GetText("FailureInstruction2") + "\n\n" + Translator.GetText("FailureInstruction3"); break; case StartGameResult.PermissionsNeeded: mainInstruction.Text = Translator.GetText("PermissionsNeededMainInstruction"); subTitle.Text = Translator.GetText("PermissionsNeededSubtitle"); instruction.Text = Translator.GetText("PermissionsNeededInstruction1") + "\n\n" + Translator.GetText("PermissionsNeededInstruction2") + "\n\n" + Translator.GetText("PermissionsNeededInstruction3"); break; case StartGameResult.ProfileNotFound: mainInstruction.Text = Translator.GetText("ProfileMissingMainInstruction"); subTitle.Text = Translator.GetText("ProfileMissingSubtitle"); instruction.Text = Translator.GetText("ProfileMissingInstruction1"); break; } }
public StartGameData Reply(StartGameResult result) { Result = result; return(this); }
private void HandleGameStart(StartGameResult startGameResult) { this.Activate(); if (startGameResult == StartGameResult.Success) return; using (var dialog = new StartGameErrorDialog(startGameResult)) { dialog.ShowDialog(); } }