XG-Proyect-v3.x.x
XG-Proyect-v3.x.x copied to clipboard
[Mejora Futura] Cupulas que solo aparesca el boton
Solo sale el boton construir en las cupulas.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Soy muy malo para los PR pero salio a lo bruto el codigo que si se puede mejorar me imagino
if (in_array($item_id, [Defenses::defense_small_shield_dome, Defenses::defense_large_shield_dome])) {
if (!$this->isShieldDomeAvailable($item_id)) {
$item_to_parse['max_element'] = '';
} else {
$item_to_parse['max_element'] = '';
}
} else {
$item_to_parse['max_element'] = '<br />' . $this->getItemInsertMaxBlock($item_id);
}
Si agregaron el Boton Max
se remplaza con esto
private function getItemInsertMaxBlock($item_id)
{
if ($this->isShieldDomeAvailable($item_id)) {
return '';
} else {
$max_by_resource = $this->getMaxConstructibleElements($item_id, $this->planet);
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 '';
}
Creamos el archivo shipyard_build_button_dome.blade.php
<input type="hidden" name="fmenge[{{ $item_id }}]" value="1" tabindex="{{ $tab_index }}">
<input type="submit" value="Build">
y modificamos el getItemInsertBlock
private function getItemInsertBlock($item_id)
{
if (
!$this->building_in_progress && !$this->userLibrary->isOnVacations($this->user)
) {
if ($this->isShieldDomeAvailable($item_id)) {
return FormatLib::colorRed($this->langs->line('sy_protection_shield_only_one'));
} else {
$box_data = [];
$box_data['item_id'] = $item_id;
$box_data['tab_index'] = $item_id;
$shields_ids = [Defenses::defense_small_shield_dome, Defenses::defense_large_shield_dome];
if (in_array($item_id, $shields_ids)) {
if (!$this->isShieldDomeAvailable($item_id)) {
return $this->template->set(
'shipyard/shipyard_build_button',
$box_data
);
}
}
return $this->template->set(
'shipyard/shipyard_build_box',
$box_data
);
}
}
return '';
}