-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_solitary.php
55 lines (42 loc) · 907 Bytes
/
ajax_solitary.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
<?php
include('./config.php');
switch ($_REQUEST['action']) {
case 'search':
search_solution();
break;
case 'random_game':
random_game();
break;
default:
break;
}
function search_solution() {
$solitary = new Solitary(52);
$solitary->create_perso_game($_REQUEST['TDeck'], $_REQUEST['TBoard']);
// Sauvegarde pour tests
file_put_contents('save/'.date('Y-m-d H:i:s').'.sol', serialize($solitary->TInit));
$solitary->get_solution();
$sol = new TTemplateTBS();
$pathHTML = $sol->render(
'tpl/solution.tpl.php'
, array(
'path' => $solitary->bestPath
)
, array(
'data' => array(
)
,'view' => array(
'http' => HTTP
)
)
);
echo json_encode(array(
'score' => $solitary->bestScore
//,'path' => $solitary->bestPath
,'pathHTML' => $pathHTML
));
}
function random_game() {
$solitary = new Solitary(52);
$solitary->create_random_game();
}