PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Templates/Build/37_hero.tpl

https://bitbucket.org/Dzoki/travianx
Smarty Template | 330 lines | 313 code | 17 blank | 0 comment | 49 complexity | 071bb2e87ff4a5349de2698de17253f3 MD5 | raw file
  1. <?php
  2. /*-------------------------------------------------------*\
  3. | ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* |
  4. +---------------------------------------------------------+
  5. | Developed by: Manni < manuel_mannhardt@web.de > |
  6. | Dzoki < dzoki.travian@gmail.com > |
  7. | Copyright: TravianX Project All rights reserved |
  8. \*-------------------------------------------------------*/
  9. include_once("GameEngine/Data/hero_full.php");
  10. if ( isset($_POST['name'])) {
  11. mysql_query("UPDATE ".TB_PREFIX."hero SET `name`='".($_POST['name'])."' where `uid`='".$session->uid."'") or die("ERROR:".mysql_error());
  12. $hero = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . "");
  13. $hero_info = mysql_fetch_array($hero);
  14. // echo "!!!!";
  15. echo "Heros name has been changed";
  16. }
  17. //============== Fixed by Salmon+ ===============================
  18. if ($hero_info['experience'] > $hero_levels[$hero_info['level']+1]) {
  19. $checklvl=0;
  20. while ($checklvl<1){
  21. mysql_query("UPDATE ".TB_PREFIX."hero SET `level` = `level` + 1 where `uid`='".$session->uid."'");
  22. mysql_query("UPDATE ".TB_PREFIX."hero SET `points` = `points` + 5 where `uid`='".$session->uid."'");
  23. $hero = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . "");
  24. $hero_info = mysql_fetch_array($hero);
  25. if ($hero_info['experience'] <= $hero_levels[$hero_info['level']+1]){$checklvl=1;}
  26. }
  27. }
  28. //===============================================================
  29. // $hero_data=array();
  30. // $hero_data=
  31. $hero = $units->Hero($session->uid);
  32. ?>
  33. <?php if ($hero_info['experience'] >= 495000) {
  34. mysql_query("UPDATE ".TB_PREFIX."hero SET `experience` = 495000 where `uid`='".$session->uid."'");
  35. mysql_query("UPDATE ".TB_PREFIX."hero SET `level` = 100 where `uid`='".$session->uid."'");
  36. ?>
  37. <table id="distribution" cellpadding="1" cellspacing="1">
  38. <thead><tr>
  39. <th colspan="5"><?php
  40. if(isset($_GET['rename'])){
  41. echo "<form action=\"\" method=\"POST\"><input type=\"hidden\" name=\"userid\" value=\"".$session->uid."\"><input type=\"hidden\" name=\"hero\" value=\"1\"><input type=\"text\" class=\"text\" name=\"name\" maxlength=\"20\" value=\"".$hero_info['name']."\">";
  42. }else{
  43. echo "<a href=\"build.php?id=".$id."&rename\">".$hero_info['name']."</a></form>";
  44. }
  45. ?> Level 100 <span class="info">( <?php echo"<img class=\"unit u".$hero_info['unit']."\" src=\"img/x.gif\" alt=\"".$technology->getUnitName($hero_info['unit'])."\" title=\"".$technology->getUnitName($hero_info['unit'])."\" /> ".$technology->getUnitName($hero_info['unit']); ?> )</span></th>
  46. </tr></thead>
  47. <tbody><tr>
  48. <th>Offence</th>
  49. <td class="val"><?php echo $hero['atk']; ?></td>
  50. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['attack'])+1; ?>px;" alt="<?php echo $hero['atk']; ?>" title="<?php echo $hero['atk']; ?>" /></td>
  51. <td class="up"><span class="none">
  52. <?php
  53. if($hero_info['points'] > 0){
  54. echo "<a href=\"build.php?id=".$id."&add=off\">(<b>+</b>)</a>";
  55. }else {
  56. echo "<span class=\"none\">(+)</span>";
  57. }
  58. ?>
  59. </td>
  60. <td class="po"><?php echo $hero_info['attack']; ?></td>
  61. </tr>
  62. <tr>
  63. <th>Defence</th>
  64. <td class="val"><?php echo $hero['di'] . "/" . $hero['dc']; ?></td>
  65. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['defence'])+1; ?>px;" alt="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" title="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" /></td>
  66. <td class="up"><span class="none">
  67. <?php
  68. if($hero_info['points'] > 0){
  69. echo "<a href=\"build.php?id=".$id."&add=deff\">(<b>+</b>)</a>";
  70. }else {
  71. echo "<span class=\"none\">(+)</span>";
  72. }
  73. ?>
  74. </td>
  75. <td class="po"><?php echo $hero_info['defence']; ?></td>
  76. </tr>
  77. <tr>
  78. <th>Off-Bonus</th>
  79. <td class="val"><?php echo ($hero['ob']-1)*100; ?>%</td>
  80. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['ob']-1)*1000+1; ?>px;" alt="<?php echo ($hero['ob']-1)*100; ?>%" title="<?php echo ($hero['ob']-1)*100; ?>%" /></td>
  81. <td class="up"><span class="none">
  82. <?php
  83. if($hero_info['points'] > 0){
  84. echo "<a href=\"build.php?id=".$id."&add=obonus\">(<b>+</b>)</a>";
  85. }else {
  86. echo "<span class=\"none\">(+)</span>";
  87. }
  88. ?>
  89. </td>
  90. <td class="po"><?php echo $hero_info['attackbonus']; ?></td>
  91. </tr>
  92. <tr>
  93. <th>Def-Bonus</th>
  94. <td class="val"><?php echo ($hero['db']-1)*100; ?>%</td>
  95. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['db']-1)*1000+1; ?>px;" alt="<?php echo ($hero['db']-1)*100; ?>%" title="<?php echo ($hero['db']-1)*100; ?>%" /></td>
  96. <td class="up"><span class="none">
  97. <?php
  98. if($hero_info['points'] > 0){
  99. echo "<a href=\"build.php?id=".$id."&add=dbonus\">(<b>+</b>)</a>";
  100. }else {
  101. echo "<span class=\"none\">(+)</span>";
  102. }
  103. ?>
  104. </td>
  105. <td class="po"><?php echo $hero_info['defencebonus']; ?></td>
  106. </tr>
  107. <tr>
  108. <th>Regeneration</th>
  109. <td class="val"><?php echo ($hero_info['regeneration']*.05); ?>%/Day</td>
  110. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['regeneration']*2)+1; ?>px;" alt="<?php echo ($hero_info['regeneration']*.05); ?>%/Day" title="<?php echo ($hero_info['regeneration']*.05); ?>%/Day" /></td>
  111. <td class="up"><span class="none">
  112. <?php
  113. if($hero_info['points'] > 0){
  114. echo "<a href=\"build.php?id=".$id."&add=reg\">(<b>+</b>)</a>";
  115. }else {
  116. echo "<span class=\"none\">(+)</span>";
  117. }
  118. ?>
  119. </td>
  120. <td class="po"><?php echo $hero_info['regeneration']; ?></td>
  121. </tr>
  122. <tr>
  123. <td colspan="5" class="empty"></td>
  124. </tr>
  125. <tr>
  126. <th title="until the next level">Experience:</th>
  127. <td class="val">100%</td>
  128. <td class="xp"><img class="bar" src="img/x.gif" style="width:200px;" alt="100%" title="100%" /></td>
  129. <td class="up"></td>
  130. <td class="rem"><?php echo $hero_info['points']; ?></td>
  131. </tr>
  132. </tbody>
  133. </table>
  134. <?php }else{ ?>
  135. <table id="distribution" cellpadding="1" cellspacing="1">
  136. <thead><tr>
  137. <th colspan="5"><?php
  138. if(isset($_GET['rename'])){
  139. echo "<form action=\"\" method=\"POST\"><input type=\"hidden\" name=\"userid\" value=\"".$session->uid."\"><input type=\"hidden\" name=\"hero\" value=\"1\"><input type=\"text\" class=\"text\" name=\"name\" maxlength=\"20\" value=\"".$hero_info['name']."\">";
  140. }else{
  141. echo "<a href=\"build.php?id=".$id."&rename\">".$hero_info['name']."</a></form>";
  142. }
  143. ?> Level <?php echo $hero_info['level']; ?> <span class="info">( <?php echo"<img class=\"unit u".$hero_info['unit']."\" src=\"img/x.gif\" alt=\"".$technology->getUnitName($hero_info['unit'])."\" title=\"".$technology->getUnitName($hero_info['unit'])."\" /> ".$technology->getUnitName($hero_info['unit']); ?> )</span></th>
  144. </tr></thead>
  145. <tbody><tr>
  146. <th>Offence</th>
  147. <td class="val"><?php echo $hero['atk']; ?></td>
  148. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['attack'])+1; ?>px;" alt="<?php echo $hero['atk']; ?>" title="<?php echo $hero['atk']; ?>" /></td>
  149. <td class="up"><span class="none">
  150. <?php
  151. if($hero_info['attack'] < 100){
  152. if($hero_info['points'] > 0){
  153. echo "<a href=\"build.php?id=".$id."&add=off\">(<b>+</b>)</a>";
  154. }else {
  155. echo "<span class=\"none\">(+)</span>";
  156. }
  157. }else{
  158. echo "<span class=\"none\">(+)</span>";
  159. }
  160. ?>
  161. </td>
  162. <td class="po"><?php echo $hero_info['attack']; ?></td>
  163. </tr>
  164. <tr>
  165. <th>Defence</th>
  166. <td class="val"><?php echo $hero['di'] . "/" . $hero['dc']; ?></td>
  167. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['defence'])+1; ?>px;" alt="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" title="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" /></td>
  168. <td class="up"><span class="none">
  169. <?php
  170. if($hero_info['defence'] < 100){
  171. if($hero_info['points'] > 0){
  172. echo "<a href=\"build.php?id=".$id."&add=deff\">(<b>+</b>)</a>";
  173. }else {
  174. echo "<span class=\"none\">(+)</span>";
  175. }
  176. }else{
  177. echo "<span class=\"none\">(+)</span>";
  178. }
  179. ?>
  180. </td>
  181. <td class="po"><?php echo $hero_info['defence']; ?></td>
  182. </tr>
  183. <tr>
  184. <th>Off-Bonus</th>
  185. <td class="val"><?php echo ($hero['ob']-1)*100; ?>%</td>
  186. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['ob']-1)*1000+1; ?>px;" alt="<?php echo ($hero['ob']-1)*100; ?>%" title="<?php echo ($hero['ob']-1)*100; ?>%" /></td>
  187. <td class="up"><span class="none">
  188. <?php
  189. if($hero_info['attackbonus'] < 100){
  190. if($hero_info['points'] > 0){
  191. echo "<a href=\"build.php?id=".$id."&add=obonus\">(<b>+</b>)</a>";
  192. }else {
  193. echo "<span class=\"none\">(+)</span>";
  194. }
  195. }else{
  196. echo "<span class=\"none\">(+)</span>";
  197. }
  198. ?>
  199. </td>
  200. <td class="po"><?php echo $hero_info['attackbonus']; ?></td>
  201. </tr>
  202. <tr>
  203. <th>Def-Bonus</th>
  204. <td class="val"><?php echo ($hero['db']-1)*100; ?>%</td>
  205. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['db']-1)*1000+1; ?>px;" alt="<?php echo ($hero['db']-1)*100; ?>%" title="<?php echo ($hero['db']-1)*100; ?>%" /></td>
  206. <td class="up"><span class="none">
  207. <?php
  208. if($hero_info['defencebonus'] < 100){
  209. if($hero_info['points'] > 0){
  210. echo "<a href=\"build.php?id=".$id."&add=dbonus\">(<b>+</b>)</a>";
  211. }else {
  212. echo "<span class=\"none\">(+)</span>";
  213. }
  214. }else{
  215. echo "<span class=\"none\">(+)</span>";
  216. }
  217. ?>
  218. </td>
  219. <td class="po"><?php echo $hero_info['defencebonus']; ?></td>
  220. </tr>
  221. <tr>
  222. <th>Regeneration</th>
  223. <td class="val"><?php echo ($hero_info['regeneration']*.05); ?>%/Day</td>
  224. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['regeneration']*2)+1; ?>px;" alt="<?php echo ($hero_info['regeneration']*.05); ?>%/Day" title="<?php echo ($hero_info['regeneration']*.05); ?>%/Day" /></td>
  225. <td class="up"><span class="none">
  226. <?php
  227. if($hero_info['regeneration'] < 100){
  228. if($hero_info['points'] > 0){
  229. echo "<a href=\"build.php?id=".$id."&add=reg\">(<b>+</b>)</a>";
  230. }else {
  231. echo "<span class=\"none\">(+)</span>";
  232. }
  233. }else{
  234. echo "<span class=\"none\">(+)</span>";
  235. }
  236. ?>
  237. </td>
  238. <td class="po"><?php echo $hero_info['regeneration']; ?></td>
  239. </tr>
  240. <tr>
  241. <td colspan="5" class="empty"></td>
  242. </tr>
  243. <tr>
  244. <th title="until the next level">Experience:</th>
  245. <td class="val"><?php echo number_format(($hero_info['experience'] - $hero_levels[$hero_info['level']]) / ($hero_levels[$hero_info['level']+1] - $hero_levels[$hero_info['level']])*100, 2, '.', ''); ?>%</td>
  246. <td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['experience'] - $hero_levels[$hero_info['level']]) / ($hero_levels[$hero_info['level']+1] - $hero_levels[$hero_info['level']])*100*2 ?>px;" alt="<?php echo ($hero_info['experience'] - $hero_levels[$hero_info['level']]) / ($hero_levels[$hero_info['level']+1] - $hero_levels[$hero_info['level']])*100 ?>%" title="<?php echo ($hero_info['experience'] - $hero_levels[$hero_info['level']]) / ($hero_levels[$hero_info['level']+1] - $hero_levels[$hero_info['level']])*100 ?>%" /></td>
  247. <td class="up"></td>
  248. <td class="rem"><?php echo $hero_info['points']; ?></td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. <?php } ?>
  253. <?php if(isset($_GET['e'])){
  254. echo "<p><font size=\"1\" color=\"red\"><b>Error: name too short</b></font></p>";
  255. }
  256. ?>
  257. <?php if($hero_info['level'] <= 3){ ?>
  258. <p>You can <a href="build.php?id=<?php echo $id; ?>&add=reset">reset</a> your points until you are level <b>3</b> or lower!</p>
  259. <?php } ?>
  260. <p>Your hero has <b><?php echo floor($hero_info['health']); ?></b>% of his hit points.<br/>
  261. Your hero has conquered <b><?php echo $database->VillageOasisCount($village->wid); ?></b> <a href="build.php?id=<?php echo $id; ?>&land">oases</a>.</p>
  262. <?php
  263. if(isset($_GET['add'])) {
  264. if($_GET['add'] == "reset") {
  265. if($hero_info['level'] <= 3){
  266. if($hero_info['attack'] != 0 OR $hero_info['defence'] != 0 OR $hero_info['attackbonus'] != 0 OR $hero_info['defencebonus'] != 0 OR $hero_info['regeneration'] != 0){
  267. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+10)."' WHERE `uid` = '" . $session->uid . "'");
  268. mysql_query("UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `uid` = '" . $session->uid . "'");
  269. mysql_query("UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `uid` = '" . $session->uid . "'");
  270. mysql_query("UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `uid` = '" . $session->uid . "'");
  271. mysql_query("UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `uid` = '" . $session->uid . "'");
  272. mysql_query("UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `uid` = '" . $session->uid . "'");
  273. header("Location: build.php?id=".$id."");
  274. }
  275. }
  276. }
  277. if($_GET['add'] == "off") {
  278. if($hero_info['points'] > 0) {
  279. mysql_query("UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `uid` = '" . $session->uid . "'");
  280. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'");
  281. header("Location: build.php?id=".$id."");
  282. }
  283. }
  284. if($_GET['add'] == "deff") {
  285. if($hero_info['points'] > 0) {
  286. mysql_query("UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `uid` = '" . $session->uid . "'");
  287. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'");
  288. header("Location: build.php?id=".$id."");
  289. }
  290. }
  291. if($_GET['add'] == "obonus") {
  292. if($hero_info['points'] > 0) {
  293. mysql_query("UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `uid` = '" . $session->uid . "'");
  294. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'");
  295. header("Location: build.php?id=".$id."");
  296. }
  297. }
  298. if($_GET['add'] == "dbonus") {
  299. if($hero_info['points'] > 0) {
  300. mysql_query("UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `uid` = '" . $session->uid . "'");
  301. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'");
  302. header("Location: build.php?id=".$id."");
  303. }
  304. }
  305. if($_GET['add'] == "reg") {
  306. if($hero_info['points'] > 0) {
  307. mysql_query("UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `uid` = '" . $session->uid . "'");
  308. mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'");
  309. header("Location: build.php?id=".$id."");
  310. }
  311. }
  312. }
  313. ?>