XGProyect / XG-Proyect-v3.x.x

XG Proyect is an OGame clone open-source web application framework designed for creating game clones, particularly those inspired by the popular game OGame, set in a vast and captivating space-themed universe.
https://xgproyect.org
GNU General Public License v3.0
142 stars 97 forks source link

[Feature] Boton Max en Hangar #537

Open jonamix-ar opened 1 year ago

jonamix-ar commented 1 year ago

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 screencapture-localhost-XG-Proyect-game-php-2023-04-26-16_16_27

screencapture-localhost-XG-Proyect-game-php-2023-04-26-16_21_31

LucasKovacs commented 1 year ago

Pense que ese botón ya no teníamos. Luego miro

jonamix-ar commented 1 year ago

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

LucasKovacs commented 1 year ago

Deben haber contratado a un ex-xnova 😝