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

Future problem with the function pretty_number(). #219

Open
yamilrh opened this issue Jun 2, 2020 · 4 comments
Open

Future problem with the function pretty_number(). #219

yamilrh opened this issue Jun 2, 2020 · 4 comments

Comments

@yamilrh
Copy link

yamilrh commented Jun 2, 2020

Message: Undefined offset: 12
File: /includes/GeneralFunctions.php
Line: 423
URL: https://localhost/htdocs/game.php
PHP-Version: 7.3.6
PHP-API: apache2handler
2Moons Version: 2.4.git
Debug Backtrace:
#0 /includes/GeneralFunctions.php(423): errorHandler(8, 'Undefined offse...', 'C://xampp//htdocs...', 423, Array)
#1 /includes/pages/game/AbstractGamePage.class.php(278): shortly_number(5.2831195950595)
#2 /includes/pages/game/AbstractGamePage.class.php(301): AbstractGamePage->getNavigationData()
#3 /includes/pages/game/AbstractGamePage.class.php(407): AbstractGamePage->getPageData()
#4 /includes/pages/game/ShowOverviewPage.class.php(374): AbstractGamePage->display('page.overview.d...')
#5 /game.php(57): ShowOverviewPage->show()
#6 {main}

GeneralFunctions.php
Line 403-424
function shortly_number($number, $decial = NULL)
{
$negate = $number < 0 ? -1 : 1;
$number = abs($number);
$unit = array("", "K", "M", "B", "T", "Q", "Q+", "S", "S+", "O", "N");
$key = 0;

if($number >= 1000000) {
	++$key;
	while($number >= 1000000)
	{
		++$key;
		$number = $number / 1000000;
	}
} elseif($number >= 1000) {
	++$key;
	$number = $number / 1000;
}

$decial	= !is_numeric($decial) ? ((int) (((int)$number != $number) && $key != 0 && $number != 0 && $number < 100)) : $decial;
return pretty_number($negate * $number, $decial).'&nbsp;'.$unit[$key];

}

@yamilrh yamilrh changed the title Future problem function pretty_number(). Future problem with the function pretty_number(). Jun 2, 2020
@Qwatayean
Copy link
Contributor

Qwatayean commented Jun 2, 2020

I guess the number you are summoning is 2 scales higher than "N" unit tag, for this reason, it throws that error because the key 12 on array is not defined ("N" ends as key 10, or "$unit[10]")

Untested, just theorizing.

@yamilrh
Copy link
Author

yamilrh commented Jun 2, 2020

sip, realmente eso lo force a que diera ese error, y da cuando tus puntos totales sobrepasa ese valor N, en este caso 12, Solamente basta con poner tu nivel de la tecnología de expedición al 255, y ya nada mas que actualicen los puntos, da este error.

@Qwatayean
Copy link
Contributor

Qwatayean commented Jun 3, 2020

@yamilrh because this is a milestone quite impossible to achieve (under normal conditions in a normal server. And truth be told, barely any player know what "N" means on these conditions.

A proposal could be, when number starts to be unreadable, have something like $unit = isset($unit[$key]) ? $unit[$key] : "&#8734; ".$key - 10; so in the case of 12, player would read ∞ 2

@yamilrh
Copy link
Author

yamilrh commented Jun 4, 2020

Si pero el caso, es que nada mas lo hice con esa tecnología o sea que a lo mejor es mas probable de que se muera antes, sin necesidad de llegar a N, ya que estructuras, flotas, defensas, y tecnologías suman . Graciaspuntos

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

2 participants