8ball, donator stuff, fixed card draws - thx gucci

This commit is contained in:
Master Kwoth 2016-02-10 17:27:49 +01:00
parent 4668985d26
commit d203f6032a
4 changed files with 108 additions and 58 deletions

View File

@ -113,6 +113,7 @@ public class Cards
} }
} }
} }
private Random r = new Random();
/// <summary> /// <summary>
/// Take a card from the pool, you either take it from the top if the deck is shuffled, or from a random place if the deck is in the default order. /// Take a card from the pool, you either take it from the top if the deck is shuffled, or from a random place if the deck is in the default order.
/// </summary> /// </summary>
@ -122,7 +123,7 @@ public class Cards
if (CardPool.Count == 0) if (CardPool.Count == 0)
Restart(); Restart();
//you can either do this if your deck is not shuffled //you can either do this if your deck is not shuffled
Random r = new Random((int)DateTime.Now.Ticks);
int num = r.Next(0, cardPool.Count); int num = r.Next(0, cardPool.Count);
Card c = cardPool[num]; Card c = cardPool[num];
cardPool.RemoveAt(num); cardPool.RemoveAt(num);
@ -141,7 +142,6 @@ public class Cards
private void Shuffle() { private void Shuffle() {
if (cardPool.Count > 1) if (cardPool.Count > 1)
{ {
Random r = new Random();
cardPool.OrderBy(x => r.Next()); cardPool.OrderBy(x => r.Next());
} }
} }
@ -195,15 +195,15 @@ public class Cards
handValues = new Dictionary<string, Func<List<Card>, bool>> handValues = new Dictionary<string, Func<List<Card>, bool>>
{ {
{ "A Pair", isPair }, { "Royal Flush", isRoyalFlush },
{ "Two Pairs", isTwoPair },
{ "Three Of A Kind", isThreeOfKind },
{ "Straight", isStraight },
{ "Flush", isFlush },
{ "Full House", isFullHouse },
{ "Four Of A Kind", isFourOfKind },
{ "Straight Flush", isStraightFlush }, { "Straight Flush", isStraightFlush },
{ "Royal Flush", isRoyalFlush } { "Four Of A Kind", isFourOfKind },
{ "Full House", isFullHouse },
{ "Flush", isFlush },
{ "Straight", isStraight },
{ "Three Of A Kind", isThreeOfKind },
{ "Two Pairs", isTwoPair },
{ "A Pair", isPair }
}; };
} }

View File

@ -579,59 +579,68 @@ namespace NadekoBot.Modules {
//THIS IS INTENTED TO BE USED ONLY BY THE ORIGINAL BOT OWNER //THIS IS INTENTED TO BE USED ONLY BY THE ORIGINAL BOT OWNER
cgb.CreateCommand(".adddon") cgb.CreateCommand(".adddon")
.Description("Add a donator to the database.") .Alias(".donadd")
.Parameter("donator") .Description("Add a donator to the database.")
.Parameter("amount") .Parameter("donator")
.Do(e => { .Parameter("amount")
try { .Do(e => {
if (NadekoBot.OwnerID != e.User.Id) try {
return; if (NadekoBot.OwnerID != e.User.Id)
var donator = e.Server.FindUsers(e.GetArg("donator")).FirstOrDefault(); return;
var amount = int.Parse(e.GetArg("amount")); var donator = e.Server.FindUsers(e.GetArg("donator")).FirstOrDefault();
Classes.DBHandler.Instance.InsertData(new Donator { var amount = int.Parse(e.GetArg("amount"));
Amount = amount, Classes.DBHandler.Instance.InsertData(new Donator {
UserName = donator.Name, Amount = amount,
UserId = (long)e.User.Id UserName = donator.Name,
}); UserId = (long)e.User.Id
e.Channel.SendMessage("Successfuly added a new donator. 👑"); });
} catch (Exception ex) { e.Channel.SendMessage("Successfuly added a new donator. 👑");
Console.WriteLine(ex); } catch (Exception ex) {
Console.WriteLine("---------------\nInner error:\n" + ex.InnerException); Console.WriteLine(ex);
} Console.WriteLine("---------------\nInner error:\n" + ex.InnerException);
}); }
});
/*
cgb.CreateCommand(".no")
.Description("desc")
.Parameter("arg", ParameterType.Required)
.Do(async e => {
var arg = e.GetArg("arg");
/*cgb.CreateCommand(".voicetext") });
.Description("Enabled or disabled voice to text channel connection. Only people in a certain voice channel will see ")
cgb.CreateCommand(".jsontype")
.Do(async e => {
Newtonsoft.Json.Linq.JArray data = Newtonsoft.Json.Linq.JArray.Parse(File.ReadAllText("data.json"));
if (data == null || data.Count == 0) return;
var wer = data.Where(jt => jt["Description"].ToString().Length > 120); cgb.CreateCommand(".voicetext")
var list = wer.Select(jt => { .Description("Enabled or disabled voice to text channel connection. Only people in a certain voice channel will see ")
var obj = new Parse.ParseObject("TypingArticles");
obj["text"] = jt["Description"].ToString();
return obj;
});
await Parse.ParseObject.SaveAllAsync(list);
await e.Send("saved to parse");
}); cgb.CreateCommand(".jsontype")
.Do(async e => {
Newtonsoft.Json.Linq.JArray data = Newtonsoft.Json.Linq.JArray.Parse(File.ReadAllText("data.json"));
if (data == null || data.Count == 0) return;
cgb.CreateCommand(".repeat") var wer = data.Where(jt => jt["Description"].ToString().Length > 120);
.Do(async e => { var list = wer.Select(jt => {
if (e.User.Id != NadekoBot.OwnerID) return; var obj = new Parse.ParseObject("TypingArticles");
obj["text"] = jt["Description"].ToString();
return obj;
});
await Parse.ParseObject.SaveAllAsync(list);
await e.Send("saved to parse");
string[] notifs = { "Admin use .bye .greet", "Unstable - fixing", "fixing ~ani, ~mang", "join NadekoLog server", "-h is help, .stats",}; });
int i = notifs.Length;
while (true) { cgb.CreateCommand(".repeat")
await e.Channel.SendMessage($".setgame {notifs[--i]}"); .Do(async e => {
await Task.Delay(20000); if (e.User.Id != NadekoBot.OwnerID) return;
if (i == 0) i = notifs.Length;
} string[] notifs = { "Admin use .bye .greet", "Unstable - fixing", "fixing ~ani, ~mang", "join NadekoLog server", "-h is help, .stats",};
}); int i = notifs.Length;
*/ while (true) {
await e.Channel.SendMessage($".setgame {notifs[--i]}");
await Task.Delay(20000);
if (i == 0) i = notifs.Length;
}
});
*/
}); });
} }

View File

@ -3,16 +3,23 @@ using System.Linq;
using Discord.Modules; using Discord.Modules;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Commands; using NadekoBot.Commands;
using Newtonsoft.Json.Linq;
using System.IO;
//🃏 //🃏
//🏁 //🏁
namespace NadekoBot.Modules namespace NadekoBot.Modules
{ {
class Games : DiscordModule class Games : DiscordModule
{ {
private string[] _8BallAnswers;
private Random _r = new Random();
public Games() : base() { public Games() : base() {
commands.Add(new Trivia()); commands.Add(new Trivia());
commands.Add(new SpeedTyping()); commands.Add(new SpeedTyping());
commands.Add(new PollCommand()); commands.Add(new PollCommand());
_8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray();
} }
public override void Install(ModuleManager manager) public override void Install(ModuleManager manager)
@ -34,6 +41,17 @@ namespace NadekoBot.Modules
await e.Send(list[new Random().Next(0, list.Length)]); await e.Send(list[new Random().Next(0, list.Length)]);
}); });
cgb.CreateCommand(">8ball")
.Description("Ask the 8ball a yes/no question.")
.Parameter("question",Discord.Commands.ParameterType.Unparsed)
.Do(async e => {
string question = e.GetArg("question").Replace("@everyone","[everyone]");
if (string.IsNullOrWhiteSpace(question))
return;
await e.Channel.SendMessage(
$":question: **Question:{question}**\n:crystal_ball: **8Ball Answers:**{_8BallAnswers[_r.Next(0, _8BallAnswers.Length)]}");
});
cgb.CreateCommand(">") cgb.CreateCommand(">")
.Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: > strike @User") .Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: > strike @User")
.Parameter("attack_type",Discord.Commands.ParameterType.Required) .Parameter("attack_type",Discord.Commands.ParameterType.Required)

View File

@ -0,0 +1,23 @@
[
"Most definitely yes",
"For sure",
"As I see it, yes",
"My sources say yes",
"Yes",
"Most likely",
"Perhaps",
"Maybe",
"Not sure",
"It is uncertain",
"Ask me again later",
"Don't count on it",
"Probably not",
"Very doubtful",
"Most likely no",
"Nope",
"No",
"My sources say no",
"Dont even think about it",
"Definitely no",
"NO - It may cause disease contraction"
]