function render_give_item($username, $target, $item)
{
    $article = get_indefinite_article($item);
    addItem($target, $item, 1);
    $give_msg = "You have been given {$article} {$item} by {$username}.";
    sendMessage($username, $target, $give_msg);
    return "{$target} will receive your {$item}.<br>\n";
}
                } else {
                    if ($item == 'Stealth Scroll') {
                        $item = $stealthScroll = new Item('Stealth Scroll');
                        $stealthScroll->setCovert(true);
                    }
                }
            }
        }
    }
}
if (!is_object($item)) {
    echo "No such item.";
    die;
    // hack to avoid fatal error, proper checking for items should be done.
}
$article = get_indefinite_article($item->getName());
if ($using_item) {
    $turn_cost = $item->getTurnCost();
}
// Attack Legal section
$attacker = $username;
$params = array('required_turns' => $turn_cost, 'ignores_stealth' => $item->ignoresStealth(), 'self_use' => $selfTarget);
assert(!!$selfTarget || $attacker != $target);
$AttackLegal = new AttackLegal($attacker, $target, $params);
$attack_allowed = $AttackLegal->check();
$attack_error = $AttackLegal->getError();
// *** Any ERRORS prevent attacks happen here  ***
if (!$attack_allowed) {
    //Checks for error conditions before starting.
    echo "<div class='ninja-error centered'>{$attack_error}</div>";
    // Display the reason the attack failed.
Exemple #3
0
function give_item($username, $target, $item)
{
    $article = get_indefinite_article($item);
    addItem($target, $item, 1);
    $give_msg = "You have been given {$article} {$item} by {$username}.";
    sendMessage($username, $target, $give_msg);
}