Skip to content

Commit 70eab17

Browse files
committed
First Commit
1 parent c2199d3 commit 70eab17

File tree

8 files changed

+124
-0
lines changed

8 files changed

+124
-0
lines changed

Classes/Autoloader.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
class Autoloader {
3+
static public function loader($className) {
4+
$filename = str_replace("\\", '/', $className) . ".php";
5+
if (file_exists($filename)) {
6+
include($filename);
7+
if (class_exists($className)) {
8+
return TRUE;
9+
}
10+
}
11+
return FALSE;
12+
}
13+
}
14+
spl_autoload_register('Autoloader::loader');

Classes/Roulete.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
namespace Classes;
3+
4+
class Roulete {
5+
6+
public function spin($items){
7+
8+
$max = 0;
9+
foreach ($items as $key => $value) {
10+
$max += $value;
11+
$items[$key] = $max;
12+
}
13+
14+
$random = mt_rand(1,$max);
15+
16+
foreach ($items as $item => $max)
17+
{
18+
if ($random <= $max){
19+
break;
20+
}
21+
}
22+
return $item;
23+
}
24+
}

Classes/pro.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
require "Roulete.php";
3+
4+
namespace Gatcha;
5+
6+
use Gatcha\Roulete;
7+
class Gatcha {
8+
private $item;
9+
10+
11+
public function drop(){
12+
$this->item = $this->spin();
13+
return $this->item;
14+
}
15+
}
16+
17+
$gatcha = new Gatcha();
18+
echo "<h2>kamu mendapatkan </h2><h2>". $gatcha->drop()."</h2>";

Gatcha.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
require_once "Classes/Autoloader.php";
3+
4+
use Classes\Roulete as Roll;
5+
6+
7+
include"view/home/head.php";
8+
?>
9+
<body>
10+
<div class="container">
11+
<div class="row">
12+
<div class="col-md-12" align="center">
13+
<div class="alert alert-primary">
14+
<?= "<h2>Selamat Kamu mendapatkan </h2><h2>". Roll::spin(['SSR ITEM' => 0.1,
15+
'SSR ITEM 2' => 0.2,
16+
'SSR ITEM 3' => 0.3,
17+
'SSR ITEM 4' => 0.4,
18+
'SR ITEM 1' => 0.5,
19+
'SR ITEM 2' => 0.6,
20+
'SR ITEM 3' => 1.2,
21+
'item 8' => 2,
22+
'item 9' => 2.8,
23+
'item 10' => 3.6,
24+
'item 11' => 4.4,
25+
'item 12' => 5.2,
26+
'item 13' => 6,
27+
'item 14' => 6.8,
28+
'item 15' => 7.6,
29+
'item 16' => 8.4,
30+
'item 17' => 9.2,
31+
'item 18' => 10,
32+
'item 19' => 10.8,
33+
'item 20' => 11.6,
34+
'item 21' => 8.3,
35+
36+
])."</h2>" ?>
37+
</div>
38+
</div>
39+
</div>
40+
</div>
41+
</body>
42+
<?php
43+
include"view/home/footer.php";

css/app.css

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/home/body.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<body>
2+
<div class="row">
3+
<div class="col-md-5">
4+
<div class="alert alert-primary">
5+
<?= "<h2>kamu mendapatkan </h2><h2>". Roll::spin()."</h2>" ?>
6+
</div>
7+
</div>
8+
</div>
9+
</body>

view/home/footer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
</html>

view/home/head.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Gatcha Gatcha</title>
5+
<link rel="stylesheet" type="text/css" href="css/app.css">
6+
</head>

0 commit comments

Comments
 (0)