mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Battleship/Connect4: put logging behind debug flag, disabled by default
This commit is contained in:
parent
9fd9e4f99c
commit
82d29fa058
@ -39,6 +39,7 @@ sub initialize {
|
|||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
|
||||||
|
|
||||||
$self->{channel} = '##battleship';
|
$self->{channel} = '##battleship';
|
||||||
|
$self->{debug} = 0;
|
||||||
$self->create_states;
|
$self->create_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +270,9 @@ sub battleship_cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when ('bomb') {
|
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') {
|
if ($self->{current_state} ne 'playermove' and $self->{current_state} ne 'checkplayer') {
|
||||||
return "$nick: It's not time to do that now.";
|
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
|
# 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);
|
$self->{pbot}->{logger}->log("Battleship: New state: $self->{current_state}\n" . Dumper $state_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.quit', sub { $self->on_departure(@_) });
|
||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
|
||||||
|
|
||||||
|
$self->{debug} = 0;
|
||||||
$self->{channel} = '##connect4';
|
$self->{channel} = '##connect4';
|
||||||
$self->create_states;
|
$self->create_states;
|
||||||
}
|
}
|
||||||
@ -317,7 +318,9 @@ sub connect4_cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when ('play') {
|
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') {
|
if ($self->{current_state} ne 'playermove') {
|
||||||
return "$nick: It's not time to do that now.";
|
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
|
# 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);
|
$self->{pbot}->{logger}->log("Connect4: New state: $self->{current_state}\n" . Dumper $state_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user