diff --git a/Irpg/Action.pm b/Irpg/Action.pm index 1be94c69db1a061a30276992eca119255ec8e8f5..9aba1627274e9ec1f8896301795d2219870ef925 100644 --- a/Irpg/Action.pm +++ b/Irpg/Action.pm @@ -459,6 +459,38 @@ sub do_action { "an undefined deed, but collapses out of exhaustion."); 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])) { Irpg::Irc::notice("You do not have enough energy to ". "look for anyone.", $usernick); @@ -477,6 +509,7 @@ sub do_action { " loneliness."); return 1; } + my $p1 = $username; my $p2; if (exists($arg[0]) && !(grep { $arg[0] eq $_ } @opps)) { if (exists($rps->{$arg[0]})) { @@ -502,10 +535,15 @@ sub do_action { else { $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); - $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 $res_action = eval $action_type.'_result($p1, $p2, $ret_action->{vict}, 1)'; @@ -552,14 +590,14 @@ sub new_action { our $commands = { action => {ref => \&do_action, adm => 0, prv => 1, pub => 1, - hlp => 'ACTION [<char name>]: perform an action '. - '(fight/mystic/steal) with someone. The action is '. - 'chosen at random, with more chance for the one you are '. - 'the better at.'}, + hlp => 'ACTION [-t <type>] [<char name>]: perform an action '. + '(fight/mystic/steal) with someone. With no type specified, '. + 'The action is chosen at random, '. + 'with more chance for the one you are the better at.'}, actions => {ref => \&do_actions, adm => 0, prv => 1, pub => 1, - hlp => 'ACTIONS [<char name>]: perform all available actions '. - 'with someone. The actions are chosen at random, with '. - 'more chance for the one you are the better at.'} + hlp => 'ACTIONS [-t <type>] [<char name>]: perform all available actions '. + 'with someone. With no type spcified, the actions are chosen '. + 'at random, with more chance for the one you are the better at.'} }; 1;