forked from shenanigans-be/miltydraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpick.php
More file actions
26 lines (19 loc) · 629 Bytes
/
pick.php
File metadata and controls
26 lines (19 loc) · 629 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
<?php
require_once 'boot.php';
$id = get('id');
$index = get('index');
$player = get('player');
$category = get('category');
$value = get('value');
$draft = \App\Draft::load($id);
$is_admin = $draft->isAdminPass(get('admin'));
if ($draft == null) return_error('draft not found');
if ($player != $draft->currentPlayer() && !$is_admin) return_error('Not your turn!');
if ($index != count($draft->log())) {
return_error('Draft data out of date, meaning: stuff has been picked or undone while this tab was open.');
}
$draft->pick($player, $category, $value);
return_data([
'draft' => $draft,
'success' => true
]);