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

📄 get.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 *//*** Used to "get" objekts of the room, or from other objekt. The objekts that* are offered to us via "put", can be collected via "get".**  Input: <get [me="x"] id="x" parent_id="x"/>* Output: <get 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_get(&$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 the source 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");            }            // Check if the character owns this objekt            if($t_entity->is_my_child($t_objekt, FALSE) == FALSE) {                throw new exception("parent_id character have not the objekt");            }            // Check if the objekt is being offered to us            if($t_objekt->offered_to != $character->get_key()) {                throw new exception("objekt is not being offered to you");            }        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");            }            // Check if the objekt is in the room            if($t_entity->is_my_child($t_objekt, FALSE) == FALSE) {                throw new exception("parent_id room have not the objekt");            }        break;        default:            throw new exception("invalid parent_id type");        break;        }        // move the entity        $entities->move_entity_to($t_objekt, $character);        // erase "offered_to" flag        $t_objekt->offered_to = "0";    } 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 get 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 + -