public async Task Move(IGuildUser user, IGuildUser lol, string[] board, string shape) { int count = 0; while (true) { EnsureFromUserCriterion e = new EnsureFromUserCriterion(user); await SendEmbed(user, "YOUR TURN", "Where do you want to place an '" + shape + "' ? (1 - 9)\nYou ha" + "ve 30 seconds. If you don't answer, you'll automatically lose."); try { string answer = (await NextMessageAsync(e, TimeSpan.FromSeconds(30))).ToString(); try { int a = Convert.ToInt32(answer); } catch { if (count != 1) { await SendEmbed(user, "WHOOPS", "Please type only numbers! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { return; } } } catch { await SendEmbed(user, "RIP", "You didn't answer! You are automatically" + " lose."); await SendEmbed(lol, "YEY", "You win! Your enemy didn't reply!"); return; } } }
public async Task MathBattleCommand(IGuildUser user) { if (!isOnAccount(user.Id)) { await SendEmbed("WHOOPS", "That user doesn't even have a " + "cowboy account!"); return; } else if (UserJoined.Contains(accName(user.Id))) { await SendEmbed("WHOOPS", "That user is battling someone right" + " now! Please wait"); return; } else { await ReplyAsync("Sending request..."); await SendEmbed("Confirmation", "User " + Context.User + " asked you to Math Battle! Type \"accept\" if you accept!", user); try { EnsureFromUserCriterion e = new EnsureFromUserCriterion(user); string answer = (await NextMessageAsync( e, TimeSpan.FromSeconds(30))).ToString(); if (answer.ToLower() == "yes" || answer.ToLower() == "accept") { int yourCount = 0; int enemyCount = 0; for (int i = 1; i <= 5; i++) { Random r = new Random(); int firstNum = r.Next(50, 201), secondNum = r.Next(50, 201), sum = firstNum + secondNum; await SendEmbed("ROUND " + i, "What is " + firstNum + " + " + secondNum + "?", user); await SendEmbed("ROUND " + i, "What is " + firstNum + " + " + secondNum + "?", Context.User as IGuildUser); int count = 0; while (count < 1) { try { var answerMathh = (await NextMessageAsync(false, false, TimeSpan.FromSeconds(30))); if (answerMathh.ToString() == sum.ToString()) { await SendEmbed("Someone Answered!", answerMathh.Author + " answer" + "ed first!", Context.User as IGuildUser); await SendEmbed("Someone Answered!", answerMathh.Author + " answer" + "ed first!", user); if (answerMathh.Author == Context.User) { yourCount++; } if (answerMathh.Author == user) { enemyCount++; } count++; break; } else { answerMathh = (await NextMessageAsync(false, false, TimeSpan.FromSeconds(30))); } } catch { continue; } } } if (enemyCount > yourCount) { await SendEmbed("You lose!", "Go learn more math son", Context. User as IGuildUser); await SendEmbed("You win!", "Nice one mate", user); } else { await SendEmbed("You lose!", "Go learn more math son", user); await SendEmbed("You win!", "Nice one mate", Context.User as IGuildUser); } } else { await SendEmbed("Cancelled", "User " + user + " didn't accept" + " your request.", Context.User as IGuildUser); await SendEmbed("Cancelled", "You declined " + "the request.", user); return; } } catch { await SendEmbed("Cancelled", "User " + user + " didn't accept" + " your request.", Context.User as IGuildUser); await SendEmbed("Cancelled", "You declined " + "the request.", user); return; } } }
public async Task playcard(IGuildUser user) { if (Context.User.ToString() != "kevz#2073") { return; } if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't even have a " + "cowboy account!"); return; } await ReplyAsync("Sending request to " + user.Mention); await user.SendMessageAsync("user " + Context.User + " asked you to play card!" + "\nType \"accept\" if you accept. You have 30 seconds."); EnsureFromUserCriterion eidk = new EnsureFromUserCriterion(user); string targetuseranswer = ""; try { targetuseranswer = (await NextMessageAsync(eidk, TimeSpan.FromSeconds(30))).ToString(); } catch { await Context.User.SendMessageAsync("The user didn't accept your request."); return; } if (targetuseranswer.ToLower() != "accept") { await Context.User.SendMessageAsync("The user didn't accept your request."); return; } else { List <string> yourCard = new List <string>(); List <string> enemyCard = new List <string>(); Random r = new Random(); try { Deck.createDeck(); Deck.Shuffle(Deck.card); } catch { Console.WriteLine("error at making deck"); } string enemyresult = ""; string yourresult = ""; try { int countforloops = 1; for (int i = 1; i <= 5; i++) { Random randforIndex = new Random(); int randomIndex = randforIndex.Next(0, Deck.card.Count); int randomIndex2 = randforIndex.Next(0, Deck.card.Count); if (i <= 4) { yourresult += "[" + countforloops + "] " + Deck.card[randomIndex] + "\n"; Deck.yourCard.Add(Deck.card[randomIndex]); Deck.card.RemoveAt(randomIndex); enemyresult += "[" + countforloops + "] " + Deck.card[randomIndex2] + "\n"; Deck.enemyCard.Add(Deck.card[randomIndex2]); Deck.card.RemoveAt(randomIndex2); } else { yourresult += "[" + countforloops + "] " + Deck.card[randomIndex]; Deck.yourCard.Add(Deck.card[randomIndex]); Deck.card.RemoveAt(randomIndex); enemyresult += "[" + countforloops + "] " + Deck.card[randomIndex2]; Deck.enemyCard.Add(Deck.card[randomIndex2]); Deck.card.RemoveAt(randomIndex2); } countforloops++; } } catch { Console.WriteLine("error at for loops"); await Context.User.SendMessageAsync("Card Game Error. Please try again."); await user.SendMessageAsync("Card Game Error. Please try again."); return; } await Context.User.SendMessageAsync("Your card : \n" + yourresult); await user.SendMessageAsync("Your card : \n" + enemyresult); int rand = r.Next(0, Deck.card.Count); string firstCard = Deck.card[rand]; List <string> enemyMatchesCards = Deck.enemyCard; List <string> yourMatchesCards = Deck.yourCard; EnsureFromUserCriterion enemyCriterion = new EnsureFromUserCriterion(user); EnsureFromUserCriterion youCriterion = new EnsureFromUserCriterion(Context.User); Deck.turn t = new Deck.turn(); t = (Deck.turn)r.Next(0, 2); await Context.User.SendMessageAsync("First Card is : " + firstCard); await user.SendMessageAsync("First Card is : " + firstCard); if (t == enemy) { string str2 = firstCard.Substring(firstCard.IndexOf(" ") + 1); bool enemyFound = false; try { foreach (string s in Deck.enemyCard) { string str1 = s.Substring(s.IndexOf(" ") + 1); if (s.Substring(s.IndexOf(" ", s.IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { enemyFound = true; } } } catch { Console.WriteLine("error at foreachloops"); } if (!enemyFound) { await user.SendMessageAsync("You took " + firstCard + " because you don't have that type of card!"); await Context.User.SendMessageAsync("Your enemy took the " + firstCard + "!"); t = you; } else { string result = ""; int count = 1; for (int i = 0; i < 5; i++) { if (Deck.enemyCard[i].Substring(Deck.enemyCard[i].IndexOf(" ", Deck.enemyCard[i].IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.enemyCard.IndexOf(Deck.enemyCard[i]) + 1) + "] " + Deck.enemyCard[i] + "\n"; enemyMatchesCards.Add(Deck.enemyCard[i]); count++; } } await user.SendMessageAsync("Which card would you like to use?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int removeCards = 0; try { removeCards = Convert.ToInt32((await NextMessageAsync(enemyCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await user.SendMessageAsync("You didn't put number! Your card is removed by default."); Random idk = new Random(); removeCards = 69420; int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); } if (removeCards != 69420) { if (Deck.enemyCard[removeCards - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await user.SendMessageAsync("You removed " + Deck.enemyCard[removeCards - 1] + "\nWaiting for opponent..."); await Context.User.SendMessageAsync("Your enemy removed " + Deck.enemyCard[removeCards - 1] + "!"); Deck.enemyCard.Remove(Deck.enemyCard[removeCards - 1]); } else { await user.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); } } } t = you; } else { string str2 = firstCard.Substring(firstCard.IndexOf(" ") + 1); bool enemyFound = false; try { foreach (string s in Deck.yourCard) { string str1 = s.Substring(s.IndexOf(" ") + 1); if (s.Substring(s.IndexOf(" ", s.IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { enemyFound = true; } } } catch { Console.WriteLine("error at foreachloops"); } if (!enemyFound) { await Context.User.SendMessageAsync("You took " + firstCard + " because you don't have that type of card!"); await user.SendMessageAsync("Your enemy took the " + firstCard + "!"); t = you; } else { string result = ""; int count = 1; for (int i = 0; i < 5; i++) { if (Deck.yourCard[i].Substring(Deck.yourCard[i].IndexOf(" ", Deck.yourCard[i].IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.yourCard.IndexOf(Deck.yourCard[i]) + 1) + "] " + Deck.yourCard[i] + "\n"; yourMatchesCards.Add(Deck.yourCard[i]); count++; } } await Context.User.SendMessageAsync("Which card would you like to hit?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int removeCards = 0; try { removeCards = Convert.ToInt32((await NextMessageAsync(youCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await Context.User.SendMessageAsync("You didn't put number! Your card is removed by default."); Random idk = new Random(); removeCards = 69420; int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await user.SendMessageAsync("Your enemy removed " + randomCard + "!"); await Context.User.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); } if (removeCards != 69420) { if (Deck.yourCard[removeCards - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await Context.User.SendMessageAsync("You removed card " + Deck.yourCard[removeCards - 1]); await user.SendMessageAsync("Your enemy removed " + Deck.yourCard[removeCards - 1] + "!"); yourCard.Remove(yourCard[removeCards - 1]); } else { await Context.User.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await user.SendMessageAsync("Your enemy removed " + randomCard + "!"); await Context.User.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); } } } t = enemy; } if (t == enemy) { string str2 = firstCard.Substring(firstCard.IndexOf(" ") + 1); bool enemyFound = false; try { foreach (string s in Deck.enemyCard) { string str1 = s.Substring(s.IndexOf(" ") + 1); if (s.Substring(s.IndexOf(" ", s.IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { enemyFound = true; } } } catch { Console.WriteLine("error at foreachloops"); } if (!enemyFound) { await user.SendMessageAsync("You took " + firstCard + " because you don't have that type of card!"); await Context.User.SendMessageAsync("Your enemy took the " + firstCard + "!"); t = you; } else { string result = ""; for (int i = 0; i < 5; i++) { if (Deck.enemyCard[i].Substring(Deck.enemyCard[i].IndexOf(" ", Deck.enemyCard[i].IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.enemyCard.IndexOf(Deck.enemyCard[i]) + 1) + "] " + Deck.enemyCard[i] + "\n"; enemyMatchesCards.Add(Deck.enemyCard[i]); } } await user.SendMessageAsync("It's your turn now!\n" + "Which card would you like to hit?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int removeCards = 0; try { removeCards = Convert.ToInt32((await NextMessageAsync(enemyCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await user.SendMessageAsync("You didn't put number! Your card is removed by default."); Random idk = new Random(); removeCards = 69420; int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); } if (removeCards != 69420) { if (Deck.enemyCard[removeCards - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await user.SendMessageAsync("You removed " + Deck.enemyCard[removeCards - 1]); await Context.User.SendMessageAsync("Your enemy removed " + Deck.enemyCard[removeCards - 1] + "!"); enemyCard.Remove(enemyCard[removeCards - 1]); } else { await user.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); } } } } else { string str2 = firstCard.Substring(firstCard.IndexOf(" ") + 1); bool enemyFound = false; try { foreach (string s in Deck.yourCard) { string str1 = s.Substring(s.IndexOf(" ") + 1); if (s.Substring(s.IndexOf(" ", s.IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { enemyFound = true; } } } catch { Console.WriteLine("error at foreachloops"); } if (!enemyFound) { await Context.User.SendMessageAsync("You took " + firstCard + " because you don't have that type of card!"); await user.SendMessageAsync("Your enemy took the " + firstCard + "!"); t = you; } else { string result = ""; for (int i = 0; i < 5; i++) { if (Deck.yourCard[i].Substring(Deck.yourCard[i].IndexOf(" ", Deck.yourCard[i].IndexOf(" ") + 1) + 1) == firstCard.Substring(firstCard.IndexOf(" ", firstCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.yourCard.IndexOf(Deck.yourCard[i]) + 1) + "] " + Deck.yourCard[i] + "\n"; yourMatchesCards.Add(Deck.yourCard[i]); } } await Context.User.SendMessageAsync("It's your turn now!\n" + "Which card would you like to hit?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int removeCards = 0; try { removeCards = Convert.ToInt32((await NextMessageAsync(youCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await Context.User.SendMessageAsync("You didn't put number! Your card is removed by default."); removeCards = 69420; Random idk = new Random(); int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await user.SendMessageAsync("Your enemy removed " + randomCard + "!"); await Context.User.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); } if (removeCards != 69420) { if (Deck.yourCard[removeCards - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await Context.User.SendMessageAsync("You removed " + Deck.yourCard[removeCards - 1]); await user.SendMessageAsync("Your enemy removed " + Deck.yourCard[removeCards - 1] + "!"); yourCard.Remove(yourCard[removeCards - 1]); } else { await user.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await user.SendMessageAsync("Your enemy removed " + randomCard + "!"); await Context.User.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); } } } } while (Deck.yourCard.Count > 0 && Deck.enemyCard.Count > 0) { string enemyresult2 = ""; string yourresult2 = ""; bool higherY = false; bool higherE = false; int enemycount = 1; int yourcount = 1; yourMatchesCards.Clear(); enemyMatchesCards.Clear(); foreach (string s in Deck.enemyCard) { enemyresult2 += "[" + enemycount + "]" + s + "\n"; enemycount++; } foreach (string s in Deck.yourCard) { yourresult2 += "[" + yourcount + "]" + s + "\n"; yourcount++; } if (t == enemy) { await user.SendMessageAsync("Which card you want to throw to enemy? [WITH NUMBER]\n" + "Your card : \n" + enemyresult2); int removedCard = 0; try { removedCard = Convert.ToInt32((await NextMessageAsync(enemyCriterion, TimeSpan.FromSeconds(30))).Content); } catch { removedCard = 69420; await Context.User.SendMessageAsync("Your enemy is skipped for either " + "not answering or wrong input."); await user.SendMessageAsync("Your turn is skipped now because you either" + " not answering or you typed the wrong input."); t = you; } if (removedCard != 69420) { lastEnemyCard = Deck.enemyCard[removedCard - 1]; Deck.enemyCard.Remove(lastEnemyCard); await Context.User.SendMessageAsync("Your enemy throw " + lastEnemyCard + "!"); await user.SendMessageAsync("You threw " + lastEnemyCard + "!\nWaiting for opponent turn..."); if (Deck.enemyCard.Contains(lastEnemyCard.Substring( lastEnemyCard.IndexOf(" ", lastEnemyCard.IndexOf(" "))) + 1)) { string result = ""; for (int i = 0; i < 5; i++) { if (Deck.enemyCard[i].Substring(Deck.enemyCard[i].IndexOf(" ", Deck.enemyCard[i].IndexOf(" ") + 1) + 1) == lastEnemyCard.Substring(lastEnemyCard.IndexOf(" ", lastEnemyCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.enemyCard.IndexOf(Deck.enemyCard[i]) + 1) + "] " + Deck.enemyCard[i] + "\n"; yourMatchesCards.Add(Deck.enemyCard[i]); } } await Context.User.SendMessageAsync("It's your turn now!\n" + "Which card would you like to hit?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int yourCardN = 0; try { yourCardN = Convert.ToInt32((await NextMessageAsync(youCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await Context.User.SendMessageAsync("You didn't put number or you didn't answer! Your card is removed by default."); yourCardN = 69420; Random idk = new Random(); int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); lastYourCard = yourMatchesCards[h]; } if (yourCardN != 69420) { string str2 = lastEnemyCard.Substring(lastEnemyCard.IndexOf(" ") + 1); if (Deck.yourCard[yourCardN - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await Context.User.SendMessageAsync("You removed " + Deck.yourCard[yourCardN - 1]); await user.SendMessageAsync("Your enemy removed " + Deck.yourCard[yourCardN - 1] + "!"); lastYourCard = Deck.yourCard[yourCardN - 1]; Deck.yourCard.Remove(Deck.yourCard[yourCardN - 1]); } else { await Context.User.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, yourMatchesCards.Count); string randomCard = yourMatchesCards[h]; await user.SendMessageAsync("Your enemy removed " + randomCard + "!"); await Context.User.SendMessageAsync("You removed " + randomCard + " as default."); Deck.yourCard.Remove(yourMatchesCards[h]); lastYourCard = yourMatchesCards[h]; } } } else { await Context.User.SendMessageAsync("You took the " + lastEnemyCard + " because you don't have!"); await user.SendMessageAsync("Your enemy took the " + lastEnemyCard + "!"); Deck.yourCard.Add(lastEnemyCard); t = enemy; higherY = true; } if (rarity(lastYourCard.Substring(0, lastYourCard.IndexOf(" "))) > rarity(lastEnemyCard.Substring(0, lastEnemyCard.IndexOf(" "))) && !higherY) { t = you; } else { t = enemy; } } } else { await Context.User.SendMessageAsync("Which card you want to throw to enemy? [WITH NUMBER]\n" + "Your card : \n" + yourresult2); int removedCard = 0; try { removedCard = Convert.ToInt32((await NextMessageAsync(youCriterion, TimeSpan.FromSeconds(30))).Content); } catch { removedCard = 69420; await user.SendMessageAsync("Your enemy is skipped for either " + "not answering or wrong input."); await Context.User.SendMessageAsync("Your turn is skipped now because you either" + " not answering or you typed the wrong input."); t = enemy; } if (removedCard != 69420) { lastYourCard = Deck.yourCard[removedCard - 1]; await user.SendMessageAsync("Your enemy throw " + lastYourCard + "!"); await Context.User.SendMessageAsync("You threw " + lastYourCard + "!\nWaiting for opponent turn..."); if (Deck.enemyCard.Contains(lastYourCard.Substring( lastYourCard.IndexOf(" ", lastYourCard.IndexOf(" "))) + 1)) { string result = ""; for (int i = 0; i < 5; i++) { if (Deck.enemyCard[i].Substring(Deck.enemyCard[i].IndexOf(" ", Deck.enemyCard[i].IndexOf(" ") + 1) + 1) == lastYourCard.Substring(lastYourCard.IndexOf(" ", lastYourCard.IndexOf(" ") + 1) + 1)) { result += "[" + (Deck.enemyCard.IndexOf(Deck.enemyCard[i]) + 1) + "] " + Deck.enemyCard[i] + "\n"; enemyMatchesCards.Add(Deck.yourCard[i]); } } await user.SendMessageAsync("It's your turn now!\n" + "Which card would you like to hit?" + "\n**__PLEASE CHOOSE BY NUMBER!__**\n Matches" + " type of cards : \n" + result); int yourCardN = 0; try { yourCardN = Convert.ToInt32((await NextMessageAsync(enemyCriterion, TimeSpan.FromSeconds(30))).Content); } catch { await user.SendMessageAsync("You didn't put number or you didn't answer! Your card is removed by default."); yourCardN = 69420; Random idk = new Random(); int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); } if (yourCardN != 69420) { string str2 = lastYourCard.Substring(lastYourCard.IndexOf(" ") + 1); if (Deck.enemyCard[yourCardN - 1].Contains(str2.Substring(str2.IndexOf("f") + 2))) { await user.SendMessageAsync("You removed " + Deck.enemyCard[yourCardN - 1]); await Context.User.SendMessageAsync("Your enemy removed " + Deck.enemyCard[yourCardN - 1] + "!"); lastEnemyCard = enemyCard[yourCardN - 1]; enemyCard.Remove(enemyCard[yourCardN - 1]); } else { await user.SendMessageAsync("The type of that card is different!"); Random idk = new Random(); int h = idk.Next(0, enemyMatchesCards.Count); string randomCard = enemyMatchesCards[h]; await Context.User.SendMessageAsync("Your enemy removed " + randomCard + "!"); await user.SendMessageAsync("You removed " + randomCard + " as default."); Deck.enemyCard.Remove(enemyMatchesCards[h]); lastEnemyCard = enemyMatchesCards[h]; } } } else { await user.SendMessageAsync("You took the " + lastEnemyCard + " because you don't have!"); await Context.User.SendMessageAsync("Your enemy took the " + lastEnemyCard + "!"); higherE = true; t = you; } if (rarity(lastYourCard.Substring(0, lastYourCard.IndexOf(" "))) > rarity(lastEnemyCard.Substring(0, lastEnemyCard.IndexOf(" "))) && !higherE) { t = you; } else { t = enemy; } } } } if (Deck.enemyCard.Count > 0) { await Context.User.SendMessageAsync("You lose!"); await user.SendMessageAsync("You win!"); } else if (Deck.yourCard.Count > 0) { await user.SendMessageAsync("You lose!"); await Context.User.SendMessageAsync("You win!"); } } }
public async Task hunt() { if (lastHunt(accName(Context.User.Id), 3) == true) { List <string> animal = new List <string>() { "Deer", "Deer", "Deer", "Deer", "Deer", "Gorilla", "Anaconda", "Tapir", "Jaguar", "Lion", "Tiger", "Monkey", "Elephant" }; var user = accName(Context.User.Id); int attackAbility = 0; int healthincrease = 0; if (player_body(user) == 2) { healthincrease = 100; } if (player_hand(user) == 2) { attackAbility = 30; } if (player_body(user) == 3) { healthincrease = 250; } if (player_hand(user) == 3) { attackAbility = 70; } // variable turn t = new turn(); int rand = r.Next(0, 2); // Program Setup int round = 1; // user info yhealth = r.Next(700, 1001) + healthincrease; yattack = 50; // enemy info ehealth = r.Next(600, 901); eattack = 50; switch (rand) { case 0: t = turn.enemy; break; case 1: t = turn.you; break; } string enemyLogs = ""; while (ehealth > 0 && yhealth > 0) { eattack += round + r.Next(11, 21) + r.Next(1, 5); yattack += round + r.Next(11, 21) + attackAbility; if (t == turn.you) { if (round == 1) { EmbedBuilder e = new EmbedBuilder(); e.AddField("GOGOGO", "Player Body : " + getClothesName("pb", player_body(user)) + "\n" + "Player Hand : " + getClothesName("ph", player_hand(user)) + "\n" + "Your health : " + yhealth + "\n" + "Enemy health : " + ehealth + "\n" + "\nWhat will you do?\n[1] Attack\n[2] Heal\n[3] Surrender") .WithAuthor("You are in the first turn, " + Context.User + "!\n") .WithColor(rr, g, b) .WithFooter("Bot made by kevz#2073") .WithCurrentTimestamp(); await ReplyAsync("", false, e.Build()); /*await ReplyAsync(enemyLogs + "You are in the first turn!\n" + * "Player Body : " + getClothesName("pb", player_body(user)) + "\n" + * "Player Hand : " + getClothesName("ph", player_hand(user)) + "\n" + * "Your health : " + yhealth + "\n" + * "Enemy health : " + ehealth + "\n" + * "\nWhat will you do?\n[1] Attack\n[2] Heal\n[3] Surrender");*/ } else { EmbedBuilder e = new EmbedBuilder(); e.AddField(enemyLogs, "Player Body : " + getClothesName("pb", player_body(user)) + "\n" + "Player Hand : " + getClothesName("ph", player_hand(user)) + "\n" + "Your health : " + yhealth + "\n" + "Enemy health : " + ehealth + "\n" + "\nWhat will you do?\n[1] Attack\n[2] Heal\n[3] Surrender") .WithAuthor("It Is " + Context.User + " Turn!\n") .WithColor(rr, g, b) .WithFooter("Bot made by kevz#2073") .WithCurrentTimestamp(); await ReplyAsync("", false, e.Build()); /*await ReplyAsync(enemyLogs + "\nIt is your turn!\n" + * "Player Body : " + getClothesName("pb", player_body(user)) + "\n" + * "Player Hand : " + getClothesName("ph", player_hand(user)) + "\n" + * "Your health : " + yhealth + "\n" + * "Enemy health : " + ehealth + "\n" + * "\nWhat will you do?\n[1] Attack\n[2] Heal\n[3] Surrender");*/ } t = turn.enemy; string answer = (await NextMessageAsync(true, true, TimeSpan.FromSeconds(60))).ToString().ToLower(); if (answer == null) { answer = "1"; } if (answer == "1" || answer.Contains("att")) { ehealth -= yattack + r.Next(1, 51); if (ehealth <= 0) { ehealth = 0; } } else if (answer == "2" || answer.Contains("heal")) { if (yhealth > 800) { await ReplyAsync("Your health is more than 80 % !\n" + "Your choice is become attack automatically."); ehealth -= yattack + r.Next(1, 51); } else { yincreaseHealth(); } } else if (answer == "3" || answer.Contains("surre")) { yhealth = 0; break; } round++; } else { if (round == 1) { await ReplyAsync("The enemy got the first place!"); if (ehealth > (ehealth * 2) / 5) { int asd = eattack + r.Next(1, 51); yhealth -= asd; enemyLogs = "The enemy used attack on you with power **" + asd + "**!\n"; if (yhealth <= 0) { yhealth = 0; } } else { enemyLogs = "The enemy increased his health by "; int nowhealth = ehealth; eincreaseHealth(); enemyLogs += (ehealth - nowhealth) + "!"; } } else { await ReplyAsync("It's enemy turn now!"); if (ehealth > (ehealth * 2) / 5) { int asd = eattack + r.Next(1, 51); yhealth -= asd; enemyLogs = "The enemy used attack on you with power **" + asd + "**!\n"; if (yhealth <= 0) { yhealth = 0; } } else { enemyLogs = "The enemy increased his health by "; int nowhealth = ehealth; eincreaseHealth(); enemyLogs += (ehealth - nowhealth) + "!"; } } t = turn.you; round++; } } if (ehealth == 0) { string animals = animal[r.Next(0, 13)]; int coinsPrize = 10 * r.Next(1, 6); EmbedBuilder e = new EmbedBuilder(); e.AddField("You Win!", "Hello " + Context.User + "! You got " + animals + " and you sold it for " + coinsPrize + " coins!") .WithAuthor("Hooray!\n") .WithColor(rr, g, b) .WithFooter("Bot made by kevz#2073") .WithCurrentTimestamp(); await ReplyAsync("", false, e.Build()); //await ReplyAsync("**YOU WIN!**\n" + "You got " + animals + " and you sold it for " + coinsPrize + " coins!"); string path = File.ReadAllText(@"database\account\" + user + ".json"); dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(path); jsonObj["coins"] += coinsPrize; string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); File.WriteAllText(@"database\account\" + user + ".json", output); EnsureFromUserCriterion ensure = new EnsureFromUserCriterion(Context.User); var a = await NextMessageAsync(); } else { string animals = animal[r.Next(0, 13)]; EmbedBuilder e = new EmbedBuilder(); e.AddField("You Lose!", "Hello " + Context.User + "! You weren't able to fight " + animals + "! You decided to surrender.") .WithAuthor("R.I.P\n") .WithColor(rr, g, b) .WithFooter("Bot made by kevz#2073") .WithCurrentTimestamp(); await ReplyAsync("", false, e.Build()); /*await ReplyAsync("**RIP**\n" + * "You weren't able to fight " + animals + "! You decided to surrender.");*/ } } else { } }
public async Task Duel(IGuildUser user) { if (Context.User == user) { await sey("You can't duel yourself!"); return; } else if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't even have cowboy account!"); } else { if (!lastInviteDuel(accName(Context.User.Id), 2)) { await sey("Please wait 2 minutes to invite someone again.\n" + "We don't want you use this feature to spam someone."); return; } await ReplyAsync("Sending request..."); await see("User " + Context.User + " asked you to play Cowboy Duel!\n" + "Type \"accept\" if u accept it.", user); string AcceptOrNo = ""; try { AcceptOrNo = (await NextMessageAsync(new EnsureFromUserCriterion(user), TimeSpan.FromSeconds(30))).ToString(); } catch { await sey("User " + user + " didn't accept your request."); await see("You didn't accept the request", user); lastInviteDuelTimer.Add(DateTimeOffset.Now); lastInviteDuelTarget.Add(accName(Context.User.Id)); return; } if (AcceptOrNo.ToLower() != "accept") { await sey("User " + user + " didn't accept your request."); await see("You didn't accept the request", user); lastInviteDuelTimer.Add(DateTimeOffset.Now); lastInviteDuelTarget.Add(accName(Context.User.Id)); return; } Random r = new Random(); DuelTurn turn = (DuelTurn)r.Next(0, 2); int round = 1; string yourLogs = ""; string enemyLogs = ""; string enemySurrenderLogs = ""; string yourSurrenderLogs = ""; ydefence = r.Next(10, 21); edefence = r.Next(10, 21); eattack = r.Next(50, 101); yattack = r.Next(50, 101); yhealth = 500; ehealth = 500; while (yhealth > 0 && ehealth > 0) { EnsureFromUserCriterion cuser = new EnsureFromUserCriterion(Context.User); EnsureFromUserCriterion euser = new EnsureFromUserCriterion(user); if (turn == enemy) { if (round == 1) { await see("You are in the first turn!", user); await sey("You are in the second turn!\nW" + "aiting for enemy.."); await see("Your health : " + ehealth + "\n" + "Your attack : " + eattack + "\n" + "Your defence : " + edefence + "\n\n" + "Enemy's health : " + yhealth + "\n" + "Enemy's attack : " + yattack + "\n" + "Enemy's defence : " + ydefence + "\n\n" + "**[1] Attack**\n" + "**[2] Defence**\n" + "**[3] Heal [HEALTH MUST LESS THAN 80%]**\n" + "**[4] Surrender**\n\n" + "What will u choose? [You have 30 seconds]", user); } if (round != 1) { await see(enemyLogs + "\nYour health : " + ehealth + "\n" + "Your attack : " + eattack + "\n" + "Your defence : " + edefence + "\n\n" + "Enemy's health : " + yhealth + "\n" + "Enemy's attack : " + yattack + "\n" + "Enemy's defence : " + ydefence + "\n\n" + "**[1] Attack**\n" + "**[2] Defence**\n" + "**[3] Heal [HEALTH MUST LESS THAN 80%]**\n" + "**[4] Surrender**\n\n" + "What will u choose? [You have 30 seconds]", user); } string answer = ""; try { answer = (await NextMessageAsync(euser, TimeSpan.FromSeconds(30))).ToString(); } catch { await see("You didn't answer in time! Your turn is skipped..", user); yourLogs = "Enemy didn't do anything!"; turn = you; continue; } if (answer == "1" || answer.ToLower().Contains("att")) { int b = r.Next(0, 2); if (b == 0) { int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = (eattack - ydefence); criticalMessage = "[CRITICAL] "; } yhealth -= (eattack - ydefence) + critical; int e = (eattack - ydefence) + critical; if (yhealth <= 0) { yhealth = 0; } yourLogs = criticalMessage + "Enemy used attack on you and caused " + e + " damage!"; await see(criticalMessage + "You attacked the enemy and caused " + e + " damage!", user); } else { await see("You failed to attack the enemy!", user); yourLogs = "Enemy failed to attack you."; } } else if (answer == "2" || answer.ToLower().Contains("def")) { int a = r.Next(1, 3); int b = r.Next(0, 2); if (b == 0) { int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = a; criticalMessage = "[CRITICAL] "; } edefence += a + critical; int e = a + critical; yourLogs = criticalMessage + "Enemy improved the defence by " + e; await see(criticalMessage + "You improved your defence by " + e, user); } else { await see("You failed to improve your defence", user); yourLogs = "Enemy failed to improve his defence!"; } } else if (answer == "3" || answer.ToLower().Contains("heal")) { if (ehealth >= 400) { await see("Your health must under `800` to heal! Skipping turn..", user); turn = you; continue; } else { int b = r.Next(0, 2); if (b == 0) { int a = r.Next(50, 81); int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = a; criticalMessage = "[CRITICAL] "; } ehealth += a + critical; int e = a + critical; yourLogs = criticalMessage + "Enemy healed itself by " + e; await see(criticalMessage + "You healed yourself by " + e, user); } else { yourLogs = "Enemy failed to heal himself!"; await see("You failed to heal yourself!", user); } } } else if (answer == "4" || answer.ToLower().Contains("surrend")) { yourSurrenderLogs = "Enemy surrender-ed !"; ehealth = 0; await see("You surrendered!", user); break; } else { await see("Invalid input! Your turn is skipped!", user); yourLogs = "Enemy did nothing!"; } turn = you; await see("Waiting for your opponent...", user); yattack = r.Next(50, 101); } else { if (round == 1) { await sey("You are in the first turn!"); await see("You are in the second turn!\nW" + "aiting for enemy..", user); await sey("Your health : " + yhealth + "\n" + "Your attack : " + yattack + "\n" + "Your defence : " + ydefence + "\n\n" + "Enemy's health : " + ehealth + "\n" + "Enemy's attack : " + eattack + "\n" + "Enemy's defence : " + edefence + "\n\n" + "**[1] Attack**\n" + "**[2] Defence**\n" + "**[3] Heal [HEALTH MUST LESS THAN 80%]**\n" + "**[4] Surrender**\n\n" + "What will u choose? [You have 30 seconds]"); } if (round != 1) { await sey(yourLogs + "\nYour health : " + yhealth + "\n" + "Your attack : " + yattack + "\n" + "Your defence : " + ydefence + "\n\n" + "Enemy's health : " + ehealth + "\n" + "Enemy's attack : " + eattack + "\n" + "Enemy's defence : " + edefence + "\n\n" + "**[1] Attack**\n" + "**[2] Defence**\n" + "**[3] Heal [HEALTH MUST LESS THAN 80%]**\n" + "**[4] Surrender**\n\n" + "What will u choose? [You have 30 seconds]"); } string answer = ""; try { answer = (await NextMessageAsync(cuser, TimeSpan.FromSeconds(30))).ToString(); } catch { await sey("You didn't answer in time! Your turn is skipped.."); turn = enemy; enemyLogs = "Enemy didn't do anything!"; continue; } if (answer == "1" || answer.ToLower().Contains("att")) { int b = r.Next(0, 2); if (b == 0) { int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = (yattack - edefence); criticalMessage = "[CRITICAL] "; } ehealth -= (yattack - edefence) + critical; int e = (yattack - edefence) + critical; if (ehealth <= 0) { ehealth = 0; } enemyLogs = criticalMessage + "Enemy used attack on you and caused " + e + " damage!"; await sey(criticalMessage + "You attacked the enemy and caused " + e + " damage!"); } else { await sey("You failed to attack the enemy!"); enemyLogs = "Enemy failed to attack you!"; } } else if (answer == "2" || answer.ToLower().Contains("def")) { int a = r.Next(1, 3); int b = r.Next(0, 2); if (b == 0) { int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = a; criticalMessage = "[CRITICAL] "; } ydefence += a + critical; int e = a + critical; enemyLogs = criticalMessage + "Enemy improved the defence by " + e; await sey(criticalMessage + "You improved your defence by " + e); } else { await sey("You failed to improve your defence"); enemyLogs = "Enemy failed to improve his defence!"; } } else if (answer == "3" || answer.ToLower().Contains("heal")) { if (yhealth >= 400) { await sey("Your health must be less than 800 to heal!\n" + "Skipping turn.."); turn = enemy; continue; } else { int b = r.Next(0, 2); if (b == 0) { int a = r.Next(50, 81); int critical = 0; string criticalMessage = ""; if (r.Next(0, 4) == 0) { critical = a; criticalMessage = "[CRITICAL] "; } int e = critical + a; yhealth += a + critical; enemyLogs = criticalMessage + "Enemy healed itself by " + e; await sey(criticalMessage + "You healed yourself by " + e); } else { enemyLogs = "Enemy failed to heal himself"; await sey("You failed to heal yourself!"); } } } else if (answer == "4" || answer.ToLower().Contains("surrend")) { enemySurrenderLogs = "Enemy surrender-ed!"; yhealth = 0; await sey("You surrendered!"); break; } else { await sey("Invalid input! Your turn is skipped!"); enemyLogs = "Enemy didn't do anything!"; } eattack = r.Next(50, 101); turn = enemy; await sey("Waiting for your opponent..."); } round++; } if (yhealth <= 0) { await see(enemySurrenderLogs + "\nYou have won the duel!", user); await sey("You lost the duel.. It's okay.."); int bounty = r.Next(1, 3); await see("You got " + bounty + " bounty points!", user); dynamic j = JsonConvert.DeserializeObject(File.ReadAllText( @"database\account\" + accName(user.Id) + ".json")); j["bounty"] += bounty; string output = JsonConvert.SerializeObject(j, Formatting.Indented); File.WriteAllText(@"database\account\" + accName(user.Id) + ".json", output); JObject haha = JObject.Parse(File.ReadAllText( @"database\account\" + accName(Context.User.Id) + ".json")); if ((int)haha["bounty"] == 0) { bounty = 0; } dynamic jj = JsonConvert.DeserializeObject(File.ReadAllText( @"database\account\" + accName(Context.User.Id) + ".json")); jj["bounty"] -= bounty; string outputj = JsonConvert.SerializeObject(jj, Formatting.Indented); File.WriteAllText(@"database\account\" + accName(Context.User.Id) + ".json", outputj); if (bounty != 0) { await sey("You lost " + bounty + " bounty points!"); } } else if (ehealth <= 0) { await see("You lost the duel.. It's okay..", user); await sey(yourSurrenderLogs + "\nYou have won the duel!"); int bounty = r.Next(1, 3); await sey("You got " + bounty + " bounty points!"); dynamic j = JsonConvert.DeserializeObject(File.ReadAllText( @"database\account\" + accName(Context.User.Id) + ".json")); j["bounty"] += bounty; string output = JsonConvert.SerializeObject(j, Formatting.Indented); File.WriteAllText(@"database\account\" + accName(Context.User.Id) + ".json", output); JObject haha = JObject.Parse(File.ReadAllText( @"database\account\" + accName(user.Id) + ".json")); if ((int)haha["bounty"] == 0) { bounty = 0; } dynamic jj = JsonConvert.DeserializeObject(File.ReadAllText( @"database\account\" + accName(user.Id) + ".json")); jj["bounty"] -= bounty; string outputj = JsonConvert.SerializeObject(jj, Formatting.Indented); File.WriteAllText(@"database\account\" + accName(user.Id) + ".json", outputj); if (bounty != 0) { await see("You lost " + bounty + " bounty points!", user); } } } }
public async Task playrps(IGuildUser user) { if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't have cowboy " + "account! Perhaps, ask him?"); return; } else if (user == Context.User) { await ReplyAndDeleteAsync("You can't trade yourself!", timeout : TimeSpan.FromSeconds(10)); } string isAccept = ""; try { await user.SendMessageAsync("User " + Context.User + " asked you to play **Rock " + "Paper Scissor!** Type anything if you want to accept. If you don't" + " just ignore this messages for 30 seconds."); isAccept = (await NextMessageAsync(new EnsureFromUserCriterion(user), TimeSpan.FromSeconds(30))).ToString(); } catch { await Context.User.SendMessageAsync("The user didn't accept your request."); } EmbedBuilder e = new EmbedBuilder(); e.AddField("Choose!", "\u200b") .WithAuthor("Rock Paper Scissors") .AddField("[1] Rock\n[2] Paper\n[3] Scissors", "You can choose by number or type.") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder ee = new EmbedBuilder(); ee.AddField("Choose!", "\u200b") .AddField("[1] Rock\n[2] Paper\n[3] Scissors", "You can choose by number or type.") .WithAuthor("It's your turn now!") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await Context.User.SendMessageAsync("", false, e.Build()); await user.SendMessageAsync("Wait for your opponent to choose..."); EnsureFromUserCriterion you = new EnsureFromUserCriterion(Context.User); EnsureFromUserCriterion enemy = new EnsureFromUserCriterion(user); string yourChoose = (await NextMessageAsync(you)).ToString(); string[] rps = { "rock", "paper", "scissor" }; string fixedChoose = ""; string fixedChooseEnemy = ""; while (true) { if (yourChoose == "1" || yourChoose.Contains("rock")) { fixedChoose = rps[0]; break; } else if (yourChoose == "2" || yourChoose.Contains("paper")) { fixedChoose = rps[1]; break; } else if (yourChoose == "3" || yourChoose.Contains("sciss")) { fixedChoose = rps[2]; break; } else { await ReplyAsync("Invalid Type! Please choose again."); yourChoose = (await NextMessageAsync(you)).ToString(); } } await user.SendMessageAsync("", false, ee.Build()); await Context.User.SendMessageAsync("Waiting for your opponent to choose..."); string enemyChoose = (await NextMessageAsync(enemy)).ToString(); while (true) { if (enemyChoose == "1" || enemyChoose.Contains("rock")) { fixedChooseEnemy = rps[0]; break; } else if (enemyChoose == "2" || enemyChoose.Contains("paper")) { fixedChooseEnemy = rps[1]; break; } else if (enemyChoose == "3" || enemyChoose.Contains("sciss")) { fixedChooseEnemy = rps[2]; break; } else { await ReplyAsync("Invalid Type! Please choose again"); enemyChoose = (await NextMessageAsync(enemy)).ToString(); } } if (fixedChoose == fixedChooseEnemy) { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("Tie!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eee.Build()); await Context.User.SendMessageAsync("", false, eee.Build()); } else if (fixedChoose == "rock" && fixedChooseEnemy == "paper") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eeee.Build()); await Context.User.SendMessageAsync("", false, eee.Build()); } else if (fixedChoose == "scissor" && fixedChooseEnemy == "paper") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eee.Build()); await Context.User.SendMessageAsync("", false, eeee.Build()); } else if (fixedChoose == "rock" && fixedChooseEnemy == "scissor") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eee.Build()); await Context.User.SendMessageAsync("", false, eeee.Build()); } else if (fixedChoose == "paper" && fixedChooseEnemy == "scissor") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eeee.Build()); await Context.User.SendMessageAsync("", false, eee.Build()); } else if (fixedChoose == "paper" && fixedChooseEnemy == "rock") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eee.Build()); await Context.User.SendMessageAsync("", false, eeee.Build()); } else if (fixedChoose == "scissor" && fixedChooseEnemy == "rock") { EmbedBuilder eee = new EmbedBuilder(); eee.AddField("You lose!", "You choose " + fixedChoose + " and your opponent" + " choose " + fixedChooseEnemy) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); EmbedBuilder eeee = new EmbedBuilder(); eeee.AddField("You Win!", "You choose " + fixedChooseEnemy + " and your opponent" + " choose " + fixedChoose) .WithAuthor("Rock Paper Scissor") .WithFooter("Bot made by kevz#2073") .WithColor(r, g, b) .WithCurrentTimestamp(); await user.SendMessageAsync("", false, eeee.Build()); await Context.User.SendMessageAsync("", false, eee.Build()); } else { Console.WriteLine("Invalid argument at " + fixedChoose + " and " + fixedChooseEnemy); } }
public async Task pcard(IGuildUser user) { if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't even have a " + "cowboy account!"); return; } await ReplyAsync("Sending request to " + user.Mention); await user.SendMessageAsync("user " + Context.User + " asked you to play card!" + "\nType \"accept\" if you accept. You have 30 seconds."); EnsureFromUserCriterion enemyCriterion = new EnsureFromUserCriterion(user); EnsureFromUserCriterion youCriterion = new EnsureFromUserCriterion(Context.User); List <string> yourMatchesCard = new List <string>(); List <string> enemyMatchesCard = new List <string>(); string targetuseranswer = ""; try { targetuseranswer = (await NextMessageAsync(enemyCriterion, TimeSpan.FromSeconds(30))).ToString(); } catch { await Context.User.SendMessageAsync("The user didn't accept your request."); return; } if (targetuseranswer.ToLower() != "accept") { await Context.User.SendMessageAsync("The user didn't accept your request."); return; } else { Random r = new Random(); string yourResult = ""; string enemyResult = ""; try { createDeck(); Deck.Shuffle(card); } catch { Console.WriteLine("error at making deck"); } int countforloops = 1; int round = 1; try { for (int i = 0; i < 5; i++) { int yourRandom = r.Next(0, card.Count); yourCard.Add(card[yourRandom]); yourResult += "[" + countforloops + "] " + card[yourRandom] + "\n"; card.RemoveAt(yourRandom); int enemyRandom = r.Next(0, card.Count); enemyCard.Add(card[enemyRandom]); enemyResult += "[" + countforloops + "] " + card[enemyRandom] + "\n"; card.RemoveAt(enemyRandom); countforloops++; } } catch { Console.WriteLine("error at for loops"); await Context.User.SendMessageAsync("Card Game Error. Please try again later."); await user.SendMessageAsync("Card Game Error. Please try again later."); return; } await sendEmbedToYou("Your card: ", yourResult); await sendEmbedToEnemy("Your card:", enemyResult, user); turn t = enemy; while (enemyCard.Count > 0 && yourCard.Count > 0) { if (round == 1) { if (t == you) { await sendEmbedToEnemy("You are in the second turn!", "Waiting for your opponent...", user); } else { await sendEmbedToYou("You are in the first turn!", "What card would you like to hit?"); } } if (t == you) { } else { } } } }
public async Task Invite(IGuildUser user) { string username = accName(Context.User.Id); JObject j = JObject.Parse(File.ReadAllText(@"database\account\" + username + ".json")); if ((string)j["guild"] != "none") { if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't have cowboy account!"); } else if (user == Context.User) { await ReplyAsync("You can't invite yourself!"); } else { await ReplyAsync("Sending request..."); await user.SendMessageAsync("User " + Context.User + " invited you to his guild!\n" + "Name : " + j["guild"] + "\nType \"accept\" if u want to join!\nYou have 30 seconds."); EnsureFromUserCriterion easd = new EnsureFromUserCriterion(user); string answer = ""; try { answer = (await NextMessageAsync(easd, TimeSpan.FromSeconds(30))).ToString(); } catch { await user.SendMessageAsync("You rejected his request!"); await Context.User.SendMessageAsync("User " + user + " rejected your request."); return; } if (answer.ToLower() == "accept") { try { JObject a = new JObject(); try { Console.WriteLine("lol"); Console.WriteLine("database\\guilds\\" + j["guild"] + ".json"); a = JObject.Parse(File.ReadAllText("database\\guilds\\" + j["guild"] + ".json")); } catch { Console.WriteLine("ERRO AT PART 1"); } try { JObject retard = JObject.Parse(File.ReadAllText("database\\guilds\\" + j["guild"] + ".json")); dynamic k = JsonConvert.DeserializeObject(File.ReadAllText("database\\guilds\\" + j["guild"] + ".json")); JArray myArray = (JArray)retard["member"]; myArray.Add(accName(user.Id) + " [" + user + "]"); File.WriteAllText("database\\guilds\\" + j["guild"] + ".json", retard.ToString()); await user.SendMessageAsync("You accepted his request!"); await Context.User.SendMessageAsync("User " + user + " accepted ur request."); } catch { Console.WriteLine("error part 2"); } } catch { Console.WriteLine("error"); } } else { await user.SendMessageAsync("You rejected his request!"); await Context.User.SendMessageAsync("User " + user + " rejected your request."); return; } } } else { await ReplyAsync("You don't even have a guild!"); } }
/*[Command("tictactoeai",RunMode = RunMode.Async)] * [Alias("playtictactoeai","playai")] * public async Task TicTacToeAI() * { * Round = 0; * string[] MainBoard = CreateBoard(); * await SendBoardAI(MainBoard); * Turn t = Turn.you; * while (!IsFull(MainBoard) && !CheckWinner(MainBoard,"X") && !CheckWinner(MainBoard,"O")) * { * if (t == Turn.you) * { * while (true) * { * await SendEmbedAI("YOUR TURN", "Where do you want to place an 'X' ? (1 - 9)\nYou ha" + * "ve 30 seconds.."); * try * { * string answer1 = (await NextMessageAsync(true,false, TimeSpan.FromSeconds(30))).ToString(); * try * { * int a = Convert.ToInt32(answer1); * if (a > 0 && a < 10) * { * if (MainBoard[a - 1] == " ") * { * MainBoard[a - 1] = "X"; * t = Turn.enemy; * break; * } * else * { * await SendEmbedAI("WHOOPS", "That grid is occupied! If you didn't" + * " reply with the correct format once more you are automatically lose."); * } * } * else * { * await SendEmbedAI("WHOOPS", "Please type numbers from 1 to 10! If you didn't" + * " reply with the correct format once more you are automatically lose."); * } * } * catch * { * await SendEmbedAI("WHOOPS", "Please type only numbers! If you didn't" + * " reply with the correct format once more you are automatically lose."); * } * } * catch * { * await SendEmbedAI("RIP", "You didn't answer! You lose!"); * return; * } * } * await SendBoardAI(MainBoard); * Round++; * } * else * { * try * { * * } * catch (Exception e) { Console.WriteLine(e.Message); } * t = Turn.you; * await SendBoardAI(MainBoard); * Round++; * } * } * * if (IsFull(MainBoard)) * { * await SendEmbedAI("WHOOPS", "TIE!!"); * return; * } * else * { * if(CheckWinner(MainBoard, "X")) * { * await SendEmbedAI("WOWOWOOW", "YOU WIN AGAINTS AI!! CONGRATS!"); * } * else * { * await SendEmbedAI("NOOB","YOU LOSE!"); * } * } * }*/ public async Task EnemyTurn(IGuildUser user, string[] MainBoard) { int count = 0; while (true) { EnsureFromUserCriterion e = new EnsureFromUserCriterion(user); await SendEmbed(user, "YOUR TURN", "Where do you want to place an 'X' ? (1 - 9)\nYou ha" + "ve 30 seconds. If you don't answer, you'll automatically lose."); try { string answer1 = (await NextMessageAsync(e, TimeSpan.FromSeconds(30))).ToString(); try { int a = Convert.ToInt32(answer1); if (a > 0 && a < 10) { if (MainBoard[a - 1] == " ") { MainBoard[a - 1] = "X"; break; } else { if (count != 1) { await SendEmbed(user, "WHOOPS", "That grid is occupied! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } else { if (count != 1) { await SendEmbed(user, "WHOOPS", "Please type numbers from 1 to 10! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } catch //no lag = true; { if (count != 1) { await SendEmbed(user, "WHOOPS", "Please type only numbers! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } catch { await SendEmbed(user, "RIP", "You didn't answer! You are automatically" + " lose."); await SendEmbed(Context.User as IGuildUser, "YEY", "You win! Your enemy didn't reply!"); return; } } }
public async Task TicTacToe(IGuildUser user) { string[] MainBoard = new string[9]; EnsureFromUserCriterion enemy = new EnsureFromUserCriterion(user); if (!isOnAccount(user.Id)) { await ReplyAsync("That user doesn't even have a " + "cowboy account!"); return; } else { await ReplyAsync("Sending request..."); await SendEmbed(user, "REQUEST", "User " + user + " asked " + "you to play `Tic Tac Toe!` type \"accept\" if you want" + " to play!"); try { string answer = (await NextMessageAsync(enemy, TimeSpan.FromSeconds(30))).ToString(); if (answer.ToLower() == "accept" || answer.ToLower() == "yes") { int count = 0; MainBoard = CreateBoard(); await SendBoard(Context.User as IGuildUser, user, MainBoard); Turn t = Turn.enemy; while (!IsFull(MainBoard) && !CheckWinner(MainBoard, "X") && !CheckWinner(MainBoard, "O")) { if (t == Turn.enemy) { await SendEmbed(Context.User as IGuildUser, "WAITING", "Waiting for opponent..."); await EnemyTurn(user, MainBoard); t = Turn.you; await SendBoard(Context.User as IGuildUser, user, MainBoard); } else { await SendEmbed(user, "WAITING", "Waiting for opponent..."); while (true) { EnsureFromUserCriterion e = new EnsureFromUserCriterion(Context.User); await SendEmbed(Context.User as IGuildUser, "YOUR TURN", "Where do you want to place an 'O' ? (1 - 9)\nYou ha" + "ve 30 seconds. If you don't answer, you'll automatically lose."); try { string answer1 = (await NextMessageAsync(e, TimeSpan.FromSeconds(30))).ToString(); try { int a = Convert.ToInt32(answer1); if (a > 0 && a < 10) { if (MainBoard[a - 1] == " ") { MainBoard[a - 1] = "O"; t = Turn.enemy; break; } else { if (count != 1) { await SendEmbed(user, "WHOOPS", "That grid is occupied! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } else { if (count != 1) { await SendEmbed(user, "WHOOPS", "Please type numbers from 1 to 10! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } catch { if (count != 1) { await SendEmbed(user, "WHOOPS", "Please type only numbers! If you didn't" + " reply with the correct format once more you are automatically lose."); count++; } else { await SendEmbed(user, "RIP", "YOU LOSE Because of wrong format"); await SendEmbed(Context.User as IGuildUser, "YAAY", "You win! your " + "opponent didn't type the correct format"); return; } } } catch { await SendEmbed(user, "RIP", "You didn't answer! You are automatically" + " lose."); await SendEmbed(Context.User as IGuildUser, "YEY", "You win! Your enemy didn't reply!"); return; } } await SendBoard(Context.User as IGuildUser, user, MainBoard); } } if (IsFull(MainBoard)) { await SendEmbed(user, "AWW", "TIE!"); await SendEmbed(Context.User as IGuildUser, "AWW", "TIE"); return; } else { if (CheckWinner(MainBoard, "X")) { await SendEmbed(user, "YAYY", "YOU WIN!!"); await SendEmbed(Context.User as IGuildUser, "NOOB", "YOU LOSE!"); } else { await SendEmbed(Context.User as IGuildUser, "YAYY", "YOU WIN!!"); await SendEmbed(user, "NOOB", "YOU LOSE!"); } } } else { await SendEmbed(user, "Cancelled", "You " + "declined the request."); return; } } catch { await SendEmbed(user, "WHOOPS", "You didn't answer! Game " + "cancelled.."); return; } } }