Jump to content

Any suggestions?


twilitegxa

Recommended Posts

What would be the best way to go about this:

 

 

I have a table that displays a random enemy from a table (hit points, defense, experience earned, etc).

Let's say to begin with, I have a set number that the enemy's hit points are reduced by if the player chooses to attack the enemy (6).

 

 

What would be the best way in which to set this up to where the enemy's hit points get reduced each time the player clicks the attack button and the hit points get reduced by the number (6 in this case)?

 

 

Since the code is generating a random enemy, other players playing at the same time could run the risk of generating the same enemy, so is there a way I could avoid this?

 

 

 

 

I was thinking there could be some way to not actually alter the table data, but rather just do it within the browser window, but I'm not sure what technology would be best to use. Maybe AJAX? Any suggestions on how would be the best way to go about this?

Link to comment
https://forums.phpfreaks.com/topic/200482-any-suggestions/
Share on other sites

when you fight an enemy, it'll set their status to fighting in the database.

So when you go to fight an enemy, you cant fight any of them that are already fighting.

 

You have a button, or form I'm guessing. In the form tag, include

"onSubmit='validateform(this)'"

you would then in javascript at the top of the page.. do the form validation for that form. (Google about javascript form validating)

 

You'd include a php script inside the javascript form validation (No need to close the javascript.. it allows php inside) for which you process your queries etc for the fight.

 

Reducing 6 each time an attack is boring. You might want to add some adventure into it.

 

$hploss = rand(0,10); //Random number between 0 and 10

Link to comment
https://forums.phpfreaks.com/topic/200482-any-suggestions/#findComment-1052042
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.