aboutsummaryrefslogtreecommitdiffstats
path: root/craftmine.php
blob: 72817cc70c6d9286ee51b3ba7e15831a5a1b4437 (plain)
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
<?php

require_once("inc/mine.inc");
require_once("inc/guild.inc");
require_once("inc/shop.inc");
require_once("inc/craftmine.inc");
require_once("inc/dungeon.inc");
session_start(); // Must be placed *BEFORE* $_SESSION is actually used and *AFTER* all classes are imported

/**
* Indique au client une message requete.
*/
function reportBadRequest() {
	header("HTTP/1.1 400 Bad Request");
	echo "Format de la requete incorrect.";
	echo "Il est attendu une requete de type POST avec 2 parametres:";
	echo "<ul>";
	echo "<li><b>op</b>: l'operation a executer ('inc', 'dec')</li>";
	echo "<li><b>pos</b>: la position du hero dans la liste</li>";
	echo "</ul>";
	echo "<br/>";
	echo "La requete aura ete executee avec succes lorsque la page retournera un code 200";
	echo "<br/>Parametres POST recu: ";
	var_dump($_POST);
	echo "<br/>Parametres GET recu: ";
	var_dump($_GET);
	exit();
}
if (!isset($_POST["op"])) {
	reportBadRequest();
}


/**
* On récupère l'opération à exécuter et on le fait.
*/
$op = $_POST["op"];
switch($op) {
	case "withdrawMine": withdrawMine(); break;
	case "createGuild": createGuild(); break;
	case "hireMiner": hireMiner(); break;
	case "getCraftMine": sendCraftMine(); break;
	case "buildShop": buildShop(); break;
	case "buyItem": buyItem(); break;
	case "buildDungeon" : buildDungeon(); break;
	case "launchDungeon" : launchDungeon(); break;
	case "exitDungeon" : exitDungeon(); break;
	default: reportBadRequest();
}

?>