Kwoth's changes
This commit is contained in:
parent
338cb6d24b
commit
fa0918806e
@ -15,9 +15,9 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
cgb.CreateCommand(Module.Prefix + "evaluate")
|
||||
.Alias(Module.Prefix + "eval")
|
||||
.Description("Evaluate a mathematical expression")
|
||||
cgb.CreateCommand(Module.Prefix + "calculate")
|
||||
.Alias(Module.Prefix + "calc")
|
||||
.Description("Evaluate a mathematical expression.\n**Usage**: ~calc 1+1")
|
||||
.Parameter("expression", ParameterType.Unparsed)
|
||||
.Do(EvalFunc());
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
await e.Channel.SendMessage("Must give expression");
|
||||
return;
|
||||
}
|
||||
string answer = evaluate(expression);
|
||||
string answer = Evaluate(expression);
|
||||
if (answer == null)
|
||||
{
|
||||
await e.Channel.SendMessage($"Expression {expression} failed to evaluate");
|
||||
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
await e.Channel.SendMessage($"`result: {answer}`");
|
||||
};
|
||||
|
||||
private string evaluate(string expression)
|
||||
private string Evaluate(string expression)
|
||||
{
|
||||
//check for factorial
|
||||
expression = Regex.Replace(expression, @"\d+!", x => x.Value + "0");
|
||||
@ -67,12 +67,10 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
public CustomParser() : base()
|
||||
{
|
||||
OperatorList.Add("!");
|
||||
OperatorList.Add("_");
|
||||
OperatorAction.Add("!", (x, y) => factorial(x));
|
||||
OperatorAction.Add("_", (x, y) => 10.130M);
|
||||
OperatorAction.Add("!", (x, y) => Factorial(x));
|
||||
}
|
||||
|
||||
static decimal factorial(decimal x)
|
||||
static decimal Factorial(decimal x)
|
||||
{
|
||||
decimal y = x-1;
|
||||
while (y >0)
|
||||
|
Loading…
Reference in New Issue
Block a user