private void Add(MatchCard match, bool left, int nRegisteredBoards) { var club = left ? match.Left : match.Right; if (!_stats.TryGetValue(club.Name, out var players)) { players = _stats[club.Name] = new Dictionary <string, PlayerMatches>(); } foreach (var pairing in match.Pairings.Take(nRegisteredBoards)) { Player player = left ? pairing.FirstPlayer : pairing.SecondPlayer; string name = $"{player.FamilyName}, {player.GivenName}"; if (!player.IsDefault && !string.IsNullOrEmpty(player.FamilyName) && !string.IsNullOrEmpty(player.GivenName)) { if (!players.TryGetValue(name, out var played)) { played = players[name] = new PlayerMatches(); } played.Add(match); } } }
public async Task StartAsync(IDialogContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Create the connector client which will be used to make requests for roster and conversation data. var connectorClient = new ConnectorClient(new Uri(context.Activity.ServiceUrl)); // Fetch members of this conversation and data from the current conversation. var members = await connectorClient.Conversations.GetConversationMembersAsync(context.Activity.Conversation.Id); var channelData = context.Activity.GetChannelData <TeamsChannelData>(); var bot = context.Activity.Recipient; // Create the match and initial results. var matchResults = members.Select(member => new MatchResult { User = member, Choice = Choices.None }); var match = new Match { SessionId = Guid.NewGuid(), Results = matchResults.ToArray() }; // Build the result card message var resultCard = new ResultCard(match.Results); var resultMessage = context.MakeMessage(); resultMessage.Attachments.Add(resultCard.ToAttachment()); // Keep track of this message so that we can update it later. var resource = await connectorClient.Conversations.ReplyToActivityAsync((Activity)resultMessage); match.MessageId = resource.Id; context.ConversationData.SetValue(match.SessionId.ToString(), match); // For each member, create the conversation and send the greetings message foreach (var member in members) { // Build the 1:1 conversation parameters var parameters = new ConversationParameters { Bot = bot, Members = new ChannelAccount[] { member }, ChannelData = new TeamsChannelData { Tenant = channelData.Tenant } }; // Create the conversation. If the bot has never talked to the user before this conversation will not exist; this ensures that the conversation exists. var conversationResource = await connectorClient.Conversations.CreateConversationAsync(parameters); // Create and send the response message. var message = Activity.CreateMessageActivity(); message.From = bot; message.Conversation = new ConversationAccount(id: conversationResource.Id); // Ensure that the match card has the conversation Id and the session Id to be able to pull up and update the appropriate data later. var matchCard = new MatchCard(context.Activity.Conversation.Id, match.SessionId); message.Attachments.Add(matchCard.ToAttachment()); await connectorClient.Conversations.SendToConversationAsync((Activity)message); } context.Done <object>(null); }
protected override void CreateButtons() { _currentAlbum = _albumData.AlbumList[_albumNumber]; _titleText.text = _currentAlbum.Title.ToUpper() + "\n" + "[TRACK LIST]"; if (!_isQuiz) { _trackGroups.spacing = 10; for (var i = 0; i < _currentAlbum.TrackList.Count; i++) { /*var title = Instantiate(_trackTitle, _trackGroups); * title.SetText("0" + (i + 1) + "\n" + _currentAlbum.TrackList[i].Title); * title.Evt_Reveal();*/ var button = Instantiate(_simpleButton, _trackGroups.transform); var buttonColors = button.colors; buttonColors.highlightedColor = Color.black; button.colors = buttonColors; button.SetText("0" + (i + 1) + "\n" + _currentAlbum.TrackList[i].Title, 30, _currentAlbum.OutlineColor); var index = i; button.Evt_BasicEvent_Click += () => { StartCoroutine(_trackDisplay.SwitchTrack(_currentAlbum.Title, index)); }; //var trackDisplay = Instantiate(_trackPrefab, _buttonParent); //trackDisplay.SetTrack(_currentAlbum.Title, i); } return; } _trackGroups.spacing = 60; if (_order == null || _order.Count == 0) { _order = new List <int>(); for (int i = 0; i < _currentAlbum.TrackList.Count; i++) { _order.Add(i); } _order = _order.Randomize(); } _groupAnswers = new MatchCard[_order.Count]; for (var i = 0; i < _order.Count; i++) { var button = Instantiate(_simpleButton, _buttonParent, false); button.Index = _order[i]; var buttonColors = button.colors; buttonColors.highlightedColor = _currentAlbum.AlbumColor; button.colors = buttonColors; button.SetText(_currentAlbum.TrackList[_order[i]].Title, 60, _currentAlbum.OutlineColor); button.Evt_CheckMatch = Evt_MatchButton; _groupButtons.Add(button); var title = Instantiate(_trackTitle, _trackGroups.transform); title.SetText("0" + (i + 1) + "\n" + _currentAlbum.TrackList[i]); _groupAnswers[i] = title; } for (var i = 0; i < _albumImages.Length; i++) { if (i == 0) { _albumImages[i].color = _currentAlbum.OutlineColor; } else { _albumImages[i].color = _currentAlbum.AlbumColor; } } }