Hey guys,
I'm having some trouble with mt_rand on a game I'm working on, at least I think thats the problem. If the activeBattle condition is 'no', and the number 1 is generated by mt_rand, the code is supposed to start a battle by updating my database.
The only issue is, it seems to be starting the battle on any number. Its completly random which number activates the battle. There is no pattern.
Here is the code, does anyone have any ideas why this may be happening?
$encounter = mt_rand(1, 6);
if (($encounter == 1) && ($activeBattle == 'no')) {
$active = "yes";
$id = 1;
$sql = "UPDATE encounter SET active=? WHERE id=?";
$statement = $connect->prepare($sql);
$statement->execute(array($active,$id));
reloadPage();
}