Ejemplo n.º 1
0
        public Task League([Remainder] string summoner)
        {
            var user = GetSummoner(summoner);

            if (user.id == null)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("The summoner does not exist or update the API key").Build()));
            }

            var champResponse = client.GetAsync($"{base_url}/lol/champion-mastery/v4/champion-masteries/by-summoner/{user.id}?api_key={key}");
            var champJson     = champResponse.Result.Content.ReadAsStringAsync().Result;

            List <MasteryModel> masteries = JsonConvert.DeserializeObject <List <MasteryModel> >(champJson);
            var em = new EmbedBuilder()
            {
                Title        = $"{user.name}: Level {user.summonerLevel}",
                ThumbnailUrl = $"http://ddragon.leagueoflegends.com/cdn/{data_version}/img/profileicon/{user.profileIconId}.png",
                Color        = Color.Orange
            };

            for (int i = 0; i < 3; i++)
            {
                string champName = AllChamps.Where(x => x.key == masteries[i].championId).FirstOrDefault().name;
                if (i == 0)
                {
                    em.ImageUrl = $"http://ddragon.leagueoflegends.com/cdn/{data_version}/img/champion/{champName}.png";
                }
                em.AddField($"{champName}: Mastery {masteries[i].championLevel}", $"{String.Format("{0:n0}", masteries[i].championPoints)} points");
            }
            return(ReplyAsync(embed: em.Build()));
        }
Ejemplo n.º 2
0
        public Task StartGame()
        {
            if (game == null)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("You Must Start The Game First").Build()));
            }
            if (game.currentPlayerId != 0)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("The Game Has Already Started").Build()));
            }

            game.table.cards = new List <Card>()
            {
                game.Draw()
            };

            foreach (Player p in game.players)
            {
                var         user  = Context.Guild.GetUser(p.id);
                List <Card> cards = game.Draw(7);
                p.cards = cards;

                var embed = new EmbedBuilder()
                {
                    Title = "Your Cards",
                    Color = Color.Gold
                };

                foreach (Card c in cards)
                {
                    embed.AddField($"Card {cards.IndexOf(c)}", $"{c.value} of {c.suit}");
                }
                user.SendMessageAsync(embed: embed.Build());
            }

            game.currentPlayerId = game.players.FirstOrDefault().id;

            using (StreamWriter file = File.CreateText(deckPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, game);
            }

            var retEmbed = new EmbedBuilder()
            {
                Title        = $"{game.GetCurrentPlayer().name}'s Turn",
                ThumbnailUrl = Context.Guild.GetUser(game.GetCurrentPlayer().id).GetAvatarUrl(),
                ImageUrl     = game.table.cards.FirstOrDefault().GetUrl(),
            };

            foreach (Player p in game.players)
            {
                var user = Context.Guild.GetUser(p.id);
                user.SendMessageAsync(embed: retEmbed.Build());
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        public Task AnimeQuotes([Remainder] string anime = null)
        {
            Random        rand  = new Random();
            MALQuoteModel quote = new MALQuoteModel();

            if (anime == null)
            {
                var response = client.GetAsync("https://animechan.vercel.app/api/random");
                var json     = response.Result.Content.ReadAsStringAsync().Result;
                quote = JsonConvert.DeserializeObject <MALQuoteModel>(json);
            }
            else
            {
                MALAnimeModel animeModel = GetAnimeByName(anime);
                var           response   = client.GetAsync($"https://animechan.vercel.app/api/quotes/anime?title={anime}");
                var           json       = response.Result.Content.ReadAsStringAsync().Result;
                if (json.Contains("No related quotes found!"))
                {
                    response = client.GetAsync($"https://animechan.vercel.app/api/quotes/anime?title={animeModel.title}");
                    json     = response.Result.Content.ReadAsStringAsync().Result;
                }
                if (json.Contains("No related quotes found!"))
                {
                    return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("Typed Anime Wrong/Could Not Find One").Build()));
                }
                List <MALQuoteModel> quotes = JsonConvert.DeserializeObject <List <MALQuoteModel> >(json);
                quote = quotes[rand.Next(0, quotes.Count)];
            }

            quote.counter = 5;

            using (StreamWriter file = File.CreateText(answerPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, quote);
            }

            var embed = new EmbedBuilder()
            {
                Title       = "Anime Quote Game",
                Description = quote.quote,
                Color       = Color.Gold,
            };

            return(ReplyAsync(embed: embed.Build()));
        }
Ejemplo n.º 4
0
        public Task Join()
        {
            if (game.currentPlayerId != 0)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("The Game Has Already Started").Build()));
            }
            if (game == null)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("You Must Start The Game First").Build()));
            }

            if (game.players.Where(x => x.name == Context.User.Username).FirstOrDefault() == null)
            {
                game.players.Add(new Player()
                {
                    id   = Context.User.Id,
                    name = Context.User.Username
                });
            }
            else
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("You're Already in The Game").Build()));
            }

            using (StreamWriter file = File.CreateText(deckPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, game);
            }

            var embed = new EmbedBuilder()
            {
                Title = "Game Set-Up",
                Color = Color.Purple,
            };

            for (int i = 0; i < game.players.Count; i++)
            {
                embed.AddField($"Player {i + 1}", game.players[i].name);
            }
            return(ReplyAsync(embed: embed.Build()));
        }
Ejemplo n.º 5
0
        public Task Draw()
        {
            if (game.IsGameFinished)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("The Game is already Over").Build()));
            }
            if (game.deck.Count <= 0)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("Out of Cards").Build()));
            }

            var    user   = Context.User;
            Player player = game.players.Where(x => x.id == user.Id).FirstOrDefault();

            if (user.Id != game.currentPlayerId)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("It is not your turn yet!").Build()));
            }

            Card drewCard = game.Draw();

            player.cards.Add(drewCard);
            var embed = new EmbedBuilder()
            {
                Title = "Your Cards",
                Color = Color.Gold
            };

            foreach (Card c in player.cards)
            {
                embed.AddField($"Card {player.cards.IndexOf(c)}", $"{c.value} of {c.suit}");
            }

            using (StreamWriter file = File.CreateText(deckPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, game);
            }

            return(user.SendMessageAsync(text: $"You Drew a **{drewCard.value} of {drewCard.suit}**", embed: embed.Build()));
        }
Ejemplo n.º 6
0
        public Task Submit(int index = -1)
        {
            if (game.IsGameFinished)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("The Game is already Over").Build()));
            }
            var user  = Context.User;
            var guild = Context.Client.GetGuild(game.currentGuildId);

            if (user.Id != game.currentPlayerId)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("It is not your turn yet!").Build()));
            }

            Player userPlayer = game.players.Where(x => x.id == user.Id).FirstOrDefault();

            if (index > userPlayer.cards.Count - 1 || index < 0)
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("Wrong Index").Build()));
            }

            Card chosenCard = userPlayer.cards[index];
            Card tableCard  = game.table.cards.FirstOrDefault();

            if (chosenCard == null || !(chosenCard.suit == tableCard.suit || chosenCard.value == tableCard.value))
            {
                return(ReplyAsync(embed: InfoModule.GetErrorEmbed().WithDescription("Card did not match the table").Build()));
            }

            game.table.cards[game.table.cards.IndexOf(tableCard)] = chosenCard;
            userPlayer.cards.Remove(chosenCard);

            if (userPlayer.cards.Count == 0)
            {
                var wonEmbed = new EmbedBuilder()
                {
                    Title    = $":crown: {userPlayer.name} :crown:",
                    Color    = Color.Green,
                    ImageUrl = Context.Client.GetGuild(game.currentGuildId).GetUser(userPlayer.id).GetAvatarUrl()
                };
                foreach (Player p in game.players)
                {
                    var won = guild.GetUser(p.id);
                    won.SendMessageAsync(embed: wonEmbed.Build());
                }
                return(Task.CompletedTask);
            }

            Player newPlayer = game.players[(game.players.IndexOf(userPlayer) + 1) % game.players.Count];

            game.currentPlayerId = newPlayer.id;

            using (StreamWriter file = File.CreateText(deckPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, game);
            }

            var userEmbed = new EmbedBuilder()
            {
                Title = "Your Cards",
                Color = Color.Gold,
            };

            foreach (Card c in userPlayer.cards)
            {
                userEmbed.AddField($"Card {userPlayer.cards.IndexOf(c)}", $"{c.value} of {c.suit}");
            }
            user.SendMessageAsync(embed: userEmbed.Build());


            var embed = new EmbedBuilder()
            {
                Title        = $"{newPlayer.name}'s Turn",
                ThumbnailUrl = guild.GetUser(newPlayer.id).GetAvatarUrl(),
                ImageUrl     = chosenCard.GetUrl(),
            };

            foreach (Player p in game.players)
            {
                var update = guild.GetUser(p.id);
                update.SendMessageAsync(embed: embed.Build());
            }

            return(Task.CompletedTask);
        }