+Added raffling system
This commit is contained in:
@@ -29,6 +29,9 @@ map=1
|
||||
perish, thenperish=1
|
||||
ping=1
|
||||
poll=1
|
||||
rafflejoin=1
|
||||
rafflespin=1
|
||||
rafflestart=1
|
||||
rating=1
|
||||
results=1
|
||||
role=1
|
||||
|
||||
+26
-23
@@ -1,50 +1,53 @@
|
||||
[ObjectBuilderFactory]
|
||||
indicator=
|
||||
boop=
|
||||
tony, stark, dontfeelgood, dontfeelsogood=
|
||||
yeet=
|
||||
role=
|
||||
guildroleremove=
|
||||
ping=
|
||||
bethistory=
|
||||
benchmark, bench=
|
||||
rating=
|
||||
roll=
|
||||
blur=
|
||||
choose=
|
||||
poll=
|
||||
rpstart=
|
||||
guildrolenotallowed=
|
||||
rafflespin=
|
||||
bet=
|
||||
perish, thenperish=
|
||||
teey=
|
||||
guildrolelist=
|
||||
stats=
|
||||
dbstats=
|
||||
beans=
|
||||
eightball, 8ball=
|
||||
catch=
|
||||
guildroleadd=
|
||||
vote=
|
||||
results=
|
||||
wolfram=
|
||||
map=
|
||||
info, about=
|
||||
givebeans=
|
||||
c++, g++, cplus, cpp=
|
||||
work=
|
||||
showpoll=
|
||||
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=
|
||||
tweet=
|
||||
java, jdoodle=
|
||||
guildroleallowed=
|
||||
help=
|
||||
buildHelp=
|
||||
fetch=
|
||||
crouton=
|
||||
invite=
|
||||
dbflush=
|
||||
shutdown=
|
||||
|
||||
|
||||
|
||||
+95
-74
@@ -17,20 +17,11 @@ BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets!
|
||||
[CommandCatch]
|
||||
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]
|
||||
GuildRoleListOutput=The allowed roles are %s!
|
||||
GuildRoleListEmpty=There are no roles allowed!
|
||||
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]
|
||||
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
|
||||
@@ -43,16 +34,6 @@ GuildRoleAllowedDuplicate=Can't add the same role twice!
|
||||
[CommandStats]
|
||||
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]
|
||||
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
|
||||
@@ -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`!
|
||||
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]
|
||||
JDoodleInfo=Will compile any java code you put in! Supports Java 1.8
|
||||
JDoodleError=Please provide some java code to get it compiled!
|
||||
@@ -76,12 +53,6 @@ ChangeIndicatorChanged=Indicator changed to `%s`
|
||||
[CommandPerish]
|
||||
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]
|
||||
TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s*
|
||||
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.
|
||||
ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown.
|
||||
|
||||
[CommandCrouton]
|
||||
CroutonInfo=Crouton
|
||||
[CommandRaffleSpin]
|
||||
RaffleSpinInfo=
|
||||
RaffleSpinSuccess=The winner issssssss %s!
|
||||
RaffleSpinFailure=I can't choose a winner D:
|
||||
|
||||
[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!
|
||||
[CommandRaffleEnd]
|
||||
RaffleEndSuccess=
|
||||
RaffleEndInfo=
|
||||
RaffleEndFailure=I don't think there's one going!
|
||||
|
||||
[CommandDoWork]
|
||||
DoWorkFinished=I finished with my work! :D
|
||||
@@ -128,10 +95,6 @@ RPStartInfo=Starts an rp, add people to it by mentioning them!
|
||||
[CommandBlurry]
|
||||
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]
|
||||
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!
|
||||
@@ -156,21 +119,10 @@ PollShowChoices=And the choices are:\n
|
||||
[CommandHelpBuilder]
|
||||
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]
|
||||
RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg <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]
|
||||
FetchError=That no picture!
|
||||
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/
|
||||
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]
|
||||
PingResponse=Pong!
|
||||
PingInfo=Will respond with Pong!
|
||||
@@ -221,26 +256,12 @@ EightBallYes10=Signs point to yes.
|
||||
[CommandInvite]
|
||||
InviteInfo=Provides a direct invite link for KittyBot
|
||||
|
||||
[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!
|
||||
[CommandRaffleJoin]
|
||||
RaffleJoinFailure=You can't join the raffle ;3;
|
||||
RaffleJoinInfo=
|
||||
RaffleJoinSuccess=You joined the raffle!
|
||||
|
||||
[CommandDBFlush]
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,6 +348,8 @@ public class ObjectBuilderFactory
|
||||
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("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
|
||||
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("crouton"), new CommandCrouton(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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dataStructures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import core.DatabaseManager;
|
||||
import core.DatabaseTrackedObject;
|
||||
@@ -15,10 +17,13 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
public KittyUser guildOwner;
|
||||
public boolean polling;
|
||||
public String poll;
|
||||
public boolean raffling;
|
||||
public int raffleCost;
|
||||
public ArrayList<String> hasVoted = new ArrayList<String>();
|
||||
public ArrayList<String> emoji = new ArrayList<String>();
|
||||
public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>();
|
||||
public AdminControl control;
|
||||
public HashMap <KittyUser, Boolean> raffleUsers = new HashMap<KittyUser, Boolean>();
|
||||
|
||||
// Database synced info
|
||||
private final String roleListName = "guildRoles";
|
||||
@@ -88,6 +93,58 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
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
|
||||
public String Serialize()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user