deannv/php-gachapon

A gachapon-like system, easy to integrate and play with.

v1.0.5 2024-08-18 08:24 UTC

This package is auto-updated.

Last update: 2025-07-18 10:17:07 UTC


README

A wild, basic gachapon system that I highly doubt will be working.

Installation

Install the package

composer require deannv/php-gachapon

Basic usage

note This package only accept associative array or key value pair data.

  1. Simple use case
// item_name => drop_rate_in_percentage
Gacha::from(['a' => 2, 'b' => 10])->pull();

or if you want to get more than 1 result

Gacha::from(['a' => 2, 'b' => 10])->pull(2);
  1. Using object
$data = [
    ["name" => "item1", "drop_rate" => 3],
    ["name" => "item2", "drop_rate" => 5],
    ["name" => "item3", "drop_rate" => 2]
];

Gacha::from($data)->pull();
  1. Or just using pull
Gacha::pull(2, ['a' => 2, 'b' => 10]);

this is the result (array)

Array
(
    [0] => item2
)

that's it!