+Added raffling system

This commit is contained in:
Alex
2019-05-27 15:22:06 -04:00
parent d915d1c2ea
commit 99bd35611e
9 changed files with 322 additions and 97 deletions
+3
View File
@@ -29,6 +29,9 @@ map=1
perish, thenperish=1 perish, thenperish=1
ping=1 ping=1
poll=1 poll=1
rafflejoin=1
rafflespin=1
rafflestart=1
rating=1 rating=1
results=1 results=1
role=1 role=1
+26 -23
View File
@@ -1,50 +1,53 @@
[ObjectBuilderFactory] [ObjectBuilderFactory]
indicator= indicator=
boop=
tony, stark, dontfeelgood, dontfeelsogood=
yeet= yeet=
role=
guildroleremove= guildroleremove=
ping=
bethistory= bethistory=
benchmark, bench= benchmark, bench=
rating= rating=
roll=
blur=
choose=
poll= poll=
rpstart= rafflespin=
guildrolenotallowed=
bet= bet=
perish, thenperish=
teey=
guildrolelist= guildrolelist=
stats= stats=
dbstats=
beans=
eightball, 8ball=
catch= catch=
guildroleadd= guildroleadd=
vote=
results= results=
wolfram= wolfram=
map=
info, about=
givebeans= givebeans=
c++, g++, cplus, cpp= c++, g++, cplus, cpp=
work= work=
showpoll=
rpend= rpend=
java, jdoodle=
rafflejoin=
guildroleallowed=
buildHelp=
dbflush=
shutdown=
boop=
tony, stark, dontfeelgood, dontfeelsogood=
role=
ping=
roll=
blur=
choose=
rpstart=
guildrolenotallowed=
perish, thenperish=
teey=
dbstats=
rafflestart=
beans=
eightball, 8ball=
vote=
map=
info, about=
showpoll=
rpg= rpg=
tweet= tweet=
java, jdoodle=
guildroleallowed=
help= help=
buildHelp=
fetch= fetch=
crouton= crouton=
invite= invite=
dbflush=
shutdown=
+95 -74
View File
@@ -17,20 +17,11 @@ BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets!
[CommandCatch] [CommandCatch]
CatchInfo=Play catch with yourself or with a friend with @! CatchInfo=Play catch with yourself or with a friend with @!
[CommandBeansShow]
BeansShowDisplay=You have %s beans!
BeansShowMentioned=I looked it up and %sbeans!
BeansShowInfo=Displays how many beans you have
[CommandGuildRoleList] [CommandGuildRoleList]
GuildRoleListOutput=The allowed roles are %s! GuildRoleListOutput=The allowed roles are %s!
GuildRoleListEmpty=There are no roles allowed! GuildRoleListEmpty=There are no roles allowed!
GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself! GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself!
[CommandHelp]
HelpInfo=Lets you look up specific commands, or get a link to a list of all commands.
HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet`
[CommandRoll] [CommandRoll]
RollError=Didn't work ;3; RollError=Didn't work ;3;
RollInfo=Based on input of xdy where x is number of dice and y is faces kitty will roll that amount of dice, display the individual rolls and total RollInfo=Based on input of xdy where x is number of dice and y is faces kitty will roll that amount of dice, display the individual rolls and total
@@ -43,16 +34,6 @@ GuildRoleAllowedDuplicate=Can't add the same role twice!
[CommandStats] [CommandStats]
StatsInfo=Displays the actively running KittyBot application information StatsInfo=Displays the actively running KittyBot application information
[CommandTweet]
TweetInfo=Kitty will tweet to her personal twitter account
TweetError=Tweet command failed!
[CommandGuildRoleAdd]
GuildRoleAddSuccess=Added %s to %s
GuildRoleAddFailure=Failed to add %s to %s
GuildRoleAddNotAllowed=You are not allowed to add %s!
GuildRoleAddInfo=Add a role to yourself!
[CommandRole] [CommandRole]
RoleInfo=Will show the current role you have, Admins can change others roles with input of 'role x @y' with x being blacklist, general, mod, or admin. Blacklist will not allow the user to interact with kitty anymore, general mod and admin will give the user access to those commands. RoleInfo=Will show the current role you have, Admins can change others roles with input of 'role x @y' with x being blacklist, general, mod, or admin. Blacklist will not allow the user to interact with kitty anymore, general mod and admin will give the user access to those commands.
RoleStandardResponse=Your role is %s RoleStandardResponse=Your role is %s
@@ -60,10 +41,6 @@ RoleError=You aren't allowed to do that! You must have the KittyRole '%s' or hig
RoleChanged=Changed %s to role `%s`! RoleChanged=Changed %s to role `%s`!
RoleNeededRole=Please enter `general`, `mod`, or `admin`! RoleNeededRole=Please enter `general`, `mod`, or `admin`!
[CommandColiru]
ColiruError=Please provide some c++ code to attempt to compile!
ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++.
[CommandJDoodle] [CommandJDoodle]
JDoodleInfo=Will compile any java code you put in! Supports Java 1.8 JDoodleInfo=Will compile any java code you put in! Supports Java 1.8
JDoodleError=Please provide some java code to get it compiled! JDoodleError=Please provide some java code to get it compiled!
@@ -76,12 +53,6 @@ ChangeIndicatorChanged=Indicator changed to `%s`
[CommandPerish] [CommandPerish]
PerishInfo=Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned PerishInfo=Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned
[CommandStark]
StarkInfo=Snaps your icon or the icon of a friend you mentioned
[CommandYeet]
YeetInfo=Yeet yourself or yeet a friend with @!
[CommandTradeBeans] [CommandTradeBeans]
TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s* TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s*
TradeBeansNoTargetError=You have to give *someone* your beans! TradeBeansNoTargetError=You have to give *someone* your beans!
@@ -104,19 +75,15 @@ ShutdownSafe=Shutting down, but first syncing database and finishing current thr
ShutdownUnsafe=Shutting down and immediately and abandoning all threads without sync. ShutdownUnsafe=Shutting down and immediately and abandoning all threads without sync.
ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown. ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown.
[CommandCrouton] [CommandRaffleSpin]
CroutonInfo=Crouton RaffleSpinInfo=
RaffleSpinSuccess=The winner issssssss %s!
RaffleSpinFailure=I can't choose a winner D:
[CommandTeey] [CommandRaffleEnd]
TeeyInfo=Teey yourself back into existance, or teey a friend with @! RaffleEndSuccess=
RaffleEndInfo=
[CommandBetBeans] RaffleEndFailure=I don't think there's one going!
BetBeansLowBet=Please bet with at least 50 beans!
BetBeansInfo=Allows you to bet your beans, set your amount after the command! Warning! House always wins!\nSets of 3 will get 2x, 4 will get 10x, and 5 will get 1000x
BetBeansNotValid=That's not a valid bet!
BetBeansLose=Sorry, you didn't win, try again!
BetBeansNotEnough=You don't have enough beans!
BetBeansWin=You won %s beans!
[CommandDoWork] [CommandDoWork]
DoWorkFinished=I finished with my work! :D DoWorkFinished=I finished with my work! :D
@@ -128,10 +95,6 @@ RPStartInfo=Starts an rp, add people to it by mentioning them!
[CommandBlurry] [CommandBlurry]
BlurryInfo=Blurs your icon or the icon of a friend you mentioned BlurryInfo=Blurs your icon or the icon of a friend you mentioned
[CommandPollResults]
PollResultsResponse=%s people voted for %s `%s` with `%s%` !\n
PollResultsInfo=Will show current results of a poll and percentages of votes per choice
[CommandRating] [CommandRating]
RatingInfo='0' is fully sfw (Derpi and e621 searches are disabled), '1' is filtered (kitty auto appends a sfw tag on any searches), '2' is nsfw (any search will go through). Some other words are supported for setting filter as well. RatingInfo='0' is fully sfw (Derpi and e621 searches are disabled), '1' is filtered (kitty auto appends a sfw tag on any searches), '2' is nsfw (any search will go through). Some other words are supported for setting filter as well.
RatingWarning=Warning: NSFW may slip through, images are only based on tags on their respective sites! RatingWarning=Warning: NSFW may slip through, images are only based on tags on their respective sites!
@@ -156,21 +119,10 @@ PollShowChoices=And the choices are:\n
[CommandHelpBuilder] [CommandHelpBuilder]
HelpBuilderInfo=Emit help for all commands as formatted HTML HelpBuilderInfo=Emit help for all commands as formatted HTML
[CommandRPEnd]
RPEndError=You can't end this RP!
RPEndInfo=Ends RP in channel and gives you a .txt file!
RPEndFileOut=Here's your file!
[CommandRPG] [CommandRPG]
RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg <rpg command> RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg <rpg command>
RPGInvalid=Invalid RPG Command! RPGInvalid=Invalid RPG Command!
[CommandBoop]
BoopPerson=%s booped %s!
BoopInfo=Kitty will react with a counter
BoopStandard=Woah! %s booped me! That's %s total!
BoopMultiple=%s booped several others - %s!
[CommandFetch] [CommandFetch]
FetchError=That no picture! FetchError=That no picture!
FetchEat=Me eat now *monch %s* FetchEat=Me eat now *monch %s*
@@ -185,6 +137,89 @@ FetchStare=*Stares at %s*
InfoResponse=I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/ InfoResponse=I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/
InfoInfo=Provides author info and a link to Kitty's website InfoInfo=Provides author info and a link to Kitty's website
[CommandGuildRoleRemove]
GuildRoleRemoveNotAllowed=You're not allowed to add %s
GuildRoleRemoveFailure=Couldn't remove %s from %s
GuildRoleRemoveSuccess=Removed %s from %s!
GuildRoleRemoveInfo=
[CommandWolfram]
WolframError=Something went wrong!
WolframInfo=Will query wolframalpha with your question and give a full image output of the answer
WolframNoArgs=You need to provide some arguments!
[CommandMap]
MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed>-w<width>-h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\nDefault seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)
MapSeed=Seed
MapInvalid=Invalid arguments provided!
MapVersion=Using mapgen v0.1
MapWidth=Width
MapHeight=Height
[CommandBeansShow]
BeansShowDisplay=You have %s beans!
BeansShowMentioned=I looked it up and %sbeans!
BeansShowInfo=Displays how many beans you have
[CommandRaffleStart]
RaffleStartSuccess=Started a raffle with an entrance fee of %s beans!
RaffleStartFailure=There's already a raffle going!
RaffleStart=
RaffleStartInfo=
[CommandHelp]
HelpInfo=Lets you look up specific commands, or get a link to a list of all commands.
HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet`
[CommandTweet]
TweetInfo=Kitty will tweet to her personal twitter account
TweetError=Tweet command failed!
[CommandGuildRoleAdd]
GuildRoleAddSuccess=Added %s to %s
GuildRoleAddFailure=Failed to add %s to %s
GuildRoleAddNotAllowed=You are not allowed to add %s!
GuildRoleAddInfo=Add a role to yourself!
[CommandColiru]
ColiruError=Please provide some c++ code to attempt to compile!
ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++.
[CommandStark]
StarkInfo=Snaps your icon or the icon of a friend you mentioned
[CommandYeet]
YeetInfo=Yeet yourself or yeet a friend with @!
[CommandCrouton]
CroutonInfo=Crouton
[CommandTeey]
TeeyInfo=Teey yourself back into existance, or teey a friend with @!
[CommandBetBeans]
BetBeansLowBet=Please bet with at least 50 beans!
BetBeansInfo=Allows you to bet your beans, set your amount after the command! Warning! House always wins!\nSets of 3 will get 2x, 4 will get 10x, and 5 will get 1000x
BetBeansNotValid=That's not a valid bet!
BetBeansLose=Sorry, you didn't win, try again!
BetBeansNotEnough=You don't have enough beans!
BetBeansWin=You won %s beans!
[CommandPollResults]
PollResultsResponse=%s people voted for %s `%s` with `%s%` !\n
PollResultsInfo=Will show current results of a poll and percentages of votes per choice
[CommandRPEnd]
RPEndError=You can't end this RP!
RPEndInfo=Ends RP in channel and gives you a .txt file!
RPEndFileOut=Here's your file!
[CommandBoop]
BoopPerson=%s booped %s!
BoopInfo=Kitty will react with a counter
BoopStandard=Woah! %s booped me! That's %s total!
BoopMultiple=%s booped several others - %s!
[CommandPing] [CommandPing]
PingResponse=Pong! PingResponse=Pong!
PingInfo=Will respond with Pong! PingInfo=Will respond with Pong!
@@ -221,26 +256,12 @@ EightBallYes10=Signs point to yes.
[CommandInvite] [CommandInvite]
InviteInfo=Provides a direct invite link for KittyBot InviteInfo=Provides a direct invite link for KittyBot
[CommandGuildRoleRemove] [CommandRaffleJoin]
GuildRoleRemoveNotAllowed=You're not allowed to add %s RaffleJoinFailure=You can't join the raffle ;3;
GuildRoleRemoveFailure=Couldn't remove %s from %s RaffleJoinInfo=
GuildRoleRemoveSuccess=Removed %s from %s! RaffleJoinSuccess=You joined the raffle!
GuildRoleRemoveInfo=
[CommandWolfram]
WolframError=Something went wrong!
WolframInfo=Will query wolframalpha with your question and give a full image output of the answer
WolframNoArgs=You need to provide some arguments!
[CommandDBFlush] [CommandDBFlush]
DBFlushInfo= DBFlushInfo=
[CommandMap]
MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed>-w<width>-h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\nDefault seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)
MapSeed=Seed
MapInvalid=Invalid arguments provided!
MapVersion=Using mapgen v0.1
MapWidth=Width
MapHeight=Height
+32
View File
@@ -0,0 +1,32 @@
package commands;
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 HelpText() { return LocStrings.Stub("RaffleEndInfo"); }
@Override
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{
if(guild.endRaffle())
{
res.Call(LocStrings.Stub("RaffleEndSuccess"));
}
else
{
res.Call(LocStrings.Stub("RaffleEndFailure"));
}
}
}
+32
View File
@@ -0,0 +1,32 @@
package commands;
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 HelpText() { return LocStrings.Stub("RaffleJoinInfo"); }
@Override
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{
if(guild.joinRaffle(user))
{
res.Call(LocStrings.Stub("RaffleJoinSuccess"));
}
else
{
res.Call(LocStrings.Stub("RaffleJoinFailure"));
}
}
}
+32
View File
@@ -0,0 +1,32 @@
package commands;
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 HelpText() { return LocStrings.Stub("RaffleSpinInfo"); }
@Override
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{
try
{
res.Call(String.format(LocStrings.Stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
}
catch(Exception e)
{
res.Call(LocStrings.Stub("RaffleSpinFailure"));
}
}
}
+42
View File
@@ -0,0 +1,42 @@
package commands;
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 HelpText() { 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.Call(String.format(LocStrings.Stub("RaffleStartSuccess"), beanCost));
}
else
{
res.Call(LocStrings.Stub("RaffleStartFailure"));
}
}
}
+3
View File
@@ -348,6 +348,8 @@ public class ObjectBuilderFactory
manager.Register(LocCommands.Stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe)); manager.Register(LocCommands.Stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
manager.Register(LocCommands.Stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe)); manager.Register(LocCommands.Stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
manager.Register(LocCommands.Stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe)); manager.Register(LocCommands.Stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
manager.Register(LocCommands.Stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
manager.Register(LocCommands.Stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
// General // General
manager.Register(LocCommands.Stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe)); manager.Register(LocCommands.Stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
@@ -382,6 +384,7 @@ public class ObjectBuilderFactory
manager.Register(LocCommands.Stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe)); manager.Register(LocCommands.Stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
manager.Register(LocCommands.Stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe)); manager.Register(LocCommands.Stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
manager.Register(LocCommands.Stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe)); manager.Register(LocCommands.Stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
manager.Register(LocCommands.Stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
return manager; return manager;
} }
+57
View File
@@ -1,6 +1,8 @@
package dataStructures; package dataStructures;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import core.DatabaseManager; import core.DatabaseManager;
import core.DatabaseTrackedObject; import core.DatabaseTrackedObject;
@@ -15,10 +17,13 @@ public class KittyGuild extends DatabaseTrackedObject
public KittyUser guildOwner; public KittyUser guildOwner;
public boolean polling; public boolean polling;
public String poll; public String poll;
public boolean raffling;
public int raffleCost;
public ArrayList<String> hasVoted = new ArrayList<String>(); public ArrayList<String> hasVoted = new ArrayList<String>();
public ArrayList<String> emoji = new ArrayList<String>(); public ArrayList<String> emoji = new ArrayList<String>();
public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>(); public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>();
public AdminControl control; public AdminControl control;
public HashMap <KittyUser, Boolean> raffleUsers = new HashMap<KittyUser, Boolean>();
// Database synced info // Database synced info
private final String roleListName = "guildRoles"; private final String roleListName = "guildRoles";
@@ -88,6 +93,58 @@ public class KittyGuild extends DatabaseTrackedObject
return "Poll ended!"; return "Poll ended!";
} }
//Raffle methods
public boolean startRaffle(int beanCost)
{
if(raffling)
{
return false;
}
raffleCost = beanCost;
raffling = true;
return true;
}
public boolean endRaffle()
{
if(raffling)
{
raffleCost = 0;
raffling = false;
return true;
}
return false;
}
public boolean joinRaffle(KittyUser user)
{
if(!raffleUsers.containsKey(user) && user.GetBeans() > raffleCost && raffling)
{
user.ChangeBeans(raffleCost);
raffleUsers.put(user, true);
return true;
}
return false;
}
public KittyUser chooseRaffleWinner()
{
if(!raffleUsers.isEmpty())
{
KittyUser chosen = (KittyUser) raffleUsers.keySet().toArray()[new Random().nextInt(raffleUsers.keySet().toArray().length)];
for(int i = 0; i < 10; i ++)
{
if(raffleUsers.get(chosen))
{
raffleUsers.replace(chosen, false);
return chosen;
}
}
}
return null;
}
@Override @Override
public String Serialize() public String Serialize()
{ {