diff options
author | David Phillips <david@yeah.nah.nz> | 2018-11-16 00:15:30 +1300 |
---|---|---|
committer | David Phillips <david@yeah.nah.nz> | 2018-11-16 00:19:18 +1300 |
commit | fb14ff03139a580a903aab4fa9b427b59475f4f5 (patch) | |
tree | a712155dec6bc0d06d3b859fd5c6dc107ef81c06 /Plugin | |
parent | 58ac2ddad36ed6a1c465549116300fa520a38c56 (diff) | |
download | idalius-fb14ff03139a580a903aab4fa9b427b59475f4f5.tar.xz |
Natural: make chances of speaking configurable
Diffstat (limited to 'Plugin')
-rw-r--r-- | Plugin/Natural.pm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Plugin/Natural.pm b/Plugin/Natural.pm index 56615e4..2d13070 100644 --- a/Plugin/Natural.pm +++ b/Plugin/Natural.pm @@ -3,26 +3,32 @@ package Plugin::Natural; use strict; use warnings; +my $config; my $root_config; sub configure { my $self = shift; shift; # cmdref shift; # run_command - shift; # module config + $config = shift; $root_config = shift; + IdaliusConfig::assert_scalar($config, $self, "chance_mentioned"); + IdaliusConfig::assert_scalar($config, $self, "chance_otherwise"); + die "chance_mentioned must be from 0 to 100" + if ($config->{chance_mentioned} < 0 || $config->{chance_mentioned} > 100); + die "chance_otherwise must be from 0 to 100" + if ($config->{chance_otherwise} < 0 || $config->{chance_otherwise} > 100); + return $self; } -# FIXME make configurable sub mention_odds { - return int(rand(10)) < 9; + return int(rand(100)) < $config->{chance_mentioned}; } -# FIXME make configurable sub normal_odds { - return int(rand(10)) < 6; + return int(rand(100)) < $config->{chance_otherwise}; } # FIXME factor out with other modules |