3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Battleship/Connect4: put logging behind debug flag, disabled by default

This commit is contained in:
Pragmatic Software 2019-12-19 23:01:16 -08:00
parent 9fd9e4f99c
commit 82d29fa058
2 changed files with 10 additions and 4 deletions

View File

@ -39,6 +39,7 @@ sub initialize {
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
$self->{channel} = '##battleship';
$self->{debug} = 0;
$self->create_states;
}
@ -269,7 +270,9 @@ sub battleship_cmd {
}
when ('bomb') {
$self->{pbot}->{logger}->log("Battleship: bomb state: $self->{current_state}\n" . Dumper $self->{state_data});
if ($self->{debug}) {
$self->{pbot}->{logger}->log("Battleship: bomb state: $self->{current_state}\n" . Dumper $self->{state_data});
}
if ($self->{current_state} ne 'playermove' and $self->{current_state} ne 'checkplayer') {
return "$nick: It's not time to do that now.";
@ -483,7 +486,7 @@ sub run_one_state {
}
# dump new state data for logging/debugging
if ($state_data->{newstate}) {
if ($self->{debug} and $state_data->{newstate}) {
$self->{pbot}->{logger}->log("Battleship: New state: $self->{current_state}\n" . Dumper $state_data);
}

View File

@ -39,6 +39,7 @@ sub initialize {
$self->{pbot}->{event_dispatcher}->register_handler('irc.quit', sub { $self->on_departure(@_) });
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
$self->{debug} = 0;
$self->{channel} = '##connect4';
$self->create_states;
}
@ -317,7 +318,9 @@ sub connect4_cmd {
}
when ('play') {
$self->{pbot}->{logger}->log("Connect4: play state: $self->{current_state}\n" . Dumper $self->{state_data});
if ($self->{debug}) {
$self->{pbot}->{logger}->log("Connect4: play state: $self->{current_state}\n" . Dumper $self->{state_data});
}
if ($self->{current_state} ne 'playermove') {
return "$nick: It's not time to do that now.";
@ -478,7 +481,7 @@ sub run_one_state {
}
# dump new state data for logging/debugging
if ($state_data->{newstate}) {
if ($self->{debug} and $state_data->{newstate}) {
$self->{pbot}->{logger}->log("Connect4: New state: $self->{current_state}\n" . Dumper $state_data);
}