#!/usr/bin/perl
#use Mooix::Thing;
#use Mooix::Root;
run sub {
	my $this=shift;
	my $damage=shift;

	return if $this->unbreakable;
	
	my $hitpoints = $this->hitpoints($this->hitpoints - $damage);

	if ($hitpoints <= 0) {
		$this->msg("break");

		my $name = $this->name;
		# Add name to aliases.
		my @aliases=$this->alias;
		if (! grep { $name eq $_ } @aliases) {
			$this->alias(@aliases, $name);
		}
		# Change name.
		$this->name("broken ".$this->name);
		# And add broken to its adjectives too.
		my @adjectives=$this->adjective;
		if (! grep { "broken" eq $_ } @adjectives) {
			$this->adjective(@adjectives, "broken");
		}
		
		$this->parent($Mooix::Root->concrete->junk);
	}
}
