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

tryMoon #17

Closed
ddialer opened this issue Mar 27, 2015 · 3 comments
Closed

tryMoon #17

ddialer opened this issue Mar 27, 2015 · 3 comments

Comments

@ddialer
Copy link

ddialer commented Mar 27, 2015

looks like tryMoon event doesn't count resources that already floating around the planet and trying to use resources that was left only from current battle

@ddialer
Copy link
Author

ddialer commented Mar 27, 2015

Here how I solve it for now, but will be better if you create player with HomeWorld to specify debris that already floats around and then using it to calculate moon chance
before BattleReport.php:

public function tryMoon()
    {
        $prob = $this->getMoonProb();
        return Math::tryEvent($prob, 'Events::event_moon', $prob);
    }
    public function getMoonProb()
    {
        return min(round(array_sum($this->getDebris()) / MOON_UNIT_PROB), MAX_MOON_PROB);
    }
    public function getDebris()
    {
        $aDebris = $this->getAttackerDebris();
        $dDebris = $this->getDefenderDebris();
        return array($aDebris[0] + $dDebris[0], $aDebris[1] + $dDebris[1]);
    }

after:

    public function tryMoon($metal = 0, $crystal = 0)
    {
        $prob = $this->getMoonProb($metal, $crystal);
        return Math::tryEvent($prob, 'Events::event_moon', $prob);
    }
    public function getMoonProb($metal = 0, $crystal = 0)
    {
        return min(round(array_sum($this->getDebris($metal, $crystal)) / MOON_UNIT_PROB), MAX_MOON_PROB);
    }
    public function getDebris($metal = 0, $crystal = 0)
    {
        $aDebris = $this->getAttackerDebris();
        $dDebris = $this->getDefenderDebris();
        return array($aDebris[0] + $dDebris[0] + $metal, $aDebris[1] + $dDebris[1] + $crystal);
    }

usage:

$report->tryMoon($metalFloatingArroundPlanet, $crystalFloatingArroundPlanet);

@jstar88 jstar88 closed this as completed Mar 28, 2015
@jstar88
Copy link
Owner

jstar88 commented Mar 28, 2015

actually this is not a bug: only debris generated from the current battle can generate the moon.
By the way, in the GenerateReport.php (2moons) all debris are shown(also old one).
Same for XGP in calculateattack

@jstar88 jstar88 reopened this Mar 28, 2015
@jstar88 jstar88 closed this as completed Apr 9, 2015
@jonamix-ar
Copy link

Jstar Hi sorry would spend the core of the new version 1.0.1 of OGP ye tried to implement yours battle engine this version and let me know if PODES test to see if the install well

the file that touch is the missions / attack.php

From already thank you very much I leave the link of the core

https://mega.co.nz/#!vNJ2DayQ!H168OMQ9k4zAAjcEbdN1oH_kBqEkhAYxtd-BmrSP708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants