Games::AssaultCube::Log::Line::Base::MasterMode - The MasterMode role for subclasses


Games-AssaultCube documentation Contained in the Games-AssaultCube distribution.

Index


Code Index:

Games::AssaultCube::Log::Line::Base::MasterMode - The MasterMode role for subclasses

ABSTRACT

Top

This module provides the MasterMode role for subclasses.

DESCRIPTION

Top

This module provides the MasterMode role for subclasses. This is the AssaultCube server status.

Attributes

Those attributes are part of the role, and will be applied to subclasses that use this.

mastermode

The numeric AssaultCube mastermode of the server

	0 = OPEN
	1 = PRIVATE ( passworded )
	2 = NUM ( full )

mastermode_name

The name of the mastermode on the server ( OPEN, PRIVATE, NUM )

AUTHOR

Top

Apocalypse <apocal@cpan.org>

Props goes to the BS clan for the support!

This project is sponsored by http://cubestats.net

COPYRIGHT AND LICENSE

Top


Games-AssaultCube documentation Contained in the Games-AssaultCube distribution.

# the mastermode role
package Games::AssaultCube::Log::Line::Base::MasterMode;
use Moose::Role;

# Initialize our version
use vars qw( $VERSION );
$VERSION = '0.04';

use Games::AssaultCube::Utils qw( get_mastermode_from_name get_mastermode_name );

has 'mastermode' => (
	isa		=> 'Int',
	is		=> 'ro',
	lazy		=> 1,
	default		=> sub {
		my $self = shift;
		return get_mastermode_from_name( $self->mastermode_name );
	},
);

has 'mastermode_name' => (
	isa		=> 'Str',
	is		=> 'ro',
	lazy		=> 1,
	default		=> sub {
		my $self = shift;
		return get_mastermode_name( $self->mastermode );
	},
);

sub BUILD {
	my $self = shift;

	# check role
	if ( ! exists $self->{'mastermode'} and ! exists $self->{'mastermode_name'} ) {
		die "Mastermode information is missing";
	}
	return;
}

1;
__END__