-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayCard.php
More file actions
30 lines (28 loc) · 842 Bytes
/
Copy pathplayCard.php
File metadata and controls
30 lines (28 loc) · 842 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
<?php
session_start();
if( !isset($_SESSION['game']))
die("No session");
include("class.php");
if( !isset($_POST['cardColor']) || !isset($_POST['cardValue']))
die("Missing parameter");
$color = $_POST['cardColor'];
$value = $_POST['cardValue'];
$card = new Card($value,$color);
$card7 = new Card(7,3);
$table = new Table(-1);
$deck = new Deck(-1,array());
$table->loadStatus($_SESSION['game']);
$deck = $deck->loadStatus($_SESSION['game'],0);
$response = new Response();
$response->setCard($card);
if(!$deck->playCard($table,$card) || !$table->addCard($card)){
$response->setMsg("這張牌不能出!");
}
else{
$response->setMsg("你出了一張牌!");
$table->nextTurn();
}
$table->saveStatus($_SESSION['game']);
$deck = $deck->saveStatus($_SESSION['game']);
echo json_encode($response);
?>