diff --git a/composer.json b/composer.json index c7e381a..d26aa8e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^7.1.3", "ext-ctype": "*", "ext-iconv": "*", - "lotgd/core": "dev-feature/admin-commands as 0.5.1", + "lotgd/core": "^0.5.0", "sensio/framework-extra-bundle": "^5.2", "symfony/asset": "4.2.*", "symfony/console": "4.2.*", @@ -33,12 +33,14 @@ "symfony/twig-bundle": "4.2.*", "symfony/validator": "4.2.*", "symfony/web-link": "4.2.*", - "symfony/yaml": "4.2.*" + "symfony/yaml": "4.2.*", + "twig/extensions": "^1.5" }, "require-dev": { "lotgd/module-forest": ">0.4", "lotgd/module-gender": ">0.4", "lotgd/module-new-day": ">0.4", + "lotgd/module-res-charstats": "dev-master", "lotgd/module-res-fight": ">0.4", "lotgd/module-scene-bundle": ">0.4", "lotgd/module-village": ">0.4", diff --git a/composer.lock b/composer.lock index 91eb9c5..4bf3adc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "60a6dc3cee211e20eaf102f14c46a233", + "content-hash": "fac7947a4353735d1a2c6f44966f18e8", "packages": [ { "name": "behat/transliterator", @@ -1887,16 +1887,16 @@ }, { "name": "lotgd/core", - "version": "dev-feature/admin-commands", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/lotgd/core.git", - "reference": "4d1ab9e7634596c353d61ff90ce4ce31bf666721" + "reference": "4ca81a37893df5dc6e442d16dc88447a47e2e4e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lotgd/core/zipball/4d1ab9e7634596c353d61ff90ce4ce31bf666721", - "reference": "4d1ab9e7634596c353d61ff90ce4ce31bf666721", + "url": "https://api.github.com/repos/lotgd/core/zipball/4ca81a37893df5dc6e442d16dc88447a47e2e4e1", + "reference": "4ca81a37893df5dc6e442d16dc88447a47e2e4e1", "shasum": "" }, "require": { @@ -1930,10 +1930,10 @@ ], "description": "Core functionality for Legend of the Green Dragon, a text-based RPG game.", "support": { - "source": "https://github.com/lotgd/core/tree/feature/admin-commands", + "source": "https://github.com/lotgd/core/tree/v0.5.0", "issues": "https://github.com/lotgd/core/issues" }, - "time": "2019-04-02T19:12:02+00:00" + "time": "2019-04-05T11:19:33+00:00" }, { "name": "monolog/monolog", @@ -3715,16 +3715,16 @@ }, { "name": "symfony/flex", - "version": "v1.2.0", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/symfony/flex.git", - "reference": "7f04fb50c5da6d020e4df743b4c764c188bb24bf" + "reference": "305a6cd75a54992f47f46eb655245b6c9a06997a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/flex/zipball/7f04fb50c5da6d020e4df743b4c764c188bb24bf", - "reference": "7f04fb50c5da6d020e4df743b4c764c188bb24bf", + "url": "https://api.github.com/repos/symfony/flex/zipball/305a6cd75a54992f47f46eb655245b6c9a06997a", + "reference": "305a6cd75a54992f47f46eb655245b6c9a06997a", "shasum": "" }, "require": { @@ -3760,7 +3760,7 @@ } ], "description": "Composer plugin for Symfony", - "time": "2019-02-21T11:31:25+00:00" + "time": "2019-04-03T17:16:03+00:00" }, { "name": "symfony/form", @@ -5864,6 +5864,61 @@ "homepage": "https://symfony.com", "time": "2019-03-30T15:58:42+00:00" }, + { + "name": "twig/extensions", + "version": "v1.5.4", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig-extensions.git", + "reference": "57873c8b0c1be51caa47df2cdb824490beb16202" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/57873c8b0c1be51caa47df2cdb824490beb16202", + "reference": "57873c8b0c1be51caa47df2cdb824490beb16202", + "shasum": "" + }, + "require": { + "twig/twig": "^1.27|^2.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3.4", + "symfony/translation": "^2.7|^3.4" + }, + "suggest": { + "symfony/translation": "Allow the time_diff output to be translated" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_Extensions_": "lib/" + }, + "psr-4": { + "Twig\\Extensions\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Common additional features for Twig that do not directly belong in core", + "keywords": [ + "i18n", + "text" + ], + "time": "2018-12-05T18:34:18+00:00" + }, { "name": "twig/twig", "version": "v2.7.4", @@ -6338,22 +6393,66 @@ }, "time": "2019-03-26T09:01:07+00:00" }, + { + "name": "lotgd/module-res-charstats", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/lotgd/module-res-charstats.git", + "reference": "da79d327aed3178fcbb53a43a45f193d53bb4716" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lotgd/module-res-charstats/zipball/da79d327aed3178fcbb53a43a45f193d53bb4716", + "reference": "da79d327aed3178fcbb53a43a45f193d53bb4716", + "shasum": "" + }, + "require": { + "lotgd/core": ">=0.5.0-alpha" + }, + "require-dev": { + "phpunit/dbunit": "*", + "phpunit/phpunit": "^4.1|^5.1" + }, + "type": "lotgd-module", + "autoload": { + "psr-4": { + "LotGD\\Module\\Res\\Charstats\\": "src/", + "LotGD\\Module\\Res\\Charstats\\Tests\\": "tests/" + } + }, + "license": [ + "AGPL-3.0" + ], + "authors": [ + { + "name": "Basilius Sauter", + "email": "basilius.sauter@gmail.com" + } + ], + "description": "This module adds basic stats to the default character stats of lotgd/core", + "support": { + "source": "https://github.com/lotgd/module-res-charstats/tree/master", + "issues": "https://github.com/lotgd/module-res-charstats/issues" + }, + "time": "2019-04-05T11:17:03+00:00" + }, { "name": "lotgd/module-res-fight", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/lotgd/module-res-fight.git", - "reference": "22d6083cce6c1f1809bf9e112d754d94148a9060" + "reference": "090b9ff1af91134b078fe93db4391c6ad2bad36c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lotgd/module-res-fight/zipball/22d6083cce6c1f1809bf9e112d754d94148a9060", - "reference": "22d6083cce6c1f1809bf9e112d754d94148a9060", + "url": "https://api.github.com/repos/lotgd/module-res-fight/zipball/090b9ff1af91134b078fe93db4391c6ad2bad36c", + "reference": "090b9ff1af91134b078fe93db4391c6ad2bad36c", "shasum": "" }, "require": { - "lotgd/core": ">0.5", + "lotgd/core": ">=0.5", "lotgd/module-new-day": ">0.4.0-alpha", "lotgd/module-village": ">0.4.0-alpha" }, @@ -6382,7 +6481,7 @@ "source": "https://github.com/lotgd/module-res-fight/tree/master", "issues": "https://github.com/lotgd/module-res-fight/issues" }, - "time": "2019-03-26T09:16:21+00:00" + "time": "2019-04-05T12:43:04+00:00" }, { "name": "lotgd/module-scene-bundle", @@ -7251,17 +7350,10 @@ "time": "2019-03-04T10:37:56+00:00" } ], - "aliases": [ - { - "alias": "0.5.1", - "alias_normalized": "0.5.1.0", - "version": "dev-feature/admin-commands", - "package": "lotgd/core" - } - ], + "aliases": [], "minimum-stability": "dev", "stability-flags": { - "lotgd/core": 20 + "lotgd/module-res-charstats": 20 }, "prefer-stable": true, "prefer-lowest": false, diff --git a/config/packages/twig_extensions.yaml b/config/packages/twig_extensions.yaml new file mode 100644 index 0000000..0881cc9 --- /dev/null +++ b/config/packages/twig_extensions.yaml @@ -0,0 +1,11 @@ +services: + _defaults: + public: false + autowire: true + autoconfigure: true + + # Uncomment any lines below to activate that Twig extension + #Twig\Extensions\ArrayExtension: ~ + #Twig\Extensions\DateExtension: ~ + #Twig\Extensions\IntlExtension: ~ + #Twig\Extensions\TextExtension: ~ diff --git a/src/Controller/CharacterController.php b/src/Controller/CharacterController.php index 6320354..90dd99f 100644 --- a/src/Controller/CharacterController.php +++ b/src/Controller/CharacterController.php @@ -6,6 +6,7 @@ use LotGD\Core\Exceptions\ActionNotFoundException; +use LotGD\Core\Models\CharacterStats; use LotGD\Crate\WWW\Service\GameService; use LotGD\Crate\WWW\Service\Realm; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -58,6 +59,7 @@ public function sceneRender( "realm" => $realm, "user" => $security->getUser(), "character" => $game->getCharacter(), + "character_stats" => new CharacterStats($game, $game->getCharacter()), "viewpoint" => $game->getViewpoint(), "viewpoint_error" => $viewpoint_error??null, ]); diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php new file mode 100644 index 0000000..325e719 --- /dev/null +++ b/src/Twig/AppExtension.php @@ -0,0 +1,51 @@ +

", $text); + return "

{$text}

"; + } +} \ No newline at end of file diff --git a/symfony.lock b/symfony.lock index e68706f..3c4059b 100644 --- a/symfony.lock +++ b/symfony.lock @@ -125,6 +125,9 @@ "lotgd/module-new-day": { "version": "v0.4.0-alpha" }, + "lotgd/module-res-charstats": { + "version": "dev-master" + }, "lotgd/module-res-fight": { "version": "v0.4.0" }, @@ -461,6 +464,18 @@ "symfony/yaml": { "version": "v4.2.2" }, + "twig/extensions": { + "version": "1.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "1.0", + "ref": "ddb2e0a77773b7fd75d8d649545f174e664500ab" + }, + "files": [ + "config/packages/twig_extensions.yaml" + ] + }, "twig/twig": { "version": "v2.6.2" }, diff --git a/templates/scene.html.twig b/templates/scene.html.twig index 81b1671..735c0b4 100644 --- a/templates/scene.html.twig +++ b/templates/scene.html.twig @@ -14,7 +14,7 @@ {% endif %} - {{ viewpoint.description }} + {{ viewpoint.description|e|viewpoint_format|raw }} {% endblock %} {% block left_content %} @@ -41,6 +41,33 @@ {% endfor %} {% endblock %} +{% macro progressBar(val, max, min=0) %} +
+
{{ val|e }}/{{ max|e }}
+
+{% endmacro %} +{% import _self as macro %} + {% block right_content %} -

You are playing {{ character.displayName }}

+ {% if character_stats %} + + {% for group in character_stats.iterate %} + + + {% for item in group.iterate %} + {% if item is instanceOf("LotGD\\Module\\Res\\CharStats\\CharacterStats\\ProgressBarCharacterStat") %} + + {% elseif item is instanceOf("LotGD\\Core\\Models\\CharacterStats\\BaseCharacterStat") %} + + {% else %} + + {% endif %} + {% endfor %} + {% endfor %} +
{{ group.name }}
{{ item.name }} {{ macro.progressBar(item.value, item.max, item.min) }}
{{ item.name }} {{ item.value }}
{{ item.name }} {{ item.valueAsString }}
+ {% else %} +

You are playing {{ character.displayName }}

+ {% endif %} {% endblock %} \ No newline at end of file