0); else if(!array_key_exists("gold", $_SESSION["mine"])) $_SESSION["mine"]["gold"] = 0; } /** * Transfers all gold from the mine to the player's account. * * @return void */ function withdrawMine() { $amount = intval($_POST["amount"]); if(!empty($_SESSION["dungeon"]) && !empty($_SESSION["dungeon"]["flat"])) { // player in dungeon sendError("cant_withdraw_in_dungeon"); return; } if($amount == 0) return; initMineIfNeeded(); $_SESSION["mine"]["gold"] += $amount; echo json_encode($_SESSION["mine"]["gold"]); } /** * Returns the amount of gold currently owned by the player. * * @return int amount of gold available */ function sendMine() { initMineIfNeeded(); $mine = $_SESSION["mine"]; return $mine["gold"]; } ?>