Keep the common BadGuy stuff in a role, and compose that into different subclasses for the client and server.
package TheGame::Roles::BadGuy {
use Moose::Role;
has 'name' => (is => 'ro', isa => 'Str');
requires 'health';
}
package TheGame::Client::BadGuy {
use Moose;
with 'TheGame::Roles::BadGuy';
sub health {
my $self = shift;
my $health = do { ... };
return int($health/10)*10; # round to nearest 10%
}
}
package TheGame::Server::BadGuy {
use Moose;
with 'TheGame::Roles::BadGuy';
has health => (is => 'rw', isa => 'Num');
has inventory => (is => 'rw', isa => 'ArrayRef');
}
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name