Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="utf-8" />
- <title>Coop Insanity</title>
- <link href="https://fonts.googleapis.com/css?family=Orbitron:400,500,700,900" rel="stylesheet">
- <style type="text/css">
- /* domain reset to /weingut-frick.relaunch/public/ #######*/
- html {
- background:url('bg.jpg') top center no-repeat;
- background-size:cover;
- font-family: 'Orbitron', sans-serif;
- }
- #main {
- position:absolute;
- width:800px;
- left:50%;
- margin-left:-400px;
- margin-top:100px;
- border-bottom:1px solid #fff;
- border-radius:20px 20px 0 0 ;
- background:#f1f1f1;
- box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.45);
- opacity:.85;
- font-family: 'Orbitron', sans-serif;
- }
- p {
- box-sizing: border-box;
- color: rgb(25, 25, 25);
- display: block;
- font-family:Arial;
- font-size: 15px;
- line-height: 20.4px;
- text-align:center;
- width:100%;
- padding-top:10px;
- font-family: 'Orbitron', sans-serif;
- }
- h1 {
- box-sizing: border-box;
- color: rgb(25, 25, 25);
- display: block;
- font-size: 26px;
- line-height: 36.4px;
- font-family: 'Orbitron', sans-serif;
- text-align:center;
- width:100%;
- }
- h2 {
- box-sizing: border-box;
- color: rgb(25, 25, 25);
- display: block;
- font-size: 22px;
- line-height: 32.4px;
- font-family: 'Orbitron', sans-serif;
- text-align:center;
- width:100%;
- }
- p a {
- color: #10B20A;
- font-family: 'Orbitron', sans-serif;
- font-size: 14px;
- line-height: 20.4px;
- text-align:center;
- text-decoration:none;
- font-weight:700;
- }
- p a:hover {
- color:#333;
- }
- p a:after{
- content:',';
- }
- p a:last-child:after {
- content:'';
- }
- </style>
- </head>
- <body>
- <div id="main">
- <h1>Coop Commander Insanity</h1>
- <?php
- $data = json_decode(file_get_contents("commander.json"),true);
- $points = 3;
- if($_GET["commander"] && $data[$_GET["commander"]]) {
- $_GET["commander"] = urldecode($_GET["commander"]);
- ?>
- <h2>Take following units:</h2><p><br>
- <?php
- $ret = getUnits($data[$_GET["commander"]],$points);
- foreach($ret as $value) {
- echo "<b>" . $value . "<b><br>";
- }
- ?>
- <br><a href="index.php">back</a></p>
- <?php
- } else {
- ?>
- <h2>Choose your Commander:</h2><p>
- <?php
- foreach($data as $key => $value) {
- echo "<a href='index.php?commander=" . $key . "' >" . $key . "</a> ";
- }
- ?>
- </p>
- <?php
- }
- function getUnits($stack,$points) {
- $choose = array();
- while(true) {
- $tmp = array();
- foreach($stack as $key => $value) {
- if($value <= $points) {
- $tmp[$key] = $value;
- }
- }
- $add = roll($tmp,$choose);
- if($add === false) {
- return $choose;
- }
- $choose[] = $add;
- $points = $points - $stack[$add];
- }
- }
- function roll($stack,$choose) {
- $tmp = array();
- // firt filter the not allready chosen
- foreach($stack as $key => $value) {
- if(!in_array($key,$choose)) {
- $tmp[] = $key;
- }
- }
- if(count($tmp) < 1) {
- return false;
- }
- // now we mix the array
- return $tmp[rand(0,(count($tmp) - 1))];
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement