Exemplo n.º 1
0
 public function action_buy()
 {
     if (!empty($_GET["get"])) {
         $inom = (int) $_GET["get"];
         $harm_ = "build/" . tbuild . "/_dat/items/harmony.php";
         if (file_exists($harm_)) {
             require $harm_;
         } else {
             $harm = array();
         }
         if (file_exists("build/" . tbuild . "/_dat/items/items.php")) {
             require "build/" . tbuild . "/_dat/items/items.php";
         } else {
             $item = array();
         }
         $cfg = Configs::readCfg("webshop", tbuild);
         $emptyItem = str_pad("", $cfg["hexLen"], "F", STR_PAD_BOTH);
         $item_ = $this->model->getInfo($inom);
         if ($item_["col_hex"] != $emptyItem) {
             $user = $this->model->aboutUser($_SESSION["mwcuser"]);
             if ($user["mwc_bankZ"] >= $item_["col_prise"]) {
                 $_item = rItem::Read($item_["col_hex"], $harm);
                 $wh = $this->model->getWH($_SESSION["mwcuser"], $cfg["hexLen"]);
                 $place = rItem::search($wh, $_item["x"], $_item["y"], $item, $cfg["hexLen"], 120);
                 if ($place >= 0) {
                     if ($this->model->buyItm($place, $cfg["hexLen"], $inom, $item_["col_hex"])) {
                         echo $user["mwc_bankZ"] - $item_["col_prise"];
                     } else {
                         echo "0";
                     }
                 }
             }
         }
     }
 }