blob: 76dfb5073e3daa669b4eaa609390edcf944cff87 (
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
|
<?php
function initMineIfNeeded() {
if(empty($_SESSION["mine"]))
$_SESSION["mine"] = array("gold" => 0);
else if(!array_key_exists("gold", $_SESSION["mine"]))
$_SESSION["mine"]["gold"] = 0;
}
function withdrawMine() {
$amount = intval($_POST["amount"]);
if(!empty($_SESSION["dungeon"])) {
sendError("cant_withdraw_in_dungeon");
return;
}
if($amount == 0) return;
initMineIfNeeded();
$_SESSION["mine"]["gold"] += $amount;
echo json_encode($_SESSION["mine"]["gold"]);
}
function sendMine() {
initMineIfNeeded();
$mine = $_SESSION["mine"];
return $mine["gold"];
}
?>
|