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


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

Index


Code Index:

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

ABSTRACT

Top

This module provides the RoleInfo role for subclasses.

DESCRIPTION

Top

This module provides the RoleInfo role for subclasses. This is the AssaultCube player "role" in the game.

Attributes

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

role

The id of the client's role

	0 = DEAFULT
	1 = ADMIN

role_name

The role name of the client ( DEFAULT, ADMIN )

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 "roleinfo" role
package Games::AssaultCube::Log::Line::Base::RoleInfo;
use Moose::Role;

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

use Games::AssaultCube::Utils qw( get_role_from_name get_role_name );

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

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

sub BUILD {
	my $self = shift;

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

1;
__END__