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

classes wip:

- goodness has one chance out of two to offer a new item
- evil players chase someone in the 7x7 square around their position
at each game clock
parent 15c7f721
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,7 +6,7 @@ use Irpg::Utils qw(:text); ...@@ -6,7 +6,7 @@ use Irpg::Utils qw(:text);
use Irpg::Irc qw(:interaction); use Irpg::Irc qw(:interaction);
use Irpg::Action; use Irpg::Action;
use Exporter qw(import); use Exporter qw(import);
our @EXPORT = qw(find_item); our @EXPORT = qw(find_item evilchase);
our @EXPORT_OK = qw(hog); our @EXPORT_OK = qw(hog);
my $opts; my $opts;
...@@ -348,16 +348,39 @@ sub evilness { ...@@ -348,16 +348,39 @@ sub evilness {
} }
} }
sub evilchase {
my ($player, $positions) = @_;
return unless ($player && $positions);
my ($x_pos, $y_pos) = ($rps->{$player}{x}, $rps->{$player}{y});
my @opps = ();
for (my $x = $x_pos-3; $x <= $x_pos+3; $x++) {
for (my $y = $y_pos-3; $y <= $y_pos+3; $y++) {
if (exists($positions->{x}{y}) &&
$positions->{x}{y}{user} ne $player) {
push @opps, $positions->{x}{y}{user};
}
}
}
return unless (@opps);
my $opp = $opps[int(rand(@opps))];
Irpg::Irc::chanmsg("$player, full of hatred and disdain for ".
pronoun(2, $rps->{$player}{gender})." kind, has chased ".
"after $opp who passed by.");
collision_action($player, $opp);
}
sub goodness { sub goodness {
my @players = grep { $rps->{$_}{alignment} eq "g" && my @players = grep { $rps->{$_}{alignment} eq "g" &&
$rps->{$_}{online} } keys(%$rps); $rps->{$_}{online} } keys(%$rps);
return unless @players > 1; return unless @players > 1;
if (int(rand(2)) < 1) {
splice(@players,int(rand(@players)),1) while @players > 2; splice(@players,int(rand(@players)),1) while @players > 2;
my $gain = 5 + int(rand(8)); my $gain = 5 + int(rand(8));
Irpg::Irc::chanmsg(Irpg::Utils::clog( Irpg::Irc::chanmsg(Irpg::Utils::clog(
"$players[0] and $players[1] have not let the iniquities of ". "$players[0] and $players[1] have not let the iniquities of ".
"evil men poison them. Together have they prayed to their ". "evil men poison them. Together have they prayed to their ".
"god, and it is his light that now shines upon them. $gain\% ". "God, and it is his light that now shines upon them. $gain\% ".
"of their time is removed from their clocks.")); "of their time is removed from their clocks."));
$rps->{$players[0]}{next} += int($rps->{$players[0]}{class}->real_gain(-$gain/100)); $rps->{$players[0]}{next} += int($rps->{$players[0]}{class}->real_gain(-$gain/100));
$rps->{$players[1]}{next} += int($rps->{$players[1]}{class}->real_gain(-$gain/100)); $rps->{$players[1]}{next} += int($rps->{$players[1]}{class}->real_gain(-$gain/100));
...@@ -366,6 +389,16 @@ sub goodness { ...@@ -366,6 +389,16 @@ sub goodness {
Irpg::Irc::chanmsg("$players[1] reaches next level in ". Irpg::Irc::chanmsg("$players[1] reaches next level in ".
duration($rps->{$players[1]}{next})."."); duration($rps->{$players[1]}{next}).".");
} }
else {
my $user = $players[int(rand(@players))];
Irpg::Irc::chanmsg(Irpg::Utils::clog(
"$user has been good to ".
pronoun(2, $rps->{$user}{gender})." kind, and ".
pronoun(2, $rps->{$user}{gender})." God has rewarded ".
pronoun(3, $rps->{$user}{gender})." with a new piece of equipment"));
find_item($user);
}
}
sub rpcheck { sub rpcheck {
my $rpreport = shift; my $rpreport = shift;
......
...@@ -200,6 +200,7 @@ sub moveplayers { ...@@ -200,6 +200,7 @@ sub moveplayers {
# temporary hash to hold player positions, detect collisions # temporary hash to hold player positions, detect collisions
my @questers = movequesters(); my @questers = movequesters();
my %positions = (); my %positions = ();
my @who_fought = ();
for my $player (keys(%$rps)) { for my $player (keys(%$rps)) {
next unless ($rps->{$player}{online}); next unless ($rps->{$player}{online});
next if (!$questers[0] || grep { $player eq $_ } @questers); next if (!$questers[0] || grep { $player eq $_ } @questers);
...@@ -223,12 +224,20 @@ sub moveplayers { ...@@ -223,12 +224,20 @@ sub moveplayers {
$positions{$rps->{$player}{x}}{$rps->{$player}{y}}{battled}=1; $positions{$rps->{$player}{x}}{$rps->{$player}{y}}{battled}=1;
collision_action($player, collision_action($player,
$positions{$rps->{$player}{x}}{$rps->{$player}{y}}{user}); $positions{$rps->{$player}{x}}{$rps->{$player}{y}}{user});
push @who_fought, $player;
} }
} }
else { else {
$positions{$rps->{$player}{x}}{$rps->{$player}{y}}{battled}=0; $positions{$rps->{$player}{x}}{$rps->{$player}{y}}{battled}=0;
$positions{$rps->{$player}{x}}{$rps->{$player}{y}}{user}=$player; $positions{$rps->{$player}{x}}{$rps->{$player}{y}}{user}=$player;
} }
# at the last move, evil users who has not fought
# chase near players
if ($i == $opts->{self_clock}-1
&& $rps->{$player}{alignment} == 'e'
&& !(grep { $player eq $_ } @who_fought)) {
evilchase($player, \%positions);
}
} }
} }
} }
......
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