XG-Proyect-v3.x.x
XG-Proyect-v3.x.x copied to clipboard
[Feature] Boton Max en Hangar
Me puse a crear el boton max para el hangar para dar una mano mas XD
pero tengo una duda existencial, por que con este codigo no funciona. me da 0
private function getMaxBuildableItemsByResource($item_id)
{
$buildable = [];
$price_metal = $this->objects->getPrice($item_id, 'metal');
$price_crystal = $this->objects->getPrice($item_id, 'crystal');
$price_deuterium = $this->objects->getPrice($item_id, 'deuterium');
if ($price_metal != 0) {
$buildable['metal'] = floor($this->resources_consumed['metal'] / $price_metal);
}
if ($price_crystal != 0) {
$buildable['crystal'] = floor($this->resources_consumed['crystal'] / $price_crystal);
}
if ($price_deuterium != 0) {
$buildable['deuterium'] = floor($this->resources_consumed['deuterium'] / $price_deuterium);
}
return max(min($buildable), 0);
}
pero con este Si
private function getMaxConstructibleElements($item_id, $planet)
{
$buildable = [];
$price_metal = $this->objects->getPrice($item_id, 'metal');
$price_crystal = $this->objects->getPrice($item_id, 'crystal');
$price_deuterium = $this->objects->getPrice($item_id, 'deuterium');
if ($price_metal != 0) {
$buildable['metal'] = floor($planet['planet_metal'] / $price_metal);
}
if ($price_crystal != 0) {
$buildable['crystal'] = floor($planet['planet_crystal'] / $price_crystal);
}
if ($price_deuterium != 0) {
$buildable['deuterium'] = floor($planet['planet_deuterium'] / $price_deuterium);
}
return max(min($buildable), 0);
}
Pasos a seguir.
Agregar en
private function setListOfShipyardItem($item_id)
$item_to_parse['max_element'] = $this->getItemInsertMaxBlock($item_id);
Agregar despues de la funcion
private function getItemInsertMaxBlock($item_id)
{
$max_by_resource = $this->getMaxConstructibleElements($item_id, $this->planet);
if ($this->getShieldDomeItemLimit($item_id)) {
return '';
}
if (!$this->building_in_progress && !$this->userLibrary->isOnVacations($this->user)) {
return $this->template->set(
'shipyard/shipyard_build_button_max',
array_merge(
$this->langs->language,
[
'item_id' => $item_id,
'max_amount' => $max_by_resource,
]
)
);
}
return '';
}
Agregar abajo de todo
private function getMaxConstructibleElements($item_id, $planet)
{
$buildable = [];
$price_metal = $this->objects->getPrice($item_id, 'metal');
$price_crystal = $this->objects->getPrice($item_id, 'crystal');
$price_deuterium = $this->objects->getPrice($item_id, 'deuterium');
if ($price_metal != 0) {
$buildable['metal'] = floor($planet['planet_metal'] / $price_metal);
}
if ($price_crystal != 0) {
$buildable['crystal'] = floor($planet['planet_crystal'] / $price_crystal);
}
if ($price_deuterium != 0) {
$buildable['deuterium'] = floor($planet['planet_deuterium'] / $price_deuterium);
}
return max(min($buildable), 0);
}
Crear shipyard_build_button_max.blade.php
<a href='javascript:' onclick="document.getElementsByName('fmenge[{{ $item_id }}]')[0].value='{{ $max_amount }}' ;">
[máx. {{ $max_amount }}]
</a>
Agregar al shipyard_table.php debajo de {add_element}
{max_element}
Imagenes
Pense que ese botón ya no teníamos. Luego miro
Pense que ese botón ya no teníamos. Luego miro
en la 1.5 estaba jajaj después se eliminó me parece con las formas de vida es como volver a las razas de la 1.5 esto de ogame copian todo
Deben haber contratado a un ex-xnova 😝