=Updated Roll Output
Made individual rolls visible
This commit is contained in:
@@ -20,6 +20,11 @@ public class CommandBlurry extends Command
|
|||||||
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
private static double [][] blur = {{0.0030, 0.0133, 0.0219, 0.0133, 0.0030},
|
||||||
|
{0.0133, 0.0596, 0.0983, 0.0596, 0.0133},
|
||||||
|
{0.0219, 0.0983, 0.1621, 0.0983, 0.0219},
|
||||||
|
{0.0133, 0.0596, 0.0983, 0.0596, 0.0133},
|
||||||
|
{0.0030, 0.0133, 0.0219, 0.0133, 0.0030}};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
|||||||
@@ -6,14 +6,7 @@ import java.util.Stack;
|
|||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.*;
|
||||||
import dataStructures.KittyEmbed;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRoll extends Command
|
public class CommandRoll extends Command
|
||||||
{
|
{
|
||||||
@@ -133,10 +126,12 @@ public class CommandRoll extends Command
|
|||||||
return "Roll```" + thing + "```" + "Steps```" + steps + "```" + "Final value ```" + values.pop() +"```";
|
return "Roll```" + thing + "```" + "Steps```" + steps + "```" + "Final value ```" + values.pop() +"```";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String calculate(Stack<Integer> nums, Stack<Character> operators)
|
private String calculate(Stack<Integer> nums, Stack<Character> operators)
|
||||||
{
|
{
|
||||||
int second = nums.pop();
|
int second = nums.pop();
|
||||||
int first = nums.pop();
|
int first = nums.pop();
|
||||||
|
int rolls[] = null;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
char op = operators.pop();
|
char op = operators.pop();
|
||||||
|
|
||||||
@@ -155,27 +150,40 @@ public class CommandRoll extends Command
|
|||||||
value = first / second;
|
value = first / second;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
value = roll(first, second);
|
rolls = roll(first, second);
|
||||||
|
System.out.println(first);
|
||||||
|
for(int i= 0; i < first; i++)
|
||||||
|
{
|
||||||
|
value += rolls[i];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
nums.add(value);
|
nums.add(value);
|
||||||
return (first + "" + op + "" + second + "=" + value);
|
if(rolls == null)
|
||||||
|
return (first + "" + op + "" + second + "=" + value);
|
||||||
|
String rollValues = "";
|
||||||
|
for(int i= 0; i < first; i++)
|
||||||
|
{
|
||||||
|
rollValues += "\uD83C\uDFB2" + rolls[i] + " ";
|
||||||
|
}
|
||||||
|
return (first + "" + op + "" + second + "=" + value + "(" + rollValues.trim() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int roll(int first, int second)
|
private int[] roll(int first, int second)
|
||||||
{
|
{
|
||||||
int total = 0;
|
|
||||||
int roll = 0;
|
int roll = 0;
|
||||||
int dice = first;
|
int dice = first;
|
||||||
int sides = second;
|
int sides = second;
|
||||||
|
int [] rolls = new int [sides];
|
||||||
|
|
||||||
if(dice < 1)
|
if(dice < 1)
|
||||||
return 0;
|
return new int[0];
|
||||||
for(int i = 0; dice > i; i ++)
|
for(int i = 0; dice > i; i ++)
|
||||||
{
|
{
|
||||||
roll = (int)(Math.random() * sides) + 1;
|
roll = (int)(Math.random() * sides) + 1;
|
||||||
total += roll;
|
rolls[i] = roll;
|
||||||
}
|
}
|
||||||
return total;
|
return rolls;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPrecendence(char op1, char op2)
|
private boolean hasPrecendence(char op1, char op2)
|
||||||
|
|||||||
Reference in New Issue
Block a user