#!/usr/bin/perl
# Standing up means get off the furniture, but it's also possible to stand
# on the furniture. Therefore, just do a toggle. If you're on it, stnd
# takes you off, if you're off, it takes you on.
#use Fcntl q{:flock};
#use Mooix::Thing;
#use Mooix::Verb;
run sub {
	my $this=shift;
	%_=@_;
	my $avatar=$_{avatar};

	my $prep = ($this->stand_prepositions)[0];
	
	my $lock = $avatar->getlock(LOCK_EX);
	
	if (($avatar->preposition)[0] eq $prep &&
	    $avatar->location == $this && $_{direct_object} == $this) {
		fail "You're already standing there.";
	}
		
	# Stand up to get off of furniture.
	if ($avatar->location == $this && ! $_{direct_object}) {
		if ($avatar->physics->move(object => $avatar, to => $this->location)) {
			$this->msg('stand', %_)
		}
		else {
			fail "You can't get up!";
		}
	}
	else {
	
		if (! $this->location->isa($Mooix::Root->concrete->room)) {
			# Let the parser try some better peice of furniture.
			exit Mooix::Verb::SKIP;
		}
	
		if ($prep &&
		    $avatar->physics->move(object => $avatar, to => $this, preposition => $prep)) {
		        $this->msg('stand_on', %_);
		}
		else {
			fail "You can't stand on that.";
		}
	}
}
