File tree Expand file tree Collapse file tree 10 files changed +88
-81
lines changed Expand file tree Collapse file tree 10 files changed +88
-81
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11{
2- "name" : " irfaardy /gatcha" ,
3- "description" : " simple items gatcha " ,
2+ "name" : " irfa /gatcha" ,
3+ "description" : " Simple Items Gatcha with PHP " ,
44 "license" : " MIT" ,
5+ "version" : " v2.0" ,
56 "authors" : [
67 {
7- "name" : " Irfa" ,
8- "email" : " irfaardiansyah95@gmail .com"
8+ "name" : " Irfa A " ,
9+ "email" : " irfa.backend@protonmail .com"
910 }
1011 ],
11- "minimum-stability" : " stable" ,
12- "require" : {}
12+ "require" : {
13+ "php" : " >=5.4.0"
14+ },
15+ "autoload" : {
16+ "psr-4" : {
17+ "Irfa\\ Gatcha\\ " : " src/"
18+ }
19+ }
1320}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11<?php
2- require_once "Autoloader .php " ;
2+ require_once "vendor/autoload .php " ;
33
4- use Irfa \Roulete as Roll ;
4+ use Irfa \Gatcha \ Roll ;
55
6-
7- include "view/home/head.php " ;
86?>
7+ <!DOCTYPE html>
8+ <html>
9+ <head>
10+ <title>Gatcha</title>
11+ <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
12+ </head>
913<body>
1014 <div class="container">
1115 <div class="row">
1216 <div class="col-md-12" align="center">
1317 <div class="alert alert-primary">
14- <?= "<h2>Selamat Kamu mendapatkan </h2><h2> " .Roll::spin (['SSR ITEM ' => 0.1 ,
18+ <?= "<h2>Selamat Kamu mendapatkan </h2><h2> " .Roll::put (['SSR ITEM ' => 0.1 ,
1519 'SSR ITEM 2 ' => 0.2 ,
1620 'SSR ITEM 3 ' => 0.3 ,
1721 'SSR ITEM 4 ' => 0.4 ,
3337 'item 20 ' => 11.6 ,
3438 'item 21 ' => 8.3 ,
3539
36- ])."</h2> " ?>
40+ ])-> spin () ."</h2> " ?>
3741 </div>
3842 </div>
3943 </div>
4044 </div>
4145</body>
42- <?php
43- include "view/home/footer.php " ;
Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ Author:Irfa Ardiansyah <[email protected] > 4+ Simple Items Gatcha with PHP
5+ */
6+ namespace Irfa \Gatcha ;
7+
8+ use Irfa \Gatcha \Roulete \Roulete ;
9+
10+ class Roll extends Roulete {
11+
12+ private static $ items ;
13+ private static $ return ;
14+
15+ public static function put ($ items )
16+ {
17+ self ::$ items = $ items ;
18+
19+ return new static ();
20+ }
21+ public static function spin ()
22+ {
23+ return self ::getItem ();
24+ }
25+ private static function getItem (){
26+ $ ret = Roulete::get (self ::$ items );
27+ self ::$ items =null ;
28+ return $ ret ;
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ Author:Irfa Ardiansyah <[email protected] > 4+ Simple Items Gatcha with PHP
5+ */
6+ namespace Irfa \Gatcha \Roulete ;
7+ use Exception ;
8+
9+ class Roulete {
10+
11+ protected function get ($ items ) {
12+ if (is_array ($ items ))
13+ {
14+ $ max = 0 ;
15+ foreach ($ items as $ key => $ value ) {
16+ $ max += $ value ;
17+ $ items [$ key ] = $ max ;
18+ }
19+
20+ $ random = mt_rand (1 , $ max );
21+
22+ foreach ($ items as $ item => $ max )
23+ {
24+ if ($ random <= $ max ) {
25+ break ;
26+ }
27+ }
28+ return $ item ;
29+ } else {
30+ throw new Exception ('Parameter must be an array. ' );
31+
32+ return false ;
33+ }
34+ }
35+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments