Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/irfaardy/php-gacha
π² Simple Items or coupons Gacha / Lottery plugin with PHP, game backend gacha
https://github.com/irfaardy/php-gacha
anime dice example fate-grand-order fgo fun gacha gacha-simulator game irfa items php plugin roll roulette roulette-wheel simple simulator spin summon
Last synced: 2 months ago
JSON representation
π² Simple Items or coupons Gacha / Lottery plugin with PHP, game backend gacha
- Host: GitHub
- URL: https://github.com/irfaardy/php-gacha
- Owner: irfaardy
- License: mit
- Created: 2020-01-31T03:24:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T02:27:01.000Z (over 2 years ago)
- Last Synced: 2024-09-17T09:53:04.664Z (4 months ago)
- Topics: anime, dice, example, fate-grand-order, fgo, fun, gacha, gacha-simulator, game, irfa, items, php, plugin, roll, roulette, roulette-wheel, simple, simulator, spin, summon
- Language: PHP
- Homepage:
- Size: 134 KB
- Stars: 32
- Watchers: 3
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
π²Simple Items Gacha with PHP
[![Code Climate Maintainabillity](https://codeclimate.com/github/irfaardy/php-gacha/badges/gpa.svg)](https://codeclimate.com/github/irfaardy/php-gacha) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/irfaardy/php-gatcha/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/irfaardy/php-gatcha/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/irfaardy/php-gatcha/badges/build.png?b=master)](https://scrutinizer-ci.com/g/irfaardy/php-gatcha/build-status/master) [![Latest Stable Version](https://poser.pugx.org/irfa/php-gatcha/v/stable)](https://packagist.org/packages/irfa/php-gatcha) [![License](https://poser.pugx.org/irfa/php-gatcha/license)](https://packagist.org/packages/irfa/php-gatcha) ![PHP Composer](https://github.com/irfaardy/php-gacha/workflows/PHP%20Composer/badge.svg) [![time tracker](https://wakatime.com/badge/github/irfaardy/php-gacha.svg)](https://wakatime.com/badge/github/irfaardy/php-gacha)
This package is useful for making gacha or lottery for shopping coupons, game items, etc. with the percentage of possibilities that you have specified
π οΈ Installation with Composer
```php
composer require irfa/php-gatcha
```>You can get Composer [ here]( https://getcomposer.org/download/)
Usage in Laravel
Open config/app.php
add aliases (optional)```php
'aliases' => [
...
'Gatcha' => Irfa\Gatcha\Roll::class,
...
];
```
**Example:**```php
...
use Gatchaclass Example {
function index()
{
return Gatcha::put([ 'Item 1' => 29.4, 'Item 2' => 0.3])->spin();
}
}
```Usage in PHP Native
```php
require_once "vendor/autoload.php";
use Irfa\Gatcha\Roll;`
```π» Basic Usage
```php
$items = [
'common ITEM1' => 70, // 70% chance
'Rare ITEM 2' => 29.4, // 29.4% chance
'Super Rare ITEM' => 0.3, // 0.3% chance
'Super Rare ITEM 2' => 0.3,
'Super Super Rare ITEM' => 0.003, // 0.003% chance
];
$item_get = Roll::put($items)->spin();
echo "Congratulations you get ".$item_get;
```π» Using DropUp
> This function is used for certain conditions such as events, bonuses, etc.
```php
use Irfa\Gatcha\Roll;
$items = [
'common ITEM1' => 70, // 70% chance
'Rare ITEM 2' => 29.4, // 29.4% chance
'Super Rare ITEM' => 0.3, // 0.3% chance
'Super Rare ITEM 2' => 0.3,
'Super Super Rare ITEM' => 0.003, // 0.003% chance
];
Roll::put($items)
if(date('Y-m-d') == '2020-03-21') //example event date
{
Roll::dropUp(['Super Rare ITEM', 'Super Rare ITEM 2'], 200)//Drop up rate 200%
->dropUp('common ITEM1', 300); //Drop up rate 300%
//Parameters items (items index in array), rate in percent
}
$item_get = Roll::spin();
echo "Congratulations you get ".$item_get;
```π» JSON Return
> If you want return to json
```php
Roll::put($items)->jsonSpin();
```
**Result:**```json
{
"data":{
"item":"SomeItem"
}
}
```
## How to Contributing?1. Fork it ()
2. Commit your changes (`git commit -m 'some New Feature'`)
3. Push to the branch (`git push origin x.x`)
4. Create a new Pull Request***
---
## Issue
If you found issues or bug please create new issues here https://github.com/irfaardy/php-gacha/issues/new
***