Exemplo n.º 1
0
        public Pendu()
        {
            mot = new Mot();
            Console.WriteLine(mot.value);
            mot.value = mot.value.ToLower();
            mot.value = Remove.removeAccents(mot.value);
            lifes     = 10;

            guess = "";
            foreach (char c in mot.value)
            {
                guess += "-";
            }
        }
Exemplo n.º 2
0
        private async Task MessageReceived(SocketMessage message)
        {
            if (message.Author.Id == _client.CurrentUser.Id)
            {
                return;
            }

            bool allowedChannel = true;

            foreach (string line in channels)
            {
                if (message.Channel.Id == ulong.Parse(line))
                {
                    allowedChannel = true;
                }
            }

            if (!allowedChannel)
            {
                return;
            }

            if (message.Content.StartsWith("!help"))
            {
                Help help = new Help(message.Content);
                await message.Channel.SendMessageAsync(help.help);
            }

            if (message.Content == "!ping")
            {
                await message.Channel.SendMessageAsync("Raspy Pong!");
            }

            if (message.Content.StartsWith("!mot"))
            {
                Mot mot = new Mot();
                await message.Channel.SendMessageAsync(mot.value);
            }

            if (message.Content == "!wedzcode")
            {
                Humor humor = new Humor();
                await message.Channel.SendMessageAsync(humor.imageUrl);
            }

            if ((message.Content.StartsWith("!pendu") && !gameStarted) || penduStarted)
            {
                if (!penduStarted)
                {
                    penduStarted = true;
                    gameStarted  = true;
                    pendu        = new Pendu();
                    penduDisplay = await message.Channel.SendMessageAsync(pendu.guess);
                }
                else
                {
                    if (message.Content.Length > 1 || !Char.IsLetter(message.Content[0]))
                    {
                        await updatePendu(message, null);
                    }
                    else
                    {
                        string toDisplay = pendu.step(message.Content[0]);
                        await updatePendu(message, toDisplay);

                        await message.DeleteAsync();

                        if (pendu.isFinished || pendu.isWon)
                        {
                            penduStarted = false;
                            gameStarted  = false;
                        }
                    }
                }
            }

            if ((message.Content == "!morpion" && !gameStarted) || morpionStarted)
            {
                if (!morpionStarted)
                {
                    if (j1 == null)
                    {
                        j1 = new MorpionPlayer(message.Author.Username, 1);
                    }
                    else
                    {
                        j2             = new MorpionPlayer(message.Author.Username, 2);
                        gameStarted    = true;
                        morpionStarted = true;
                        morpion        = new Morpion(j1, j2);
                        await message.Channel.SendMessageAsync("Jouer avec le pavé numérique (en haut à droite => 9)");

                        morpionDisplay = await message.Channel.SendMessageAsync(morpion.display());
                    }
                }
                else
                {
                    int  n         = 0;
                    bool isNumeric = int.TryParse(message.Content, out n);

                    if (!isNumeric || n < 1 || n > 9)
                    {
                        await updateMorpion(message, null);
                    }
                    else
                    {
                        await updateMorpion(message, morpion.step(n, message.Author.Username));

                        await message.DeleteAsync();

                        if (morpion.isWon)
                        {
                            string winner = message.Author.Mention;
                            winner += " a gagné !";
                            await message.Channel.SendMessageAsync(winner);

                            gameStarted    = false;
                            morpionStarted = false;
                            j1             = null;
                            j2             = null;
                        }
                        if (morpion.isEnd)
                        {
                            await message.Channel.SendMessageAsync("Égalité");

                            gameStarted    = false;
                            morpionStarted = false;
                            j1             = null;
                            j2             = null;
                        }
                    }
                }
            }
        }