<commit_before><?php

/**
 * Russian Roulette. Live or die...
 *
 * Do not directly edit this file.
 * If you want to change the rank, see commands.permissions in the configuration.
 */

use Dan\Irc\Location\Channel;
use Dan\Irc\Location\User;

command(['roulette', 'rr'])
    ->allowPrivate()
    ->helpText('Live or die...')
    ->handler(function (User $user, $message, Channel $channel = null) {
        $location = $channel ?? $user;

        $round = $location->getData('rr.round', 0);
        $bullets = $user->getData('rr.bullets', [false, false, false, true, false, false]);

        $shuffle = function() use ($location, &$bullets) {
            shuffle($bullets);
            $location->setData('rr.bullets', $bullets);
            $location->setData('rr.round', 0);
            $location->save();
        };

        if ($message == 'reload') {
            $shuffle();
            return;
        }

        if ($round > 5) {
            $shuffle();
        }

        $response = 'The gun clicks...';
        $fire = $bullets[$round];

        if ($fire) {
            $response = sprintf("<red>%s dies! D:</red>", $location->nick);
            $shuffle();
        } else {
            $location->setData('rr.round', ($round + 1));
        }

        $location->action(sprintf("<i>points the gun at %s</i> - <i>*pulls the trigger*</i> - <i>%s</i>", $user->nick, $response));

        $location->save();
    });<commit_msg>Fix nick not grabbed from User respectively<commit_after><?php

/**
 * Russian Roulette. Live or die...
 *
 * Do not directly edit this file.
 * If you want to change the rank, see commands.permissions in the configuration.
 */

use Dan\Irc\Location\Channel;
use Dan\Irc\Location\User;

command(['roulette', 'rr'])
    ->allowPrivate()
    ->helpText('Live or die...')
    ->handler(function (User $user, $message, Channel $channel = null) {
        $location = $channel ?? $user;

        $round = $location->getData('rr.round', 0);
        $bullets = $user->getData('rr.bullets', [false, false, false, true, false, false]);

        $shuffle = function() use ($location, &$bullets) {
            shuffle($bullets);
            $location->setData('rr.bullets', $bullets);
            $location->setData('rr.round', 0);
            $location->save();
        };

        if ($message == 'reload') {
            $shuffle();
            return;
        }

        if ($round > 5) {
            $shuffle();
        }

        $response = 'The gun clicks...';
        $fire = $bullets[$round];

        if ($fire) {
            $response = sprintf("<red>%s dies! D:</red>", $user->nick);
            $shuffle();
        } else {
            $location->setData('rr.round', ($round + 1));
        }

        $location->action(sprintf("<i>points the gun at %s</i> - <i>*pulls the trigger*</i> - <i>%s</i>", $user->nick, $response));

        $location->save();
    });
{'fraction_non_alphanumeric': 0.1899171270718232, 'fraction_numerical': 0.0027624309392265192, 'mean_word_length': 2.118406889128095, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 47, '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': '7557580', 'n_tokens_mistral': 891, 'n_tokens_neox': 876, 'n_words': 216}