Skip to content

Commit

Permalink
Add save-able characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Overmyer committed Jun 14, 2018
1 parent fa8d466 commit a0bba3e
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 104 deletions.
24 changes: 20 additions & 4 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,30 @@
namespace App\Http\Controllers;

use App\CharacterGenerator;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Facades\Cache;

class HomeController extends Controller
{
public function index(){
public function index()
{
return view( 'index' );
}

public function character( $guid )
{
$character = Cache::rememberForever( "character-$guid", function () {
$characterGenerator = new CharacterGenerator();
return $characterGenerator->generate();
} );

return view( 'character', [ 'character' => $character ] );
}

$characterGenerator = new CharacterGenerator();
$character = $characterGenerator->generate();
public function characterGenerate()
{
$guid = Uuid::uuid4();

return view('index', ['character' => $character]);
return redirect()->route( 'character', [ 'guid' => $guid ] );
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.7",
"rcrowe/twigbridge": "^0.9.6"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions resources/views/character.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{% extends 'layout.twig' %}

{% block content %}
<div class="column">
<section class="section">
<div class="box">
<em>Name</em>
</div>
<h2 class="title is-2 has-text-centered">{{ character.origin.name }} {{ character.careerOne.name }} {{ character.careerTwo.name }}</h2>
<h3 class="title is-3">Description</h3>
{% for descriptor in character.descriptors %}
<span>{{ descriptor }}{% if not loop.last %}, {% endif %}</span>
{% endfor %}
</section>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Mettle</p>
<p class="title">{{ character.mettle }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Physique</p>
<p class="title">{{ character.physique }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Influence</p>
<p class="title">{{ character.influence }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Expertise</p>
<p class="title">{{ character.expertise }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Interface</p>
<p class="title">{{ character.interface }}</p>
</div>
</div>

</nav>
<section class="section">
<h3 class="title is-3">Skills</h3>
{% for skill in character.skills %}
<div class="box">
<h4 class="title is-4">{{ skill.name }}</h4>
<p>
{{ skill.text|nl2br }}
</p>
</div>
{% endfor %}
</section>
</div>
<div class="column">
<section class="section">
<h3 class="title is-3">Assets</h3>
<div class="box">
<h4 class="title is-4">Workspace: {{ character.workspace.name }}</h4>
<p>{{ character.workspace.text }}</p>
</div>
{% for asset in character.assets %}
<div class="box">
<h4 class="title is-4">{{ asset.name }}</h4>
<p>{{ asset.description }}</p>
<p><strong>Type:</strong> {{ asset.type }}</p>
{% if asset.upgrades|length > 0 %}
<hr>
<h5 class="title is-5">Upgrades</h5>
<ul>
{% for upgrade in asset.upgrades %}
<li><strong>{{ upgrade.name }}:</strong> {{ upgrade.effect }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endfor %}
</section>
<section class="section">
<h3 class="title is-3">Advancement</h3>
<p><em>All characters mark XP the first time...</em></p>
<p>- {{ character.advancement }}</p>
</section>
</div>
{% endblock %}
111 changes: 12 additions & 99 deletions resources/views/index.twig
Original file line number Diff line number Diff line change
@@ -1,102 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Uncharted Worlds Character Generator</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/app.css" type="text/css">
</head>
<body>
<section class="section">
<div class="container">
<div class="columns">
<div class="column">
<section class="section">
<div class="box">
<em>Name</em>
</div>
<h2 class="title is-2 has-text-centered">{{ character.origin.name }} {{ character.careerOne.name }} {{ character.careerTwo.name }}</h2>
<h3 class="title is-3">Description</h3>
{% for descriptor in character.descriptors %}
<span>{{ descriptor }}{% if not loop.last %}, {% endif %}</span>
{% endfor %}
</section>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Mettle</p>
<p class="title">{{ character.mettle }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Physique</p>
<p class="title">{{ character.physique }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Influence</p>
<p class="title">{{ character.influence }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Expertise</p>
<p class="title">{{ character.expertise }}</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Interface</p>
<p class="title">{{ character.interface }}</p>
</div>
</div>
{% extends 'layout.twig' %}

</nav>
<section class="section">
<h3 class="title is-3">Skills</h3>
{% for skill in character.skills %}
<div class="box">
<h4 class="title is-4">{{ skill.name }}</h4>
<p>
{{ skill.text|nl2br }}
</p>
</div>
{% endfor %}
</section>
</div>
<div class="column">
<section class="section">
<h3 class="title is-3">Assets</h3>
<div class="box">
<h4 class="title is-4">Workspace: {{ character.workspace.name }}</h4>
<p>{{ character.workspace.text }}</p>
</div>
{% for asset in character.assets %}
<div class="box">
<h4 class="title is-4">{{ asset.name }}</h4>
<p>{{ asset.description }}</p>
<p><strong>Type:</strong> {{ asset.type }}</p>
{% if asset.upgrades|length > 0 %}
<hr>
<h5 class="title is-5">Upgrades</h5>
<ul>
{% for upgrade in asset.upgrades %}
<li><strong>{{ upgrade.name }}:</strong> {{ upgrade.effect }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endfor %}
</section>
<section class="section">
<h3 class="title is-3">Advancement</h3>
<p><em>All characters mark XP the first time...</em></p>
<p>- {{ character.advancement }}</p>
</section>
</div>
{% block content %}
<div class="column content">
<h1 class="title is-1">Uncharted Worlds Character Generator</h1>

<p>This is the Uncharted Worlds character generator. It will create a random character for you.</p>
<p>That character has a unique URL, so you can bookmark it or share it with others.</p>

<div>
<a href="{{ route('character_generate') }}" class="button is-primary is-large">Generate!</a>
</div>

</div>
</section>
</body>
</html>
{% endblock %}
17 changes: 17 additions & 0 deletions resources/views/layout.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Uncharted Worlds Character Generator</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ url('/') }}/css/app.css" type="text/css">
</head>
<body>
<section class="section">
<div class="container">
<div class="columns">
{% block content %}{% endblock %}
</div>
</div>
</section>
</body>
</html>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
*/

Route::get( '/', 'HomeController@index' )->name( 'home' );
Route::get( '/character/', 'HomeController@characterGenerate' )->name( 'character_generate' );
Route::get( '/character/{guid}', 'HomeController@character' )->name( 'character' );

0 comments on commit a0bba3e

Please sign in to comment.