public function run() { $lvl = new Level(); $lvl->game_id = 1; $lvl->level_name = 'First Lvl'; $lvl->save(); }
public function update(LevelRequest $request, Level $level) { $level->name = $request->txtName; $level->role_id = $request->sltRole; $level->save(); return redirect()->route('admin.level.index')->with('success', 'Edited completely!'); }
public function load() { $this->clear(); $level = new Level('College'); $level->save(); print_r(sprintf("Created Level: %s (%s)\n", $level->getName(), $level->getId())); $level = new Level('Summer'); $level->save(); print_r(sprintf("Created Level: %s (%s)\n", $level->getName(), $level->getId())); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Level(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Level'])) { $model->attributes = $_POST['Level']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function agregar() { $data = array(); if ($_POST) { $nivel = new Level(elements(array('nivel'), $_POST)); if ($nivel->is_valid()) { $nivel->save(); $this->session->set_flashdata('msg', '<div class="success">El Nivel se guardó correctamente.</div>'); redirect('niveles'); } else { $data['errors'] = $nivel->errors; } } $data['titulo'] = "Agregar Nivel"; $data['action'] = "niveles/agregar"; $this->template->write_view('content', 'niveles/agregar', $data); $this->template->render(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $validator = new Validator::make(Input::all(), ObjectsData::$rules); // if( $validator->fails()) // { // return Redirect::back()->withInput()->withErrors($validator); // } else { // $oldData = ObjectsData::were('level_id', 1)->get(); // dd($oldData); $prev = Level::where('next_level', '=', NULL)->first(); $lvl = new Level(); $lvl->game_id = 1; $lvl->level_name = Input::get('level_name'); $lvl->next_level = null; $lvl->save(); $prev->next_level = $lvl->id; $prev->save(); // $oldData = Call::where('level_id', $lvl->id)->get(); // foreach($oldData as $old) // { // $old->destroy($old->id); // } $lines = explode('*', Input::get('csvString')); foreach ($lines as $line) { $data = explode(',', $line); $submit = new Call(); $submit->level_id = $lvl->id; $submit->function = $data[0]; $submit->x = $data[1]; $submit->y = $data[2]; $submit->width = $data[3]; $submit->height = $data[4]; $submit->color = $data[5]; $submit->save(); } if ($submit) { return Redirect::action('GamesController@show', $lvl->id); } else { return Redirect::action('GamesController@create')->withInput(); } // } }
public function unloadLevel(Level $level, $force = false) { $name = $level->getName(); if ($name === $this->default and $force !== true) { return false; } console("[INFO] Unloading level \"" . $name . "\""); $level->nextSave = PHP_INT_MAX; $level->save(); foreach ($this->server->api->player->getAll($level) as $player) { $player->teleport($this->server->spawn); } foreach ($this->server->api->entity->getAll($level) as $entity) { if ($entity->class !== ENTITY_PLAYER) { $entity->close(); } } foreach ($this->server->api->tile->getAll($level) as $tile) { $tile->close(); } $level->close(); unset($this->levels[$name]); return true; }
require './config.php'; require_once './helpers/session.php'; require './helpers/boot.php'; require_once './helpers/User.php'; require './helpers/functions.php'; require './helpers/Level.php'; $session = new Session(); if (!$session->getLoggedin()) { header("Location: index.php"); } $user = User::find($session->getUsername()); if (isset($_POST['level'])) { $level = new Level(); $level->user_id = $session->getUsername(); $level->level = $_POST['level']; $level->save(); header("Location: index.php"); } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Form</title> <link href="./static/css/awe.css" rel="stylesheet"> <link href="./static/css/player.css" rel="stylesheet"> <style> b{
public function create_level() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_nuevo_nivel', $data["actions"])) { // Validate the info, create rules for the inputs $attributes = array('name' => 'Nombre del Nivel', 'teacher_id' => 'Profesor de aula o Tutor'); $messages = array(); $rules = array('name' => 'required|alpha_num_dash|min:2|max:45|unique:levels,name,NULL,id,deleted_at,NULL', 'teacher_id' => 'required'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules, $messages, $attributes); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('levels/new_level')->withErrors($validator)->withInput(Input::all()); } else { $teacher_id = Input::get('teacher_id'); if (!$teacher_id) { Session::flash('error', 'Debe seleccionar un profesor de aula o Tutor.'); return Redirect::to('levels/new_level')->withInput(Input::all()); } $level = new Level(); $level->name = Input::get('name'); $teacher = Teacher::find($teacher_id); // verificar si el profesor ya es tutor de otro nivel if ($teacher->level) { Session::flash('error', 'El profesor ya es Profesor de Aula o Tutor de otro nivel.'); return Redirect::to('levels/new_level')->withInput(Input::all()); } // asignar el perfil de tutor al profesor $user = $teacher->user; $user->profiles()->attach(Profile::where('name', '=', 'Tutor')->first()->id); $level->teacher_id = $teacher_id; $level->save(); Session::flash('message', 'Se creó correctamente el Nivel.'); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el Nivel con id: {{$level->id}}"; Helpers::registerLog(3, $log_description); return Redirect::to('levels/list_levels'); } } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }
public function exportLevel(Level $level) { $level->save(false, true); @mkdir($this->api->plugin->configPath($this) . "export/"); $path = $this->api->plugin->configPath($this) . "export/" . $level->getName() . "/"; @mkdir($path); $chunks = fopen($path . "chunks.dat", "w"); fwrite($chunks, self::$chunkHeader); for ($Z = 0; $Z < 16; ++$Z) { for ($X = 0; $X < 16; ++$X) { $chunk = ""; $miniChunks = array(); for ($Y = 0; $Y < 8; ++$Y) { $miniChunks[$Y] = $level->level->getMiniChunk($X, $Z, $Y); } $columns = array(); for ($x = 0; $x < 16; ++$x) { for ($z = 0; $z < 16; ++$z) { $index = ($x << 4) + $z; $j = ($z << 9) + ($x << 5); $columns[$index] = array("", "", str_repeat("", 64), str_repeat("", 64)); foreach ($miniChunks as $raw) { $columns[$index][0] .= substr($raw, $j, 16); //Block IDs $columns[$index][1] .= substr($raw, $j + 16, 8); //Block Metadata } } } for ($i = 0; $i < 4; ++$i) { for ($x = 0; $x < 16; ++$x) { for ($z = 0; $z < 16; ++$z) { $chunk .= $columns[($x << 4) + $z][$i]; } } } unset($columns, $miniChunks); $chunk = str_pad($chunk, 86012, "", STR_PAD_RIGHT); fwrite($chunks, Utils::writeLInt(strlen($chunk)) . $chunk); } } fclose($chunks); $nbt = new NBT(); $nbt->write(chr(NBT::TAG_COMPOUND) . ""); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("GameType"); $nbt->writeTAG_Int(0); //$nbt->writeTAG_Int((int) $level->getGamemode()); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("LastPlayed"); $nbt->writeTAG_Int(time()); $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("LevelName"); $nbt->writeTAG_String($level->getName()); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("Platform"); $nbt->writeTAG_Int(2); $nbt->write(chr(NBT::TAG_COMPOUND)); $nbt->writeTAG_String("Player"); //Nothing here! $nbt->write(chr(NBT::TAG_END)); $nbt->write(chr(NBT::TAG_LONG)); $nbt->writeTAG_String("RandomSeed"); $nbt->writeTAG_Long($level->getSeed()); $nbt->write(chr(NBT::TAG_LONG)); $nbt->writeTAG_String("SizeOnDisk"); $nbt->writeTAG_Long(filesize($path . "chunks.dat")); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("SpawnX"); $nbt->writeTAG_Int((int) $level->getSpawn()->x); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("SpawnY"); $nbt->writeTAG_Int((int) $level->getSpawn()->y); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("SpawnZ"); $nbt->writeTAG_Int((int) $level->getSpawn()->z); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("StorageVersion"); $nbt->writeTAG_Int(3); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("Time"); $nbt->writeTAG_Int($level->getTime()); $nbt->write(chr(NBT::TAG_END)); @file_put_contents($path . "level.dat", Utils::writeLInt(3) . Utils::writeLInt(strlen($nbt->binary)) . $nbt->binary); $nbt->binary = ""; $nbt->write(chr(NBT::TAG_COMPOUND) . ""); $nbt->write(chr(NBT::TAG_LIST)); $nbt->writeTAG_String("Entities"); $nbt->writeTAG_Byte(NBT::TAG_COMPOUND); $nbt->writeTAG_Int(0); $nbt->write(chr(NBT::TAG_LIST)); $nbt->writeTAG_String("TileEntities"); $nbt->writeTAG_Byte(NBT::TAG_COMPOUND); $tiles = $level->tiles->getAll(); $nbt->writeTAG_Int(count($tiles)); foreach ($tiles as $tid => $data) { $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("id"); $nbt->writeTAG_String($data["id"]); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("x"); $nbt->writeTAG_Int($data["x"]); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("y"); $nbt->writeTAG_Int($data["y"]); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("z"); $nbt->writeTAG_Int($data["z"]); if ($data["id"] === "Sign") { $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("Text1"); $nbt->writeTAG_String($data["Text1"]); $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("Text2"); $nbt->writeTAG_String($data["Text2"]); $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("Text3"); $nbt->writeTAG_String($data["Text3"]); $nbt->write(chr(NBT::TAG_STRING)); $nbt->writeTAG_String("Text4"); $nbt->writeTAG_String($data["Text4"]); } elseif ($data["id"] === "Furnace") { $nbt->write(chr(NBT::TAG_SHORT)); $nbt->writeTAG_String("BurnTime"); $nbt->writeTAG_Short($data["BurnTime"]); $nbt->write(chr(NBT::TAG_SHORT)); $nbt->writeTAG_String("CookTime"); $nbt->writeTAG_Short($data["CookTime"]); } elseif ($data["id"] === "Chest" and isset($data["pairx"]) and isset($data["pairz"])) { $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("pairx"); $nbt->writeTAG_Int($data["pairx"]); $nbt->write(chr(NBT::TAG_INT)); $nbt->writeTAG_String("pairz"); $nbt->writeTAG_Int($data["pairz"]); } if ($data["id"] === "Furnace" or $data["id"] === "Chest") { $nbt->write(chr(NBT::TAG_LIST)); $nbt->writeTAG_String("Items"); $nbt->writeTAG_Byte(NBT::TAG_COMPOUND); $nbt->writeTAG_Int(count($data["Items"])); foreach ($data["Items"] as $index => $item) { $nbt->write(chr(NBT::TAG_BYTE)); $nbt->writeTAG_String("Slot"); $nbt->writeTAG_Byte($item["Slot"]); $nbt->write(chr(NBT::TAG_SHORT)); $nbt->writeTAG_String("id"); $nbt->writeTAG_Short($data["id"]); $nbt->write(chr(NBT::TAG_SHORT)); $nbt->writeTAG_String("Damage"); $nbt->writeTAG_Short($data["Damage"]); $nbt->write(chr(NBT::TAG_BYTE)); $nbt->writeTAG_String("Count"); $nbt->writeTAG_Byte($item["Count"]); $nbt->write(chr(NBT::TAG_END)); } } $nbt->write(chr(NBT::TAG_END)); } $nbt->write(chr(NBT::TAG_END)); @file_put_contents($path . "entities.dat", "ENT" . Utils::writeLInt(1) . Utils::writeLInt(strlen($nbt->binary)) . $nbt->binary); }
function updatePosition() { $positionList = $this->input->post('positionList'); $idList = $this->input->post('idList'); $levels = new Level(); for ($i = 0; $i < count($idList); $i++) { $levels->where("id", $idList[$i]); $levels->get(); $levels->position = $positionList[$i]; $levels->save(); $levels->clear(); } redirect("admin/levels/listAll/"); }
public function writedata() { $level = new Level(); $level->score = Input::get('taskTimes'); $level->mistakes = Input::get('mistakes'); $level->hits = Input::get('hits'); $level->info = Input::get('info'); $level->player_id = Input::get('player'); $level->save(); return View::make('empty'); }