From e22bcfc0c5c6aa5f9d64e2ce2db2f47a0b194016 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 28 Dec 2020 12:02:23 +1300 Subject: Random: add 8ball command --- Plugin/Random.pm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Plugin/Random.pm b/Plugin/Random.pm index 26d5250..03a050b 100644 --- a/Plugin/Random.pm +++ b/Plugin/Random.pm @@ -11,10 +11,15 @@ sub configure { $cmdref->($self, "shuffle", sub { $self->shuffle(@_); } ); $cmdref->($self, "choose", sub { $self->choose(@_); } ); + $cmdref->($self, "8ball", sub { $self->eight_ball(@_); } ); return $self; } +sub _choose { + return (List::Util::shuffle(@_))[0]; +} + sub shuffle { my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_; @@ -23,6 +28,33 @@ sub shuffle { sub choose { my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_; - return (List::Util::shuffle(@arguments))[0]; + return _choose(@arguments); +} + +sub eight_ball { + my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_; + my @responses = ( + "It is certain.", + "Without a doubt.", + "You may rely on it", + "Yes. Definitely.", + "It is decidedly so.", + "As I see it, yes.", + "Most likely.", + "Yes.", + "Outlook good.", + "Signs point to yes.", + "Reply hazy, try again.", + "Better not tell you now.", + "Ask again later.", + "Cannot predict now.", + "Concentrate and ask again.", + "Don't count on it.", + "Outlook not so good.", + "My sources say no.", + "Very doubtful.", + "My reply is no.", + ); + return _choose(@responses); } 1; -- cgit v1.1