#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift; # or boots, or a tunic, or blue jeans..
	%_=@_;
	my $avatar=$_{avatar};

	if ($this->worn) {
		if ($this->location == $avatar) {
			fail "You're already wearing that.";
		}
		else {
			fail "Someone else is wearing that.";
		}
	}

	# Auto-take.
	if ($this->location != $avatar) {
		$this->take_verb(avatar => $avatar);
		if ($this->location != $avatar) {
			fail "You're not holding that.";
		}
	}
	
	# XXX might be good to look at the avatar's size here and not allow
	# wearing of too small/large stuff.
	
	if ($this->worn(1) && $this->immobile(1)) {
		$this->msg("wear", %_);
	}
	else {
		# back out any changes made
		$this->worn(0) if $this->worn;
		$this->immobile(0) if $this->immobile;
		fail "You cannot wear that.";
	}
}
