Example #1
0
 /**
  * Gestion du changement de carte.
  * 
  * @return  void
  */
 public function index()
 {
     if (isset($this->data->action_map->item) && $this->data->action_map->item && !($obj = Item_Model::instance()->select($this->user->id, $this->data->action_map->item, 1))) {
         echo 'no';
         return;
     }
     if ($this->data->action_map->prix && is_numeric($this->data->action_map->prix) && $this->user->argent >= $this->data->action_map->prix) {
         $this->user->argent -= $this->data->action_map->prix;
     }
     if (!$this->data->action_map->prix || $this->user->argent >= $this->data->action_map->prix) {
         $this->user->positionX = $this->data->action_map->x_move * 50 + 25;
         $this->user->positionY = $this->data->action_map->y_move * 50 + 25;
         $this->user->positionZ = $this->data->action_map->z_move * 50 + 25;
         $this->user->region_id = $this->data->action_map->id_region_move;
         $this->user->update();
         History_Model::instance()->user_insert($this->user->id, $this->data->id, $this->data->action_map->id_region_move, 'change_map');
         echo '<script>window.location.reload();</script>';
     }
 }
Example #2
0
 /**
  * Valider une quete utilisateur.
  *
  * @param integer ID quĂȘte
  * @return  void
  */
 public function valid($id_quete)
 {
     $this->auto_render = FALSE;
     $list_user_quete = self::list_user();
     $txt = '';
     if (!($quete = $this->quete->select(array('id_quete' => $id_quete, 'status' => 1), 1))) {
         echo Kohana::lang('quete.no_access');
     }
     if (isset($list_user_quete[$quete->id_quete]) && $list_user_quete[$quete->id_quete]->status == 1 && $quete->element_detail_id_stop == $this->data->id) {
         $txt = Kohana::lang('quete.ok_stop');
         if ($this->user->niveau > $quete->niveau) {
             $ratio = $this->user->niveau - $quete->niveau;
             $quete->xp = round($quete->xp / $ratio);
             $quete->argent = round($quete->argent / $ratio);
         }
         $this->user->xp += $quete->xp;
         $this->user->argent += $quete->argent;
         if ($quete->fonction) {
             eval('?>' . $quete->fonction . '<?php');
         }
         $this->user->update();
         $this->quete->quete_update(array('status' => 2), $this->user->id, $quete->id_quete);
         if ($quete->argent) {
             $txt .= '<br />+ ' . $quete->argent . ' pt' . ($quete->argent > 1 ? 's' : '');
             echo '<script>app.sound.effect(\'' . $quete->audio_stop . '\');</script>';
         }
         History_Model::instance()->user_insert($this->user->id, $this->data->id, $id_quete, 'quete_valide');
         echo str_replace('{{joueur}}', $this->user->username, $quete->article_stop);
     } else {
         echo Kohana::lang('quete.no_valide_now');
     }
     echo '<script>';
     echo 'app.messages.push("' . $txt . '");';
     echo 'app.hero.xp = ' . $this->user->xp . ';';
     echo 'app.hero.niveau = ' . $this->user->niveau . ';';
     echo 'app.hero.argent = ' . $this->user->argent . ';';
     echo '</script>';
     $this->index();
 }