Skip to content

infocyph/Game-Draw

Repository files navigation

Game Draw (v4)

Security & Standards Documentation Packagist Downloads License: MIT Packagist Version Packagist PHP Version GitHub Code Size

Unified PHP draw engine with a single request/response contract for item, user, and campaign draw methods.

Campaign state uses PSR-6 (Psr\Cache\CacheItemPoolInterface) via options.cachePool.

Install

Requirements:

  • PHP 8.4+
  • ext-bcmath
composer require infocyph/game-draw

Quick Example

<?php
use Infocyph\Draw\Draw;

$draw = new Draw();

$result = $draw->execute([
    'method' => 'lucky',
    'items' => [
        ['item' => 'gift_a', 'chances' => 10, 'amountMode' => 'list', 'amounts' => [1, 2]],
        ['item' => 'gift_b', 'chances' => 20, 'amountMode' => 'weighted', 'amounts' => ['5' => 0.25, '10' => 0.75]],
    ],
    'options' => ['count' => 2],
]);

Supported Methods

  • lucky
  • grand
  • probability, elimination, weightedElimination, roundRobin, cumulative
  • batched, timeBased, weightedBatch, sequential, rangeWeighted
  • campaign.run, campaign.batch, campaign.simulate

Documentation

Published docs: https://docs.infocyph.com/projects/Game-Draw/