I haven't kept up with Pugs OO (cause cygwin sucks rocks), but can't you create a base class for Person and Monster? Something along the lines of:
class Baseclass {
has Int $.life is rw;
has Weapon $.weapon is rw;
method hit (Int $power) { $.life -= $power; };
method dead () { $.life <= 0 };
method attack() { $.weapon.damage }
}
class Monster is Baseclass {
};
class Person is Baseclass {
};
Where $.weapon is the active weapon and the rest stay in the inventory.
Also, note the variable types. :-)
- In general, if you think something isn't in Perl, try it out, because it usually is. :-)
- "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"