forked from shenanigans-be/miltydraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.php
More file actions
32 lines (26 loc) · 865 Bytes
/
Copy pathgenerate.php
File metadata and controls
32 lines (26 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
use App\Draft;
use App\GeneratorConfig;
use App\Tile;
use App\Slice;
require_once 'boot.php';
if (get('regen') != null) {
$draft = Draft::load(get('regen'));
if (!$draft->isAdminPass(get('admin'))) return_error('You are not allowed to do this');
if (!empty($draft->log())) return_error('Draft already in progress');
$regen_slices = get('shuffle_slices', "false") == "true";
$regen_factions = get('shuffle_factions', "false") == "true";
$regen_order = get('shuffle_order', "false") == "true";
$draft->regenerate($regen_slices, $regen_factions, $regen_order);
return_data([
'ok' => true
]);
} else {
$config = new GeneratorConfig(true);
$draft = Draft::createFromConfig($config);
$draft->save();
return_data([
'id' => $draft->getId(),
'admin' => $draft->getAdminPass()
]);
}