diff --git a/App/GameModule/Model/Units/UnitModel.php b/App/GameModule/Model/Units/UnitModel.php index 9bb6dd71..0e981ef9 100644 --- a/App/GameModule/Model/Units/UnitModel.php +++ b/App/GameModule/Model/Units/UnitModel.php @@ -7,4 +7,14 @@ class UnitModel extends App\Model\BaseModel { protected $table = 'unit'; + + + /** + * @return array + */ + public function getNames() + { + return $this->database->select('id, name')->from($this->table) + ->fetchPairs('id', 'name'); + } } \ No newline at end of file diff --git a/App/GameModule/Model/Units/UnitService.php b/App/GameModule/Model/Units/UnitService.php index 27737449..3e32b157 100644 --- a/App/GameModule/Model/Units/UnitService.php +++ b/App/GameModule/Model/Units/UnitService.php @@ -158,7 +158,7 @@ class UnitService ]; /** - * @var App\GameModule\Model\Units\UnitsModel + * @var App\GameModule\Model\Units\UnitModel */ private $unitModel; /** @@ -217,6 +217,9 @@ public function train($form, $values, $village) } else { $amount = $trainable; } + if ($amount == 0) { + continue; + } $this->VDataModel->update($village->getId(), [ 'wood' => $village->getActualWood() - $amount * $unit->getWood(), @@ -411,10 +414,10 @@ public function getTrainableUnits($village, $units) */ public function getTrainableUnit($village, $unit) { - $wood = round($village->getActualWood() / $unit->getWood()); - $clay = round($village->getActualClay() / $unit->getClay()); - $iron = round($village->getActualIron() / $unit->getIron()); - $crop = round($village->getActualCrop() / $unit->getCrop()); + $wood = floor($village->getActualWood() / $unit->getWood()); + $clay = floor($village->getActualClay() / $unit->getClay()); + $iron = floor($village->getActualIron() / $unit->getIron()); + $crop = floor($village->getActualCrop() / $unit->getCrop()); return min($wood, $clay, $iron, $crop); } @@ -429,4 +432,13 @@ public function getUnits($village) return $unitData; } + + + /** + * @return array + */ + public function getNames() + { + return $this->unitModel->getNames(); + } } \ No newline at end of file diff --git a/App/GameModule/Presenters/OuterVillagePresenter.php b/App/GameModule/Presenters/OuterVillagePresenter.php index 267f08aa..59b66431 100644 --- a/App/GameModule/Presenters/OuterVillagePresenter.php +++ b/App/GameModule/Presenters/OuterVillagePresenter.php @@ -15,6 +15,12 @@ class OuterVillagePresenter extends GamePresenter /** @var App\FrontModule\Model\VData\VDataModel @inject */ public $VDataModel; + /** @var App\GameModule\Model\Units\UnitsModel @inject */ + public $unitsModel; + + /** @var App\GameModule\Model\Units\UnitService @inject */ + public $unitService; + public function startup() { @@ -37,6 +43,8 @@ public function actionDefault($id) $id = $field->wref; } $this->template->village = $this->villageService->getVillage($id); + $this->template->units = $this->unitsModel->get($id); + $this->template->unitNames = $this->unitService->getNames(); } diff --git a/App/GameModule/Templates/OuterVillage/default.latte b/App/GameModule/Templates/OuterVillage/default.latte index 1287714d..852df43b 100644 --- a/App/GameModule/Templates/OuterVillage/default.latte +++ b/App/GameModule/Templates/OuterVillage/default.latte @@ -67,6 +67,36 @@ + + + + + + + + {var $hasUnits = FALSE} + {for $i = 1; $i < 50; $i++} + {if $units['u' . $i] > 0} + + + + + + {var $hasUnits = TRUE} + {/if} + {/for} + + + + +
Troops
+ {$unitNames[$i]} + + {$units['u' . $i]} + + {$unitNames[$i]} +
none
{control building} diff --git a/www/Templates/troops.tpl b/www/Templates/troops.tpl deleted file mode 100644 index bb419396..00000000 --- a/www/Templates/troops.tpl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - -getAllUnits($village->wid,True,1); -$TroopsPresent = False; -for($i=1;$i<=50;$i++) { - if($troops['u'.$i] > 0) { - echo ""; - echo ""; - $TroopsPresent = True; - } -} -if($troops['hero'] > 0) { - echo ""; - echo ""; - $TroopsPresent = True; -} -$units = $technology->getUnitList($village->wid); -if(!$TroopsPresent) { - echo ""; -} -?> -
\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" />".$troops['u'.$i]."".$technology->getUnitName($i)."
\"Hero\"".$troops['hero']."Hero
none
- diff --git a/www/Templates/version.tpl b/www/Templates/version.tpl deleted file mode 100644 index 8bb1762e..00000000 --- a/www/Templates/version.tpl +++ /dev/null @@ -1,5 +0,0 @@ -
-

TravianZ VERSION CREDITS

-
- -
diff --git a/www/dorf1.php b/www/dorf1.php index 6bc68f2c..b7edaffb 100644 --- a/www/dorf1.php +++ b/www/dorf1.php @@ -10,8 +10,6 @@