Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Boton Max en Hangar #537

Open
jonamix-ar opened this issue Apr 26, 2023 · 3 comments
Open

[Feature] Boton Max en Hangar #537

jonamix-ar opened this issue Apr 26, 2023 · 3 comments
Assignees
Labels
Feature Issues that will become new features
Milestone

Comments

@jonamix-ar
Copy link

jonamix-ar commented Apr 26, 2023

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
Copy link
Member

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

@jonamix-ar
Copy link
Author

jonamix-ar commented Apr 26, 2023

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
Copy link
Member

Deben haber contratado a un ex-xnova 😝

@LucasKovacs LucasKovacs self-assigned this Apr 27, 2023
@LucasKovacs LucasKovacs added the Feature Issues that will become new features label Apr 27, 2023
@LucasKovacs LucasKovacs modified the milestones: v3.4.0, v3.5.0 Apr 27, 2023
@LucasKovacs LucasKovacs modified the milestones: v3.5.0, V3.6.0 Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issues that will become new features
Projects
Status: No status
Development

No branches or pull requests

2 participants