mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-16 16:21:01 +00:00
This commit is contained in:
+43
-13
@@ -430,11 +430,33 @@ class Technology {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function trainUnit($unit, $amt, $great = false) {
|
private function trainUnit($unit, $amt, $great = false) {
|
||||||
global $session, $database, ${'u'.$unit}, $building, $village, $bid19, $bid20, $bid21, $bid25, $bid26, $bid29, $bid30, $bid36, $bid41, $bid42;
|
global $database, ${'u'.$unit}, $village;
|
||||||
|
|
||||||
if (!$database->getTrainingLock($village->wid)) return;
|
if (!$database->getTrainingLock($village->wid)) return;
|
||||||
try {
|
try {
|
||||||
if($this->getTech($unit) || $unit % 10 <= 1 || $unit == 99) {
|
if($this->getTech($unit) || $unit % 10 <= 1 || $unit == 99) {
|
||||||
|
if(!$this->checkTrainingBuilding($unit)) return;
|
||||||
|
|
||||||
|
$each = $this->getTrainingTime($unit, $great);
|
||||||
|
$amt = $this->getMaxTrainable($unit, $amt, $great);
|
||||||
|
|
||||||
|
$wood = ${'u'.$unit}['wood'] * $amt * ($great ? 3 : 1);
|
||||||
|
$clay = ${'u'.$unit}['clay'] * $amt * ($great ? 3 : 1);
|
||||||
|
$iron = ${'u'.$unit}['iron'] * $amt * ($great ? 3 : 1);
|
||||||
|
$crop = ${'u'.$unit}['crop'] * $amt * ($great ? 3 : 1);
|
||||||
|
|
||||||
|
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
|
||||||
|
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
$database->releaseTrainingLock($village->wid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkTrainingBuilding($unit) {
|
||||||
|
global $building;
|
||||||
|
|
||||||
$footies = [1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 41, 42, 43, 44];
|
$footies = [1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 41, 42, 43, 44];
|
||||||
$calvary = [4, 5, 6, 15, 16, 23, 24, 25, 26, 35, 36, 45, 46];
|
$calvary = [4, 5, 6, 15, 16, 23, 24, 25, 26, 35, 36, 45, 46];
|
||||||
$workshop = [7, 8, 17, 18, 27, 28, 37, 38, 47, 48];
|
$workshop = [7, 8, 17, 18, 27, 28, 37, 38, 47, 48];
|
||||||
@@ -446,8 +468,19 @@ class Technology {
|
|||||||
(in_array($unit, $calvary) && ($building->getTypeLevel(20) == 0 && $building->getTypeLevel(30) == 0)) ||
|
(in_array($unit, $calvary) && ($building->getTypeLevel(20) == 0 && $building->getTypeLevel(30) == 0)) ||
|
||||||
(in_array($unit, $workshop) && ($building->getTypeLevel(21) == 0 && $building->getTypeLevel(42) == 0)) ||
|
(in_array($unit, $workshop) && ($building->getTypeLevel(21) == 0 && $building->getTypeLevel(42) == 0)) ||
|
||||||
(in_array($unit, $special) && ($building->getTypeLevel(25) < 10 && $building->getTypeLevel(26) < 10)) ||
|
(in_array($unit, $special) && ($building->getTypeLevel(25) < 10 && $building->getTypeLevel(26) < 10)) ||
|
||||||
(in_array($unit, $trapper) && $building->getTypeLevel(36) == 0)) return;
|
(in_array($unit, $trapper) && $building->getTypeLevel(36) == 0)) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTrainingTime($unit, $great) {
|
||||||
|
global $building, ${'u'.$unit}, $bid19, $bid20, $bid21, $bid25, $bid26, $bid29, $bid30, $bid41, $bid42;
|
||||||
|
|
||||||
|
$footies = [1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 41, 42, 43, 44];
|
||||||
|
$calvary = [4, 5, 6, 15, 16, 23, 24, 25, 26, 35, 36, 45, 46];
|
||||||
|
$workshop = [7, 8, 17, 18, 27, 28, 37, 38, 47, 48];
|
||||||
|
$special = [9, 10, 19, 20, 29, 30, 39, 40, 49, 50];
|
||||||
|
$trapper = [99];
|
||||||
|
|
||||||
if(in_array($unit, $footies)) {
|
if(in_array($unit, $footies)) {
|
||||||
if($great) {
|
if($great) {
|
||||||
@@ -481,6 +514,13 @@ class Technology {
|
|||||||
|
|
||||||
$each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
|
$each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $each;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getMaxTrainable($unit, $amt, $great) {
|
||||||
|
global $database, $village, $bid36;
|
||||||
|
|
||||||
if($unit % 10 == 0 || $unit % 10 == 9 && $unit != 99) {
|
if($unit % 10 == 0 || $unit % 10 == 9 && $unit != 99) {
|
||||||
if($this->maxUnit($unit, $great) < $amt) $amt = 0;
|
if($this->maxUnit($unit, $great) < $amt) $amt = 0;
|
||||||
else
|
else
|
||||||
@@ -507,18 +547,8 @@ class Technology {
|
|||||||
if($max1 < $amt) $amt = 0;
|
if($max1 < $amt) $amt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$wood = ${'u'.$unit}['wood'] * $amt * ($great ? 3 : 1);
|
|
||||||
$clay = ${'u'.$unit}['clay'] * $amt * ($great ? 3 : 1);
|
|
||||||
$iron = ${'u'.$unit}['iron'] * $amt * ($great ? 3 : 1);
|
|
||||||
$crop = ${'u'.$unit}['crop'] * $amt * ($great ? 3 : 1);
|
|
||||||
|
|
||||||
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
|
return $amt;
|
||||||
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
$database->releaseTrainingLock($village->wid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function meetRRequirement($tech) {
|
public function meetRRequirement($tech) {
|
||||||
|
|||||||
Reference in New Issue
Block a user