Jump to content
Tekku

[Dúvida] Acesso ao valor das variáveis

Recommended Posts

Tekku

Boas, tenho seguinte problema "Dúvida", tenho um determinado código, e gostava de saber se é possível aceder ao valor que essas variáveis têm...

<?php

/**
*
* AddBuildingToQueue.php
*
* @version 1
* @copyright 2008 by Chlorel for XNova
*/

// Ajoute un batiment dans la queue
// $CurrentPlanet -> Planete sur laquelle on construit
// $CurrentUser   -> Joueur courrant
// $Element       -> Batiment a construire
//
// Retour         -> Valeur de l'element inseré
//                   ou false s'il ne peut pas l'inserer (queue pleine)
//
function AddBuildingToQueue ( &$CurrentPlanet, $CurrentUser, $Element, $AddMode = true) {
global $lang, $resource;

$CurrentQueue  = $CurrentPlanet['b_building_id'];
if ($CurrentQueue != 0) {
	$QueueArray    = explode ( ";", $CurrentQueue );
	$ActualCount   = count ( $QueueArray );
} else {
	$QueueArray    = "";
	$ActualCount   = 0;
}

if ($AddMode == true) {
	$BuildMode = 'build';
} else {
	$BuildMode = 'destroy';
}

if ( $ActualCount < MAX_BUILDING_QUEUE_SIZE ) {
	$QueueID      = $ActualCount + 1;
} else {
	$QueueID      = false;
}

if ( $QueueID != false ) {
	// Faut verifier si l'Element que l'on veut integrer est deja dans le tableau !
	if ($QueueID > 1) {
		$InArray = 0;
		for ( $QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++ ) {
			$QueueSubArray = explode ( ",", $QueueArray[$QueueElement] );
			if ($QueueSubArray[0] == $Element) {
				$InArray++;
			}
		}
	} else {
		$InArray = 0;
	}

	if ($InArray != 0) {
		$ActualLevel  = $CurrentPlanet[$resource[$Element]];
		if ($AddMode == true) {
			$BuildLevel   = $ActualLevel + 1 + $InArray;
			$CurrentPlanet[$resource[$Element]] += $InArray;
			$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
			$CurrentPlanet[$resource[$Element]] -= $InArray;
		} else {
			$BuildLevel   = $ActualLevel - 1 + $InArray;
			$CurrentPlanet[$resource[$Element]] -= $InArray;
			$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
			$CurrentPlanet[$resource[$Element]] += $InArray;
		}
	} else {
		$ActualLevel  = $CurrentPlanet[$resource[$Element]];
		if ($AddMode == true) {
			$BuildLevel   = $ActualLevel + 1;
			$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
		} else {
			$BuildLevel   = $ActualLevel - 1;
			$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
		}
	}

	if ($QueueID == 1) {
		$BuildEndTime = time() + $BuildTime;
	} else {
		$PrevBuild = explode (",", $QueueArray[$ActualCount - 1]);
		$BuildEndTime = $PrevBuild[3] + $BuildTime;
	}
	$QueueArray[$ActualCount]       = $Element .",". $BuildLevel .",". $BuildTime .",". $BuildEndTime .",". $BuildMode;
	$NewQueue                       = implode ( ";", $QueueArray );
	$CurrentPlanet['b_building_id'] = $NewQueue;
}
return $QueueID;
}

?>

Cumps e obrigado desde já...

Share this post


Link to post
Share on other sites
scorch

Quais variáveis?


PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum.

Share this post


Link to post
Share on other sites
Tekku

Boas, nem eu sei bem o que o outro programador queria, mas pelos vistos ele já arranjou alguém que o entende melhor, obrigado na mesma ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.