Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -22,12 +22,9 @@ public class CommandCharacterMain extends Command
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterInfo"); }
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input.args).Call(res);
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,21 @@ import core.CharacterManager;
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandCreate extends SubCommand
|
||||
{
|
||||
public SubCommandCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String [] info = input.split(",");
|
||||
String [] info = input.args.split(",");
|
||||
if(info.length < 3)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterCreateNullInfo"));
|
||||
|
||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandEditBio extends SubCommand
|
||||
{
|
||||
public SubCommandEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editBio(character, input.substring(input.indexOf(' ')));
|
||||
CharacterManager.instance.editBio(character, input.args.substring(input.args.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioSuccess"));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandEditName extends SubCommand
|
||||
{
|
||||
public SubCommandEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editName(character, input.substring(input.indexOf(' ')));
|
||||
CharacterManager.instance.editName(character, input.args.substring(input.args.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameSuccess"));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandEditURL extends SubCommand
|
||||
{
|
||||
public SubCommandEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editRefImage(character, input.substring(input.indexOf(' ')));
|
||||
CharacterManager.instance.editRefImage(character, input.args.substring(input.args.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLSuccess"));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -12,15 +12,16 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandSearch extends SubCommand
|
||||
{
|
||||
public SubCommandSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input);
|
||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input.args);
|
||||
if(characters.size() < 1)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||
|
||||
@@ -20,6 +20,8 @@ public class CommandBlurry extends Command
|
||||
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
private static float [] weights = {.00390625f, .0156625f, .0234475f, .0156625f, .00390625f};
|
||||
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
@@ -53,7 +55,7 @@ public class CommandBlurry extends Command
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
applySnap(ImageIO.read(preProcessed), name);
|
||||
applyBlur(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -67,51 +69,77 @@ public class CommandBlurry extends Command
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void applySnap(BufferedImage image, String name) throws IOException
|
||||
private static void applyBlur(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
BufferedImage blurred = ImageUtils.copyImage(image);
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
for(int i = 0; i < 50; ++i)
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
for(int x = 1; x < image.getWidth() - 1; ++x)
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
for(int y = 1; y < image.getHeight() - 1; ++y)
|
||||
for(int y = 0; y < image.getHeight(); ++y)
|
||||
{
|
||||
blurred.setRGB(x, y, getColorAvg(image, x, y).getRGB());
|
||||
}
|
||||
}
|
||||
image = ImageUtils.copyImage(blurred);
|
||||
image = blurred;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File outputfile = new File(name);
|
||||
ImageIO.write(blurred, "png", outputfile);
|
||||
}
|
||||
|
||||
private static Color getColorAvg(BufferedImage image, int x, int y)
|
||||
{
|
||||
Color center = new Color(image.getRGB(x, y), true);
|
||||
Color one = new Color(image.getRGB(x - 1, y), true);
|
||||
Color two = new Color(image.getRGB(x - 1, y - 1), true);
|
||||
Color three = new Color(image.getRGB(x, y - 1), true);
|
||||
Color four = new Color(image.getRGB(x + 1, y - 1), true);
|
||||
Color five = new Color(image.getRGB(x + 1, y), true);
|
||||
Color six = new Color(image.getRGB(x + 1, y + 1), true);
|
||||
Color seven = new Color(image.getRGB(x, y + 1), true);
|
||||
Color eight = new Color(image.getRGB(x -1, y + 1), true);
|
||||
Color current;
|
||||
float r = 0;
|
||||
float g = 0;
|
||||
float b = 0;
|
||||
|
||||
int blue = center.getBlue() + one.getBlue() + two.getBlue() + three.getBlue() + four.getBlue() + five.getBlue() + six.getBlue() + seven.getBlue() + eight.getBlue();
|
||||
int red = center.getRed() + one.getRed() + two.getRed() + three.getRed() + four.getRed() + five.getRed() + six.getRed() + seven.getRed() + eight.getRed();
|
||||
int green = center.getGreen() + one.getGreen() + two.getGreen() + three.getGreen() + four.getGreen() + five.getGreen() + six.getGreen() + seven.getGreen() + eight.getGreen();
|
||||
int alpha = center.getAlpha() + one.getAlpha() + two.getAlpha() + three.getAlpha() + four.getAlpha() + five.getAlpha() + six.getAlpha() + seven.getAlpha() + eight.getAlpha();
|
||||
for(int xCor = -2; xCor <= 2; xCor++)
|
||||
{
|
||||
for(int yCor = -2; yCor <= 2; yCor++)
|
||||
{
|
||||
int curX = clamp(x + xCor, 0, image.getWidth() - 1);
|
||||
int curY = clamp(y + yCor, 0, image.getHeight() - 1);
|
||||
|
||||
|
||||
current = new Color(image.getRGB(curX, curY));
|
||||
|
||||
r += getGaus(current.getRed(), xCor, yCor);
|
||||
g += getGaus(current.getGreen(), xCor, yCor);
|
||||
b += getGaus(current.getBlue(), xCor, yCor);
|
||||
}
|
||||
}
|
||||
int red = (int)r;
|
||||
int green = (int)g;
|
||||
int blue = (int)b;
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
private static int clamp(int num, int min, int max)
|
||||
{
|
||||
if(num >= max)
|
||||
return max;
|
||||
if(num < min)
|
||||
return min;
|
||||
return num;
|
||||
}
|
||||
|
||||
private static float getGaus(int col, int x, int y)
|
||||
{
|
||||
x += 2;
|
||||
y+= 2;
|
||||
float result = weights[x];
|
||||
if(y == 2 || y == 4)
|
||||
result *= 4;
|
||||
if(y==3)
|
||||
result *= 6;
|
||||
|
||||
blue /= 9;
|
||||
red /= 9;
|
||||
green /= 9;
|
||||
alpha /= 9;
|
||||
result *= col;
|
||||
|
||||
Color blur = new Color(red, green, blue, alpha);
|
||||
|
||||
return blur;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandPollManage extends Command
|
||||
{
|
||||
public CommandPollManage(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollManageInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
switch(input.args.split(" ")[0].toLowerCase())
|
||||
{
|
||||
case "start":
|
||||
res.send(guild.startPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "choice":
|
||||
res.send(guild.addChoiceToPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "stop":
|
||||
res.send(guild.endPoll());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollShow extends Command
|
||||
{
|
||||
public CommandPollShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollShowInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(!guild.polling)
|
||||
{
|
||||
res.send(LocStrings.stub("PollShowNoPoll"));
|
||||
return;
|
||||
}
|
||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.stub("PollShowChoices");
|
||||
for(int i = 0; i < guild.choices.size(); i++)
|
||||
{
|
||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||
}
|
||||
|
||||
res.send(poll);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollVote extends Command
|
||||
{
|
||||
public CommandPollVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollVoteInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.polling)
|
||||
{
|
||||
if(guild.hasVoted.contains(user.uniqueID))
|
||||
{
|
||||
res.send(LocStrings.stub("PollVoteAlreadyVoted"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int voteNum = Integer.parseInt(input.args)-1;
|
||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||
return;
|
||||
}
|
||||
|
||||
KittyPoll polled = guild.choices.get(voteNum);
|
||||
polled.votes++;
|
||||
guild.hasVoted.add(user.uniqueID);
|
||||
res.send(LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
res.send(LocStrings.stub("PollVoteNotValidNumber"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
res.send(LocStrings.stub("PollVoteNoPoll"));
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleEnd extends Command
|
||||
{
|
||||
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleEndInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.endRaffle())
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleEndSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleEndFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleJoin extends Command
|
||||
{
|
||||
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleJoinInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.joinRaffle(user))
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleJoinSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleJoinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleSpin extends Command
|
||||
{
|
||||
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleSpinInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleSpinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleStart extends Command
|
||||
{
|
||||
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleStartInfo"); }
|
||||
|
||||
public int beanCost;
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
beanCost = Integer.parseInt(input.args);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
beanCost = 100;
|
||||
}
|
||||
|
||||
if(guild.startRaffle(beanCost))
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleStartFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
import java.util.Stack;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandRoll extends Command
|
||||
{
|
||||
@@ -23,7 +20,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 +40,7 @@ public class CommandRoll extends Command
|
||||
{
|
||||
Stack<Integer> values = new Stack<Integer>();
|
||||
Stack<Character> operators = new Stack<Character>();
|
||||
String steps = "";
|
||||
for(int i = 0; i < thing.length(); i ++)
|
||||
{
|
||||
char current = thing.charAt(i);
|
||||
@@ -49,7 +55,7 @@ public class CommandRoll extends Command
|
||||
operators.add(current);
|
||||
else
|
||||
{
|
||||
calculate(values, operators);
|
||||
steps += "\n" + calculate(values, operators);
|
||||
operators.add(current);
|
||||
}
|
||||
|
||||
@@ -65,7 +71,7 @@ public class CommandRoll extends Command
|
||||
else
|
||||
{
|
||||
i --;
|
||||
calculate(values, operators);
|
||||
steps += "\n" + calculate(values, operators);
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -73,7 +79,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 +120,22 @@ 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<Integer> nums, Stack<Character> operators)
|
||||
|
||||
private String calculate(Stack<Integer> nums, Stack<Character> operators)
|
||||
{
|
||||
int second = nums.pop();
|
||||
int first = nums.pop();
|
||||
int rolls[] = null;
|
||||
int value = 0;
|
||||
char op = operators.pop();
|
||||
|
||||
switch(operators.pop())
|
||||
switch(op)
|
||||
{
|
||||
case '+':
|
||||
value = first + second;
|
||||
@@ -141,27 +150,39 @@ public class CommandRoll extends Command
|
||||
value = first / second;
|
||||
break;
|
||||
case 'd':
|
||||
value = roll(first, second);
|
||||
rolls = roll(first, second);
|
||||
for(int i= 0; i < first; i++)
|
||||
{
|
||||
value += rolls[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nums.add(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 dice = first;
|
||||
int sides = second;
|
||||
int [] rolls = new int [sides];
|
||||
|
||||
if(dice < 1)
|
||||
return 0;
|
||||
return new int[0];
|
||||
for(int i = 0; dice > i; i ++)
|
||||
{
|
||||
roll = (int)(Math.random() * sides) + 1;
|
||||
total += roll;
|
||||
rolls[i] = roll;
|
||||
}
|
||||
return total;
|
||||
return rolls;
|
||||
}
|
||||
|
||||
private boolean hasPrecendence(char op1, char op2)
|
||||
|
||||
@@ -19,6 +19,7 @@ public class CommandGuildRoleMain extends Command
|
||||
super(level, rating);
|
||||
framework.addCommand("add", new SubCommandAdd (KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("remove", new SubCommandRemove(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("list", new SubCommandList(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("allowed", new SubCommandAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
framework.addCommand("unallowed", new SubCommandNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
}
|
||||
@@ -26,12 +27,9 @@ public class CommandGuildRoleMain extends Command
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleInfo"); }
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input.args).Call(res);
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,30 +7,38 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandAdd extends SubCommand
|
||||
{
|
||||
public SubCommandAdd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String role = input.split(" ")[0];
|
||||
if(guild.roleList.contains(role))
|
||||
String [] roles = input.args.split(",");
|
||||
String role;
|
||||
String formatted = "";
|
||||
for(int i = 0; i < roles.length; i++)
|
||||
{
|
||||
if(guild.control.addRole(user.discordID, role))
|
||||
role = roles[i].trim();
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
return new SubCommandFormattable("ADDED RIN YOU NEED TO FIX THIS");
|
||||
if(guild.control.addRole(user.discordID, role))
|
||||
{
|
||||
formatted += "Addded " + role + "!";
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += "Failed to add " + role + "!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable("FAILED RIN YOU NEED TO FIX THIS TOO");
|
||||
formatted += "You're not allowed to add " + role + "!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable("NOT ALLOWED FIX THIS ONE TOO SNEP FACE");
|
||||
}
|
||||
return new SubCommandFormattable(formatted);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,15 +8,16 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandAllowed extends SubCommand
|
||||
{
|
||||
public SubCommandAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String [] roles = input.split(",");
|
||||
String [] roles = input.args.split(",");
|
||||
String role;
|
||||
String formatted = "";
|
||||
for(int i = 0; i < roles.length; i++)
|
||||
|
||||
@@ -8,6 +8,7 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandList extends SubCommand
|
||||
{
|
||||
@@ -15,7 +16,7 @@ public class SubCommandList extends SubCommand
|
||||
public SubCommandList(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String roles = "";
|
||||
if(guild.roleList.isEmpty())
|
||||
|
||||
@@ -8,28 +8,36 @@ import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandNotAllowed extends SubCommand
|
||||
{
|
||||
public SubCommandNotAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
input = input.toLowerCase();
|
||||
String [] roles = input.split(",");
|
||||
String lowerInput = input.args.toLowerCase();
|
||||
String [] roles = lowerInput.split(",");
|
||||
String formatted = "";
|
||||
|
||||
if(roles.length < 1)
|
||||
{
|
||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedNoArgs")));
|
||||
}
|
||||
|
||||
for(String role:roles)
|
||||
{
|
||||
if(guild.roleList.contains(role.trim()))
|
||||
{
|
||||
guild.roleList.remove(role);
|
||||
return new SubCommandFormattable(LocStrings.stub("GuildRoleNotAllowedSuccess"));
|
||||
formatted += String.format(LocStrings.stub("GuildRoleNotAllowedSuccess"), role);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedFailure"), role));
|
||||
formatted += String.format(LocStrings.stub("GuildRoleNotAllowedFailure"), role);
|
||||
}
|
||||
}
|
||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedNoArgs")));
|
||||
return new SubCommandFormattable(formatted);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ public class SubCommandRemove extends SubCommand
|
||||
public SubCommandRemove(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String role = input.split(" ")[0];
|
||||
String role = input.args.split(" ")[0];
|
||||
String formatted = "";
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package commands.mod;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandModMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandModMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("kick", new SubCommandKick(KittyRole.Admin, KittyRating.Safe));
|
||||
framework.addCommand("mute", new SubCommandMute(KittyRole.Admin, KittyRating.Safe));
|
||||
framework.addCommand("ban", new SubCommandBan(KittyRole.Admin, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.mod;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandBan extends SubCommand
|
||||
{
|
||||
public SubCommandBan(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable(guild.control.banMember(input.mentions[0].discordID) + " ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package commands.mod;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandKick extends SubCommand
|
||||
{
|
||||
public SubCommandKick(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(guild.control.kickMember(input.mentions[0].discordID))
|
||||
{
|
||||
return new SubCommandFormattable("Success");
|
||||
}
|
||||
return new SubCommandFormattable("Fail");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.mod;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandMute extends SubCommand
|
||||
{
|
||||
public SubCommandMute(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable("" + guild.control.muteMember(input.mentions[0].avatarID));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package commands.music;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandMusicMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandMusicMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("join", new SubCommandJoin(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("leave", new SubCommandLeave(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("MusicInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package commands.music;
|
||||
|
||||
import com.google.api.services.youtube.YouTube;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandAddTrack extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandAddTrack(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.music;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandJoin extends SubCommand
|
||||
{
|
||||
public SubCommandJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable("" + guild.audio.joinChannel(input.args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.music;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandLeave extends SubCommand
|
||||
{
|
||||
public SubCommandLeave(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable("" + guild.audio.leaveChannel());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.Command;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandPollMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandPollMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
|
||||
framework.addCommand("start", new SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("addoption", new SubCommandAddOption(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
|
||||
framework.addCommand("show", new SubCommandShow(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("results", new SubCommandResults(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("vote", new SubCommandVote(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandAddOption extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandAddOption(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating);}
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.addChoiceToPoll(input.args));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandEnd extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandEnd(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.endPoll());
|
||||
}
|
||||
|
||||
}
|
||||
+33
-36
@@ -1,36 +1,33 @@
|
||||
package commands.general;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollResults extends Command
|
||||
{
|
||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollResultsInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String results = "";
|
||||
int totalVotes = 0;
|
||||
ArrayList<KittyPoll> votes = guild.choices;
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
totalVotes += votes.get(i).votes;
|
||||
}
|
||||
|
||||
results += "The poll was " + guild.poll + "\n";
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
results += String.format(LocStrings.stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100));
|
||||
}
|
||||
|
||||
res.send(results);
|
||||
}
|
||||
}
|
||||
package commands.poll;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class SubCommandResults extends SubCommand
|
||||
{
|
||||
public SubCommandResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String results = "";
|
||||
int totalVotes = 0;
|
||||
ArrayList<KittyPoll> votes = guild.choices;
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
totalVotes += votes.get(i).votes;
|
||||
}
|
||||
|
||||
results += "The poll was " + guild.poll + "\n";
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
results += String.format(LocStrings.stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100)) + "\n";
|
||||
}
|
||||
|
||||
return new SubCommandFormattable (results);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandShow extends SubCommand
|
||||
{
|
||||
public SubCommandShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(!guild.polling)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollShowNoPoll"));
|
||||
}
|
||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.stub("PollShowChoices");
|
||||
for(int i = 0; i < guild.choices.size(); i++)
|
||||
{
|
||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||
}
|
||||
|
||||
return new SubCommandFormattable (poll);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandStart extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandStart(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.startPoll(input.args));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyPoll;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandVote extends SubCommand
|
||||
{
|
||||
public SubCommandVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(guild.polling)
|
||||
{
|
||||
if(guild.hasVoted.contains(user.uniqueID))
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteAlreadyVoted"));
|
||||
}
|
||||
try
|
||||
{
|
||||
int voteNum = Integer.parseInt(input.args.substring(input.args.indexOf(" ")).trim())-1;
|
||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||
}
|
||||
|
||||
KittyPoll polled = guild.choices.get(voteNum);
|
||||
polled.votes++;
|
||||
guild.hasVoted.add(user.uniqueID);
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteNotValidNumber"));
|
||||
}
|
||||
}
|
||||
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteNoPoll"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.Command;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandRaffleMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandRaffleMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("start", new SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("spin", new SubCommandSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("join", new SubCommandJoin(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandEnd extends SubCommand
|
||||
{
|
||||
public SubCommandEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(guild.endRaffle())
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleEndSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleEndFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandJoin extends SubCommand
|
||||
{
|
||||
public SubCommandJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(guild.joinRaffle(user))
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleJoinSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleJoinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandSpin extends SubCommand
|
||||
{
|
||||
public SubCommandSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleSpinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandStart extends SubCommand
|
||||
{
|
||||
public SubCommandStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
public int beanCost;
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
beanCost = Integer.parseInt(input.args);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
beanCost = 100;
|
||||
}
|
||||
|
||||
if(guild.startRaffle(beanCost))
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleStartFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user