#!/usr/bin/perl
# Giving an object is really just offering it; you hold it out and allow
# someone to take it; you do not force it upon them.
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $object = $_{direct_object};
	
	# Make sure that this command is not spoofed, just in case.
        if ($_{avatar} != $this) {
		fail "No!"; 
	}
	
	# This doesn't allow offering say, something from a box you're
	# holding, but I guess that's ok.
	if ($object->location != $this) {
		my $object = $_{indirect_object};
		if ($object->location != $this) {
			fail "You're not holding that.";
		}
		else {
			# So the direct object seems to be the avatar to
			# offer the object to. Switch everything around.
			$_{indirect_object} = $_{direct_object};
			$_{direct_object} = $object;
		}
	}
	
	$this->msg('offer', %_);
}
