in reply to P6: OO Wizard Game (RPG kinda, sorta)
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. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: P6: OO Wizard Game (RPG kinda, sorta)
by eric256 (Parson) on May 13, 2005 at 02:30 UTC | |
|
Re^2: P6: OO Wizard Game (RPG kinda, sorta)
by broquaint (Abbot) on May 13, 2005 at 13:22 UTC | |
by Anonymous Monk on Nov 22, 2007 at 13:33 UTC |