forked from halo-battle/game
98 lines
2.2 KiB
PHP
98 lines
2.2 KiB
PHP
|
<?php
|
||
|
/***************************************************************************
|
||
|
* class.planete.php
|
||
|
* -------------------
|
||
|
* begin : Jeudi 21 août 2008
|
||
|
* update : Dimanche 7 septembre 2008
|
||
|
* email : nemunaire@gmail.com
|
||
|
*
|
||
|
*
|
||
|
***************************************************************************/
|
||
|
class Planete extends User{
|
||
|
var $id,
|
||
|
$metal,
|
||
|
$cristal,
|
||
|
$hydrogene,
|
||
|
$batiments = array(),
|
||
|
$casernes = array(),
|
||
|
$terrestres = array(),
|
||
|
$vaisseaux = array();
|
||
|
|
||
|
/**
|
||
|
* Constructeur
|
||
|
* @param int $id id de la planète à importer
|
||
|
*
|
||
|
* @return void
|
||
|
* @access public
|
||
|
*/
|
||
|
function Planete($plan, $user){
|
||
|
global $batimentVAR, $casernenVAR, $nomterrnVAR, $nomvaisnVAR;
|
||
|
parent::User($user);
|
||
|
$this->id = $plan["id"];
|
||
|
$this->metal = $plan["metal"];
|
||
|
$this->cristal = $plan["cristal"];
|
||
|
$this->hydrogene = $plan["hydrogene"];
|
||
|
|
||
|
foreach($batimentVAR as $bat){
|
||
|
$this->batiments[] = $plan[$bat];
|
||
|
}
|
||
|
foreach($casernenVAR as $cas){
|
||
|
$this->casernes[] = $plan[$cas];
|
||
|
}
|
||
|
foreach($nomterrnVAR as $ter){
|
||
|
$this->terrestres[] = $plan[$ter];
|
||
|
}
|
||
|
foreach($nomvaisnVAR as $vais){
|
||
|
$this->vaisseaux[] = $plan[$vais];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function calculerBatiments(){
|
||
|
global $batimentCALC;
|
||
|
$pointsbat = 0;
|
||
|
$planete = $this;
|
||
|
|
||
|
foreach($this->batiments as $k => $n){
|
||
|
eval($batimentCALC[$k][0]);
|
||
|
eval($batimentCALC[$k][1]);
|
||
|
eval($batimentCALC[$k][2]);
|
||
|
$pointsbat += $a + $b + $c;
|
||
|
}
|
||
|
|
||
|
return $pointsbat;
|
||
|
}
|
||
|
|
||
|
function calculerCasernes(){
|
||
|
global $casernenCALC;
|
||
|
$pointscas = 0;
|
||
|
|
||
|
foreach($this->casernes as $k => $n){
|
||
|
$pointscas += ($casernenCALC[$k][0] + $casernenCALC[$k][1] + $casernenCALC[$k][2]) * $n;
|
||
|
}
|
||
|
|
||
|
return $pointscas;
|
||
|
}
|
||
|
|
||
|
function calculerTerrestres(){
|
||
|
global $nomterrnCALC;
|
||
|
$pointster = 0;
|
||
|
|
||
|
foreach($this->terrestres as $k => $n){
|
||
|
$pointster += ($nomterrnCALC[$k][0] + $nomterrnCALC[$k][1] + $nomterrnCALC[$k][2]) * $n;
|
||
|
}
|
||
|
|
||
|
return $pointster;
|
||
|
}
|
||
|
|
||
|
function calculerVaisseaux(){
|
||
|
global $nomvaisnCALC;
|
||
|
$pointsvai = 0;
|
||
|
|
||
|
foreach($this->vaisseaux as $k => $n){
|
||
|
$pointsvai += ($nomvaisnCALC[$k][0] + $nomvaisnCALC[$k][1] + $nomvaisnCALC[$k][2]) * $n;
|
||
|
}
|
||
|
|
||
|
return $pointsvai;
|
||
|
}
|
||
|
}
|
||
|
?>
|