escape(stripslashes($_POST['name'])); mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `name`='" . $_POST['name'] . "' where `uid`='" . $database->escape($session->uid) . "' AND dead = 0") or die("ERROR:" . mysqli_error($database->dblink)); $hero_info['name'] = $_POST['name']; echo "" . NAME_CHANGED . ""; } // Explicit lookup: action from URL (?add=...) => column from `hero` table. // Used for both "(+)" links in the table and for the update // in the DB below. Single source of truth instead of 5 identical blocks. $heroStatColumns = [ 'off' => 'attack', 'deff' => 'defence', 'obonus' => 'attackbonus', 'dbonus' => 'defencebonus', 'reg' => 'regeneration', ]; // Render the "(+)" link for a stat, or "(+)" uneditable // if the hero has no more points or the stat is already at the top (100). // Identical behavior to the original 5 if/else blocks. $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) { $field = $heroStatColumns[$action]; if ($hero_info['points'] > 0 && $hero_info[$field] < 100) { return "(+)"; } return "(+)"; }; ?> $expCurrent && $curLevel < 100){ $percent = ($curExp - $expCurrent) / ($expNext - $expCurrent) * 100; $percent = max(0, min(100, $percent)); ?>
uid."\">"; }else{ echo "".$hero_info['name'].""; } ?> ( getUnitName($hero_info['unit'])."\" title=\"".$technology->getUnitName($hero_info['unit'])."\" /> ".$technology->getUnitName($hero_info['unit']); ?> )
<?php echo $hero_info['atk']; ?>
<?php echo ($hero_info['di']) . " title="" />
% <?php echo ($hero_info['ob']-1)*100; ?>%
% <?php echo ($hero_info['db']-1)*100; ?>%
/ <?php echo ($hero_info['regeneration']*5*SPEED); ?>%/Day
: % <?php echo (int)$percent; ?>% : 100% 100%
".ERROR_NAME_SHORT."

"; } ?>

3

% .
VillageOasisCount($village->wid); ?> .

dblink, "UPDATE " . TB_PREFIX . "hero SET `points` = (`level` * 5) + 5, `attack` = 0, `defence` = 0, `attackbonus` = 0, `defencebonus` = 0, `regeneration` = 0 WHERE `heroid` = " . $hero_info['heroid'] . " AND `level` <= 3 AND (`attack` != 0 OR `defence` != 0 OR `attackbonus` != 0 OR `defencebonus` != 0 OR `regeneration` != 0)"); header("Location: build.php?id=" . $id . ""); exit; } // if level > 3, exactly like in the original: nothing happens (no redirect). } elseif (isset($heroStatColumns[$action])) { $column = $heroStatColumns[$action]; mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `$column` = `$column` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `$column` < 100"); header("Location: build.php?id=" . $id . ""); exit; } } ?>