Файл: include/room.php
Строк: 87
<?php
include_once("table_name.php");
include_once("base.php");
/**
    class room in games
*/
class CRoom extends CBase 
{
    var $table_exits;
    
    /**
        Constructor
    */
    function CRoom($database,$vnum = 0)
    {
        global $table_room,$table_room_exits;
    
        $this->db = $database;
        $this->table_name=$table_room;
        $this->table_exits=$table_room_exits;
        $this->vnum=$vnum;    
    }
    
    function addRoom($vnum,$caption,$description)
    {
        $sql = "insert into $this->table_name(vnum,caption,description) VALUES ('$vnum','$caption','$description')";
        
        $this->execSQL($sql);    
    }
    
    function delRoom($vnum)
    {
        $sql = "delete from $this->table_name where vnum='$vnum'";
        
        $this->execSQL($sql);
    }
    
    function addRoomDirection($vnum,$direction,$room_link)
    {
        $sql = "insert into $this->table_exits(vnum,direction,vnum_link) VALUES ('$vnum','$direction','$room_link')";
        
        $this->execSQL($sql);
    }
    
    function delRoomDirections($vnum)
    {
        $sql = "delete from $this->table_exits where vnum='$vnum'";
        
        $this->execSQL($sql);
    }
    
    function getLinkRoom($direction)
    {
        $sql = "select vnum_link from $this->table_exits where vnum='$this->vnum' and direction='$direction'";
        
        $result = $this->execSQL($sql);
        
        if($result->numRows()==0) return -1;
        $row = $result->fetchRow();
        return $row[0];
    }
    
    function getRoomDesc()
    {
        return $this->getProperty('description');       
    }
    
    function getRoomCaption()
    {
        return $this->getProperty('caption');       
    }
    
    function getRoomExits()
    {
        $sql = "select direction from $this->table_exits where vnum='$this->vnum'";
 
        $result = $this->execSQL($sql);
        
        $exits = array();
        
        //cycle on all player
        while($row = $result->fetchRow())
        {
            $exits[] = array("direction" => $row[0]);
        }
        
        return $exits;
    }
}
?>