package include; use strict; use warnings; use Exporter; our @ISA = ("Exporter"); our @EXPORT = qw( &new_pqueue &debug &debugga &GAME &CONFIG &PC &STOP &args &inform ); use include::pqueue; use include::config; use Data::Dumper; my $game; # An interface to the pqueue. sub new_pqueue { return include::pqueue->queueify; } # Data::Dumpers everything it gets to STDERR. sub debug { print STDERR Dumper(@_); } # Debugs with complete code-deparsing. sub debugga { $Data::Dumper::Deparse = 1; debug(@_); $Data::Dumper::Deparse = 0; } # Returns an interface to the master game object. sub GAME { return $game; } # Returns an interface to the config system. sub CONFIG { return $game->{Config} } # Returns an interface to the player. sub PC { return $game->{Player}; } $game = {}; GAME->{Config} = include::config->configurate; # Every game has a player! Likewise an event DB. GAME->{Player} = 42; # *Somebody* will initialize this. GAME->{Events} = {}; # The action flow needs to halt! # TODO: namespace pollution... :( sub STOP { return -1; } # Get the arguments from an action bit sub args { my $self = shift; @{ $self->{Args} } = @_ if @_; return @{ $self->{Args} }; } # Print status messages. sub inform { my $msg = shift; return unless GAME->{UI}{Msg}; GAME->{UI}{Msg}->msg($msg); GAME->{UI}{Msg}->draw; } 42;