Skip to content
Extraits de code Groupes Projets
Valider c7262892 rédigé par ElTata's avatar ElTata :ok_hand:
Parcourir les fichiers

exponential distribution to choose player for events

parent 4a065351
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -12,6 +12,9 @@ before it. ...@@ -12,6 +12,9 @@ before it.
Thanks for your interest in the Idle RPG! Feel free to contact me with ideas and Thanks for your interest in the Idle RPG! Feel free to contact me with ideas and
comments, or post them in the issues of the project for public view. comments, or post them in the issues of the project for public view.
---
## v5.3.0:
- players are chosen based on exponential distribution (of their levels) for the random events
--- ---
## v5.2.2: released 12/02/19 ## v5.2.2: released 12/02/19
...@@ -20,6 +23,7 @@ comments, or post them in the issues of the project for public view. ...@@ -20,6 +23,7 @@ comments, or post them in the issues of the project for public view.
- new command ACTIONS, do all available actions - new command ACTIONS, do all available actions
- actions messages now colorize the status of the action, and the changed TTL - actions messages now colorize the status of the action, and the changed TTL
- fixed chclass for classes with ' ' in their name - fixed chclass for classes with ' ' in their name
- no more warnings "argument isn't numeric" in steal_result subroutine
--- ---
## v5.2.1: released 10/28/19 ## v5.2.1: released 10/28/19
......
...@@ -139,8 +139,9 @@ sub find_item { # find item for argument player ...@@ -139,8 +139,9 @@ sub find_item { # find item for argument player
sub hog { # summon the hand of god sub hog { # summon the hand of god
my @players = grep { $rps->{$_}{online} } keys(%$rps); #my @players = grep { $rps->{$_}{online} } keys(%$rps);
my $player = $players[rand(@players)]; #my $player = $players[rand(@players)];
my $player = choose_player() || return;
my $win = int(rand(5)); my $win = int(rand(5));
my $time = int(((5 + int(rand(71)))/100) * $rps->{$player}{next}); my $time = int(((5 + int(rand(71)))/100) * $rps->{$player}{next});
if ($win) { if ($win) {
...@@ -162,10 +163,33 @@ sub hog { # summon the hand of god ...@@ -162,10 +163,33 @@ sub hog { # summon the hand of god
Irpg::Irc::chanmsg("$player reaches next level in ".duration($rps->{$player}{next})."."); Irpg::Irc::chanmsg("$player reaches next level in ".duration($rps->{$player}{next}).".");
} }
sub calamity { # suffer a little one sub choose_player {
my @players = grep { $rps->{$_}{online} } keys(%$rps); my @players = grep { $rps->{$_}{online} } keys(%$rps);
return unless @players; return unless @players;
my $player = $players[rand(@players)];
#sort players by group of same levels
my %levels = ();
foreach (@players) {
if (exists $levels{$rps->{$_}{level}}) {
push $levels{$rps->{$_}{level}}, $_;
}
else {
$levels{$rps->{$_}{level}} = [$_,];
}
}
@players = @levels{sort keys %levels};
#exponential distribution on levels (lambda = 0.5)
@players = @{$players[-log(rand) / 0.5]};
#then uniform distribution for players of the same level
return $players[rand(@players)];
}
sub calamity { # suffer a little one
#my @players = grep { $rps->{$_}{online} } keys(%$rps);
#return unless @players;
#my $player = $players[rand(@players)];
my $player = choose_player() || return;
if (rand(10) < 1) { if (rand(10) < 1) {
my @items = ("amulet","charm","weapon","tunic","set of leggings", my @items = ("amulet","charm","weapon","tunic","set of leggings",
"shield"); "shield");
...@@ -234,9 +258,10 @@ sub calamity { # suffer a little one ...@@ -234,9 +258,10 @@ sub calamity { # suffer a little one
} }
sub godsend { # bless the unworthy sub godsend { # bless the unworthy
my @players = grep { $rps->{$_}{online} } keys(%$rps); #my @players = grep { $rps->{$_}{online} } keys(%$rps);
return unless @players; #return unless @players;
my $player = $players[rand(@players)]; #my $player = $players[rand(@players)];
my $player = choose_player() || return;
if (rand(10) < 1) { if (rand(10) < 1) {
my @items = ("amulet","charm","weapon","tunic","set of leggings", my @items = ("amulet","charm","weapon","tunic","set of leggings",
"shield"); "shield");
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter