mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-25 14:06:12 +00:00
Last fix for Hero T4 & V11
/* |-------------------------------------------------------------------------- | FIX List |-------------------------------------------------------------------------- | | 1. Hero Attribute Points | - When adding attribute points to the hero, the page currently refreshes | after every click on the "+" button. | - Implement a faster allocation method (AJAX or similar) so multiple | points can be assigned without a full page refresh. | - The implementation must remain secure and not be exploitable | (validate requests server-side, prevent double submissions, | verify available points, etc.). | | 2. Hero Equipment Restrictions (Original Travian Behavior) | - Prevent equipping or unequipping hero items while the hero is: | • On an adventure. | • Attacking (alone or with troops). | • Away as reinforcements. | | 3. Oasis Navigation | - When opening an oasis (37_land.tpl), the 37_t4nav.tpl navigation | disappears. | - Include the navigation menu on the oasis page as well. | | 4. Auction House Redesign | - Redesign 37_auction.tpl to match the Merchant.png mockup. | - Keep the existing auction functionality exactly as it is. | - Only improve the UI/UX. | - You may crop and reuse graphics from Merchant.png. | - Add Gold ⇄ Silver exchange functionality. | | 5. Hero Item Bonuses (Highest Priority) | - Verify that hero equipment bonuses are applied correctly. | - Example: | • Helmet of the Ruler should reduce Barracks training time by 20%. | • Currently, training time remains unchanged whether the helmet | is equipped or not. | - Also verify: | • Stable training speed bonuses. | • Boots bonuses. | • Any other related hero equipment effects. | | 6. Adventures Page Redesign | - Redesign 37_adventures.tpl to match the Adventure.png mockup. | - Keep the "Expires in" column intact. | */
This commit is contained in:
@@ -212,10 +212,84 @@ trait AutomationVillageUpkeep {
|
||||
|
||||
private function culturePoints() {
|
||||
global $database;
|
||||
|
||||
|
||||
// FIX: punctele de cultura date de coifuri (Gladiator/Tribune/Consul =
|
||||
// 100/400/800 pe zi) nu erau adaugate nicaieri - HB_CP exista doar in
|
||||
// definitia itemelor si in agregarea din HeroItems::getBonuses().
|
||||
// Se aplica INAINTE de updateVSumField, fiindca acela reseteaza
|
||||
// users.lastupdate; asa ambele folosesc exact aceeasi fereastra de timp.
|
||||
$this->applyHeroCulturePoints();
|
||||
|
||||
$database->updateVSumField('cp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adauga in users.cp punctele de cultura ale coifurilor echipate.
|
||||
*
|
||||
* Acumularea imita formula din updateVSumField(): valoarea e "pe zi", iar
|
||||
* ziua de joc e 86400/SPEED (minim o ora), la fel ca pentru cladiri.
|
||||
* Valorile sunt luate din catalog prin scaledBonusValue(), care aplica deja
|
||||
* regula de server rapid (coifurile de cultura se injumatatesc la SPEED>=3).
|
||||
*
|
||||
* Se numara doar eroii vii (hero.dead = 0). Cum exista un singur slot de
|
||||
* coif, un jucator nu poate avea doua iteme cu CP echipate simultan, deci
|
||||
* join-ul nu poate dubla castigul.
|
||||
*/
|
||||
private function applyHeroCulturePoints() {
|
||||
global $database, $heroItemCatalog;
|
||||
|
||||
if (!class_exists('HeroBattleBonus') || !HeroBattleBonus::enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($heroItemCatalog) || !is_array($heroItemCatalog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$heroItems = new HeroItems();
|
||||
$cpValues = array();
|
||||
|
||||
foreach ($heroItemCatalog as $itemid => $def) {
|
||||
if (!isset($def['bonus']) || !is_array($def['bonus']) || !isset($def['bonus'][HB_CP])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = (int) $heroItems->scaledBonusValue($def, (int) $def['bonus'][HB_CP]);
|
||||
|
||||
if ($value > 0) {
|
||||
$cpValues[(int) $itemid] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cpValues)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$durDay = 86400 / SPEED;
|
||||
|
||||
if ($durDay < 3600) {
|
||||
$durDay = 3600;
|
||||
}
|
||||
|
||||
$case = '';
|
||||
|
||||
foreach ($cpValues as $itemid => $value) {
|
||||
$case .= ' WHEN ' . (int) $itemid . ' THEN ' . (int) $value;
|
||||
}
|
||||
|
||||
$ids = implode(',', array_map('intval', array_keys($cpValues)));
|
||||
|
||||
$q = "UPDATE " . TB_PREFIX . "users AS u
|
||||
INNER JOIN " . TB_PREFIX . "hero_items AS hi
|
||||
ON hi.uid = u.id AND hi.equipped = 1 AND hi.itemid IN (" . $ids . ")
|
||||
INNER JOIN " . TB_PREFIX . "hero AS h
|
||||
ON h.uid = u.id AND h.dead = 0
|
||||
SET u.cp = u.cp + ((CASE hi.itemid" . $case . " END) * (UNIX_TIMESTAMP() - u.lastupdate) / " . $durDay . ")
|
||||
WHERE u.lastupdate < (UNIX_TIMESTAMP() - 600)";
|
||||
|
||||
mysqli_query($database->dblink, $q);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recompute a warehouse/granary capacity after a build completion.
|
||||
* Returns [$fieldDbName, $max]: the vdata column to update and its new value.
|
||||
|
||||
Reference in New Issue
Block a user