mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-09 21:01:00 +00:00
Fix max donation Alliance Bonuses
Fix max donation Alliance Bonuses - cannot donate over max
This commit is contained in:
@@ -49,6 +49,11 @@ class AllianceBonus
|
||||
const DONATE_RESOURCES = 5;
|
||||
const DONATE_INVALID = 6;
|
||||
const DONATE_NO_GOLD = 7;
|
||||
/** Ultimul nivel: s-a donat mai mult decat mai era nevoie. */
|
||||
const DONATE_OVER_MAX = 8;
|
||||
|
||||
/** Cat se putea dona de fapt; citit de interfata cand primeste DONATE_OVER_MAX. */
|
||||
public static $overMaxAllowed = 0;
|
||||
|
||||
private $db;
|
||||
|
||||
@@ -442,8 +447,36 @@ class AllianceBonus
|
||||
return self::DONATE_INVALID;
|
||||
}
|
||||
|
||||
// valoarea contorizata (triplata sau nu) si plafonul zilnic
|
||||
// valoarea contorizata (triplata sau nu)
|
||||
$counted = $triple ? $total * 3 : $total;
|
||||
|
||||
/**
|
||||
* ULTIMUL NIVEL: nu se accepta mai mult decat mai e nevoie.
|
||||
*
|
||||
* La nivelurile intermediare surplusul e util - ramane in fond si
|
||||
* finanteaza nivelul urmator. Dar la trecerea spre nivelul MAXIM nu mai
|
||||
* exista nivel urmator: ce depaseste costul ar ramane blocat in fond
|
||||
* pentru totdeauna, fara sa mai poata fi folosit sau recuperat.
|
||||
*
|
||||
* Asa ca aici oprim donatia si spunem exact cat se poate dona. Nu
|
||||
* plafonam automat: jucatorul ar plati fara sa stie cat, iar cu triplare
|
||||
* diferenta ar fi si mai greu de urmarit.
|
||||
*/
|
||||
if ($state[$btype]['level'] === self::MAX_LEVEL - 1) {
|
||||
|
||||
$needed = self::costFor($state[$btype]['level']) - (float) $state[$btype]['pool'];
|
||||
$needed = max(0, $needed);
|
||||
|
||||
if ($counted > $needed) {
|
||||
// cat trebuie sa introduca in casute (inainte de triplare)
|
||||
self::$overMaxAllowed = $triple
|
||||
? (float) floor($needed / 3)
|
||||
: $needed;
|
||||
|
||||
return self::DONATE_OVER_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
$limit = self::dailyLimit($this->highestLevel($aid));
|
||||
$already = $this->donatedToday($uid);
|
||||
|
||||
|
||||
@@ -4355,3 +4355,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Each tribe sees its own World Wonder artwork, both o
|
||||
// MINUNEA LUMII - satul nu poate fi capitala
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('TZ_WW_NO_CAPITAL', 'The World Wonder village cannot become your capital.');
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('ALLYBONUS_MSG_OVERMAX', 'This is the final level: you can donate at most %s more resources.');
|
||||
|
||||
@@ -4298,3 +4298,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Chaque tribu voit sa propre Merveille du Monde, sur
|
||||
// MINUNEA LUMII - satul nu poate fi capitala
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('TZ_WW_NO_CAPITAL', 'Le village de la Merveille du Monde ne peut pas devenir votre capitale.');
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('ALLYBONUS_MSG_OVERMAX', 'Ceci est le dernier niveau : vous pouvez donner au maximum %s ressources supplementaires.');
|
||||
|
||||
@@ -4095,3 +4095,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Fiecare trib isi vede propria Minune a Lumii, atat p
|
||||
// MINUNEA LUMII - satul nu poate fi capitala
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('TZ_WW_NO_CAPITAL', 'Satul Minunii Lumii nu poate deveni capitala.');
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
tz_def('ALLYBONUS_MSG_OVERMAX', 'Acesta e ultimul nivel: poti dona cel mult %s resurse.');
|
||||
|
||||
@@ -71,6 +71,16 @@ if (isset($_POST['ab_donate'])) {
|
||||
: 'Not enough resources in this village.';
|
||||
$abError = true;
|
||||
break;
|
||||
case AllianceBonus::DONATE_OVER_MAX:
|
||||
// La ultimul nivel surplusul ar ramane blocat, deci spunem exact
|
||||
// cat se mai poate dona.
|
||||
$abMessage = sprintf(
|
||||
defined('ALLYBONUS_MSG_OVERMAX') ? ALLYBONUS_MSG_OVERMAX
|
||||
: 'This is the final level: you can donate at most %s more resources.',
|
||||
number_format(AllianceBonus::$overMaxAllowed)
|
||||
);
|
||||
$abError = true;
|
||||
break;
|
||||
case AllianceBonus::DONATE_NO_GOLD:
|
||||
$abMessage = defined('ALLYBONUS_MSG_NOGOLD') ? ALLYBONUS_MSG_NOGOLD
|
||||
: 'Not enough gold to triple this donation.';
|
||||
|
||||
Reference in New Issue
Block a user