-
Notifications
You must be signed in to change notification settings - Fork 0
/
uno.php
89 lines (74 loc) · 2.42 KB
/
uno.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
require_once "lib/dbconnect2.php";
require_once "lib/show_board.php";
require_once "lib/reset_board.php";
require_once "lib/do_move.php";
require_once "lib/do_paso.php";
require_once "lib/do_draw.php";
require_once "lib/show_card_info.php";
require_once "lib/show_player_info.php";
require_once "lib/show_players.php";
require_once "lib/show_game.php";
require_once "lib/do_uno.php";
$method = $_SERVER['REQUEST_METHOD'];
$request = explode('/', trim($_SERVER['PATH_INFO'],'/'));
$input = json_decode(file_get_contents('php://input'),true);
switch ($r=array_shift($request)) {
case 'board' :
switch ($b=array_shift($request)) {
case '':
case null: handle_board($method);
break;
case 'card': handle_card($method,$request[0]);
break;
case 'player': handle_player($request[0]);
break;
case 'players': handle_players();
break;
case 'paso': handle_paso();
break;
case 'draw': handle_draw();
break;
case 'uno': handle_uno();
break;
case 'game': handle_game();
default: header("HTTP/1.1 404 Not Found");
break;
}
break;
default: header("HTTP/1.1 404 Not Found");
exit;
}
function handle_board($method) {
if($method=='GET') {
show_board();
} else if ($method=='POST') {
reset_board();
}
}
function handle_card($method,$card) {
if($method=='PUT'){
do_move($card);}
else if($method=='GET'){
show_card_info($card);
}
}
function handle_paso(){
do_paso();
}
function handle_draw(){
do_draw();
}
function handle_player($player) {
show_player_nickname($player);
}
function handle_players() {
show_players();
}
function handle_uno(){
do_uno();
}
function handle_game(){
show_game();
}
?>