=SubCommand Routine modifications
This commit is contained in:
@@ -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,36 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user