Version 1.5

This commit is contained in:
nemunaire 2008-11-30 12:00:00 +01:00
commit a66ed9797b
157 changed files with 29787 additions and 3531 deletions

1
Class/.htaccess Normal file
View file

@ -0,0 +1 @@
Deny from all

View file

@ -49,8 +49,8 @@ class Combat {
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
if ($j == 0) $groupe[] = array($nbvaispgroupe + $nbrest, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
else $groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
}
$this->ATvais[] = array($i, $flotteAT['vaisseau_'.$i], $nbgroupes, $groupe);
}
@ -76,8 +76,8 @@ class Combat {
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
if ($j == 0) $groupe[] = array($nbvaispgroupe + $nbrest, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
else $groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
}
$this->ENvais[] = array($i, $flotteEN['vaisseau_'.$i], $nbgroupes, $groupe);
}
@ -95,8 +95,8 @@ class Combat {
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $defense_bc[$i-1], $defense_pv[$i-1]);
if ($j == 0) $groupe[] = array($nbvaispgroupe + $nbrest, $defense_bc[$i-1], $defense_pv[$i-1]);
else $groupe[] = array($nbvaispgroupe, $defense_bc[$i-1], $defense_pv[$i-1]);
}
$this->ENdef[] = array($i, $defEN['def_'.$i], $nbgroupes, $groupe);
}
@ -300,13 +300,13 @@ class Combat {
$this->ENvais[$k][3][$l][2] -= abs($this->ENvais[$k][3][$l][1]);
$this->ENvais[$k][3][$l][1] = 0;
if ($this->ENvais[$k][3][$l][2] <= 0) {
$this->debriM += $this->ENvais[$k][3][$l][0] * $nomvais_md[$this->ENvais[$k][0]];
$this->debriC += $this->ENvais[$k][3][$l][0] * $nomvais_cd[$this->ENvais[$k][0]];
$this->ENvais[$k][1] -= $this->ENvais[$k][3][$l][0];
$this->ENvais[$k][2] --;
unset($this->ENvais[$k][3][$l]);
$this->ENvais[$k][3] = array_merge($this->ENvais[$k][3]);
array_splice($this->ENvais[$k][3], $l, 1);
if (!count($this->ENvais[$k][3])) {
unset($this->ENvais[$k]);
$this->ENvais[$k] = array_merge($this->ENvais[$k]);
array_splice($this->ENvais, $k, 1);
}
}
}
@ -322,13 +322,13 @@ class Combat {
$this->ENdef[$k][3][$l][2] -= abs($this->ENdef[$k][3][$l][1]);
$this->ENdef[$k][3][$l][1] = 0;
if ($this->ENdef[$k][3][$l][2] <= 0) {
$this->debriM += $this->ENdef[$k][3][$l][0] * $nomvais_md[$this->ENdef[$k][0]];
$this->debriC += $this->ENdef[$k][3][$l][0] * $nomvais_cd[$this->ENdef[$k][0]];
$this->ENdef[$k][1] -= $this->ENdef[$k][3][$l][0];
$this->ENdef[$k][2] --;
unset($this->ENdef[$k][3][$l]);
$this->ENdef[$k][3] = array_merge($this->ENdef[$k][3]);
array_splice($this->ENdef[$k][3], $l, 1);
if (!count($this->ENdef[$k][3])) {
unset($this->ENdef[$k]);
$this->ENdef[$k] = array_merge($this->ENdef[$k]);
array_splice($this->ENdef, $k, 1);
}
}
}
@ -356,21 +356,21 @@ class Combat {
//On lance l'attaque
for ($j=0 ; $j<$nbgroupes ; $j++){
$k = rand(0, count($this->ENdef)-1);
$l = rand(0, count($this->ENdef[$k][3])-1);
$k = rand(0, count($this->ATvais)-1);
$l = rand(0, count($this->ATvais[$k][3])-1);
$this->ENdef[$k][3][$l][1] -= $ppv;
if ($this->ENdef[$k][3][$l][1] < 0) {
$this->ENdef[$k][3][$l][2] -= abs($this->ENdef[$k][3][$l][1]);
$this->ENdef[$k][3][$l][1] = 0;
if ($this->ENdef[$k][3][$l][2] <= 0) {
$this->ENdef[$k][1] -= $this->ENdef[$k][3][$l][0];
$this->ENdef[$k][2] --;
unset($this->ENdef[$k][3][$l]);
$this->ENdef[$k][3] = array_merge($this->ENdef[$k][3]);
if (!count($this->ENdef[$k][3])) {
unset($this->ENdef[$k]);
$this->ENdef[$k] = array_merge($this->ENdef[$k]);
$this->ATvais[$k][3][$l][1] -= $ppv;
if ($this->ATvais[$k][3][$l][1] < 0) {
$this->ATvais[$k][3][$l][2] -= abs($this->ATvais[$k][3][$l][1]);
$this->ATvais[$k][3][$l][1] = 0;
if ($this->ATvais[$k][3][$l][2] <= 0) {
$this->debriM += $this->ATvais[$k][3][$l][0] * $nomvais_md[$this->ATvais[$k][0]];
$this->debriC += $this->ATvais[$k][3][$l][0] * $nomvais_cd[$this->ATvais[$k][0]];
$this->ATvais[$k][1] -= $this->ATvais[$k][3][$l][0];
$this->ATvais[$k][2] --;
array_splice($this->ATvais[$k][3], $l, 1);
if (!count($this->ATvais[$k][3])) {
array_splice($this->ATvais, $k, 1);
}
}
}

View file

@ -10,6 +10,7 @@ class gererFile {
}
function addObjet($objet,$nombre,$temps) {
$this->file = array_merge($this->file);
$nbF = count($this->file);
if ($nbF >= $this->limite) return false;
$this->chaine = false;
@ -30,21 +31,23 @@ class gererFile {
function delobjet($objet, $nombre=1) {
$this->file = array_merge($this->file);
for($i=count($this->file)-1 ; $i>=0 ; $i--) {
for($i = count($this->file)-1; $i >= 0; $i--) {
if($this->file[$i][0] == $objet){
$nombre=min($nombre, $this->file[$i][1]);
$nombre = min($nombre, $this->file[$i][1]);
$this->file[$i][1] -= $nombre;
if($this->file[$i][1]<=0) {
if($this->file[$i][1] <= 0) {
unset($this->file[$i]);
$this->file = array_merge($this->file);
}
break;
}
if ($i == 0) $this->timestamp = time();
if ($i == 1) $this->timestamp = time();
}
return $nombre;
}
function pret() {
$this->file = array_merge($this->file);
$out = array();
$nbF = count($this->file);
if ($nbF == 1 && $this->chaine) {

View file

@ -100,10 +100,105 @@ class Rapport{
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilB)."', '', '$titreB', '$rapportB', '$temps')");
}
function sendCombat(){
include('includes/vars.php');
include_once('includes/function.php');
require_once(SMARTY_DIR."Smarty.class.php");
$rapportA = new Smarty();
$rapportB = new Smarty();
$rapportA->template_dir = _FCORE.'templates/templates/';
$rapportA->compile_dir = _FCORE.'templates/templates_c/';
$rapportA->config_dir = _FCORE.'templates/configs/';
$rapportA->cache_dir = _FCORE.'templates/cache/';
$rapportB->template_dir = _FCORE.'templates/templates/';
$rapportB->compile_dir = _FCORE.'templates/templates_c/';
$rapportB->config_dir = _FCORE.'templates/configs/';
$rapportB->cache_dir = _FCORE.'templates/cache/';
$this->var[4]['pseudo'] = trouvNom($this->var[4]['id_user']);
$this->var[5]['pseudo'] = trouvNom($this->var[5]['id_user']);
$rapportA->assign('tour', $this->var[3]);
$rapportA->assign('EN', $this->var[4]);
$rapportA->assign('flotte', $this->var[5]);
$rapportA->assign('vaisseaux1', $this->var[0]);
$rapportA->assign('vaisseaux2', $this->var[1]);
$rapportA->assign('defenses1', $this->var[2]);
$rapportA->assign('vaisseaux3', $this->var[7]);
$rapportA->assign('vaisseaux4', $this->var[8]);
$rapportA->assign('defenses2', $this->var[9]);
$rapportA->assign('termine', $this->var[6][0]);
$rapportA->assign('attaquantG', $this->var[6][1]);
$rapportA->assign('pillage', $this->var[11]);
$rapportA->assign('vaisBC', $nomvais_bc);
$rapportA->assign('vaisPV', $nomvais_pv);
$rapportA->assign('nextTour', $this->var[10]);
$race = trouvInfo($this->utilA, 'race');
include('includes/noms.php');
$rapportA->assign('ressources', $ressourc);
$rapportA->assign('nomvaisAT', $nomvaisa);
$race = trouvInfo($this->var[4]['id_user'], 'race');
include('includes/noms.php');
$rapportA->assign('nomvaisEN', $nomvaisa);
array_splice($nomterra, 0, 8);
$rapportA->assign('nomdefEN', $nomterra);
$rapportA = $rapportA->fetch('game/ATrapport_combat.tpl');
$rapportB->assign('tour', $this->var[3]);
$rapportB->assign('EN', $this->var[4]);
$rapportB->assign('flotte', $this->var[5]);
$rapportB->assign('vaisseaux1', $this->var[0]);
$rapportB->assign('vaisseaux2', $this->var[1]);
$rapportB->assign('defenses1', $this->var[2]);
$rapportB->assign('vaisseaux3', $this->var[7]);
$rapportB->assign('vaisseaux4', $this->var[8]);
$rapportB->assign('defenses2', $this->var[9]);
$rapportB->assign('termine', $this->var[6][0]);
$rapportB->assign('attaquantG', $this->var[6][1]);
$rapportB->assign('pillage', $this->var[11]);
$rapportB->assign('vaisBC', $nomvais_bc);
$rapportB->assign('vaisPV', $nomvais_pv);
$rapportB->assign('nextTour', $this->var[10]);
$race = trouvInfo($this->utilA, 'race');
include('includes/noms.php');
$rapportB->assign('ressources', $ressourc);
$rapportB->assign('nomvaisAT', $nomvaisa);
$race = trouvInfo($this->var[4]['id_user'], 'race');
include('includes/noms.php');
$rapportB->assign('nomvaisEN', $nomvaisa);
array_splice($nomterra, 0, 8);
$rapportB->assign('nomdefEN', $nomterra);
$rapportB = $rapportB->fetch('game/ENrapport_combat.tpl');
$titreA = mysql_real_escape_string('Combat contre '.$this->var[4]['pseudo']);
$rapportA = mysql_real_escape_string($rapportA);
$titreB = mysql_real_escape_string('Combat contre '.$this->var[5]['pseudo']);
$rapportB = mysql_real_escape_string($rapportB);
$temps = $this->timestamp;
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilA)."', '', '$titreA', '$rapportA', '$temps')");
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilB)."', '', '$titreB', '$rapportB', '$temps')");
}
function sendAlliance(){
include_once('includes/function.php');
$titreA = 'Déclaration officielle de votre alliance !';
$rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous randant sur la page Alliance.';
$rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous rendant sur la page Alliance.';
$titreA = mysql_real_escape_string($titreA);
$rapportA = mysql_real_escape_string($rapportA);