<commit_before>'use strict';
const CommandUtil = require('../src/command_util').CommandUtil;
const l10nFile = __dirname + '/../l10n/commands/wield.yml';
const l10n = require('../src/l10n')(l10nFile);
const util = require('util');

exports.command = (rooms, items, players, npcs, Commands) => {
	return (args, player) => {
		let location = 'wield';
		const wielded = player.getEquipped(location);
		const offhand = player.getEquipped('offhand')
		const canDual = player.getSkills('dual')

		if (wielded && (!canDual || offhand)) {
			player.sayL10n(l10n, 'CANT_WIELD', items.get(wielded).getShortDesc(player.getLocale()));
			return;
		} else if (canDual && !offhand) {
		  location = 'offhand';
		}

		wield(location);

		function wield(location) {
			let weapon = args.split(' ')[0];
			weapon = CommandUtil.findItemInInventory(weapon, player, true);

			if (!weapon) {
				player.sayL10n(l10n, 'ITEM_NOT_FOUND');
				return;
			}

			util.log(player.getName() + ' wields ' + weapon.getShortDesc('en'));
			player.say('You wield the ' + weapon.getShortDesc(player.getLocale()) + '.\n' + location);
			weapon.emit(location, location, player, players);<commit_msg>LOL LOGIC :japanese_ogre:<commit_after>'use strict';
const CommandUtil = require('../src/command_util').CommandUtil;
const l10nFile = __dirname + '/../l10n/commands/wield.yml';
const l10n = require('../src/l10n')(l10nFile);
const util = require('util');

exports.command = (rooms, items, players, npcs, Commands) => {
	return (args, player) => {
		let location = 'wield';
		const wielded = player.getEquipped(location);
		const offhand = player.getEquipped('offhand')
		const canDual = player.getSkills('dual')

		if (wielded && offhand && !canDual) {
			player.sayL10n(l10n, 'CANT_WIELD', items.get(wielded).getShortDesc(player.getLocale()));
			return;
		} else if (wielded && canDual && !offhand) {
		  location = 'offhand';
		}

		util.log(location);
		wield(location);

		function wield(location) {
			let weapon = args.split(' ')[0];
			weapon = CommandUtil.findItemInInventory(weapon, player, true);

			if (!weapon) {
				player.sayL10n(l10n, 'ITEM_NOT_FOUND');
				return;
			}

			util.log(player.getName() + ' ' + location + ' wields ' + weapon.getShortDesc('en'));
			player.say('You wield the ' + weapon.getShortDesc(player.getLocale()));
			weapon.emit(location, location, player, players);
{'fraction_non_alphanumeric': 0.17237008871989862, 'fraction_numerical': 0.01605407689057879, 'mean_word_length': 4.456221198156682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1499718', 'n_tokens_mistral': 936, 'n_tokens_neox': 828, 'n_words': 160}