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:
<?php
require_once("funkcje.php");
?>
<?php
if (!isset($_GET['fight'])) { Opis
<ul>
<li><a href=battle.php?action=monster>Walcz z potworami</a>
</ul>
";
}
if ($_GET['action'] == 'monster' && !isset($_GET['fight'])) { print "<table align=center width=100%><tr><td width=50% align=center>Nazwa</td><td width=50% align=center>Opcje</td></tr>"; $elist = mysql_query("select * from monsters order by level asc"); 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>";
}
}
$round = 1;
if (isset($_GET['fight'])) { $mydamage1 = $wep[power] + $stat[strenght];
$mydamage2 = $mydamage1 + $stat[bj];
$mydamage = $mydamage2 - ($enemy[defense] + $enemy[agility]);
$edamage1 = rand($enemy[damage1
], $enemy[damage2
]); $edamage = $edamage1 + $enemy[strenght];
$ehp = $enemy['hp'];
if ($mydamage < 1) {
$mydamage = 1;
}
print "<center><b><u>TURA</u></b>: $round</center><br><br>"; <table width=100% align=center>
<tr>
<td width=50%>
<b>$stat[user]</b><br>
HP :[$stat[hp]/$stat[max_hp]]<br>
MP :[$stat[mp]/$stat[max_mp]]<br>
<b>$enemy[name]</b><br>
HP: [$enemy[hp]]<br>
</td>
<td width=50%>
<br>
<form method=post action=battle.php?action=monster&fight=$enemy[id]>
<input type=radio name=action value=attack> Atak<br>
<input type=radio name=action value=potion> Wypij miksture<br>
<input type=radio name=action value=escape> Ucieczka<br>
<input type=submit value=Dalej></form>
</td>
</tr>
</table>
";
if ($_POST['action'] == 'attack') {
print "<b>$stat[user]</b> atakuje <b>$enemy[name]</b> zadając $mydamage obrażeń<br>"; while ($ehp = ($ehp - $mydamage)) {
print "<b>$stat[user]</b> atakuje <b>$enemy[name]</b> ($ehp zostało)<br>"; $round = ($round + 1);
break;
}
print "<b>$enemy[name]</b> atakuje <b>$stat[user]</b> zadajać $edamage obrażeń<br>"; mysql_query("update players set hp=hp-$edamag where id=$stat[id]"); }
}
?>