fduh/poker-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Results manager for poker and other card games.

dev-master 2018-02-14 07:43 UTC

This package is not auto-updated.

Last update: 2022-05-28 05:21:10 UTC


README

Installation

Add the dependency:

$ composer require fduh/poker-bundle dev-master

Add the bundle:

// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Fduh\PokerBundle\FduhPokerBundle(),
            // Optional, for Google Chart
            new SaadTazi\GChartBundle\SaadTaziGChartBundle(),
        );
    }
}

How to use

Results Handler

After you created some seasons, events and results, you now want to manage players, rankings and scores. Here's how to use the bundle:

$resultsHandler = $this->get('poker.results_handler');
// Add events
$resultsHandler->addEvents($yourEvents);
// Or a season
$resultsHandler->addSeason($yourSeason);

Of course, you can retrieve events by using:

// Reduces requests count
$events = $this->get('poker.repository.hydrated.event')->findAllViewableEventsByDateAsc();

Now there's how you should use the results handler in your template:

{% for eventData in resultsHandler.eventManager.eventsData %}
    {{ eventData.event }} // Access to the Event entity
    {# And other functions... #}
{% endfor %}

{% for playerData in resultsHandler.playerManager.playersData %}
    {{ playerData.player }} // Access to the Player entity
    {{ playerData.score }}
    {{ playerData.rank }}
    {{ playerData.wonEvents }}
    {# And a lot of functions... #}
{% endfor %}

Open PlayerDataInterface.php and EventDataInterface.php to read more about provided properties.

Watch a practical example at standrewspokerclub.fr.

Chart

If you want to display score evolution (in controller):

$chartMaker = $this->get('poker.chart_maker');
$chartMaker->setSeason($season);
$chart = $chartMaker->getChart();

return array(
    'chart'  => $chart->toArray(),
    'width'  => $chartMaker->getWidth(),
    'height' => $chartMaker->getHeight()
    // ...
}

And in the template (mine for the example):

<script>
    $(function() {
        {{ gchart_line_chart(chart, 'chart', width, height, null,
           { // your options }
          )
        }}
    });
</script>

Watch a practical example at standrewspokerclub.fr.

Configuration

Reference dump:

fduh_poker:
    calculation_class: ~

If you want the bundle to calculate scores differently, override the calculation_class with a class implementing Fduh\PokerBundle\Calculator\CalculationStrategyInterface.

Run this command to recalculate every score:

$ php app/console poker:update-scores

To do

  • TwigExtensions
  • a lot of things.....

Feel free to contribute this project.