<commit_before>#!/usr/bin/perl

package BobboBot::roulette;

use warnings;
use strict;

use POSIX;
use List::MoreUtils qw(none); # array searching
use BotData;

my $chamber = load();

my @players;
my $file = 'data/roulette.json';
my $data = BotData->new($file, \&addPlayer);

sub addPlayer
{
  return {survive => 0, death => 0, game => 0, click => 0};
}

sub load
{
  return floor(rand(6)) + 1;
}

sub reload
{
  $chamber = load();
  $data->incStat('reload');
  $data->save();
  undef(@players); # clear array
  return {type => 'ACTION', text => 'loads a single round and spins the chamber.'};
}

sub run
{
  my @args = @{$_[0]->{arg}};
  if (defined $args[0] && ($args[0] eq "stat" || $args[0] eq "stats"))
  {
    my $player = $args[1] || undef;
    return $data->printStats($player);
  }

  if (index($_[0]->{where}, '#') == -1)
  {
    return ""; # do nothing if not in public
  }

  my $player = $_[0]->{who};

  $chamber--;
  if ($chamber == 0)
  {
    foreach my $p (@players)
    {
      next if ($p eq $player);
      $data->incStat('game', $p);
      $data->incStat('survive', $p);
    }
    $data->incStat('game', $player);
    $data->incStat('death', $player);
    $data->incStat('kill');

    return ['BANG! ' . $player . ' has been shot!', reload()];
  }
  else
  {
    $data->incStat('click');
    $data->incStat('click', $player);
    push(@players, $player) if (none {$_ eq $player} @players);
    return 'CLICK! Whose next?!';
  }
}

sub help
{
  return ['!roulette - Think you\'ve got good luck?',
          '!roulette stat [player] - Retrieve game stats.'];
}

sub auth<commit_msg>"Whose" -> "Who's" for roulette<commit_after>#!/usr/bin/perl

package BobboBot::roulette;

use warnings;
use strict;

use POSIX;
use List::MoreUtils qw(none); # array searching
use BotData;

my $chamber = load();

my @players;
my $file = 'data/roulette.json';
my $data = BotData->new($file, \&addPlayer);

sub addPlayer
{
  return {survive => 0, death => 0, game => 0, click => 0};
}

sub load
{
  return floor(rand(6)) + 1;
}

sub reload
{
  $chamber = load();
  $data->incStat('reload');
  $data->save();
  undef(@players); # clear array
  return {type => 'ACTION', text => 'loads a single round and spins the chamber.'};
}

sub run
{
  my @args = @{$_[0]->{arg}};
  if (defined $args[0] && ($args[0] eq "stat" || $args[0] eq "stats"))
  {
    my $player = $args[1] || undef;
    return $data->printStats($player);
  }

  if (index($_[0]->{where}, '#') == -1)
  {
    return ""; # do nothing if not in public
  }

  my $player = $_[0]->{who};

  $chamber--;
  if ($chamber == 0)
  {
    foreach my $p (@players)
    {
      next if ($p eq $player);
      $data->incStat('game', $p);
      $data->incStat('survive', $p);
    }
    $data->incStat('game', $player);
    $data->incStat('death', $player);
    $data->incStat('kill');

    return ['BANG! ' . $player . ' has been shot!', reload()];
  }
  else
  {
    $data->incStat('click');
    $data->incStat('click', $player);
    push(@players, $player) if (none {$_ eq $player} @players);
    return 'CLICK! Who\'s next?!';
  }
}

sub help
{
  return ['!roulette - Think you\'ve got good luck?',
          '!roulette stat [player] - Retrieve game stats.'];
}

sub auth
{'fraction_non_alphanumeric': 0.21390872399875815, 'fraction_numerical': 0.009313877677739833, 'mean_word_length': 3.1574193548387095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7278507', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1211, 'n_words': 320}