-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathepave.php
More file actions
88 lines (78 loc) · 2.6 KB
/
Copy pathepave.php
File metadata and controls
88 lines (78 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
include_once ("constantes_carte.php");
class Epave {
private $typeEpave;
private $nomEpave;
private $volumeEpave;
private $volMateriaux;
private $volMateriauxAlien;
private $listeMAteriaux =array();
//const NOM_EPAVE = ["Débris de structure","Station abandonnée","Epave de vaisseau","Epave extra-terrestre"];
// const QTE_MATERIAU_EPAVE_MIN = [1,2000,500,500];
// const QTE_MATERIAU_EPAVE_MAX = [1000,10000,5000,2000];
// const QTE_MATERIAU_ALIEN_EPAVE_MIN = [0,0,0,500];
// const QTE_MATERIAU_ALIEN_EPAVE_MAX = [0,0,0,2000];
//const NOM_MATERIAU = ["Acier","Aluminium","Titane","Cuivre","Plomb","Argent","Or","Uranium","Bolognium","Carbonium"];
//const MATERIAU_ORI = [0,0,0,0,0,0,0,0,1,1];
// const TAUX_MATERIAU_EPAVE = [700,700,500,500,300,80,5,1,850,150];
// const MODULE_MATERIAU_EPAVE = [100,100,30,20,10,1,1,1,100,1];
public function __construct($type) {
$this->typeEpave = $type;
$this->nomEpave = NOM_EPAVE[$type];
$nb = count (NOM_MATERIAU);
$this->volMateriaux=rand(QTE_MATERIAU_EPAVE_MIN[$type],QTE_MATERIAU_EPAVE_MAX[$type]);
$this->volMateriauxAlien=rand(QTE_MATERIAU_ALIEN_EPAVE_MIN[$type],QTE_MATERIAU_ALIEN_EPAVE_MAX[$type]);
$this->listeMAteriaux = $this->calculMatEpave($this->volMateriaux*1000,$this->volMateriauxAlien*1000); // *1000 pour passer en kg
$i=0;
foreach($this->listeMAteriaux as $arrayQuantiteMateriau) {
new Materiau($i, $arrayQuantiteMateriau);
$i++;
}
}
private function calculMatEpave($mat,$matalien) {
$liste_mat=array();
$nb_mat=count(NOM_EPAVE);
for ($z=1;$z<=$nb_mat;$z++) {
array_push($liste_mat,0);
}
$i=0;
While ($mat>0) {
if (ORIGINE_MATERIAU[$i]==0) { // test si materiau humain
$t=rand(1,1000);
If ($t<=TAUX_MATERIAU_EPAVE[$i]) {
$mat-=MODULE_MATERIAU_EPAVE[$i];
$liste_mat[$i]+=MODULE_MATERIAU_EPAVE[$i];
}
}
$i++;
if ($i==$nb_mat) {
$i=0;
}
}
$i=0;
While ($matalien>0) {
if (ORIGINE_MATERIAU[$i]==1) { // test si materiau alien
$t=rand(1,1000);
If ($t<=TAUX_MATERIAU_EPAVE[$i]) {
$matalien -= MODULE_MATERIAU_EPAVE[$i];
$liste_mat[$i] += MODULE_MATERIAU_EPAVE[$i];
}
}
$i++;
if ($i==$nb_mat) {
$i=0;
}
}
return $liste_mat; // renvoi une liste contenant la quantité de tous les materiaux
}
public function getEpaveType() {
return $this->typeEpave;
}
public function getEpaveNom() {
return $this->nomEpave;
}
public function getEpaveVolume() {
return $this->volumeEpave;
}
}
?>