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

improvement: new option to select action type

The ACTION command has a new option -t <type>
which allows to specify a type of action (physic,
mystic or steal). This costs 3 extra action points.
parent 183e9620
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -459,6 +459,38 @@ sub do_action { ...@@ -459,6 +459,38 @@ sub do_action {
"an undefined deed, but collapses out of exhaustion."); "an undefined deed, but collapses out of exhaustion.");
return 1; return 1;
} }
my ($type,) = join(' ', @arg) =~ m/-t (\w+)/;
if (defined($type)) {
if (!($type =~ m/fight|mystic|steal/i)) {
Irpg::Irc::notice("Despite your intensive training, ".
"you are still unable to perform a '$type' action.", $usernick);
return 1;
}
#remove "-t xxx" from @arg
foreach ('-t', $type) {
my $index = 0;
$index++ until $arg[$index] eq $_;
splice(@arg, $index, 1);
}
}
if ($rps->{$username}{actions} < 6 && exists($arg[0]) && defined($type)) {
Irpg::Irc::notice("You are far to weak willed and feeble to ".
"both choose for yourself the action you want to perform and ".
"look for anyone.", $usernick);
Irpg::Irc::chanmsg("$usernick fails to handle his own path as the ".
"Gods did not made ".pronoun(3, $rps->{$username}{gender})." ".
"for such inanity.");
return 1;
}
if ($rps->{$username}{actions} < 4 && defined($type)) {
Irpg::Irc::notice("You do not have enough initiative to ".
"choose for yourself the action you want to perform.",
$usernick);
Irpg::Irc::chanmsg("$username tries to overstep what the Gods ".
"have planned for ".pronoun(3, $rps->{$username}{gender}).
", but fails.");
return 1;
}
if ($rps->{$username}{actions} < 2 && exists($arg[0])) { if ($rps->{$username}{actions} < 2 && exists($arg[0])) {
Irpg::Irc::notice("You do not have enough energy to ". Irpg::Irc::notice("You do not have enough energy to ".
"look for anyone.", $usernick); "look for anyone.", $usernick);
...@@ -477,6 +509,7 @@ sub do_action { ...@@ -477,6 +509,7 @@ sub do_action {
" loneliness."); " loneliness.");
return 1; return 1;
} }
my $p1 = $username;
my $p2; my $p2;
if (exists($arg[0]) && !(grep { $arg[0] eq $_ } @opps)) { if (exists($arg[0]) && !(grep { $arg[0] eq $_ } @opps)) {
if (exists($rps->{$arg[0]})) { if (exists($rps->{$arg[0]})) {
...@@ -502,10 +535,15 @@ sub do_action { ...@@ -502,10 +535,15 @@ sub do_action {
else { else {
$p2 = $opps[int(rand(@opps))]; $p2 = $opps[int(rand(@opps))];
} }
my $action_type = choose_action($p1);;
if (defined($type)) {
$action_type = $type;
# selecting an action's type cost 3 extra action points
consume_action($username);
consume_action($username);
consume_action($username);
}
consume_action($username); consume_action($username);
$rps->{$username}{next_a} = 3600 unless ($rps->{$username}{next_a});
my $p1 = $username;
my $action_type = choose_action($p1);
my $ret_action = perform_action($p1, $p2, $action_type); my $ret_action = perform_action($p1, $p2, $action_type);
my $res_action = eval $action_type.'_result($p1, $p2, $ret_action->{vict}, 1)'; my $res_action = eval $action_type.'_result($p1, $p2, $ret_action->{vict}, 1)';
...@@ -552,14 +590,14 @@ sub new_action { ...@@ -552,14 +590,14 @@ sub new_action {
our $commands = { our $commands = {
action => {ref => \&do_action, adm => 0, prv => 1, pub => 1, action => {ref => \&do_action, adm => 0, prv => 1, pub => 1,
hlp => 'ACTION [<char name>]: perform an action '. hlp => 'ACTION [-t <type>] [<char name>]: perform an action '.
'(fight/mystic/steal) with someone. The action is '. '(fight/mystic/steal) with someone. With no type specified, '.
'chosen at random, with more chance for the one you are '. 'The action is chosen at random, '.
'the better at.'}, 'with more chance for the one you are the better at.'},
actions => {ref => \&do_actions, adm => 0, prv => 1, pub => 1, actions => {ref => \&do_actions, adm => 0, prv => 1, pub => 1,
hlp => 'ACTIONS [<char name>]: perform all available actions '. hlp => 'ACTIONS [-t <type>] [<char name>]: perform all available actions '.
'with someone. The actions are chosen at random, with '. 'with someone. With no type spcified, the actions are chosen '.
'more chance for the one you are the better at.'} 'at random, with more chance for the one you are the better at.'}
}; };
1; 1;
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