public function call()
 {
     $pdo = core\paDB::conn();
     $sql = "SELECT * FROM {$this->paPrefix}_scenes";
     if ($this->args['sceneID']) {
         $sql .= " WHERE id={$this->args['sceneID']}";
     }
     $rs = $pdo->query($sql);
     $output = array();
     $scints = array('id');
     $exints = array("id", "sceneID", "destID");
     $chints = array("id", "isPlayer", "startX", "startY", "startX2", "startY2", "startFrame2");
     foreach ($rs as $row) {
         $rsx = $pdo->query("SELECT * FROM {$this->paPrefix}_sceneExits WHERE sceneID={$row['id']}");
         $row['exits'] = $rsx->fetchAll();
         $rch = $pdo->query("SELECT c.id,c.isPlayer,cs.startX,cs.startY,cs.startFrame,cs.startX2,cs.startY2,cs.startFrame2 FROM {$this->paPrefix}_characterScenes cs JOIN {$this->paPrefix}_characters c on c.id=cs.characterID WHERE cs.sceneID={$row['id']}");
         $row['chars'] = $rch->fetchAll();
         foreach ($scints as $int) {
             $row[$int] = (int) $row[$int];
         }
         //required for sqlite as it returns strings for all variables.
         foreach ($row['exits'] as &$ex) {
             foreach ($exints as $int) {
                 $ex[$int] = (int) $ex[$int];
             }
         }
         foreach ($row['chars'] as &$ch) {
             foreach ($chints as $int) {
                 $ch[$int] = (int) $ch[$int];
             }
         }
         $output[] = $row;
     }
     return $output;
 }
 public function call()
 {
     $output = array();
     $pdo = core\paDB::conn();
     if ($this->args['id']) {
         $old = core\paMain::call(array('module' => 'loadCharacters', 'charID' => $this->args['id']));
         if ($old['success']) {
             $old = $old['results'][0];
         } else {
             throw new core\paException('Failed to load existing character #' . $this->args['id']);
         }
         $chquery = $this->charUpdate($pdo);
         $pdo->query($chquery);
         $output['id'] = $this->args['id'];
         $spquery = $this->spriteUpdate($pdo);
         $pdo->query($spquery);
         $output['spriteID'] = $this->args['spriteID'];
     } else {
         $chquery = $this->charInsert($pdo);
         $pdo->query($chquery);
         $output['id'] = $pdo->lastInsertId();
         $spquery = $this->spriteInsert($pdo);
         $pdo->query($spquery);
         $output['spriteID'] = $pdo->lastInsertId();
     }
     return $output;
 }
 public function call()
 {
     $pdo = core\paDB::conn();
     $sql = "SELECT * FROM {$this->paPrefix}_conversations WHERE saidTo={$this->args['charID']} AND saidBy=1";
     $rs = $pdo->query($sql);
     $output = array();
     foreach ($rs as $row) {
         $output[] = $row;
     }
     return $output;
 }
 public function call()
 {
     $output = array();
     $pdo = core\paDB::conn();
     $queries = array();
     if ($this->args['id']) {
         $old = core\paMain::call(array('module' => 'loadScenes', 'sceneID' => $this->args['id']));
         if ($old['success']) {
             $old = $old['results'][0];
         } else {
             throw new core\paException('Failed to load existing scene #' . $this->args['id']);
         }
         $scquery = $this->sceneUpdate($pdo);
         $pdo->query($scquery);
         $output['id'] = $this->args['id'];
         foreach ($this->args['exits'] as $exit) {
             if ($this->hasExitId($exit, $old['exits'])) {
                 //exit being saved matches an existing one?
                 $queries[] = $this->exitUpdate($pdo, $exit, $output['id']);
                 //then update it
             } else {
                 //otherwise insert it.
                 $queries[] = $this->exitInsert($pdo, $exit, $this->args['id']);
             }
         }
         foreach ($old['exits'] as $oexit) {
             if (!$this->hasExitId($oexit, $this->args['exits'])) {
                 //existing exit isn't in the exit list being saved?
                 $queries[] = $this->exitDelete($pdo, $oexit, $output['id']);
                 //then delete it.
             }
         }
     } else {
         $scquery = $this->sceneInsert($pdo);
         $pdo->query($scquery);
         $output['id'] = $pdo->lastInsertId();
         foreach ($this->args['exits'] as $exit) {
             $queries[] = $this->exitInsert($pdo, $exit, $output['id']);
         }
     }
     foreach ($queries as $query) {
         try {
             if ($query) {
                 $pdo->query($query);
             }
         } catch (\Exception $e) {
             print "Error with query";
             die;
         }
     }
     return $output;
 }
 public function call()
 {
     $pdo = core\paDB::conn();
     $sql = "SELECT * FROM {$this->paPrefix}_items";
     if ($this->args['itemID']) {
         $sql .= " WHERE id={$this->args['itemID']}";
     }
     $rs = $pdo->query($sql);
     $output = array();
     foreach ($rs as $row) {
         $output[] = $row;
     }
     return $output;
 }
 public function call()
 {
     $pdo = core\paDB::conn();
     $sql = "SELECT c.id,c.name,c.startSceneID,c.talkColour, c.isPlayer, csp.id as spriteID, csp.sprite, csp.width, csp.height, csp.frames, csp.animList FROM {$this->paPrefix}_characters c LEFT JOIN {$this->paPrefix}_characterSprites csp ON csp.characterID=c.id";
     if ($this->args['charID']) {
         $sql .= " WHERE c.id={$this->args['charID']}";
     }
     $rs = $pdo->query($sql);
     $output = array();
     $ints = array('id', 'startSceneID', 'isPlayer', 'width', 'height', 'frames');
     foreach ($rs as $row) {
         foreach ($ints as $int) {
             $row[$int] = (int) $row[$int];
         }
         //this is necessary for sqlite which returns everything as a string.
         $output[] = $row;
     }
     return $output;
 }