<commit_before>/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2012, 2013, 2014  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <kotaka/paths/text.h>
#include <kotaka/paths/verb.h>
#include <type.h>

inherit LIB_EMIT;
inherit LIB_VERB;

string *query_parse_methods()
{
	return ({ "english" });
}

/* ({ role, prepositions, raw }) */
mixed **query_roles()
{
	return ({
		({ "dob", ({ nil }), 0 }),
		({ "iob", ({ "in" }), 0 })
	});
}

void main(object actor, mapping roles)
{
	mixed dob;
	mixed iob;
	string look;

	if (!actor) {
		send_out("You must be in character to use this command.\n");
		return;
	}

	dob = roles["dob"];
	iob = roles["iob"];

	if (dob == actor) {
		send_out("Try as you might, you cannot lift yourself.\n");
		return;
	}

	if (!dob) {
		send_out("Put what?\n");
		return;
	}

	if (typeof(dob) == T_STRING) {
		send_out(dob + "\n");
		return;
	}

	if (!iob) {
		send_out("Put it where?\n");
		return;
	}

	if (typeof(iob) == T_STRING) {
		send_out(iob + "\n");
		return;
	}

	if (dob[0]) {
		send_out("Your grammar stinks.\n");
		return;
	}

	dob = dob[1];

	if (dob->query_environment() != actor) {
		send_out("It doesn't appear to be in your hands.\n");
		return;
	}

	iob = iob[1];

	if (dob->query_environment() == actor) {
		if (dob->is_container_of(iob)) {
			send_out("Turn it inside out first.\n");
			return;
		}

		if (dob == iob) {
			send_out("Just turn it inside out.\n");
			return;
		}

		if (dob->query_property("is_immobile")) {
			send_out("It is stuck like glue and cannot be put anywhere.\n");
			return;
		}

		emit_from(actor, ({ "put", "puts" }), dob, "in", iob);
		dob->move(iob);
		dob->set_x_position(0);
		dob->set_y_position(0);
		dob->set_z_position(0);
		return;
	}
}<commit_msg>Update put verb to use multiple objects<commit_after>/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2012, 2013, 2014  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <kotaka/paths/text.h>
#include <kotaka/paths/verb.h>
#include <type.h>

inherit LIB_EMIT;
inherit LIB_VERB;

string *query_parse_methods()
{
	return ({ "english" });
}

/* ({ role, prepositions, raw }) */
mixed **query_roles()
{
	return ({
		({ "dob", ({ nil }), 0 }),
		({ "iob", ({ "in" }), 0 })
	});
}

private string validate_put(object actor, object obj, object iob)
{
	if (obj == actor) {
		return "Your attempt at contortion is unacceptable.";
	}

	if (obj->query_environment() != actor) {
		return "It has to be in your possession first.";
	}

	if (obj->is_container_of(iob)) {
		return "Quantum implosion prevented.";
	}

	if (obj == iob) {
		return "Just turn it inside out.";
	}

	if (obj->query_property("is_immobile")) {
		return "It is stuck like glue and cannot be put anywhere.";
	}
}

private void do_put(object actor, object obj, object iob)
{
	obj->move(iob);
	obj->set_x_position(0);
	obj->set_y_position(0);
	obj->set_z_position(0);
}

void main(object actor, mapping roles)
{
	mixed dob;
	mixed iob;
	string look;

	if (!actor) {
		send_out("You must be in character to use this command.\n");
		return;
	}

	dob = roles["dob"];
	iob = roles["iob"];

	if (!dob) {
		send_out("put what?\n");
		return;
	}

	if (!iob) {
		send_out("Put it where?\n");
		return;
	}

	if (dob[0]) {
		send_out("Bad grammar.\n");
		return;
	}

	if (iob[0] != "in") {
		send_out("Bad grammar.\n");
		return;
	}

	dob = dob[1];
	iob = iob[1];

	switch(typeof(dob)) {
	case T_STRING:
		send_out(dob + "\n");
		return;

	case T_ARRAY:
	case T_OBJECT:
		switch(typeof(iob)) {
		case T_STRING:
			send_out(iob + "\n");
			return;

		case T_ARRAY:
			send_out("Please be more specific on who or what you are putting things in.\n");
			return;

		case T_OBJECT:
			switch(typeof(dob)) {
			case T_ARRAY:
				{
					int i, sz;
					sz = sizeof(dob);

					for (i = 0; i < sz; i++) {
						string err;

						err = validate_put(actor, dob[i], iob);

						if (err) {
							send_out(err + "\n");
							return;
						}
					}

					for (i = 0; i < sz; i++) {
						do_put(actor, dob[i], iob);
					}
				}
				break;

			case T_OBJECT:
				{
					string err;

					err = validate_put(actor, dob, iob);

					if (err) {
						send_out(err + "\n");
						return;
					}

					do_put(actor, dob, iob);
				}
				break;
			}
		}
	}

	emit_from(actor, ({ "put", "puts" }), dob, "in", iob);
}
{'fraction_non_alphanumeric': 0.1516695957820738, 'fraction_numerical': 0.007908611599297012, 'mean_word_length': 3.138909090909091, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5820675', 'n_tokens_mistral': 2351, 'n_tokens_neox': 2069, 'n_words': 646}