Exemplo n.º 1
0
        private async Task HandleAdventureResultAsync(Cat cat, AdventureEntry adventureEntry)
        {
            var adventure = _adventureRepository.FindByAdventureRef(adventureEntry.AdventureRef);

            var owner = await _ownerRepository.FindAsync(cat.OwnerId);

            var reward = adventure.GetReward();
            var item   = await _itemRepository.FindByItemRefAsync(reward.ItemRef);

            cat.ApplyStatModifiers(adventure.StatGain);
            owner.GiveItem(reward.ItemRef, reward.Quantity);

            var user = await _discordClient.GetUserAsync(Convert.ToUInt64(owner.AuthorId));

            var guild = ((DiscordSocketClient)_discordClient).Guilds.FirstOrDefault(i => i.Users.Any(j => j.Id == user.Id));

            // TODO: For now we select the default channel. Replace with configurable channel
            var channel = guild.GetTextChannel(guild.DefaultChannel.Id);

            var embed = CatSheet.GetRewardSheet(owner, cat, adventure, item, reward);
            await channel.SendMessageAsync(string.Empty, embed : embed);

            ////await channel.SendMessageAsync($"{cat.Name} got {reward.Quantity} {item.Name}!");
        }