Bueno me gustaria que me den consejos y tips para programar mejor, que cosas no debo hacer, que debo hacer que le falat para que la programacion sea impecable y mas perfecta...
Código PHP:
Ver original
<?php $tipo = "submit"; $vidaA = 100; $vidaB = 100; $hpA = 500; $hpB = 500; $hpcolorA = "#66FF00"; $hpcolorB = "#66FF00"; $heroA = "Lord of Avernus"; $heroB = "Warchief"; //Skils NOMBRES y ATAQUE $skillA = "Death Coil"; $skillB = "Return"; $skillBdmg = 30; //Atake if($_POST['action'] == "true") { //ATAQUE MAGICO $daño = $atkB-($atkB*0.10); if ($_POST['atacar'] == "Skill") { //Atake Abaddon $msj= "+<b><font color=green>".$heroA."</font></b> uso <font color=brown><i>".$skillA."</i></font> en <b><font color=blue>".$heroB."</font></b> causando <b><font color=red>".$skillAdmg. "</font></b> daño magico<br>"; //Atake Centauro $rpta = "-<b><font color=blue>".$heroB."</font></b> respondio al ataque de <b><font color=green>".$heroA."</font></b> causando <b><font color=red>".$daño. "</font></b> daño fisico<br>"; //Calcular daño causado $hpBtmp = $skillAdmg; $hpAtmp = $daño; } //Ataque FISICO else { $daño = $atkA-($atkA*0.08); $daño2 = $atkB-($atkB*0.10); if ($skill <= 30) { $dañoRE = $atkA-($atkA*0.20); $return= "--<b><font color=blue>".$heroB."</font></b> uso <font color=brown><i>".$skillB."</i></font> contra <b><font color=green>".$heroA."</font></b> devolviendo <b><font color=red>".$skillBdmg. "</font></b> de daño fisico y reduciendo el ataque en <font color=brown><b>".$dañoRE."</b></font><br>"; $hpBtmp = $dañoRE; $hpAtmp = ($daño2+$skillBdmg); }else { $hpBtmp = $daño; $hpAtmp = $daño2; } //Ataque Abaddon $msj= "+<b><font color=green>".$heroA."</font></b> ataco a <b><font color=blue>".$heroB."</font></b> causando <b><font color=red>".$daño. "</font></b> daño fisico<br>".$return; //Ataque Centauro $rpta = "-<b><font color=blue>".$heroB."</font></b> respondio al ataque de <b><font color=green>".$heroA."</font></b> causando <b><font color=red>".$daño2. "</font></b> daño fisico<br>"; } //Calculando el % de la vida y la cantidad $hpA = (int)(($hpA - $hpAtmp)); $_SESSION['hpAresult'] = $_SESSION['hpAresult']+(500-$hpA); $hpB = (int)(($hpB - $hpBtmp)); $_SESSION['hpBresult'] = $_SESSION['hpBresult']+(500-$hpB); $vidaA = (int)($vidaA-($vidaA-(100*($hpA/500)))); $_SESSION['vidaAresult'] = $_SESSION['vidaAresult']+(100-$vidaA); $vidaB = (int)($vidaB-($vidaB-(100*($hpB/500)))); $_SESSION['vidaBresult'] = $_SESSION['vidaBresult']+(100-$vidaB); //Colorear VIDAS if ($_SESSION['vidaAresult'] >= 50) { $hpcolorA = "#FF3300"; } if ($_SESSION['vidaBresult'] >= 50) { $hpcolorB = "#FF3300"; } //Destruir la Session carajo if ($_SESSION['hpAresult'] > 500 or $_SESSION['hpBresult'] > 500 ){ $tipo = "hidden"; $combate = "true"; } if ($_SESSION['hpAresult'] < $_SESSION['hpBresult'] ){ $ganador = $heroA; }else{ $ganador = $heroB; } print $_SESSION['hpAresult']." ".$_SESSION['hpBresult']; } ?> <form id="form1" name="form1" method="post" action="dota.php"> <table width="100%"> <tr> <td width="50%"><fieldset> <legend style="font-weight: bold; font-family: Verdana, Geneva, sans-serif; font-size: 24px;">Abaddon</legend> <table width="100%"> <tr> <td width="12%"><span style="font-size: 36px; font-weight: bold;"><img src="abaddon.gif" alt="" width="64" height="64"></span></td> <td width="76%" align="center" bgcolor="#333333" style="font-size: 36px; color: #FFF;"><?php print $heroA; ?></td> <td width="12%" align="center" bgcolor="#333333"><img src="skill1.gif" alt="" width="64" height="64"></td> </tr> <tr> <td colspan="3"><table width="100%"> <tr> <td><span style="font-size: 14px; font-weight: bold; font-family: Verdana, Geneva, sans-serif;">Damage:</span></td> <td colspan="3"><span style="font-size: 14px; font-family: Verdana, Geneva, sans-serif;"> 45 - 60 </span></td> </tr> <tr> <td width="13%" style="font-weight: bold; font-family: Verdana, Geneva, sans-serif; font-size: 14px;">Armor:</td> <td colspan="3">10</td> </tr> <tr> <td><span style="font-size: 12px; font-weight: bold; font-family: Verdana, Geneva, sans-serif;">VIDA:</span></td> <td width="67%" bgcolor="#333333"><table width="%<?php print 100-$_SESSION['vidaAresult']; ?>"> <tr> <td bgcolor="<?php print $hpcolorA ;?>"> </td> </tr> </table></td> <td width="20%" colspan="2" align="center"><span style="font-size: 18px; font-family: Verdana, Geneva, sans-serif;"> [<span style="font-weight: bold">500 </span>- <?php print 500-$_SESSION['hpAresult'];?>]</span></td> </tr> </table></td> </tr> <tr> <td></td> </tr> </table> </fieldset></td> <td width="50%"><fieldset> <legend style="font-family: Verdana, Geneva, sans-serif; font-weight: bold; font-size: 24px;">Centauro</legend> <table width="100%"> <tr> <td width="12%"><span style="font-size: 36px; font-weight: bold;"><img src="centauro.gif" alt="" width="64" height="64"></span></td> <td width="76%" align="center" bgcolor="#333333" style="font-size: 36px; color: #FFF;"><?php print $heroB; ?></td> <td width="12%" align="center" bgcolor="#333333"><img src="skill1a.gif" alt="" width="64" height="64"></td> </tr> <tr> <td colspan="3"><table width="100%"> <tr> <td><span style="font-size: 14px; font-weight: bold; font-family: Verdana, Geneva, sans-serif;">Damage:</span></td> <td colspan="3"><span style="font-size: 14px; font-family: Verdana, Geneva, sans-serif;"> 55 - 65 </span></td> </tr> <tr> <td width="13%" style="font-weight: bold; font-family: Verdana, Geneva, sans-serif; font-size: 14px;">Armor:</td> <td colspan="3">8</td> </tr> <tr> <td><span style="font-size: 12px; font-weight: bold; font-family: Verdana, Geneva, sans-serif;">VIDA:</span></td> <td width="67%" bgcolor="#333333"><table width="%<?php print 100-$_SESSION['vidaBresult']; ?>>"> <tr> <td bgcolor="<?php print $hpcolorB ;?>"> </td> </tr> </table></td> <td width="20%" colspan="2" align="center"><span style="font-size: 18px; font-family: Verdana, Geneva, sans-serif;"> [<span style="font-weight: bold">500 </span>- <?php print 500-$_SESSION['hpBresult'];?>]</span></td> </tr> </table></td> </tr> <tr> <td></td> </tr> </table> </fieldset></td> </tr> <tr> <td colspan="2"><input type="<?php print $tipo; ?>" name="atacar" id="atacar" value="Atacar"> <input type="<?php print $tipo; ?>" name="atacar" id="atacar" value="Skill" /> <input name="action" type="hidden" id="action" value="true"></td></tr> </table> </form> <?php if ($_POST['action'] == "true") { ?> <fieldset><legend>Resultado</legend> <table width="100%" bgcolor="#E8E8E8"><tr><td> <?php print $msj.$rpta; ?> </td></tr></table> </fieldset> <?php } ?> <?php if ($combate == true){ ?> <fieldset><legend>Resumen:</legend> <table width="100%"><tr><td align="center" bgcolor="#333333"><span style="font-size: 36px; color: #FFF;"><?php print $ganador; ?> ha resultado ser el ganador</span></td></tr> </table> </fieldset> <?php } ?>
El ejemplo en linea: http://peruguitar.net/DOTA/dota.php
EXTRAS:
El centauro tiene un 20% de chance de utilizar su habilidad return el cual devuelve 30 de daño
Las armaduras defienden a los hereos del ataque fisico (no magico) , es decir ARMOR 10, un 10% de proteccion del ataque TOTAL causado