Fix Alliance Level Require Bonus

Fix Alliance Level Require Bonus
This commit is contained in:
novgorodschi catalin
2026-07-28 13:32:10 +03:00
parent 0d11d75104
commit 6d02a8ff03
8 changed files with 136 additions and 19 deletions
+9 -5
View File
@@ -416,11 +416,15 @@ class Alliance {
}
$database->updateUserField($session->uid, "alliance", $aid, 1);
// Bonusurile de alianta devin disponibile treptat pentru
// membrii noi, deci retinem cand a intrat. Fara asta,
// cineva ar putea sari dintr-o alianta in alta doar ca sa
// culeaga bonusuri de nivel mare.
$database->updateUserField($session->uid, "alliance_joined", time(), 1);
// FONDATORUL nu e "membru nou": alianta nu exista inaintea lui, deci nu
// are de unde sa "sara" ca sa culeaga bonusuri deja deblocate. Lasam
// alliance_joined pe 0, adica acces complet.
//
// Intarzierea de disponibilitate exista ca sa nu poti trece dintr-o
// alianta in alta doar ca sa profiti de nivelurile ei mari - lucru
// imposibil intr-o alianta pe care tocmai ai infiintat-o.
$database->updateUserField($session->uid, "alliance_joined", 0, 1);
$database->procAllyPop($aid);
$database->createAlliPermissions($session->uid, $aid, 'Alliance founder', '1', '1', '1', '1', '1', '1', '1', '1');
+46
View File
@@ -304,6 +304,52 @@ class AllianceBonus
return max(0, min($level, $allowed));
}
/**
* Cat mai are de asteptat un jucator pana i se deschide nivelul urmator.
*
* Intoarce numarul de secunde, sau 0 daca deja beneficiaza de tot ce a
* deblocat alianta. Se foloseste in pagina de bonusuri: fara asta, un
* membru nou vede "nivel 2" dar simte efectul nivelului 1 si nu are cum
* sa-si dea seama de ce.
*/
public function waitingFor($uid, $btype)
{
if (!self::enabled()) {
return 0;
}
$uid = (int) $uid;
$res = mysqli_query($this->db,
"SELECT alliance, alliance_joined FROM " . TB_PREFIX . "users WHERE id = " . $uid . " LIMIT 1");
$row = $res ? mysqli_fetch_assoc($res) : null;
if (!$row || (int) $row['alliance'] <= 0) {
return 0;
}
$levels = $this->getLevels((int) $row['alliance']);
$unlocked = isset($levels[(int) $btype]) ? (int) $levels[(int) $btype] : 0;
$effective = $this->effectiveLevel($uid, $btype);
if ($effective >= $unlocked) {
return 0; // beneficiaza deja de tot
}
$joined = (int) $row['alliance_joined'];
if ($joined <= 1) {
return 0;
}
$speed = (defined('SPEED') && SPEED > 0) ? (float) SPEED : 1.0;
$step = max(60, (int) (86400 / $speed));
// nivelul (effective + 1) devine disponibil dupa effective * step
$ready = $joined + ($effective * $step);
return max(0, $ready - time());
}
/* ------------------------------------------------------------------ */
/* Donatii */
/* ------------------------------------------------------------------ */
+7
View File
@@ -4276,3 +4276,10 @@ tz_def('ADM_PLUS_STATISTICS_INTERVAL', 'Statistics snapshot interval (hours)');
tz_def('ADM_PLUS_STATISTICS_INTERVAL_TIP', 'How often a snapshot is taken. On a fast server a day is a lot of play, so a few hours gives a readable curve.');
tz_def('ADM_PLUS_STATISTICS_KEEP', 'Statistics history kept (days)');
tz_def('ADM_PLUS_STATISTICS_KEEP_TIP', '0 keeps everything, so players see the full history of their account since recording began.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// BONUSURI DE ALIANTA - disponibilitate pentru membrii noi
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_YOURLEVEL', 'Your level');
tz_def('ALLYBONUS_UNLOCKS_IN', 'next unlocks in');
tz_def('ALLYBONUS_NEWMEMBER', 'New members gain access to higher levels gradually: level 2 after 24 hours in the alliance, level 3 after 48 hours, and so on.');
+7
View File
@@ -4219,3 +4219,10 @@ tz_def('ADM_PLUS_STATISTICS_INTERVAL', 'Intervalle des relevés (heures)');
tz_def('ADM_PLUS_STATISTICS_INTERVAL_TIP', 'Fréquence des relevés. Sur un serveur rapide, une journée représente beaucoup de jeu ; quelques heures donnent une courbe lisible.');
tz_def('ADM_PLUS_STATISTICS_KEEP', 'Historique conservé (jours)');
tz_def('ADM_PLUS_STATISTICS_KEEP_TIP', '0 conserve tout, afin que les joueurs voient l\'historique complet de leur compte depuis le début de l\'enregistrement.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// BONUSURI DE ALIANTA - disponibilitate pentru membrii noi
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_YOURLEVEL', 'Votre niveau');
tz_def('ALLYBONUS_UNLOCKS_IN', 'prochain dans');
tz_def('ALLYBONUS_NEWMEMBER', 'Les nouveaux membres accèdent progressivement aux niveaux supérieurs : niveau 2 après 24 heures dans l\'alliance, niveau 3 après 48 heures, etc.');
+7
View File
@@ -4016,3 +4016,10 @@ tz_def('ADM_PLUS_STATISTICS_INTERVAL', 'Intervalul intre masuratori (ore)');
tz_def('ADM_PLUS_STATISTICS_INTERVAL_TIP', 'Cat de des se ia o masuratoare. Pe un server rapid o zi inseamna mult joc, asa ca cateva ore dau o curba lizibila.');
tz_def('ADM_PLUS_STATISTICS_KEEP', 'Istoric pastrat (zile)');
tz_def('ADM_PLUS_STATISTICS_KEEP_TIP', '0 pastreaza tot, ca jucatorii sa vada istoricul complet al contului de la inceputul inregistrarii.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// BONUSURI DE ALIANTA - disponibilitate pentru membrii noi
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_YOURLEVEL', 'Nivelul tau');
tz_def('ALLYBONUS_UNLOCKS_IN', 'urmatorul in');
tz_def('ALLYBONUS_NEWMEMBER', 'Membrii noi capata acces treptat la nivelurile mari: nivelul 2 dupa 24 de ore in alianta, nivelul 3 dupa 48 de ore si asa mai departe.');
+15 -13
View File
@@ -655,19 +655,12 @@ class Technology {
}
/**
* Reduce timpul de instruire cu procentul dat de coiful echipat al eroului.
*
* Proprietarul e luat din satul in care se face instruirea (nu din sesiune),
* ca sa fie corect si cand codul ruleaza in alt context decat o pagina a
* jucatorului. HeroBattleBonus::bonuses() are deja gard de feature flag si
* cache per request, si intoarce null cand sistemul T4 e oprit.
*/
/**
* Aplica bonusul de alianta "Recruitment" asupra timpului de instruire.
*
* Proprietarul se ia din satul in care se instruieste, nu din sesiune, ca sa
* fie corect si cand codul ruleaza in alt context (cron, sitter).
*/
* Aplica bonusul de alianta "Recruitment" asupra timpului de instruire.
*
* Proprietarul se ia din satul in care se instruieste, nu din sesiune, ca sa
* fie corect si cand codul ruleaza in alt context (cron, sitter).
*/
private function applyAllianceRecruitmentBonus($each) {
global $village, $database;
@@ -693,6 +686,15 @@ class Technology {
// bonusul de X% inseamna productie mai rapida, deci timp impartit
return max(1, (int) round($each / $mult));
}
/**
* Reduce timpul de instruire cu procentul dat de coiful echipat al eroului.
*
* Proprietarul e luat din satul in care se face instruirea (nu din sesiune),
* ca sa fie corect si cand codul ruleaza in alt context decat o pagina a
* jucatorului. HeroBattleBonus::bonuses() are deja gard de feature flag si
* cache per request, si intoarce null cand sistemul T4 e oprit.
*/
private function applyHeroTrainingBonus($each, $unit, array $footies, array $calvary) {
global $village, $database;
+21
View File
@@ -67,14 +67,31 @@ Travian 4-style hero system ported into the T3.6 engine, in phases:
* Items backend (HeroItems.php) with equippable hero items and data layer.
* Adventures backend (HeroAdventure.php) with adventure generation and rewards.
* Auction house (HeroAuction.php) for player-to-player item trading.
* A new ability : resources production added.
* Battle and speed integration (HeroBattleBonus.php + Battle.php hooks): item fighting strength, per-unit weapon bonuses, armor damage reduction, hunting horn and speed effects, artwork culture-point item.
Alliance Bonus System
Travian 4-style alliance system ported into the T3.6 engine, in phases:
* Added Metalurgy Bonus - Speeds up troop training in every troop-producing building. Multiplies with hero helmets.
* Added Philosophy Bonus - Increases culture point production from buildings and hero helmets. Town hall celebrations are not affected.
* Added Metallurgy Bonus - Increases the offensive and defensive strength of your troops, on top of your smithy upgrades.
* Added Commerce Bonus - Increases how much each merchant can carry. Multiplies with the trade office.
Admin Panel
* Complete frontend and backend redesign.
* Multi-Account Detection
* Push Protection Dashboard
* Registration Blocklist
* Quest Editor Page
* New Admin Panel design.
* World Map Heatmap
* New homepage with server statistics.
* New Server Info page.
* New Natars Management format.
@@ -107,6 +124,10 @@ Admin Panel
Gameplay Improvements
* Vacation Mode added (requires 9 conditions).
* Added Graphical Statistics
* Added Server Milestones
* Activated gpack for each player
* NEW gpack travian_t4 style buildings
* Alliance rank and privilege management added.
* Main Building instant demolition with 10 gold.
* Account Statement added in Travian Plus section (received/spent gold history).
+24 -1
View File
@@ -113,6 +113,7 @@ $abGpack = defined('GP_LOCATE') ? GP_LOCATE : 'gpack/travian_default/';
/* descrierea sta in dreapta numelui si ocupa spatiul ramas */
.ab-desc{flex:1;color:#666;font-size:11px;line-height:1.35;padding-left:4px}
.ab-eff{color:#1f7a1f;font-weight:bold}
.ab-wait{color:#a60;font-size:10px}
.ab-bar{background:#fff;border:1px solid #c9c9c9;height:13px;overflow:hidden;margin:4px 0}
.ab-bar i{display:block;height:100%;background:#7db72f}
.ab-num{font-size:11px;color:#555}
@@ -156,7 +157,24 @@ $abGpack = defined('GP_LOCATE') ? GP_LOCATE : 'gpack/travian_default/';
<span class="ab-lvl">
<?php echo defined('ALLYBONUS_LEVEL') ? ALLYBONUS_LEVEL : 'Level'; ?>
<?php echo $abLevel; ?> / <?php echo AllianceBonus::MAX_LEVEL; ?>
&nbsp;<span class="ab-eff">+<?php echo (int) AllianceBonus::percentFor($abT, $abLevel); ?>%</span>
<?php
// Nivelul de care beneficiezi TU poate fi mai mic decat cel
// al aliantei: membrii noi capata acces treptat. Aratam
// amandoua valorile, altfel bonusul pare ca nu se aplica.
$abMine = $abEngine->effectiveLevel($session->uid, $abT);
$abWait = $abEngine->waitingFor($session->uid, $abT);
?>
&nbsp;<span class="ab-eff">+<?php echo (int) AllianceBonus::percentFor($abT, $abMine); ?>%</span>
<?php if ($abMine < $abLevel) { ?>
<br><span class="ab-wait">
<?php echo defined('ALLYBONUS_YOURLEVEL') ? ALLYBONUS_YOURLEVEL : 'Your level'; ?>:
<b><?php echo $abMine; ?></b>
<?php if ($abWait > 0) { ?>
&ndash; <?php echo defined('ALLYBONUS_UNLOCKS_IN') ? ALLYBONUS_UNLOCKS_IN : 'next in'; ?>
<?php echo $generator->getTimeFormat($abWait); ?>
<?php } ?>
</span>
<?php } ?>
</span>
</span>
<span class="ab-desc"><?php
@@ -204,6 +222,11 @@ $abGpack = defined('GP_LOCATE') ? GP_LOCATE : 'gpack/travian_default/';
<?php } ?>
</div>
<div class="ab-note">
<?php echo defined('ALLYBONUS_NEWMEMBER') ? ALLYBONUS_NEWMEMBER
: 'New members gain access to higher levels gradually: level 2 after 24 hours in the alliance, level 3 after 48 hours, and so on.'; ?>
</div>
<div class="ab-note">
<?php echo defined('ALLYBONUS_HINT') ? ALLYBONUS_HINT
: 'The resource type does not matter, only the total amount. While a level is unlocking, that bonus cannot receive donations.'; ?>