diff --git a/src/commands/general/CommandRoll.java b/src/commands/general/CommandRoll.java index 30c9d31..6dcfc2e 100644 --- a/src/commands/general/CommandRoll.java +++ b/src/commands/general/CommandRoll.java @@ -1,9 +1,13 @@ package commands.general; +import java.awt.Color; +import java.util.Random; import java.util.Stack; -import core.*; +import core.Command; +import core.LocStrings; import dataStructures.KittyChannel; +import dataStructures.KittyEmbed; import dataStructures.KittyGuild; import dataStructures.KittyRating; import dataStructures.KittyRole; @@ -23,7 +27,15 @@ public class CommandRoll extends Command { try { - res.send(rollDice(input.args)); + KittyEmbed embed = new KittyEmbed(); + embed.title = user.name +"'s roll!"; + embed.descriptionText = rollDice(input.args); + Random numGen = new Random(user.name.hashCode()); + float hue = numGen.nextFloat(); + float sat = .7f; + float bright = .7f; + embed.color = Color.getHSBColor(hue, sat, bright); + res.send(embed); } catch(Exception e) { @@ -35,6 +47,7 @@ public class CommandRoll extends Command { Stack values = new Stack(); Stack operators = new Stack(); + String steps = ""; for(int i = 0; i < thing.length(); i ++) { char current = thing.charAt(i); @@ -49,7 +62,7 @@ public class CommandRoll extends Command operators.add(current); else { - calculate(values, operators); + steps += "\n" + calculate(values, operators); operators.add(current); } @@ -65,7 +78,7 @@ public class CommandRoll extends Command else { i --; - calculate(values, operators); + steps += "\n" + calculate(values, operators); } continue; @@ -73,7 +86,7 @@ public class CommandRoll extends Command if(operators.isEmpty() || operators.peek() == '(' || !hasPrecendence(operators.peek(), current)) operators.add(current); else - calculate(values, operators); + steps += "\n" + calculate(values, operators); continue; case ' ': @@ -114,19 +127,20 @@ public class CommandRoll extends Command while(operators.size() > 0) { - calculate(values, operators); + steps += "\n" + calculate(values, operators); } - return "" + values.pop(); + return "Roll```" + thing + "```" + "Steps```" + steps + "```" + "Final value ```" + values.pop() +"```"; } - private void calculate(Stack nums, Stack operators) + private String calculate(Stack nums, Stack operators) { int second = nums.pop(); int first = nums.pop(); int value = 0; + char op = operators.pop(); - switch(operators.pop()) + switch(op) { case '+': value = first + second; @@ -143,8 +157,8 @@ public class CommandRoll extends Command case 'd': value = roll(first, second); } - nums.add(value); + return (first + "" + op + "" + second + "=" + value); } private int roll(int first, int second)