Пример #1
0
        public async Task CreateGame(ulong invitationId)
        {
            Guid            battleTokenId = Guid.NewGuid();
            InvitationGroup invitation    = _pendingInvitations[invitationId];

            // Update our users in our database:
            await UpdateUser(battleTokenId, invitation.PlayerOneId);
            await UpdateUser(battleTokenId, invitation.PlayerTwoId);

            //Create the game for our dictionary:
            PokeBattleGame gameToAdd = new PokeBattleGame(battleTokenId, _pokemonController, _userController);

            gameToAdd.PlayerOne = new BattlePlayer(invitation.PlayerOneId);
            gameToAdd.PlayerTwo = new BattlePlayer(invitation.PlayerTwoId);
            _games.Add(battleTokenId, gameToAdd);
        }
Пример #2
0
        public async Task SendInviteToPlayer(SocketUser sender, SocketUser receiver)
        {
            if (_pendingPlayers.Contains(sender.Id))
            {
                _pendingPlayers.ToList().ForEach(x => System.Console.WriteLine(x));
                var busyMsg = @"You are currently busy right now. You can cancel your current invitation or game by typing `!cancel`. **Beware**, if you leave the middle of a game, your pokemon will lose experience.";
                await SendPlayerMessage(busyMsg, sender.Id);

                return;
            }
            else if (_pendingPlayers.Contains(receiver.Id))
            {
                var busyMsg = $"**{receiver.Username}** is currently busy at the moment. Try again later!";
                await SendPlayerMessage(busyMsg, sender.Id);

                return;
            }
            //Send the invitation:
            var message    = EmbeddedMessageUtil.CreateInvitationMessage(_discord.CurrentUser, sender, receiver);
            var invitation = await SendPlayerMessage(message, receiver.Id);

            await invitation.AddReactionAsync(new Emoji("✅"));

            await invitation.AddReactionAsync(new Emoji("❌"));

            //Create an invitation group:
            InvitationGroup invGroup = new InvitationGroup
            {
                PlayerOneId = sender.Id,
                PlayerTwoId = receiver.Id
            };

            _pendingInvitations.Add(invitation.Id, invGroup);
            _pendingPlayers.Add(sender.Id);
            _pendingPlayers.Add(receiver.Id);
        }