Mam problem ze skryptem walki, otóż gdy klikne na przycisk (radio) ataku to od zmiennej $ehp odejmuje mi $mydamage ale gdy poraz kolejny klikne na ten przycisk to już nieodejmuje :/. Jak zrobić aby cały czas po nacisnięciu przycisku odejmowało mi tą zmienną?prubowałem już wielu sposobów i nic, to mój skrypt:
  1. <?php
  2. require_once("funkcje.php");
  3. ?>
  4. <?php
  5. if (!isset($_GET['fight'])) {
  6. Opis
  7.  
  8. <ul>
  9. <li><a href=battle.php?action=monster>Walcz z potworami</a>
  10. </ul>
  11. ";
  12. }
  13.  
  14. if ($_GET['action'] == 'monster' && !isset($_GET['fight'])) {
  15. print "<table align=center width=100%><tr><td width=50% align=center>Nazwa</td><td width=50% align=center>Opcje</td></tr>";
  16. $elist = mysql_query("select * from monsters order by level asc");
  17. while ($elist2 = mysql_fetch_array($elist)) {
  18. print "<tr><td width=50% align=center>$elist2[name]</td><td width=50% align=center><a href=battle.php?action=monster&fight=$elist2[id]>Walka</a></td></tr></table>";
  19.  
  20. }
  21. }
  22.  
  23. $round = 1;
  24. if (isset($_GET['fight'])) {
  25. $enemy = mysql_fetch_array(mysql_query("select * from monsters where id=$_GET[fight]"));
  26. $wep = mysql_fetch_array(mysql_query("select * from players where owner=$stat[id] and status='E' and type='W'"));
  27. $mydamage1 = $wep[power] + $stat[strenght];
  28. $mydamage2 = $mydamage1 + $stat[bj];
  29. $mydamage = $mydamage2 - ($enemy[defense] + $enemy[agility]);
  30. $edamage1 = rand($enemy[damage1], $enemy[damage2]);
  31. $edamage = $edamage1 + $enemy[strenght];
  32. $ehp = $enemy['hp'];
  33. if ($mydamage < 1) {
  34. $mydamage = 1;
  35. }
  36. print "<center><b><u>TURA</u></b>: $round</center><br><br>";
  37. <table width=100% align=center>
  38. <tr>
  39. <td width=50%>
  40. <b>$stat[user]</b><br>
  41. HP :[$stat[hp]/$stat[max_hp]]<br>
  42. MP :[$stat[mp]/$stat[max_mp]]<br>
  43. <b>$enemy[name]</b><br>
  44. HP: [$enemy[hp]]<br>
  45. </td>
  46. <td width=50%>
  47. <br>
  48. <form method=post action=battle.php?action=monster&fight=$enemy[id]>
  49. <input type=radio name=action value=attack> Atak<br>
  50. <input type=radio name=action value=potion> Wypij miksture<br>
  51. <input type=radio name=action value=escape> Ucieczka<br>
  52. <input type=submit value=Dalej></form>
  53. </td>
  54. </tr>
  55. </table>
  56. ";
  57. if ($_POST['action'] == 'attack') {
  58. print "<b>$stat[user]</b> atakuje <b>$enemy[name]</b> zadając $mydamage obrażeń<br>";
  59. while ($ehp = ($ehp - $mydamage)) {
  60. print "<b>$stat[user]</b> atakuje <b>$enemy[name]</b> ($ehp zostało)<br>";
  61. $round = ($round + 1);
  62. break;
  63. } 
  64. print "<b>$enemy[name]</b> atakuje <b>$stat[user]</b> zadajać $edamage obrażeń<br>";
  65. mysql_query("update players set hp=hp-$edamag where id=$stat[id]");
  66. print "$ehp";
  67. }
  68.  
  69. }
  70. ?>