I think I have somewhat of a battle system at least started for the arena NPC battles now. Problem I'm going to run into very soon is when I go to loop the battle scenario, I wont 'be able to use the table that holds the NPC's information in them, since EVERY player will be attacking the same NPC's. So I will need to store their hp during the battle so I can determine when they win/lose the fight...
Also...
When the player defeats the NPC, how in the world am I going to tell it that it needs to hit the next row in the database? The code for getting the information and fighting the NPC is below. Upon registering, the first NPC will be placed into the Arena Log Table, that way when they go to the arena, they will see the first NPC to attack. Then when they attack and win, I was going to delete that record from the arena logs, but didn't think of how I would go about inserting the 2nd NCP information in there. Any Ideas?
Code: Select all
<?php
$sql = "SELECT * FROM arenalogs WHERE userid = '$_SESSION[userid]'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
$row = mysqli_fetch_array($user_query, MYSQLI_ASSOC);
$arena_id = $row['userid'];
$arena_char_name = $row['charname'];
$character = $row['charid'];
$sql = "SELECT * FROM characters where id ='$character' ORDER BY id ASC LIMIT $character";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$playerHp = $user_health;
$enemyHp = $row['hpoints'];
//Player's Attack Turn
?>