GithubHelp home page GithubHelp logo

pokerbundle's Introduction

FDuhPokerBundle

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.

pokerbundle's People

Contributors

fabienduhamel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.