Created
November 22, 2017 09:28
-
-
Save blazarecki/67ae7af0dd84aa91d8542caf01a260b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html.twig' %} | |
{% block body %} | |
{{ form(form) }} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use App\Fight\DamageCalculator; | |
use App\Form\FightType; | |
use Doctrine\ORM\EntityManager; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\Request; | |
class FightController extends Controller | |
{ | |
/** | |
* @Route(path="/fight", name="fight") | |
*/ | |
public function indexAction(Request $request, EntityManager $manager) | |
{ | |
$form = $this->createForm(FightType::class); | |
$form->handleRequest($request); | |
if ($form->isSubmitted() && $form->isValid()) { | |
/** @var \App\Fight\Fight $fight */ | |
$fight = $form->getData(); | |
} | |
return $this->render('Fight/index.html.twig', ['form' => $form->createView()]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html.twig' %} | |
{% block body %} | |
<a href="{{ path('player_new') }}">Create player</a> | |
<table> | |
<thead> | |
<th>Status</th> | |
<th>Name</th> | |
<th>HP</th> | |
<th>Weapon</th> | |
<th>Damage</th> | |
<th>Coef</th> | |
<th>Fire rate</th> | |
</thead> | |
<tbody> | |
{% for player in players %} | |
<tr> | |
<td>{{ player.healthPoint < 0 ? 'DEAD' : 'Alive' }}</td> | |
<td>{{ player.name }}</td> | |
<td>{{ player.healthPoint }}</td> | |
<td>{{ player.currentWeapon.name }}</td> | |
<td>{{ player.currentWeapon.damage }}</td> | |
<td>{{ player.currentWeapon.damageDistanceCoef }}</td> | |
<td>{{ player.currentWeapon.fireRate }}/s</td> | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use App\Entity\Player; | |
use App\Form\PlayerType; | |
use Doctrine\ORM\EntityManager; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\Request; | |
class PlayerController extends Controller | |
{ | |
/** | |
* @Route(path="/", name="player_list") | |
*/ | |
public function indexAction() | |
{ | |
$players = $this->getDoctrine()->getRepository(Player::class)->findAll(); | |
return $this->render('Player/index.html.twig', ['players' => $players]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment