<?php include_once "topmenu.php"; include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/User.php"; function calculateHealCost($user) { //dummy value. the value is random, based on level, and can't exceed what's in user bank. return 50; } $user = User::getUser($_SESSION['userID']); if ($user->getHealth() >= $user->getHealthMax()) { echo "You are already at full health."; print "<br>"; } else { $healCost = calculateHealCost($user); ?> Pay the doctor to regain all your health. You must pay him from the bank.<br> You currently have $<?php echo $user->getBankBalance(); ?> cash in the bank. <form action='backend/healuser.php' method='post'> <input type='hidden' name='healCost' value='<?php echo $healCost; ?> ' /> <input type='submit' value='Heal for $<?php echo $healCost; ?> ' /> </form>
if ($_GET['heal'] == 'false') { $hospital_html = '<div class="notificationbox notifybox needcash"> <h3>You need $' . $healCost . ' cash in the bank !</h3> <p>You can only pay the doctor with money in the bank.<br> You only have <strong>$' . $user->getBankBalance() . ' </strong> in the bank.</p> <a class="blackbutton visitbank" href="#">Go to the Bank</a> </div>'; } } } else { if ($user->getHealth() >= $user->getHealthMax()) { $hospital_html = '<div class="hospitaltop"> <h2>Hospital</h2> <p>You are already at full health<p> </div>'; } else { $healCost = calculateHealCost($user->getHealth(), $user->getHealthMax(), $user->getLevel()); if ($user->getBankBalance() > $healCost) { $hospital_html = "<div class='hospitaltop'>\n <h2>Hospital</h2>\n <p>Pay the doctor to regain full health. Doctors must be paid with money from the bank.<p>\n <p>You currently have <strong>\$" . $user->getBankBalance() . " </strong> in the bank.</p></div><a href='backend/healuser.php?healCost=" . $healCost . "' class='healinhospital'><span class='healer'>Heal for \$" . $healCost . "</span></a>"; } else { $hospital_html = '<div class="notificationbox notifybox needcash"> <h3>You need $' . $healCost . ' cash in the bank!</h3> <p>You can only pay the doctor with money in the bank.<br> You only have <strong>' . $user->getBankBalance() . ' $</strong> in the bank.</p> <a class="blackbutton visitbank" href="' . $serverRoot . 'bank.php">Go to the Bank</a> </div>'; } } } unset($_SESSION['healCost']); ?> <?php