⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 put.php

📁 一个基于web的rpg游戏源代码
💻 PHP
字号:
<?php/*** Netlands World Server is the coordinator of the VR in the Netlands Project* Copyright (C) 2002 Ricard Pillosu* * This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* 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 General Public License for more details.* * You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*//* vim: set expandtab tabstop=4 shiftwidth=4 *//*** With this command we can "move" objekts. You can give them to other* characater or drop it to the room, or put them into other objekt**  Input: <put [me="x"] id="x" parent_id="x"/>* Output: <put to="x"   id="x" parent_id="x" ok="<0|1>" msg="x"/>** @param connection object  Reference to connection* @param user       object  Reference to user* @param character  object  Reference to character* @param command    array   Contains command received*/function command_put(&$connection, &$user, &$character, $command){    global $entities;    try {        // Check the objekt        $t_objekt = & $entities->get_entity($command["id"]);        if($t_objekt->type != entity_list::T_OBJK) {            throw new exception("this is not an objekt");        }        // Check if this objekt is owned by you        if($character->is_my_child($t_objekt, FALSE) == FALSE) {            throw new exception("this objekt is not yours");        }        // Check the target entity        $t_entity = & $entities->get_entity($command["parent_id"]);        switch($t_entity->type) {        case entity_list::T_OBJK:            // Check if this objekt is owned by you            if($character->is_my_child($t_entity, FALSE) == FALSE) {                throw new exception("parent_id objekt is not yours");            }        break;        case entity_list::T_CHAR:            // Check if this character is near you            if($character->parent->is_my_child($t_entity, FALSE) == FALSE) {                throw new exception("parent_id character is not near");            }        break;        case entity_list::T_ROOM:            // Check if you are in this room            if($t_entity->is_my_child($character, FALSE) == FALSE) {                throw new exception("parent_id room is not here");            }        break;        default:            throw new exception("invalid parent_id type");        break;        }        // Go        if($t_entity->type == entity_list::T_CHAR) {            // "offer" the entity            $t_objekt->offered_to = $t_entity->get_key();        } else {            // move the entity            $entities->move_entity_to($t_objekt, $t_entity);        }    } catch(exception $exception) {        $answer = array(            "ok"    => "0",            "id"    => $command["id"],            "msg"   => $exception->get_msg());        return($answer);    }        // ok, all done :)    $answer = array(        "to"    => $character->get_key(),        "ok"    => "1",        "msg"   => "you put the objekt",        "id"    => $t_objekt->get_key(),        "parent_id" => $t_entity->get_key());    return($answer);}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -