} */ echo "</tr>"; echo "</table>"; } else { $turn_cost = 0; echo "You do not have enough turns to cast {$command}.\n"; // Ye gods this repeated code needs to be made into a single check. } } elseif ($command == "Steal") { $covert = true; if ($starting_turns >= $turn_cost) { $gold_decrease = rand(1, 50); $target_gold = getGold($target); $gold_decrease = $target_gold < $gold_decrease ? $target_gold : $gold_decrease; changeGold($username, $gold_decrease); // *** This one actually adds the value. subtractGold($target, $gold_decrease); // *** Subtracts whatever positive value is put in. $msg = "You have had pick pocket cast on you for {$gold_decrease} by {$attacker_id} at {$today}"; sendMessage($attacker_id, $target, $msg); $result = "You have stolen {$gold_decrease} gold from {$target}!<br>\n"; } else { $turn_cost = 0; echo "You do not have enough turns to cast {$command}.\n"; } } else { if ($command == "Unstealth") { $mode = -1 * STEALTH; $state = "unstealthed"; if ($starting_turns >= $turn_cost) {
function subtractGold($who, $amount) { return changeGold($who, -1 * $amount); }