- Construit une image anti-spam. Vous pouvez définir la chaîne de caractères à afficher sur l'image avec $string.
- Si vous ne donnez aucune chaîne de caractères, voyez AntiSpam::setRand() pour générer une valeur aléatoire.
-
- Enregistre la valeur de l'image anti-spam dans la session de l'utilisateur sous le nom $qName.
- Cette méthode doit être utilisée en combinaison avec AntiSpam::check().
-
- Vérifie que la valeur $value correspond à la valeur enregistrée sous le nom $qName avec AntiSpam::save().
- Si $case est mis à TRUE, alors la vérification NE sera PAS sensible à la casse, elle le sera à FALSE.
- Cette méthode doit être utilisée en combinaison avec AntiSpam::save().
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Axis.html b/artichow/doc/Axis.html
deleted file mode 100644
index 747bb01..0000000
--- a/artichow/doc/Axis.html
+++ /dev/null
@@ -1,385 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Axis
-
- La classe Axis permet de manipuler des axes.
- Un axe permet à un utilisateur de répérer les points et leurs valeurs sur un graphique.
-
-
- De nombreuses méthodes de la classe Axis ne sont pas documentées,
- car elles ne sont utilisées qu'en interne par Artichow.
- Néanmoins, si vous développez Artichow, vous aurez besoin de ces méthodes.
- N'hésitez donc pas à parcourir le code source de cette classe.
-
- Déclare un nouvel axe.
- Les variables $min et $max représentent respectivement la valeurs minimales et maximales associées à l'axe.
- Par exemple, choisir $min = -12 et $max = 42 signifie tout simplement que l'axe ira de -12 à 42.
-
- Active/désactive la gestion automatique de l'axe.
- La gestion automatique est automatiquement désactivée en cas d'appel aux méthodes suivantes : Axis::setLabelNumber(), Axis::setLabelInterval(), Axis::setLabelPrecision() et Axis::setLabelText().
- Lorsqu'un axe est sous gestion automatique, l'échelle est le nombre de valeurs à afficher sur l'axe sont automatiquement calculés.
-
- Cache ou non l'axe. Le paramètre $hide est par défaut à TRUE (ce qui signifie que l'axe ne sera pas dessiné).
- S'il est mis à FALSE, l'axe sera dessiné.
-
- Supprime l'objet Tick de nom $name associé à l'axe.
- Pour pouvoir être supprimé, cet objet doit avoir été précédemment ajouté avec la méthode Axis::addTick().
-
- Inverse le style de tous les ticks associés à l'axe pour $style.
- Si les ticks étaient tournés vers l'extérieur, ils seront désormais tournés vers l'intérieur.
- Et vice-versa.
-
- Change l'intervalle d'affichage de tous les ticks associés à l'axe pour $interval.
- Cette méthode permet d'espacer l'affichage des ticks par rapport aux valeurs de l'axe.
-
- Cette méthode permet de modifier la fréquence d'affichage d'un objet Tick par rapport à un autre.
- $to représente l'objet dont la fréquence d'affichage doit être modifiée et $from l'objet auquel on se réfère.
- A chaque fois qu'un tick $from sera affiché, on affichera $number ticks $to.
- Si $number vaut 2, cela signifie que deux ticks $to seront affichés pour un tick $from.
- Cette méthode prend tout son sens donc le cadre des Plot par exemple :
-
-
-<?php
-
-require_once 'LinePlot.class.php';
-
-$graph = new Graph(400, 400);
-
-$plot = new LinePlot(array(1, 2, 3));
-
-// Pour chaque tick major affiché,
-// on affichera 10 ticks minor
-$plot->xAxis->setNumberByTick('minor', 'major', 10);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
-
-
- Change la précision des valeurs affichées sur chaque étiquette de l'axe.
- $number représente le nombre de chiffres après la virgule qui doivent être affiché.
- Par défaut, $precision vaut 0.
-
- Cette méthode permet d'afficher des valeurs arbitraires plutôt que des valeurs numériques sur les étiquettes de l'axe.
- $texts est un tableau comportant autant d'entrées que d'étiquettes et qui contient les nouvelles valeurs à afficher.
-
- Change la position du titre sur l'axe.
- $position est une fraction de la taille de l'axe.
- Par exemple, si $position est placé à 0.5, le titre sera affiché au milieu de l'axe.
- Si $position vaut 0.25, alors le titre sera affiché sur le premier quart de l'axe.
- Pour aligner le titre par rapport à cette position, utilisez la méthode Axis::setTitleAlignment().
-
- Change l'espace interne à gauche et à droite de l'axe.
- Gauche et droite n'ont de sens que pour les axes verticaux.
- Pour les axes plus horizontaux, préférez haut à gauche et bas à droite.
-
- Créé un nouvel histogramme avec les valeurs présentes dans $values.
- $number représente le nombre d'histogrammes affichés en parallèle tandis que $identifier permet de spécifier où se situe l'histogramme courant.
- $depth représente la profondeur de l'histogramme en pixels.
- Le tableau $values doit être une liste de valeurs dans un tableau incrémental, c'est-à-dire dont les clés valent de 0 à n - 1 (où n est la taille du tableau).
-
- Change l'espace interne de gauche et de droite sur chaque barre.
- Laisser $left ou $right à NULL permet de ne pas modifier l'ancienne valeur.
- Les valeurs données doivent être comprises entre 0 et 1 et représentent une fraction de l'espace réservé à chaque barre.
-
- Change la taille de chaque barre pour $size.
- Les valeurs données doivent être comprises entre 0 et 1 et représentent une fraction de l'espace réservé à chaque barre.
-
- Change le dégradé de fond des barres de l'histogramme.
- Le dégradé de fond remplit le polygone définit par tous les points de la ligne additionés des points extrêmes de l'axe des abscisses.
-
- Cette classe permet de décrire un dégradé bilinéaire. Un dégradé bilinéaire à ceci de particulier par rapport au dégradé linéaire que son centre peut être décalé.
-
-
- ATTENTION, les dégradés bilinéaires sont en cours de développement et ne sont pas encore disponibles sur Artichow.
-
- Construit une nouveu dégradé. Cette méthode doit être appelée par toutes les classes qui dérivent de celle-ci. Le paramètre $from décrit la couleur de départ du dégradé et le paramètre $to celle de fin. Le troisième paramètre $angle décrit l'angle du dégradé. Ce peut être un dégradé horizontal (angle de 0°) ou un dégradé vertical (angle de 90°). Le dernier paramètre doit être compris entre 0 et 1 permet de spécifier le centre du dégradé. Une valeur de 0.5 signifie que le dégradé sera symétrique.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Color.html b/artichow/doc/Color.html
deleted file mode 100644
index abb4cb3..0000000
--- a/artichow/doc/Color.html
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Color
-
- La classe Color permet de gérer les couleurs de manière uniforme sur Artichow.
-
-
- Afin de simplifier l'utilisation de cette classe, plusieurs couleurs sont déjà prédéfinies sur Artichow.
- Chacune de ces couleurs est une classe qui dérive de Color et dont le constructeur ne prend qu'un paramètre, le degré de transparence. Voici les couleurs prédéfinies triées par ton :
-
-
-
-Gris : Black, AlmostBlack, VeryDarkGray, DarkGray, MidGray, LightGray, VeryLightGray, White
- Voici un exemple d'utilisation pour les couleurs prédéfinies :
-
-
-<?php
-
-// On créé un bleu foncé
-$blue = new DarkBlue; // Equivalent à new Color(0, 0, 128);
-
-// On créé de l'orange transparent à 50 %
-$orange = new Orange(50); // Equivalent à new Color(255, 128, 0, 50);
-
-?>
-
-
- Construit une nouvelle couleur. Les trois premiers paramètres représentent l'intensité en rouge, vert et bleu pour cette couleur. L'intensité de chaque couleur est un nombre compris entre 0 et 255 (du foncé vers le clair). Le paramètre $alpha représente le dégré de transparence de la couleur, et doit être compris entre 0 et 100.
-
- Change la luminosité de la couleur, en ajoutant la valeur $brightness à chaque composante (rouge, vert, bleu) de cette couleur.
- $brightness peut prendre des valeurs comprises entre -255 et +255.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Component.html b/artichow/doc/Component.html
deleted file mode 100644
index b7f5055..0000000
--- a/artichow/doc/Component.html
+++ /dev/null
@@ -1,464 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-abstract Class Component
-
- Un composant est un objet qui peut être ajouté à une Image. Les composants sont indépendants les uns des autres. La classe Component est une classe abstraite, dont doivent dériver tous les objets qui vont pouvoir être ajoutés sur une image.
-
-
- Sur un composant, l'axe des abscisses rejoint l'axe des ordonnées sur le coin haut-gauche. Le coin haut-gauche du composant a donc pour coordonnées (0, 0) et le coin bas-droite (largeur, hauteur). Par exemple, sur une image de largeur 100 et de hauteur 50, un point à 50 sur l'axe des abscisses et 25 sur l'axe des ordonnées sera au centre de l'image.
-
- Position du composant sur l'axe des ordonnées entre 0 et 1. Représente une fraction de la hauteur de l'image.
- Attention, la position 0 correspond au haut de l'image.
-
- Espace interne dans la zone de dessin effective du composant. Les valeurs doivent être données en pourcentage de la taille de la zone de dessin.
- Le zone de dessin est la zone dans laquelle est dessiné le composant, c'est-à-dire la zone du composant amputée des axes et de l'espace interne.
-
- Construit le composant en lui affectant une taille égale à celle de l'image et en le positionnant au centre de cette image.
- Le composant remplit donc toute la surface de l'image.
-
- TRUE si le composant doit être automatiquement ajusté, FALSE sinon.
- La notion d'ajustage automatique est propre à chaque classe qui dérive de celle-ci.
- Par exemple, sur les histogrammes, si le composant n'est pas automatiquement ajusté, alors les barres ne seront pas centrées sur zéro mais sur leur valeur minimum.
-
- Change la largeur $width et la hauteur $height du composant.
- Les nouvelles valeurs doivent être comprises entre 0 et 1 et correspondent à une fraction des largeur et hauteur de l'image à laquelle le composant appartient.
-
-
-<?php
-
-require_once "LinePlot.class.php";
-
-$graph = new Graph(400, 400);
-
-// LinePLot dérive de Component
-$plot = new LinePlot(array(1, 2, 3));
-
-// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
-$plot->setSize(1 / 3, 1 / 3);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
-
-
- Retourne le fond de l'image. Cela peut être une couleur, un dégradé ou encore une image. Si aucun fond n'a été spécifié, cette méthode retourne NULL.
-
- Change l'espace interne dans la zone de dessin effective du composant. Les valeurs doivent être données en pourcentage de la taille de la zone de dessin.
- Le zone de dessin est la zone dans laquelle est dessiné le composant, c'est-à-dire la zone du composant amputée des axes et de l'espace interne.
-
- Change la position du centre du composant sur l'image.
- Les nouvelles positions $x et $y représentent une fraction des largeur et hauteur de l'image.
- Attention, la position 0 pour $y place le centre du composant en haut de l'image. La position 1 le place en bas de l'image.
-
-
-<?php
-
-require_once "LinePlot.class.php";
-
-$graph = new Graph(400, 400);
-
-// LinePLot dérive de Component
-$plot = new LinePlot(array(1, 2, 3));
-
-// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
-$plot->setSize(1 / 3, 1 / 3);
-// Place le composant en haut à gauche
-$plot->setCenter(1 / 6, 1 / 6);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
-
-
- Change la position du composant sur l'image.
- Contrairement à setCenter(), cette méthode ne place pas le composant par rapport à son centre, mais par rapport à son coin haut-gauche. Les positions $left à gauche et $top pour la hauteur doivent être données en pixels.
- Attention, la position 0 pour $top place le composant en haut de l'image.
-
-
-<?php
-
-require_once "LinePlot.class.php";
-
-$graph = new Graph(400, 400);
-
-// LinePLot dérive de Component
-$plot = new LinePlot(array(1, 2, 3));
-
-// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
-$plot->setSize(1 / 3, 1 / 3);
-// Place le composant en haut à gauche
-$plot->setAbsPosition(0, 0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
-
-
- Retourne la position de la zone de dessin effective du composant.
- Les coordonnées doivent être retournées sous la forme d'un tableau de quatre valeurs.
- Les première et deuxième valeurs sont les positions en abscisse et en ordonnée du coin haut-gauche de la zone de dessin.
- Les troisième et quatrième valeurs sont les positions en abscisse et en ordonnée du coin bas-droit de la zone de dessin.
-
- Dessine l'enveloppe autour de la zone de dessin effective du composant.
- Cette enveloppe comprend généralement les axes et la grille du composant.
-
- Un groupe de composant permet de gérer plusieurs composants.
- Cette classe est abstraite et doit être redéfinit pour être utilisée avec les composants que vous aurez choisis.
-
-
- Les classes suivantes dérivent de ComponentGroup :
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Drawer.html b/artichow/doc/Drawer.html
deleted file mode 100644
index b050cf5..0000000
--- a/artichow/doc/Drawer.html
+++ /dev/null
@@ -1,425 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Driver
-
- La classe Driver est une couche d'abstraction à GD et permet de dessiner toutes sortes de formes géométriques sur une Image.
-
-
- Sur une image, l'axe des abscisses rejoint l'axe des ordonnées sur le coin haut-gauche. Le coin haut-gauche de l'image a donc pour coordonnées (0, 0) et le coin bas-droite (largeur, hauteur). Par exemple, sur une image de largeur 100 et de hauteur 50, un point à 50 sur l'axe des abscisses et 25 sur l'axe des ordonnées sera au centre de l'image.
-
- Informe le pilote de la position de la sous-image sur l'image.
- Les positions X et Y sont données via les paramètres $x et $y, qui représentent une fraction de la taille de l'image.
-
- Demande au pilote de déplacer la position de la sous-image sur l'image.
- $x et $y représentent respectivement les déplacements latéral et vertical de la position en pixels.
-
- Informe le pilote de la position de la sous-image sur l'image.
- Les positions X et Y sont données via les paramètres $x et $y, dont l'unité est le pixel.
-
- Informe le pilote de la taille de la sous-image sur l'image.
- Les largeur et hauteur de la sous-image sont données via les paramètres $w et $h, qui représentent une fraction de la taille de l'image.
-
- Informe le pilote de la taille de la sous-image sur l'image.
- Les largeur et hauteur de la sous-image sont données via les paramètres $w et $h, dont l'unité est le pixel.
-
- Construit l'image passée en paramètre et l'envoie sur la sortie standard accompagnée des en-têtes HTTP correspondants.
- A aucun moment vous ne devriez avoir besoin d'appeler vous-même cette méthode. Pour générez les images, utilisez Graph::draw().
-
- Construit l'image passée en paramètre et la renvoie sous forme de données binaires. Vous pouvez donc la stocker dans une variable si vous voulez faire des manipulations spécifiques.
- A aucun moment vous ne devriez avoir besoin d'appeler vous-même cette méthode. Pour générez les images, utilisez Graph::draw().
-
- Active ou désactive l'anti-aliasing lors du dessin.
- L'anti-aliasing permet d'avoir des graphiques plus propres mais demande plus de ressources.
- L'anti-aliasing n'est pas activé par défaut.
-
- Copie l'image $image vers la sous-image courante.
- L'image sera copiée sur la sous-image du point $p1 (coin haut-gauche) ou point $p2 (coin bas-droit).
- Les coordonnées de $p1 et $p2 doivent être relatives à celles de la sous-image.
-
- Copie l'image $image vers l'image courante.
- L'image $image sera copiée des points $s1 (coin haut-gauche) et $s2 (coin bas-droit) vers les points $d1 (coin haut-gauche) et $d2 (coin bas-droit) de l'image courante.
- Si $resampled est placé à TRUE, l'image sera rééchantillonée.
-
- Dessine la chaîne de caractères $text à partir du point $point.
- Les coordonnées de $point doivent être relatives à celles de la sous-image.
- Le paramètre $width permet de spécifier la largeur maximale en pixels de la boîte de texte.
-
- Dessine un arc d'ellipse de couleur $color dont les deux extrémités sont reliées au centre de l'ellipse.
- L'ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- L'angle de départ pour l'arc est $from et l'angle d'arrivée $to.
-
- Dessine un arc d'ellipse dont les deux extrémités sont reliées au centre de l'ellipse et le remplit avec la couleur ou le dégradé $background.
- L'ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- L'angle de départ pour l'arc est $from et l'angle d'arrivée $to.
-
- Dessine une ellipse de couleur $color, ayant pour centre $center et de largeur et hauteur respectives $width et $height.
- Les coordonnées de l'ellipse doivent être relatives à celles de la sous-image.
-
- Dessine et remplit une ellipse avec la couleur ou le dégradé $background. Cette ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- Les coordonnées de l'ellipse doivent être relatives à celles de la sous-image.
-
- Dessine un rectangle de couleur $color des points $p1 à $p2 (le segment qui relie ces points représente la diagonale du rectangle).
- Les coordonnées du rectangle doivent être relatives à celles de la sous-image.
-
- Dessine et remplit un rectangle avec la couleur ou le dégradé $background des points $p1 à $p2 (le segment qui relie ces points représente la diagonale du rectangle).
- Les coordonnées du rectangle doivent être relatives à celles de la sous-image.
-
- Dessine et remplit le polygone $polygon avec la couleur ou le dégradé $background.
- Les coordonnées de chaque point du polygone doivent être relatives à celles de la sous-image.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Driver.html b/artichow/doc/Driver.html
deleted file mode 100644
index 34f7923..0000000
--- a/artichow/doc/Driver.html
+++ /dev/null
@@ -1,494 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Driver
-
- La classe abstraite Driver rassemble toutes les méthodes permettant de dessiner sur une Image. Cette classe ne contient aucune implémentation. Celle-ci doit être effectué à l'intérieur de chaque pilote dérivant de Driver.
-
-
- Sur une image, l'axe des abscisses rejoint l'axe des ordonnées sur le coin haut-gauche. Le coin haut-gauche de l'image a donc pour coordonnées (0, 0) et le coin bas-droite (largeur, hauteur). Par exemple, sur une image de largeur 100 et de hauteur 50, un point à 50 sur l'axe des abscisses et 25 sur l'axe des ordonnées sera au centre de l'image.
-
- Informe le pilote de la position de la sous-image sur l'image.
- Les positions X et Y sont données via les paramètres $x et $y, qui représentent une fraction de la taille de l'image.
-
- Demande au pilote de déplacer la position de la sous-image sur l'image.
- $x et $y représentent respectivement les déplacements latéral et vertical de la position en pixels.
-
- Informe le pilote de la position de la sous-image sur l'image.
- Les positions X et Y sont données via les paramètres $x et $y, dont l'unité est le pixel.
-
- Informe le pilote de la taille de la sous-image sur l'image.
- Les largeur et hauteur de la sous-image sont données via les paramètres $w et $h, qui représentent une fraction de la taille de l'image.
-
- Informe le pilote de la taille de la sous-image sur l'image.
- Les largeur et hauteur de la sous-image sont données via les paramètres $w et $h, dont l'unité est le pixel.
-
- Convertit un objet Color pour qu'il soit exploitable directement par les fonctions de dessins employées par le pilote.
- Le type de donnée renvoyée dépend du pilote.
-
- Construit l'image passée en paramètre et l'envoie sur la sortie standard accompagnée des en-têtes HTTP correspondants.
- A aucun moment vous ne devriez avoir besoin d'appeler vous-même cette méthode. Pour générez les images, utilisez Graph::draw().
-
- Construit l'image passée en paramètre et la renvoie sous forme de données binaires. Vous pouvez donc la stocker dans une variable si vous voulez faire des manipulations spécifiques.
- A aucun moment vous ne devriez avoir besoin d'appeler vous-même cette méthode. Pour générez les images, utilisez Graph::draw().
-
- Active ou désactive l'anti-aliasing lors du dessin.
- L'anti-aliasing permet d'avoir des graphiques plus propres mais demande plus de ressources.
- L'anti-aliasing n'est pas activé par défaut.
-
- Copie l'image $image vers la sous-image courante.
- L'image sera copiée sur la sous-image du point $p1 (coin haut-gauche) ou point $p2 (coin bas-droit).
- Les coordonnées de $p1 et $p2 doivent être relatives à celles de la sous-image.
-
- Copie l'image $image vers l'image courante.
- L'image $image sera copiée des points $s1 (coin haut-gauche) et $s2 (coin bas-droit) vers les points $d1 (coin haut-gauche) et $d2 (coin bas-droit) de l'image courante.
- Si $resampled est placé à TRUE, l'image sera rééchantillonée.
-
- Dessine la chaîne de caractères $text à partir du point $point.
- Les coordonnées de $point doivent être relatives à celles de la sous-image.
- Le paramètre $width permet de spécifier la largeur maximale en pixels de la boîte de texte.
-
- Dessine un arc d'ellipse de couleur $color dont les deux extrémités sont reliées au centre de l'ellipse.
- L'ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- L'angle de départ pour l'arc est $from et l'angle d'arrivée $to.
-
- Dessine un arc d'ellipse dont les deux extrémités sont reliées au centre de l'ellipse et le remplit avec la couleur ou le dégradé $background.
- L'ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- L'angle de départ pour l'arc est $from et l'angle d'arrivée $to.
-
- Dessine une ellipse de couleur $color, ayant pour centre $center et de largeur et hauteur respectives $width et $height.
- Les coordonnées de l'ellipse doivent être relatives à celles de la sous-image.
-
- Dessine et remplit une ellipse avec la couleur ou le dégradé $background. Cette ellipse a pour centre $center et est de largeur et hauteur respectives $width et $height.
- Les coordonnées de l'ellipse doivent être relatives à celles de la sous-image.
-
- Dessine un rectangle de couleur $color dont la ligne $line représente la diagonale.
- Les coordonnées du rectangle doivent être relatives à celles de la sous-image.
-
- Dessine et remplit un rectangle avec la couleur ou le dégradé $background dont la ligne $line représente la diagonale.
- Les coordonnées du rectangle doivent être relatives à celles de la sous-image.
-
- Dessine et remplit le polygone $polygon avec la couleur ou le dégradé $background.
- Les coordonnées de chaque point du polygone doivent être relatives à celles de la sous-image.
-
- Renvoie TRUE si le pilote actuel est compatible avec la police $font, FALSE sinon.
- Chaque pilote doit définir les polices avec lesquelles il est compatible.
-
- La classe FileFont permet de gérer les polices représentée par un fichier, donc externe à PHP.
- Quelques polices sont disponibles dans le répertoire font/ de Artichow.
- Si vous connaissez d'autres polices intéressantes et dans le domaine public, n'hésitez pas à le signaler à vincent sur artichow point org.
-
-
- Afin de simplifier l'utilisation de cette classe, plusieurs polices sont déjà prédéfinies sur Artichow.
- Chacune de ces polices est une classe qui dérive de FileFont et dont le constructeur ne prend qu'un paramètre, la taille de la police. Voici les polices prédéfinies :
-
- Voici un exemple d'utilisation pour les polices prédéfinies :
-
-
-<?php
-
-// On utilise Tuffy de taille 12
-// Equivalent à new FileFont(ARTICHOW_FONT.'/Tuffy.ttf', 12);
-$blue = new Tuffy(12);
-
-// On utilise Tuffy en italique taille 42
-// Equivalent à new FileFont(ARTICHOW_FONT.'/TuffyItalic.ttf', 42);
-$orange = new TuffyItalic(42);
-
-?>
-
-
- L'extension du fichier. Cette propriété est utile si deux polices pouvant être utilisé par plusieurs pilotes doivent avoir une extension différente selon le cas. Voir à ce sujet le classe TTFFont.
-
- Construit la police de nom $name et de taille $size.
- Le nom doit être soit un chemin d'accès absolu, soit un simple nom de fichier. Dans ce dernier cas, la police correspondante sera recherchée dans le dossier font/ d'Artichow.
-
- Définit le nom du fichier contenant les informations de la police.
- Ce nom doit être soit un chemin d'accès absolu, soit un simple nom de fichier. Dans ce dernier cas, la police correspondante sera recherchée dans le dossier font/ d'Artichow.
-
- La classe FileImage permet de charger une image existante à partir d'un fichier. L'image ainsi créée peut être utilisée avec un Driver pour être copiée sur une autre image par exemple.
-
- Dessine avec la police courante le texte $text.
- Le pilote $driver sera utilisé pour le dessin tandis que le texte sera positionné au point $point.
- Le paramètre $width permet de spécifier la largeur maximale en pixels de la boîte de texte.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/FontDriver.html b/artichow/doc/FontDriver.html
deleted file mode 100644
index db3e639..0000000
--- a/artichow/doc/FontDriver.html
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class FontDriver
-
- La classe abstraite FontDriver définit toutes les méthodes devant être implémentées pour gérer l'affichage et les calculs à effectuer sur les polices. On dérivera cette classe une fois pour chaque classe enfant de Font, en l'occurence PHPFontDriver pour PHPFont et FileFontDriver pour FileFont.
-
-
- A aucun moment vous ne devriez avoir à instancier un objet de ce type. La documentation est là à titre informatif pour les développeurs en herbe.
-
-
- Les classes suivantes dérivent de FontDriver :
-
- Dessine le texte $text.
- Le pilote $driver sera utilisé pour le dessin tandis que le texte sera positionné au point $point.
- Le paramètre $width permet de spécifier la largeur maximale en pixels de la boîte de texte.
-
- La classe GDDriver est une implémentation de Driver qui repose sur la bibliothèque GD. C'est le pilote par défaut utilisé par Artichow, PHP doit donc être compilé avec le support de GD pour que tout fonctionne.
-
-
- Seules seront mentionnées ici les méthodes dont l'implémentation pourrait avoir un comportement spécifique. Pour le reste, veuillez vous référer à la doc de la classe parente Driver.
-
- Convertit un objet Color pour qu'il soit exploitable directement par les fonctions de dessins de GD.
- Renvoie un entier identifiant la couleur aux yeux de GD.
-
- Construit une nouveu dégradé. Cette méthode doit être appelée par toutes les classes qui dérivent de celle-ci. Le paramètre $from décrit la couleur de départ du dégradé et le paramètre $to celle de fin.
-
- La classe Graph permet de générer des graphiques, de les mettre éventuellement en cache et d'afficher le temps de génération de l'image. Il est possible de dessiner plusieurs composants sur une image de type Graph.
-
- Construit une image de largeur $width et de hauteur $height au nom $name (ce nom peut être laissé à NULL) et qui expirera dans le cache au timestamp $timeout. Si vous ne souhaitez pas utiliser le cache, vous pouvez laisser ce timestamp à 0.
- $name ne représente pas le titre du graphique, c'est uniquement un moyen d'identification pour le cache.
-
- Ajoute une étiquette $label aux positions $x et $y.
- Les nouvelles positions $x et $y représentent une fraction des largeur et hauteur du graphique.
-
- Ajoute une étiquette $label en position absolue sur le graphique aux coordonnées X et Y spécifiées par le point $point.
- Le point (0, 0) se situe sur le coin haut-gauche du graphique.
-
- Créé et affiche l'image à l'utilisateur. Tous les composants précédemment ajoutés avec add() sont dessinés sur l'image.
- Cette méthode appelle successivement create(), drawComponent() autant de fois que de composants ont été ajoutés et send().
-
- Si vous souhaitez enregistrer l'image dans un fichier plutôt qu'à l'écran, indiquez un nom de fichier destination pour le paramètre $file.
- Ce paramètre est optionnel, et si il n'est pas rempli, alors l'image sera affichée à l'écran.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Grid.html b/artichow/doc/Grid.html
deleted file mode 100644
index fa9e83e..0000000
--- a/artichow/doc/Grid.html
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Grid
-
- La classe Grid permet de manipuler des grilles de fond sur les Plot ou groupes de Plot.
- Une grille facilite la lecture des données pour l'utilisateur.
- Un exemple de grille est montré ci-dessous.
-
- Change le type de ligne à utiliser sur la grille. $type peut être Line::SOLID pour une ligne continue, Line::DOTTED pour une ligne pointillée ou encore Line::DASHED.
-
- Change l'interval d'affichage des lignes horizontales de la grille avec $hInterval et verticales avec $vInterval.
- Par défaut, cet interval est à 1 et toutes les lignes sont affichées.
- Si vous choisissez un interval de 2 par exemple, une ligne sur deux sera affichée sur la grille.
-
- Change l'espace interne de la grille.
- Les valeurs $left, $right, $top et $bottom représentent respectivement les nouvelles valeurs pour l'espace gauche, droit, haut et bas de la grille.
-
- Précise la position sur la grille des lignes horizontales avec $ygrid et verticales avec $xgrid.
- Ces deux paramètres sont des tableaux qui contiennent des entiers entre 0 et 1. Chaque valeur représente la position d'une ligne comme une fraction de la taille de la grille.
-
- Dessine la grille avec le pilote $driver.
- La grille sera dessinée dans un rectangle dont la diagonale est le segment qui relie les points ($x1, $y1) et ($x2, $y2).
- Les lignes dessinées auront été préalablement précisées avec setGrid().
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Image.html b/artichow/doc/Image.html
deleted file mode 100644
index 1d2cce8..0000000
--- a/artichow/doc/Image.html
+++ /dev/null
@@ -1,354 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-abstract Class Image
-
- La classe Image est une classe abstraite à la base de toutes les images sur Artichow. Une image peut être copiée sur d'autres images et chaque image peut être générée soit au format PNG, soit au format JPEG.
-
- Retourne un objet de type Driver qui permet de dessiner sur l'image.
- Le Driver aura une largeur $w et une hauteur $h, et son centre sera positionné au point ($x, $y).
- La largeur doit être comprise entre 0 et 1 et représente une fraction de la taille réelle de l'image.
- La position doit être elle aussi comprise entre 0 et 1.
- Les paramètres par défaut centrent le pilote au milieu de l'image et lui donnent la taille de l'image.
-
- Active ou désactive l'anti-aliasing sur l'image.
- L'anti-aliasing permet d'avoir des graphiques plus propres mais demande plus de ressources.
- L'anti-aliasing n'est pas activé par défaut.
-
- Construit l'image et l'envoie sur la sortie standard accompagnée des en-têtes HTTP correspondants.
- Cette fonction ne prend plus d'arguments depuis Artichow 1.1.0. Pour récupérer les données brutes de l'image, utilisez la méthode get(). Pour sauvegarder l'image dans un fichier sur le disque, voyez la méthode Graph::draw().
-
- Construit l'image et la renvoie sous forme de données binaires. Vous pouvez donc la stocker dans une variable si vous voulez faire des manipulations spécifiques.
-
-public__construct(string$label := NULL, Font$font := new Font(Text::FONT_2), color$color := new Color(0, 0, 0), int$angle := 0)
-
- Construit un nouvel objet qui permettra l'affichage d'étiquettes sur une image.
- $label est un chaîne de caractères qui représente la première étiquette (peut être laissée à NULL).
- $font est la police à utiliser pour l'étiquette tandis que $color sera utilisé pour la couleur du texte.
- Enfin, l'angle du texte prendra la valeur de $angle.
-
- Retourne la valeur de l'élément de l'étiquette dont la clé vaut $key.
- Si la clé n'est associée à aucune valeur, alors cette méthode retourne NULL.
-
- Change le texte des étiquettes à afficher sur l'image.
- $labels peut être une chaîne de caractères si vous n'avez besoin que d'une étiquette, ou un tableau de chaînes de caractères si vous avez besoin de plusieurs étiquettes.
-
- Change le nom de la fonction de callback qui sera appelé lors du dessin des textes du paragraphe. $function peut être une simple chaîne de caractères, ou un tableau du type array($this, 'methodName') pour permettre d'appeler des méthodes statiques.
-
- Change l'interval d'affichage des étiquettes.
- L'interval est à 1 par défaut, ce qui signifie que toutes les étiquettes sont affichées.
- Si cet interval est placé à 2 par exemple, alors la méthode draw() n'affichera qu'une étiquette sur 2.
-
- Déplace l'affichage de l'étiquette de $x pixels sur l'axe des abscisses et de $y pixels sur l'axe des ordonnées.
- Les appels à move() sont cumulés, c'est-à-dire qu'un appel avec de nouvelles valeurs additionnera ces valeurs avec les anciennes.
- Par défaut, $x et $y sont à 0.
-
- Retourne un objet de type Text qui correspond à la valeur du tableau de textes passé au constructeur ou à Label::set() pour la clé $key.
- Cette object Text se verra attribué toutes les propriétés (couleur, police, angle, etc.) définies pour le paragraphe.
-
- Essaie de déterminer la longueur maximale des étiquettes. Cette méthode a besoin d'un Driver pour établir la taille de chaque texte.
- La longueur maximale trouvée est déterminée et rétournée en pixels.
-
- Essaie de déterminer la hauteur maximale des étiquettes. Cette méthode a besoin d'un Driver pour établir la taille de chaque texte.
- La hauteur maximale trouvée est déterminée et rétournée en pixels.
-
- Dessine l'étiquette identifiée par $key avec le pilote $driver. L'étiquette sera placée au point $point décalé des valeurs successivement passées à move(), et alignée par rapport à ce point selon les valeurs passées à setAlign().
- L'étiquette ne sera pas affichée si sa clé $key n'est pas dans l'interval d'affichage donné avec setInterval().
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Legend.html b/artichow/doc/Legend.html
deleted file mode 100644
index c41edcb..0000000
--- a/artichow/doc/Legend.html
+++ /dev/null
@@ -1,442 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Legend
-
- La classe Legend permet de manipuler des légendes.
- Un objet de la classe Legend est disponible sur tous les composants.
- N'importe quel objet peut être légendé à condition qu'il implémente l'interface Legendable.
-
- Cette propriété permet de manipuler l'ombre associée éventuellement avec la légende.
- Par défaut, aucune ombre n'est affichée. Si vous souhaitez afficher une ombre, il vous suffit de lui donner une taille :
-
-
-<?php
-
-require_once "Tools.class.php";
-
-$legend = new Legend();
-
-// On associe une ombre de 4 pixels à la légende
-$legend->shadow->setSize(4);
-
-?>
-
-
- Change le modèle de légende pour $model.
- L'appel à cette méthode peut écraser les valeurs passées à d'autres méthodes comme setPadding() ou setHorizontalAlign() par exemple (liste non exhaustive).
- Les valeurs possibles pour $model sont Legend::MODEL_BOTTOM et Legend::MODEL_RIGHT.
-
- Change l'espace interne de la légende.
- Les nouvelles valeurs doivent être données en pixels.
- Laissez les paramètres dont vous ne souhaitez pas modifier la valeur à NULL.
-
- Change l'alignement de la légende par rapport au point où elle sera affichée.
- $h correspond à l'alignement horizontal (Legend::LEFT, Legend::RIGHT ou Legend::CENTER) et $v à l'alignement vertical (Legend::TOP, Legend::BOTTOM ou Legend::MIDDLE).
- Si vous ne souhaitez pas modifier une des deux valeurs, vous pouvez passer NULL.
-
- Déclare une nouvelle ligne des points $p1 à $p2. La ligne est de style $style (Line::SOLID pour une ligne continue, Line::DOTTED pour une ligne pointillée ou encore Line::DASHED) et d'épaisseur $thickness.
-
- Renvoie la valeur de la pente de la ligne.
- Si celle-ci est verticale, la pente vaudra NULL; si elle est horizontale, la pente vaudra 0.
- La valeur est calculée uniquement lorsqu'elle est demandée.
-
- Renvoie la valeur de l'ordonnée à l'origine.
- Si la ligne est verticale, l'ordonnée à l'origine vaudra NULL.
- La valeur est calculée uniquement lorsqu'elle est demandée.
-
- Renvoie la valeur de l'abscisse du point d'ordonnée $y situé sur la droite portant la ligne.
- Si la ligne est horizontale et que $y est différent de l'ordonnée à l'origine, aucun point ne pourra être trouvé et la méthode renverra NULL.
-
- Renvoie la valeur de l'ordonnée du point d'abscisse $x situé sur la droite portant la ligne.
- Si la ligne est verticale et qu'aucun point correspondant à $x ne peut être trouvé, la méthode renverra NULL.
-
- Créé une nouvelle courbe de type $mode avec les valeurs présentes dans $values.
- Le tableau $values doit être une liste de valeurs dans un tableau incrémental, c'est-à-dire dont les clés valent de 0 à n - 1 (où n est la taille du tableau).
-
- Change la couleur de fond de la ligne qui relie les valeurs de la courbe.
- La couleur de fond remplit le polygone définit par tous les points de la ligne additionés des points extrêmes de l'axe des abscisses.
-
- Change le dégradé de fond de la ligne qui relie les valeurs de la courbe.
- Le dégradé de fond remplit le polygone définit par tous les points de la ligne additionés des points extrêmes de l'axe des abscisses.
-
- Construit une nouveu dégradé. Cette méthode doit être appelée par toutes les classes qui dérivent de celle-ci. Le paramètre $from décrit la couleur de départ du dégradé et le paramètre $to celle de fin. Le troisième paramètre $angle décrit l'angle du dégradé. Ce peut être un dégradé horizontal (angle de 0°) ou un dégradé vertical (angle de 90°).
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Mark.html b/artichow/doc/Mark.html
deleted file mode 100644
index 84be142..0000000
--- a/artichow/doc/Mark.html
+++ /dev/null
@@ -1,265 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Mark
-
- La classe Mark permet de créer des marques, qui peuvent être affichées n'importe où sur une image.
- Typiquement, les marques sont affichées sur les courbes pour mettre en valeur chaque point.
-
- Déplace l'affichage des marques de $x pixels sur l'axe des abscisses et de $y pixels sur l'axe des ordonnées.
- Les appels à move() sont cumulés, c'est-à-dire qu'un appel avec de nouvelles valeurs additionnera ces valeurs avec les anciennes.
- Par défaut, $x et $y sont à 0 pixel.
-
- Change le type de marque à utiliser.
- Les valeurs possibles sont , , , , , ou encore .
- L'argument optionnel $size permet de déterminer la taille de la marque et n'a aucun effet sur , et .
-
- Créé un objet MathFunction avec la fonction $f.
- $f est une fonction qui prend un paramètre $x en paramètre et qui doit retourner une valeur $y.
- Les valeurs $fromX et $toX représentent les valeurs de X à partir desquelles commencer et terminer le calcul de la courbe représentative de la fonction.
-
- Cette classe permet de représenter simplement des fonctions f(x) sur un graphique.
- L'archive de Artichow contient plusieurs exemples pour vous aider dans la conception de ces graphiques.
-
- Change l'interval sur lequel sont calculées les valeurs affichées sur le graphique.
- Par défaut, cet interval est de 1, c'est-à-dire que Artichow calcule f(x) pour toutes les valeurs entières de x.
-
- Ajoute une fonction mathématique au graphique.
- Sur la légende, la fonction aura pour nom $name et le type de légende utilisé sera $type (Legend::LINE, Legend::BACKGROUND ou encore Legend::MARK).
- Si vous ne souhaitez pas associer de légende à cette fonction, laissez l'argument $name à NULL.
-
- La classe PHPFont permet de gérer les polices fournie avec PHP. Ce sont des polices pouvant subir peu de transformation (rotation de 90° uniquement par exemple).
-
-
- Il existe 5 polices prédéfinies, ainsi que les 5 classes "raccourcies" correspondantes:
-
-
-<?php
-
-// Equivalent à new PHPFont(1);
-$font = new Font1;
-
-// Equivalent à new PHPFont(2);
-$font = new Font2;
-
-// etc.
-
-?>
-
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Pattern.html b/artichow/doc/Pattern.html
deleted file mode 100644
index 65c5d09..0000000
--- a/artichow/doc/Pattern.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Pattern
-
- La classe Pattern simplifie la création de graphiques avec Artichow.
-
-
- Cette partie de la documentation est encore en cours de réalisation.
- Pour obtenir la liste des méthodes de cette classe, voyez le fichier Pattern.class.php.
- Pour savoir comment utiliser cette classe, n'hésitez pas à aller jeter un coup d'oeil aux exemples (examples/pattern-*.php)
- fournis avec l'archive de Artichow.
-
- Construit un nouveau camembert avec comme valeurs $values.
- Le paramètre $colors peut soit être un tableau de couleurs, soit un thème prédéfini (Pie::DARK, Pie::COLORED, Pie::AQUA ou Pie::EARTH).
-
- Change les valeurs de la légende associée au camembert.
- $legend est un tableau qui contient autant d'entrées que de valeurs présentes sur le camembert.
-
- Change la couleur de la bordure entourant le camembert et séparant chaque part.
- Cette méthode a été remplacée par Pie::setBorderColor() depuis Artichow 1.0.9.
-
- Change la précision des étiquettes associées à chaque part du camembert.
- Par défaut à 0, cette précision donne le nombre de chiffres après la virgule à afficher.
-
- Change la distance des étiquettes par rapport au camembert.
- La valeur est à donner en pixels et vaut par défaut 15 pixels.
- Elle peut également être négative.
-
- Permet de choisir une valeur minimum pour l'affichage des étiquettes.
- Tout part dont le pourcentage sera inférieur à $minimum n'aura aucune étiquette associée.
- Par défaut, il n'y a aucun minimum.
-
- Cette méthode permet de séparer une ou plusieurs parts du camembert.
- Le paramètre $explode est un tableau dont les clés représente les numéros des parts à séparer et les valeurs la distance de séparation.
-
- Réduit le nombre de valeurs à afficher sur le composant à $number.
- Cette fonctionnalité est utile dans le cas où vous souhaitez afficher plus de 400 ou 500 valeurs sur un graphique.
- En effet, au delà d'un certain nombre de valeurs, toutes ne seront pas affichées et le temps de création du graphique sera très élevé.
- La solution est de réduire le nombre de valeurs sur votre graphique, ce que permet cette fonction.
- Le processus de réduction se fait à travers un système de moyennes, afin de garder une courbe identique à celle que vous auriez eu en affichant toutes les valeurs.
- Le nombre $number que vous spécifiez en paramètre est un nombre maximal. Pas plus de $number valeurs seront affichées sur le graphique. En revanche, dans certains cas, il est possible qu'un nombre inférieur de valeurs soient affichées.
- Voici un exemple d'utilisation de cette fonctionnalité :
-
-
-<?php
-
-require_once "LinePlot.class.php";
-
-$graph = new Graph(400, 400);
-
-$datay = array();
-$datax = array();
-
-// On créé un tableau avec 3000 valeurs
-for($i = 1; $i <= 3000; $i++) {
- $datay[] = log($i);
- $datax[] = $i;
-}
-
-$plot = new LinePlot($datay);
-$plot->xAxis->setLabelText($datax);
-$plot->xAxis->label->setAngle(90);
-
-// On réduit le nombre de valeurs à afficher sur le graphique à 30,
-// soit 100 fois moins
-$plot->reduce(30);
-
-// On affiche le graphique
-// Les valeurs de l'axe des X ont été automatiquement mises à jour
-$graph->add($plot);
-$graph->draw();
-
-// Finalement, la courbe représentative de log(x) apparaît très correctement
-
-?>
-
-
- Précise si le ou les axes des abscisses doivent être centrés sur le zéro de l'axe des ordonnées.
- Comme il peut y avoir plus axes des ordonnées, l'axe de gauche est choisi en premier pour sélectionner la valeur du zéro. S'il n'existe pas, alors on utilise l'axe de droite.
-
- Précise si le ou les axes des ordonnées doivent être centrés sur le zéro de l'axe des abscisses.
- Comme il peut y avoir plus axes des abscisses, l'axe du bas est choisi en premier pour sélectionner la valeur du zéro. S'il n'existe pas, alors on utilise l'axe du haut.
-
- Ajoute ou remplace un point $point dans le polygon à la position $pos.
- Cette méthode accepte la valeur NULL pour spécifier que ce point doit être ignoré.
-
- Renvoie un tableau contenant les ordonnées minimales et maximales de n'importe quel point appartenant au polygone (c'est à dire l'étendue du polygone le long de l'axe des ordonnées).
-
- Renvoie un tableau contenant les abscisses minimales et maximales de n'importe quel point appartenant au polygone (c'est à dire l'étendue du polygone le long de l'axe des abscisses).
-
- Les ScatterPlot (ou graphiques libres) permettent de dessiner des points aux coordonnées (x, y) sur une image.
- Ce type de graphique est plus pluissant que les LinePlot car plusieurs points de même abscisse peuvent être placés sur le même graphique.
-
- Créé un nouveau ScatterPlot avec des points d'abscisses $datax et d'ordonnées $datay.
- Si la valeur $datax est laissée à NULL, alors la librairie utilisera des valeurs incrémentales pour X, en commençant par zéro.
-
-
-<?php
-
-require_once "ScatterPlot.class.php";
-
-$graph = new Graph(400, 400);
-
-// Tableaux de valeurs
-$y = array(2, 4, 6);
-$x = array(1, 4, 3);
-
-// On dessine les points (1, 2), (4, 4) et (3, 6)
-$plot = new ScatterPlot($y, $x);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
-
-
- Si vous appelez cette méthode, les points de la courbe seront reliés à l'axe des abscisses par des segments de droite verticaux de couleur $color.
- Cette méthode permet notamment de représenter des graphiques à impulsions.
-
- Si $linkNull vaut TRUE, alors les valeurs en ordonnée égales à nulles n'interrompront pas le lien entre tous les points.
- A l'inverse, si $linkNull vaut FALSE, alors le lien sera rompu à chaque fois qu'une valeur égale à NULL sera trouvée.
- Cette méthode n'a de sens que lorsque vous avez choisi de relier les points entre eux.
-
- Dessine l'ombre avec le pilote $driver dans un rectangle dont la diagonale est le segment qui relie les points $p1 et $p2.
- Le paramètre $mode détermine le mode d'affichage de l'ombre. Si Shadow::OUT est spécifié, alors l'ombre sera dessinée en dehors du rectangle. Si Shadow::IN est spécifié, alors l'ombre sera dessinée à l'intérieur du rectangle.
-
- Change le style du pourtour de la forme. Peut être Shape::SOLID pour un pourtour continu, Shape::DOTTED pour un pourtour pointillé ou encore Shape::DASHED.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Side.html b/artichow/doc/Side.html
deleted file mode 100644
index ed74977..0000000
--- a/artichow/doc/Side.html
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Side
-
- La classe Side est un objet qui fournit des méthodes pour gérer des situations où il est besoin de valoriser les côtés gauche, droit, haut et bas avec des entiers.
-
- Change les valeurs associées aux côtés gauche, droit, haut et bas.
- Laisser un paramètre à NULL permet d'éviter que la valeur du côté soit modifiée.
-
- La classe TTFFont permet de manipuler des polices TrueType.
- Quelques polices sont disponibles dans le répertoire font/ de Artichow.
- Si vous connaissez d'autres polices intéressantes et dans le domaine public, n'hésitez pas à le signaler à vincent sur artichow point org.
-
- Construit la police $font de taille $size pixels.
- La chaîne $font peut être soit le chemin vers un fichier de police TrueType, soit juste le nom de ce fichier. Dans ce dernier cas, le fichier de police sera recherché dans le dossier font/ du répertoire d'Artichow qui contient les quelques polices disponible de base.
-
- Créé un nouveau pavé de texte avec pour texte $text. $font représente la police utilisée pour le texte tandis que $color représente sa couleur.
- L'angle est définit par le paramètre $angle, qui peut prendre les valeurs de 0 et 90°.
-
- Retourne le fond du texte. Si aucun fond n'a été spécifié, cette méthode retourne NULL.
- Dans le cas contraire, elle retourne un objet de la classe Color pour les couleurs, soit une instance de Gradient pour les dégradés.
-
- Retourne la valeur de l'espace qui entoure le texte par rapport à sa bordure. Cette méthode retourne un tableau de quatre valeurs, qui correspondent à l'espace de gauche, droite, haut et bas.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/Tick.html b/artichow/doc/Tick.html
deleted file mode 100644
index 9302862..0000000
--- a/artichow/doc/Tick.html
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Class Tick
-
- La classe Tick permet de représenter des ticks, petits traits réguliers associés à un axe.
-
-
-
-
-
-
- De nombreuses méthodes de la classe Tick ne sont pas documentées,
- car elles ne sont utilisées qu'en interne par Artichow.
- Néanmoins, si vous développez Artichow, vous aurez besoin de ces méthodes.
- N'hésitez donc pas à parcourir le code source de cette classe.
-
- Change le style des ticks. Peut être Tick::IN, Tick::OUT ou Tick::IN_OUT.
- Dans le premier cas, les ticks seront tournés vers l'intérieur. Dans le second vers l'extérieur et dans le troisième et vers l'extérieur et vers l'intérieur.
-
- Change l'intervalle d'affichage des ticks par rapport à leur nombre.
- Si $interval vaut 1, alors tous les ticks seront affichés.
- Si $interval vaut 0.5, alors un tick sur deux sera affiché.
-
-
-
\ No newline at end of file
diff --git a/artichow/doc/image/back-rayures.png b/artichow/doc/image/back-rayures.png
deleted file mode 100644
index 127b1c3..0000000
Binary files a/artichow/doc/image/back-rayures.png and /dev/null differ
diff --git a/artichow/doc/image/coin-bd.gif b/artichow/doc/image/coin-bd.gif
deleted file mode 100644
index 7eac688..0000000
Binary files a/artichow/doc/image/coin-bd.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-bd.png b/artichow/doc/image/coin-bd.png
deleted file mode 100644
index 3a74021..0000000
Binary files a/artichow/doc/image/coin-bd.png and /dev/null differ
diff --git a/artichow/doc/image/coin-bg-long.gif b/artichow/doc/image/coin-bg-long.gif
deleted file mode 100644
index a029ea1..0000000
Binary files a/artichow/doc/image/coin-bg-long.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-bg.gif b/artichow/doc/image/coin-bg.gif
deleted file mode 100644
index 53de14d..0000000
Binary files a/artichow/doc/image/coin-bg.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-hd-transparent.gif b/artichow/doc/image/coin-hd-transparent.gif
deleted file mode 100644
index fd32211..0000000
Binary files a/artichow/doc/image/coin-hd-transparent.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-hd.gif b/artichow/doc/image/coin-hd.gif
deleted file mode 100644
index 14b0c9a..0000000
Binary files a/artichow/doc/image/coin-hd.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-hg-transparent.gif b/artichow/doc/image/coin-hg-transparent.gif
deleted file mode 100644
index bb7dac6..0000000
Binary files a/artichow/doc/image/coin-hg-transparent.gif and /dev/null differ
diff --git a/artichow/doc/image/coin-hg.gif b/artichow/doc/image/coin-hg.gif
deleted file mode 100644
index 1da6df7..0000000
Binary files a/artichow/doc/image/coin-hg.gif and /dev/null differ
diff --git a/artichow/doc/image/fond-flou.gif b/artichow/doc/image/fond-flou.gif
deleted file mode 100644
index 4299f56..0000000
Binary files a/artichow/doc/image/fond-flou.gif and /dev/null differ
diff --git a/artichow/doc/image/fond.png b/artichow/doc/image/fond.png
deleted file mode 100644
index f616c01..0000000
Binary files a/artichow/doc/image/fond.png and /dev/null differ
diff --git a/artichow/doc/index.html b/artichow/doc/index.html
deleted file mode 100644
index 8df2010..0000000
--- a/artichow/doc/index.html
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
- Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
La documentation de Artichow
-
- Cette documentation vous explique comment utiliser les classes de Artichow.
- Vous retrouverez sur le site de Artichow une documentation plus complète, ainsi que des tutoriels.
- Attention, cette documentation est conçue pour la version PHP 5 de Artichow, qui est incompatible avec la version PHP 4 & 5.
- Vous pouvez retrouver sur le site une liste de ces incompatibilités afin de pouvoir utiliser tout de même cette documentation.
-
-
\ No newline at end of file
diff --git a/artichow/examples/bar-001.php b/artichow/examples/bar-001.php
deleted file mode 100644
index aef1410..0000000
--- a/artichow/examples/bar-001.php
+++ /dev/null
@@ -1,30 +0,0 @@
-title->set('The title');
-$graph->border->setStyle(Line::DASHED);
-$graph->border->setColor(new DarkGray);
-
-$values = array(19, 42, 15, -25, 3);
-
-$plot = new BarPlot($values);
-$plot->setSize(1, 0.96);
-$plot->setCenter(0.5, 0.52);
-
-$plot->setBarColor(
- new VeryLightPurple(25)
-);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/bar-002.php b/artichow/examples/bar-002.php
deleted file mode 100644
index 822812c..0000000
--- a/artichow/examples/bar-002.php
+++ /dev/null
@@ -1,37 +0,0 @@
-setBarGradient(
- new LinearGradient(
- new LightBlue(25),
- new VeryLightOrange(25),
- 90
- )
-);
-
-$plot->setSpace(5, 5, NULL, NULL);
-
-$plot->barShadow->setSize(4);
-$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
-$plot->barShadow->setColor(new Color(180, 180, 180, 10));
-$plot->barShadow->smooth(TRUE);
-
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/bar-003.php b/artichow/examples/bar-003.php
deleted file mode 100644
index 39ab795..0000000
--- a/artichow/examples/bar-003.php
+++ /dev/null
@@ -1,37 +0,0 @@
-title->set('Two bars');
-
-$values = array(12, 8, 13, 2, 4);
-
-$group = new PlotGroup;
-$group->setPadding(NULL, NULL, 35, NULL);
-
-$plot = new BarPlot($values, 1, 2);
-$plot->setBarColor(new LightBlue(25));
-$plot->setBarSpace(5);
-
-$group->add($plot);
-
-$values = array(1, 7, 2, 10, 6);
-
-$plot = new BarPlot($values, 2, 2);
-$plot->setBarColor(new LightOrange(25));
-$plot->setBarSpace(5);
-
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/bar-004.php b/artichow/examples/bar-004.php
deleted file mode 100644
index 8b76239..0000000
--- a/artichow/examples/bar-004.php
+++ /dev/null
@@ -1,36 +0,0 @@
-title->set('Two bars with depth');
-
-$group = new PlotGroup;
-$group->setPadding(NULL, NULL, 35, NULL);
-$group->setSpace(5, 5, NULL, NULL);
-
-$group->grid->hide(TRUE);
-
-$values = array(1, 7, 2, 10, 6, 3, 4, 7);
-
-$plot = new BarPlot($values, 1, 1, 5);
-$plot->setBarColor(new LightBlue(25));
-$group->add($plot);
-
-$values = array(12, 8, 13, 2, 4, 8, 4, 3);
-
-$plot = new BarPlot($values, 1, 1, 0);
-$plot->setBarColor(new LightRed(25));
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/bar-005.php b/artichow/examples/bar-005.php
deleted file mode 100644
index e0e3f57..0000000
--- a/artichow/examples/bar-005.php
+++ /dev/null
@@ -1,59 +0,0 @@
-title->set('The title');
-
-// Change graph background color
-$graph->setBackgroundColor(new Color(230, 230, 230));
-
-$values = array(8, 2, 6, 1, 3, 5);
-
-// Declare a new BarPlot
-$plot = new BarPlot($values);
-
-// Reduce padding around the plot
-$plot->setPadding(NULL, NULL, NULL, 20);
-
-// Reduce plot size and move it to the bottom of the graph
-$plot->setSize(1, 0.96);
-$plot->setCenter(0.5, 0.52);
-
-// Set a background color to the plot
-$plot->grid->setBackgroundColor(new White);
-// Set a dashed grid
-$plot->grid->setType(Line::DASHED);
-
-
-$plot->label->set($values);
-$plot->label->move(0, -10);
-$plot->label->setColor(new DarkBlue);
-
-// Set a shadow to the bars
-$plot->barShadow->setSize(2);
-
-// Bar size is at 60%
-$plot->setBarSize(0.6);
-
-// Change the color of the bars
-$plot->setBarColor(
- new Orange(15)
-);
-
-// Add the plot to the graph
-$graph->add($plot);
-
-// Draw the graph
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/champignon.png b/artichow/examples/champignon.png
deleted file mode 100644
index 1ab0caf..0000000
Binary files a/artichow/examples/champignon.png and /dev/null differ
diff --git a/artichow/examples/line-001.php b/artichow/examples/line-001.php
deleted file mode 100644
index efc1870..0000000
--- a/artichow/examples/line-001.php
+++ /dev/null
@@ -1,29 +0,0 @@
-setSpace(6, 6, 10, 10);
-
-$plot->hideLine(TRUE);
-$plot->setFillColor(new Color(180, 180, 180, 75));
-
-$plot->mark->setType(Mark::IMAGE);
-$plot->mark->setImage(new FileImage("champignon.png"));
-
-$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
-
-$plot->label->set($x);
-$plot->label->move(0, -23);
-$plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0));
-$plot->label->border->setColor(new Color(20, 20, 20, 20));
-$plot->label->setPadding(3, 1, 1, 0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-002.php b/artichow/examples/line-002.php
deleted file mode 100644
index 2227869..0000000
--- a/artichow/examples/line-002.php
+++ /dev/null
@@ -1,52 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 0.5, 3, 8
-);
-
-$plot = new LinePlot($x);
-
-$plot->setSpace(6, 6, 10, 10);
-$plot->setXAxisZero(FALSE);
-
-// Set a background gradient
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(255, 255, 255),
- 0
- )
-);
-
-// Change line color
-$plot->setColor(new Color(0, 0, 150, 20));
-
-// Set line background gradient
-$plot->setFillGradient(
- new LinearGradient(
- new Color(150, 150, 210),
- new Color(230, 230, 255),
- 90
- )
-);
-
-// Change mark type
-$plot->mark->setType(Mark::CIRCLE);
-$plot->mark->border->show();
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-003.php b/artichow/examples/line-003.php
deleted file mode 100644
index 8f3461d..0000000
--- a/artichow/examples/line-003.php
+++ /dev/null
@@ -1,44 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
-);
-
-$plot = new LinePlot($x);
-
-// Set a background gradient
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(255, 255, 255),
- 0
- )
-);
-
-// Set semi-transparent background gradient
-$plot->setFillGradient(
- new LinearGradient(
- new Color(230, 150, 150, 20),
- new Color(230, 230, 180, 50),
- 90
- )
-);
-
-$plot->yAxis->setLabelPrecision(1);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-004.php b/artichow/examples/line-004.php
deleted file mode 100644
index 9cb3d3e..0000000
--- a/artichow/examples/line-004.php
+++ /dev/null
@@ -1,59 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
-);
-
-$plot = new LinePlot($x);
-
-// Change component padding
-$plot->setPadding(10, NULL, NULL, NULL);
-
-// Change component space
-$plot->setSpace(5, 5, 5, 5);
-
-// Set a background color
-$plot->setBackgroundColor(
- new Color(230, 230, 230)
-);
-
-// Change grid background color
-$plot->grid->setBackgroundColor(
- new Color(235, 235, 180, 60)
-);
-
-// Hide grid
-$plot->grid->hide(TRUE);
-
-// Hide labels on Y axis
-$plot->yAxis->label->hide(TRUE);
-
-$plot->xAxis->label->setInterval(2);
-
-$plot->label->set($x);
-$plot->label->setFormat('%.1f');
-$plot->label->setBackgroundColor(new Color(240, 240, 240, 15));
-$plot->label->border->setColor(new Color(255, 0, 0, 15));
-$plot->label->setPadding(5, 3, 1, 1);
-
-$plot->xAxis->label->move(0, 5);
-$plot->xAxis->label->setBackgroundColor(new Color(240, 240, 240, 15));
-$plot->xAxis->label->border->setColor(new Color(0, 150, 0, 15));
-$plot->xAxis->label->setPadding(5, 3, 1, 1);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-005.php b/artichow/examples/line-005.php
deleted file mode 100644
index c03240e..0000000
--- a/artichow/examples/line-005.php
+++ /dev/null
@@ -1,36 +0,0 @@
-setFilledArea(7, 9, new DarkGreen(25));
-
-// Filled the area with a gradient
-$gradient = new LinearGradient(
- new Yellow(25),
- new Orange(25),
- 90
-);
-$plot->setFilledArea(1, 4, $gradient);
-
-// Hide first label
-$plot->xAxis->label->hideFirst(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-006.php b/artichow/examples/line-006.php
deleted file mode 100644
index 709b08e..0000000
--- a/artichow/examples/line-006.php
+++ /dev/null
@@ -1,49 +0,0 @@
-setTiming(TRUE);
-$graph->setAntiAliasing(TRUE);
-
-
-$x = array();
-for($i = 0; $i < 10; $i++) {
- $x[] = mt_rand(0, 100);
-}
-
-$plot = new LinePlot($x);
-$plot->setColor(
- new Color(60, 60, 150)
-);
-$plot->setFillGradient(
- new LinearGradient(
- new Color(120, 175, 80, 47),
- new Color(231, 172, 113, 30),
- 0
- )
-);
-
-$plot->grid->setType(Line::DASHED);
-
-$plot->setYMin(-5);
-
-$plot->yAxis->setLabelNumber(8);
-$plot->yAxis->setLabelPrecision(1);
-
-$plot->xAxis->setNumberByTick('minor', 'major', 3);
-
-$plot->setXAxisZero(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-007.php b/artichow/examples/line-007.php
deleted file mode 100644
index bdc6894..0000000
--- a/artichow/examples/line-007.php
+++ /dev/null
@@ -1,67 +0,0 @@
-setAntiAliasing(TRUE);
-$graph->title->set("Some lines");
-
-$group = new PlotGroup;
-$group->setXAxisZero(FALSE);
-$group->setBackgroundColor(new Color(197, 180, 210, 80));
-
-$group->setPadding(40, NULL, 50, NULL);
-
-$group->axis->left->setLabelNumber(8);
-$group->axis->left->setLabelPrecision(1);
-$group->axis->left->setTickStyle(Tick::OUT);
-
-$group->axis->bottom->setTickStyle(Tick::OUT);
-
-// Display two lines
-for($n = 0; $n < 2; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 10; $i++) {
- $x[] = (cos($i * M_PI / 5)) / ($n + 1);
- }
-
- $plot = new LinePlot($x);
- $plot->setColor(color(10)); // Random line color
- $plot->setFillColor(color(90)); // Random background color
-
- $plot->label->set($x);
- $plot->label->setBackgroundColor(new Color(220, 234, 230, 25));
- $plot->label->setPadding(1, 0, 0, 0);
- $plot->label->setCallbackFunction("formatLabel");
- $plot->label->setInterval(2);
-
- $group->add($plot);
- $group->legend->add($plot, "Line #".($n + 1), Legend::LINE);
-
-}
-
-$group->legend->setSpace(12);
-$group->legend->setBackgroundColor(new Color(255, 255, 255));
-$group->setPadding(NULL, 100, NULL, NULL);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-008.php b/artichow/examples/line-008.php
deleted file mode 100644
index bffea9d..0000000
--- a/artichow/examples/line-008.php
+++ /dev/null
@@ -1,34 +0,0 @@
-setAntiAliasing(TRUE);
-$graph->border->setStyle(Line::DOTTED);
-$graph->border->setColor(new Red);
-
-$x = array();
-for($i = 0; $i < 10; $i++) {
- $x[] = mt_rand(20, 100);
-}
-
-$plot = new LinePlot($x);
-$plot->setFilledArea(0, 1, new Red(40));
-$plot->setFilledArea(1, 2, new LinearGradient(new Red(40), new Orange(40), 90));
-$plot->setFilledArea(2, 4, new LinearGradient(new Orange(40), new Green(40), 90));
-$plot->setFilledArea(4, 7, new LinearGradient(new Green(40), new Blue(40), 90));
-$plot->setFilledArea(7, 8, new LinearGradient(new Blue(40), new Purple(40), 90));
-$plot->setFilledArea(8, 9, new Purple(40));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-009.php b/artichow/examples/line-009.php
deleted file mode 100644
index 50ce6ee..0000000
--- a/artichow/examples/line-009.php
+++ /dev/null
@@ -1,66 +0,0 @@
-setAntiAliasing(TRUE);
-
-$group = new PlotGroup;
-$group->setXAxisZero(FALSE);
-$group->grid->setType(Line::DASHED);
-
-$group->setBackgroundColor(new Color(197, 180, 210, 80));
-
-$group->setPadding(40, NULL, 20, NULL);
-
-$group->axis->left->setLabelNumber(8);
-$group->axis->left->setLabelPrecision(1);
-$group->axis->left->setTickStyle(Tick::IN);
-$group->axis->left->label->move(-4, 0);
-
-$group->axis->bottom->setTickStyle(Tick::OUT);
-$group->axis->bottom->label->move(0, 4);
-
-$x = array();
-
-for($i = 0; $i < 15; $i++) {
- $x[] = cos($i * M_PI / 5);
-}
-
-$plot = new LinePlot($x);
-$plot->setColor(new Color(40, 40, 150, 10));
-$plot->setFillColor(new Color(40, 40, 150, 90));
-
-$group->add($plot);
-$group->legend->add($plot, "Ligne #1", Legend::LINE);
-
-$x = array();
-
-for($i = 5; $i < 15; $i++) {
- $x[] = (cos($i * M_PI / 5)) / 2;
-}
-
-$plot = new LinePlot($x);
-$plot->setColor(new Color(120, 120, 30, 10));
-$plot->setFillColor(new Color(120, 120, 30, 90));
-
-$group->add($plot);
-$group->legend->add($plot, "Ligne #2", Legend::LINE);
-
-$group->legend->setTextFont(new Tuffy(8));
-$group->legend->shadow->setSize(0);
-$group->legend->setSpace(12);
-$group->legend->setBackgroundColor(new Color(255, 255, 255));
-$group->setPadding(NULL, 100, NULL, NULL);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/line-010.php b/artichow/examples/line-010.php
deleted file mode 100644
index 128f366..0000000
--- a/artichow/examples/line-010.php
+++ /dev/null
@@ -1,46 +0,0 @@
-title->set('Star marks');
-$graph->title->setFont(new Tuffy(12));
-$graph->title->setColor(new DarkRed);
-
-$plot = new LinePlot(array(5, 3, 4, 7, 6, 5, 8, 4, 7));
-
-// Change plot size and position
-$plot->setSize(0.76, 1);
-$plot->setCenter(0.38, 0.5);
-
-$plot->setPadding(30, 15, 38, 25);
-$plot->setColor(new Orange());
-$plot->setFillColor(new LightOrange(80));
-
-// Change grid style
-$plot->grid->setType(Line::DASHED);
-
-// Add customized marks
-$plot->mark->setType(Mark::STAR);
-$plot->mark->setFill(new MidRed);
-$plot->mark->setSize(6);
-
-// Change legend
-$plot->legend->setPosition(1, 0.5);
-$plot->legend->setAlign(Legend::LEFT);
-$plot->legend->shadow->smooth(TRUE);
-
-$plot->legend->add($plot, 'My line', Legend::MARK);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/math-001.php b/artichow/examples/math-001.php
deleted file mode 100644
index 1c91b31..0000000
--- a/artichow/examples/math-001.php
+++ /dev/null
@@ -1,23 +0,0 @@
-setInterval(0.1);
-
-$function = new MathFunction('cos');
-$plot->add($function);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/math-002.php b/artichow/examples/math-002.php
deleted file mode 100644
index 79bcdf3..0000000
--- a/artichow/examples/math-002.php
+++ /dev/null
@@ -1,36 +0,0 @@
-title->set('f(x) = x * x');
-$graph->title->setBackgroundColor(new White(0));
-$graph->title->setPadding(NULL, NULL, 10, 10);
-$graph->title->move(0, -10);
-
-$plot = new MathPlot(-3, 3, 10, -2);
-$plot->setInterval(0.2);
-$plot->setPadding(NULL, NULL, NULL, 20);
-
-// Defines x²
-function x2($x) {
- return $x * $x;
-}
-
-$function = new MathFunction('x2');
-$function->setColor(new Orange);
-$plot->add($function);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/math-003.php b/artichow/examples/math-003.php
deleted file mode 100644
index 2ae8374..0000000
--- a/artichow/examples/math-003.php
+++ /dev/null
@@ -1,33 +0,0 @@
-setInterval(0.2);
-$plot->setPadding(NULL, NULL, NULL, 20);
-
-$plot->yAxis->setLabelInterval(4);
-
-$function = new MathFunction('exp');
-$function->setColor(new DarkRed);
-$function->mark->setType(Mark::SQUARE);
-$function->mark->setSize(3);
-$function->mark->setFill(new DarkBlue);
-$plot->add($function, "f(x) = exp(x)", Legend::MARK);
-
-$plot->legend->setPosition(0.4, 0.2);
-$plot->legend->setPadding(3, 3, 3, 3, 3);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/math-004.php b/artichow/examples/math-004.php
deleted file mode 100644
index 8873288..0000000
--- a/artichow/examples/math-004.php
+++ /dev/null
@@ -1,39 +0,0 @@
-setInterval(0.2);
-$plot->setPadding(NULL, NULL, NULL, 20);
-
-$function = new MathFunction('exp');
-$function->setColor(new DarkRed);
-$function->mark->setType(Mark::SQUARE);
-$function->mark->setSize(3);
-$function->mark->setFill(new DarkBlue);
-$plot->add($function, "f(x) = exp(x)", Legend::MARK);
-
-function x2($x) {
- return - $x * $x;
-}
-
-$function = new MathFunction('x2');
-$function->setColor(new DarkBlue);
-$plot->add($function, "f(x) = - x * x");
-
-$plot->legend->setPosition(0.4, 0.4);
-$plot->legend->setPadding(3, 3, 3, 3, 3);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/math-005.php b/artichow/examples/math-005.php
deleted file mode 100644
index 849bee2..0000000
--- a/artichow/examples/math-005.php
+++ /dev/null
@@ -1,34 +0,0 @@
-setInterval(0.05);
-
-$function = new MathFunction('sqrt', 0);
-$plot->add($function, "sqrt(x)");
-
-function x2($x) {
- return - $x * $x;
-}
-
-$function = new MathFunction('sin', -2, 2);
-$function->setColor(new DarkBlue);
-$plot->add($function, "sin(x) (-2 < x < 2)");
-
-$plot->legend->setPosition(0.98, 0.8);
-$plot->legend->setTextFont(new Tuffy(8));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/pattern-001.php b/artichow/examples/pattern-001.php
deleted file mode 100644
index ceb50ce..0000000
--- a/artichow/examples/pattern-001.php
+++ /dev/null
@@ -1,26 +0,0 @@
-title->set('Pattern 1');
-$graph->title->move(100, 0);
-$graph->title->setFont(new Tuffy(9));
-$graph->title->setColor(new DarkRed);
-
-$pattern = Pattern::get('BarDepth');
-$pattern->setArgs(array(
- 'yForeground' => array(5, 3, 4, 7, 6, 5, 8, 4, 7, NULL, NULL),
- 'yBackground' => array(NULL, NULL, 4, 5, 6, 4, 2, 3, 7, 5, 4),
- 'legendForeground' => '2003',
- 'legendBackground' => '2004'
-));
-
-$group = $pattern->create();
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pattern-002.php b/artichow/examples/pattern-002.php
deleted file mode 100644
index ca88b82..0000000
--- a/artichow/examples/pattern-002.php
+++ /dev/null
@@ -1,24 +0,0 @@
-title->set('Customized pattern 1');
-$graph->title->setFont(new Tuffy(12));
-
-$pattern = Pattern::get('BarDepth');
-$pattern->setArgs(array(
- 'yForeground' => array(5, 3, 4, 7, 6, 5, 8, 4, 7, NULL, NULL),
- 'yBackground' => array(NULL, NULL, 4, 5, 6, 4, 2, 3, 7, 5, 4),
- 'colorForeground' => new Color(230, 230, 230),
- 'colorBackground' => new Color(250, 90, 90)
-));
-
-$group = $pattern->create();
-$group->legend->setPosition(0.5, 0.78);
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pattern-003.php b/artichow/examples/pattern-003.php
deleted file mode 100644
index b61c00c..0000000
--- a/artichow/examples/pattern-003.php
+++ /dev/null
@@ -1,23 +0,0 @@
-title->set('Pattern 2');
-$graph->title->setFont(new Tuffy(12));
-$graph->title->setColor(new DarkRed);
-
-$pattern = Pattern::get('LightLine');
-$pattern->setArgs(array(
- 'y' => array(5, 3, 4, 7, 6, 5, 8, 4, 7),
- 'legend' => 'John Doe'
-));
-
-$plot = $pattern->create();
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-001.php b/artichow/examples/pie-001.php
deleted file mode 100644
index 172b0ec..0000000
--- a/artichow/examples/pie-001.php
+++ /dev/null
@@ -1,40 +0,0 @@
-title->set("Pie (example 1)");
-
-$values = array(12, 5, 13, 18, 10, 6, 11);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->shadow->setSize(0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-002.php b/artichow/examples/pie-002.php
deleted file mode 100644
index 5ed41ae..0000000
--- a/artichow/examples/pie-002.php
+++ /dev/null
@@ -1,41 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 2)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-$plot->explode(array(1 => 20, 4 => 26, 0 => 25));
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-003.php b/artichow/examples/pie-003.php
deleted file mode 100644
index e61aa5a..0000000
--- a/artichow/examples/pie-003.php
+++ /dev/null
@@ -1,42 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 3)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::AQUA);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(15);
-$plot->explode(array(4 => 20, 0 => 30));
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-004.php b/artichow/examples/pie-004.php
deleted file mode 100644
index 25332b0..0000000
--- a/artichow/examples/pie-004.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new White,
- new VeryLightGray,
- 0
- )
-);
-$graph->title->set("Pie (example 4)");
-$graph->shadow->setSize(7);
-$graph->shadow->smooth(TRUE);
-$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-005.php b/artichow/examples/pie-005.php
deleted file mode 100644
index 0a2cbd2..0000000
--- a/artichow/examples/pie-005.php
+++ /dev/null
@@ -1,47 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new VeryLightGray,
- new White,
- 0
- )
-);
-$graph->title->set("Pie (example 5) - Initial angle: 140°");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-$plot->setStartAngle(140);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-006.php b/artichow/examples/pie-006.php
deleted file mode 100644
index 871ce42..0000000
--- a/artichow/examples/pie-006.php
+++ /dev/null
@@ -1,37 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new VeryLightGray,
- new White,
- 0
- )
-);
-$graph->title->set("Pie (example 6)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values);
-$plot->setCenter(0.5, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(5);
-$plot->setBorderColor(new Black);
-
-
-$plot->legend->hide(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-007.php b/artichow/examples/pie-007.php
deleted file mode 100644
index 0720861..0000000
--- a/artichow/examples/pie-007.php
+++ /dev/null
@@ -1,56 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 7)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::DARK);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(5);
-$plot->setBorderColor(new White);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-$plot->legend->shadow->setPosition(Shadow::RIGHT_TOP);
-
-$plot->label->setPadding(2, 2, 2, 2);
-$plot->label->border->setColor(new Red(60));
-$plot->label->setFont(new Tuffy(7));
-$plot->label->setBackgroundGradient(
- new LinearGradient(
- new Red(80),
- new White(80),
- 0
- )
-);
-$plot->setLabelPrecision(1);
-
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-008.php b/artichow/examples/pie-008.php
deleted file mode 100644
index 7235b6d..0000000
--- a/artichow/examples/pie-008.php
+++ /dev/null
@@ -1,54 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 8)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setSize(0.85, 0.60);
-$plot->set3D(15);
-$plot->setBorderColor(new LightGray);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->shadow->setSize(3);
-$plot->legend->setModel(Legend::MODEL_BOTTOM);
-$plot->legend->setPosition(NULL, 1.1);
-
-$plot->label->setPadding(2, 2, 2, 2);
-$plot->label->border->setColor(new Red(60));
-$plot->label->setFont(new Tuffy(7));
-$plot->label->setBackgroundGradient(
- new LinearGradient(
- new Red(80),
- new White(80),
- 0
- )
-);
-$plot->setLabelPrecision(1);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-009.php b/artichow/examples/pie-009.php
deleted file mode 100644
index d3e6419..0000000
--- a/artichow/examples/pie-009.php
+++ /dev/null
@@ -1,49 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 9) - User defined colors");
-$graph->title->border->show();
-$graph->title->setBackgroundColor(new LightRed(60));
-$graph->title->setPadding(3, 3, 3, 3);
-
-$values = array(8, 4, 6, 3, 4);
-$colors = array(
- new LightOrange,
- new LightPurple,
- new LightBlue,
- new LightRed,
- new LightPink
-);
-
-$plot = new Pie($values, $colors);
-$plot->setSize(0.70, 0.60);
-$plot->setCenter(0.40, 0.55);
-$plot->set3D(10);
-$plot->setBorderColor(new LightGray);
-
-$plot->setLegend(array(
- 'Alpha',
- 'Beta',
- 'Gamma',
- 'Delta',
- 'Epsilon'
-));
-
-$plot->legend->setPosition(1.30);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-010.php b/artichow/examples/pie-010.php
deleted file mode 100644
index e670297..0000000
--- a/artichow/examples/pie-010.php
+++ /dev/null
@@ -1,29 +0,0 @@
-title->set("Pie (example 10) - Just a pie");
-$graph->title->setFont(new Tuffy(10));
-
-$values = array(8, 4, 6, 1, 2, 3, 4);
-
-$plot = new Pie($values);
-$plot->set3D(10);
-
-$plot->legend->hide(TRUE);
-$plot->label->hide(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-011.php b/artichow/examples/pie-011.php
deleted file mode 100644
index 074fe91..0000000
--- a/artichow/examples/pie-011.php
+++ /dev/null
@@ -1,48 +0,0 @@
-title->set($title);
- $plot->title->setFont(new TuffyBold(8));
- $plot->title->move(NULL, -12);
-
- $plot->label->setFont(new Tuffy(7));
- $plot->legend->hide(TRUE);
- $plot->setLabelPosition(5);
- $plot->setSize(0.45, 0.45);
- $plot->setCenter($x, $y);
- $plot->set3D(10);
- $plot->setBorderColor(new Color(230, 230, 230));
-
- return $plot;
-
-}
-
-$graph = new Graph(400, 300);
-
-$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.22, 0.25);
-$graph->add($plot);
-
-$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.68, 0.25);
-$graph->add($plot);
-
-$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.22, 0.75);
-$graph->add($plot);
-
-$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.68, 0.75);
-$plot->legend->hide(FALSE); // We print only one legend
-$plot->legend->setPosition(1.18, 0);
-$graph->add($plot);
-
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-012.php b/artichow/examples/pie-012.php
deleted file mode 100644
index 59683c1..0000000
--- a/artichow/examples/pie-012.php
+++ /dev/null
@@ -1,38 +0,0 @@
-title->set("Pie (example 12)");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->explode(array(1 => 20, 4 => 25));
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-013.php b/artichow/examples/pie-013.php
deleted file mode 100644
index f038dac..0000000
--- a/artichow/examples/pie-013.php
+++ /dev/null
@@ -1,40 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 13)");
-
-$values = array(12, 5, 13, 18, 10, 6, 11);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setAbsSize(180, 180);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.5);
-$plot->legend->shadow->setSize(0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-014.php b/artichow/examples/pie-014.php
deleted file mode 100644
index dd4bd75..0000000
--- a/artichow/examples/pie-014.php
+++ /dev/null
@@ -1,48 +0,0 @@
-title->set($title);
- $plot->title->setFont(new TuffyBold(8));
- $plot->title->move(NULL, -12);
-
- $plot->label->setFont(new Tuffy(7));
- $plot->legend->hide(TRUE);
- $plot->setLabelPosition(5);
- $plot->setSize(0.40, 0.40);
- $plot->setCenter($x, $y);
- $plot->setBorderColor(new Black);
-
- return $plot;
-
-}
-
-$graph = new Graph(400, 400);
-$graph->setAntiAliasing(TRUE);
-
-$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.22, 0.25);
-$graph->add($plot);
-
-$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.66, 0.25);
-$graph->add($plot);
-
-$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.22, 0.75);
-$graph->add($plot);
-
-$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.66, 0.75);
-$plot->legend->hide(FALSE); // We print only one legend
-$plot->legend->setPosition(1.25, 0);
-$graph->add($plot);
-
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-015.php b/artichow/examples/pie-015.php
deleted file mode 100644
index b2ee5cc..0000000
--- a/artichow/examples/pie-015.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new VeryLightGray,
- new White,
- 0
- )
-);
-$graph->title->set("Pie (example 15) - Arbitrary labels");
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.6, 0.6 * 4 / 3);
-
-$plot->label->set(array(
- 'Arthur', 'Abel', 'Bernard', 'Thierry', 'Paul', 'Gaston', 'Joe'
-));
-$plot->label->setCallbackFunction(NULL); // We must disable the default callback function
-
-$plot->setLegend(array(
- 'ABC',
- 'DEF',
- 'GHI',
- 'JKL',
- 'MNO',
- 'PQR',
- 'STU'
-));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-016.php b/artichow/examples/pie-016.php
deleted file mode 100644
index 7b92d24..0000000
--- a/artichow/examples/pie-016.php
+++ /dev/null
@@ -1,45 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 13) - Adjusting labels");
-
-$values = array(16, 9, 13, 23, 10);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setAbsSize(220, 220);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->setLabelPosition(-40);
-$plot->label->setPadding(2, 2, 2, 2);
-$plot->label->setFont(new Tuffy(7));
-$plot->label->setBackgroundColor(new White(60));
-
-$plot->legend->setPosition(1.3);
-$plot->legend->shadow->setSize(0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-017.php b/artichow/examples/pie-017.php
deleted file mode 100644
index eb3cc0b..0000000
--- a/artichow/examples/pie-017.php
+++ /dev/null
@@ -1,48 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 17)");
-$graph->title->setFont(new Tuffy(14));
-
-$values = array(12, 16, 13, 18, 10, 20, 11);
-
-$plot = new Pie($values, Pie::AQUA);
-$plot->setCenter(0.4, 0.55);
-$plot->setAbsSize(180, 180);
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$explode = array();
-for($i = 0; $i < count($values); $i++) {
- $explode[] = 15;
-}
-
-$plot->explode($explode);
-
-$plot->legend->setPosition(1.5);
-$plot->legend->shadow->setSize(0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/pie-018.php b/artichow/examples/pie-018.php
deleted file mode 100644
index 30390e4..0000000
--- a/artichow/examples/pie-018.php
+++ /dev/null
@@ -1,32 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Pie (example 18) - Display labels > 10 %");
-$graph->title->setFont(new Tuffy(14));
-
-$values = array(1, 5, 6, 16, 18, 19, 21, 3, 4, 7, 6);
-
-$plot = new Pie($values);
-$plot->setCenter(0.4, 0.55);
-$plot->setAbsSize(180, 180);
-$plot->setLabelMinimum(10);
-
-$plot->legend->setPosition(1.5);
-$plot->legend->shadow->setSize(0);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-001.php b/artichow/examples/scatter-001.php
deleted file mode 100644
index 5d33eda..0000000
--- a/artichow/examples/scatter-001.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title->set('Simple ScatterPlot');
-
-$y = array(1, 10, 3,-4, 1, 4, 8, 7);
-$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
-
-$plot = new ScatterPlot($y, $x);
-$plot->setBackgroundColor(new VeryLightGray);
-$plot->setPadding(NULL, NULL, 40, 20);
-
-$plot->legend->add($plot, 'Some points', Legend::MARKONLY);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-002.php b/artichow/examples/scatter-002.php
deleted file mode 100644
index fb980c1..0000000
--- a/artichow/examples/scatter-002.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title->set('Linked ScatterPlot');
-
-$y = array(1, 10, 3,-4, 1, 4, 8, 7);
-$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
-
-$plot = new ScatterPlot($y, $x);
-$plot->setBackgroundColor(new VeryLightGray);
-$plot->setPadding(NULL, NULL, 40, 20);
-
-$plot->link(TRUE, new DarkBlue);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-003.php b/artichow/examples/scatter-003.php
deleted file mode 100644
index 388ec0f..0000000
--- a/artichow/examples/scatter-003.php
+++ /dev/null
@@ -1,30 +0,0 @@
-shadow->setSize(5);
-$graph->title->set('ScatterPlot with values');
-
-$y = array(4, 3, 2, 5, 8, 1, 3, 6, 4, 5);
-$x = array(1, 2, 5, 4, 3, 6, 2, 4, 5, 1);
-
-$plot = new ScatterPlot($y, $x);
-$plot->setSpace(6, 6, 6, 0);
-$plot->setPadding(NULL, NULL, 40, 20);
-
-// Set dashed lines on the grid
-$plot->grid->setType(Line::DASHED);
-
-$plot->mark->setSize(30);
-$plot->mark->setFill(new DarkOrange(20));
-
-
-$plot->label->set($y);
-$plot->label->setColor(new White);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-004.php b/artichow/examples/scatter-004.php
deleted file mode 100644
index c550b78..0000000
--- a/artichow/examples/scatter-004.php
+++ /dev/null
@@ -1,32 +0,0 @@
-shadow->setSize(5);
-
-$y = array();
-for($i = 0; $i < 60; $i++) {
- $y[] = cos($i / 30 * 2 * M_PI);
-}
-
-$plot = new ScatterPlot($y);
-$plot->setSpace(6, 6);
-
-// Set impulses
-$plot->setImpulse(new DarkGreen);
-
-$plot->grid->hideVertical();
-
-// Hide axis labels and ticks
-$plot->xAxis->label->hide();
-$plot->xAxis->hideTicks();
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setSize(4);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-005.php b/artichow/examples/scatter-005.php
deleted file mode 100644
index cd4f3d1..0000000
--- a/artichow/examples/scatter-005.php
+++ /dev/null
@@ -1,37 +0,0 @@
-title->set('Impulses');
-$graph->title->move(0, 30);
-$graph->shadow->setSize(5);
-
-$y = array();
-for($i = 0; $i < 60; $i++) {
- $y[] = cos($i / 30 * 2 * M_PI) / (1.5 + $i / 15);
-}
-
-$plot = new ScatterPlot($y);
-$plot->setBackgroundColor(new VeryLightOrange);
-$plot->setSpace(5);
-
-// Set impulses
-$plot->setImpulse(new DarkBlue);
-
-$plot->grid->hideVertical();
-
-// Hide ticks
-$plot->xAxis->hideTicks();
-
-// Change labels interval
-$plot->xAxis->label->setInterval(5);
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setSize(4);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-006.php b/artichow/examples/scatter-006.php
deleted file mode 100644
index e904475..0000000
--- a/artichow/examples/scatter-006.php
+++ /dev/null
@@ -1,39 +0,0 @@
-setBackgroundColor(new VeryLightGray);
-$plot->setPadding(30, 30, 30, 30);
-$plot->setSpace(5, 5, 5, 5);
-
-$plot->link(TRUE, new DarkGreen);
-
-$plot->mark->setFill(new DarkOrange);
-$plot->mark->setType(Mark::SQUARE, 4);
-
-$plot->setXAxis(Plot::BOTH);
-$plot->setXAxisZero(FALSE);
-$plot->setYAxis(Plot::BOTH);
-
-$plot->legend->add($plot, 'A circle', Legend::MARK);
-$plot->legend->setPosition(0.5, 0.5);
-$plot->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/scatter-007.php b/artichow/examples/scatter-007.php
deleted file mode 100644
index 43cb57d..0000000
--- a/artichow/examples/scatter-007.php
+++ /dev/null
@@ -1,60 +0,0 @@
-setBackgroundColor(new VeryLightGray);
-$group->setPadding(30, 30, 30, 30);
-$group->setSpace(5, 5, 5, 5);
-
-$group->legend->setPosition(0.5, 0.62);
-$group->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
-
-function getCircle($size) {
-
- $center = 0;
-
- $x = array();
- $y = array();
-
- for($i = 0; $i <= 30; $i++) {
- $rad = ($i / 30) * 2 * M_PI;
- $x[] = $center + cos($rad) * $size;
- $y[] = $center + sin($rad) * $size;
- }
-
- return array($x, $y);
-
-}
-
-list($x, $y) = getCircle(3);
-
-$plot = new ScatterPlot($y, $x);
-
-$plot->link(TRUE, new DarkBlue);
-
-$plot->mark->setFill(new DarkPink);
-$plot->mark->setType(Mark::CIRCLE, 6);
-
-$group->legend->add($plot, 'Circle #1', Legend::MARK);
-$group->add($plot);
-
-list($x, $y) = getCircle(5);
-
-$plot = new ScatterPlot($y, $x);
-
-$plot->link(TRUE, new DarkGreen);
-
-$plot->mark->setFill(new DarkOrange);
-$plot->mark->setType(Mark::SQUARE, 4);
-
-$group->legend->add($plot, 'Circle #2', Legend::MARK);
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/bar-001.php b/artichow/examples/site/bar-001.php
deleted file mode 100644
index d2b118b..0000000
--- a/artichow/examples/site/bar-001.php
+++ /dev/null
@@ -1,80 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 0.5, 3, 8, 6
-);
-
-$plot = new BarPlot($x);
-
-$plot->setSpace(4, 4, 10, 0);
-$plot->setPadding(40, 15, 10, 40);
-
-$plot->title->set("Zoé and friends");
-$plot->title->setFont(new TuffyBold(11));
-$plot->title->border->show();
-$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
-$plot->title->setPadding(4, 4, 4, 4);
-$plot->title->move(-20, 25);
-
-$plot->yAxis->title->set("Axe des Y");
-$plot->yAxis->title->setFont(new TuffyBold(10));
-$plot->yAxis->title->move(-4, 0);
-$plot->yAxis->setTitleAlignment(Label::TOP);
-
-$plot->xAxis->title->set("Axe des X");
-$plot->xAxis->title->setFont(new TuffyBold(10));
-$plot->xAxis->setTitleAlignment(Label::RIGHT);
-
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(230, 230, 230),
- new Color(255, 255, 255),
- 0
- )
-);
-
-$plot->barBorder->setColor(new Color(0, 0, 150, 20));
-
-$plot->setBarGradient(
- new LinearGradient(
- new Color(150, 150, 210, 0),
- new Color(230, 230, 255, 30),
- 0
- )
-);
-
-$y = array(
- 'Zoé',
- 'Yvan',
- 'Fred',
- 'Lucie',
- 'Ilia',
- 'Nino',
- 'Marie'
-);
-
-$plot->xAxis->setLabelText($y);
-$plot->xAxis->label->setFont(new TuffyBold(7));
-
-$graph->shadow->setSize(4);
-$graph->shadow->setPosition(Shadow::LEFT_TOP);
-$graph->shadow->smooth(TRUE);
-$graph->shadow->setColor(new Color(160, 160, 160));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/bar-002.php b/artichow/examples/site/bar-002.php
deleted file mode 100644
index 5e75cad..0000000
--- a/artichow/examples/site/bar-002.php
+++ /dev/null
@@ -1,80 +0,0 @@
-setAntiAliasing(TRUE);
-
-$group = new PlotGroup;
-$group->setSpace(6, 6, 5, 5);
-$group->setBackgroundGradient(
- new LinearGradient(
- new Color(235, 235, 235),
- new White(),
- 0
- )
-);
-$group->setPadding(40, 10, 10, 50);
-
-$group->axis->left->setLabelPrecision(2);
-$group->axis->bottom->label->hide(TRUE);
-$group->axis->bottom->hideTicks(TRUE);
-
-$group->grid->setType(Line::DASHED);
-$group->grid->hideHorizontal(TRUE);
-
-$gradients = array(
- new LinearGradient(
- new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0
- ),
- new LinearGradient(
- new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0
- ),
- new LinearGradient(
- new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0
- )
-);
-
-for($n = 0; $n < 3; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 6; $i++) {
- $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0);
- }
-
- $plot = new BarPlot($x, $n + 1, 3);
-
- $plot->setXAxis(Plot::BOTTOM);
-
- $plot->barShadow->setSize(1);
- $plot->barShadow->setPosition(Shadow::RIGHT_TOP);
- $plot->barShadow->setColor(new Color(160, 160, 160, 10));
-
- $plot->barBorder->setColor($gradients[$n]->from);
-
- $plot->setBarGradient($gradients[$n]);
-
- $plot->setBarSpace(2);
-
- $group->legend->add($plot, 'Bar#'.($n + 1), Legend::BACKGROUND);
-
- $group->add($plot);
-
-}
-
-$group->legend->setModel(Legend::MODEL_BOTTOM);
-$group->legend->setPosition(NULL, 0.86);
-$group->legend->shadow->hide();
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/bar-003.php b/artichow/examples/site/bar-003.php
deleted file mode 100644
index 22ab916..0000000
--- a/artichow/examples/site/bar-003.php
+++ /dev/null
@@ -1,73 +0,0 @@
-setAntiAliasing(TRUE);
-$graph->border->hide();
-
-$group = new PlotGroup;
-$group->setSpace(5, 10, 20, 15);
-$group->setPadding(40, 10, NULL, 20);
-$group->setXAxisZero(FALSE);
-
-$group->axis->left->setLabelPrecision(2);
-
-$colors = array(
- new Color(100, 180, 154, 12),
- new Color(100, 154, 180, 12),
- new Color(154, 100, 180, 12),
- new Color(180, 100, 154, 12)
-);
-
-for($n = 0; $n < 4; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 6; $i++) {
- $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 1400) / 1000 - 0.5);
- }
-
- $plot = new BarPlot($x, 1, 1, (3 - $n) * 7);
- $plot->barBorder->setColor(new Color(0, 0, 0));
-
- $plot->setBarSize(0.54);
-
- $plot->barShadow->setSize(3);
- $plot->barShadow->setPosition(Shadow::RIGHT_TOP);
- $plot->barShadow->setColor(new Color(160, 160, 160, 10));
- $plot->barShadow->smooth(TRUE);
-
- $plot->setBarColor($colors[$n]);
-
- $group->add($plot);
- $group->legend->add($plot, "Barre #".$n, Legend::BACKGROUND);
-
-}
-
-$group->legend->shadow->setSize(0);
-$group->legend->setAlign(Legend::CENTER);
-$group->legend->setSpace(6);
-$group->legend->setTextFont(new Tuffy(8));
-$group->legend->setPosition(0.50, 0.12);
-$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
-$group->legend->setColumns(2);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/bar-004.php b/artichow/examples/site/bar-004.php
deleted file mode 100644
index 1f85ecb..0000000
--- a/artichow/examples/site/bar-004.php
+++ /dev/null
@@ -1,92 +0,0 @@
-setAntiAliasing(TRUE);
-
-$group = new PlotGroup;
-$group->setSpace(5, 5, 15, 0);
-$group->setPadding(40, 40);
-
-$group->axis->left->setLabelPrecision(2);
-$group->axis->right->setLabelPrecision(2);
-
-$colors = array(
- new Color(80, 105, 190, 10),
- new Color(105, 190, 80, 10)
-);
-
-$darkColor = array(
- new Color(40, 55, 120, 10),
- new Color(55, 120, 40, 10)
-);
-
-$axis = array(
- Plot::LEFT,
- Plot::RIGHT
-);
-
-$group->axis->left->setColor($darkColor[0]);
-$group->axis->left->label->setColor($darkColor[0]);
-$group->axis->right->setColor($darkColor[1]);
-$group->axis->right->label->setColor($darkColor[1]);
-
-$group->setBackgroundGradient(
- new LinearGradient(
- new Color(225, 225, 225),
- new Color(255, 255, 255),
- 0
- )
-);
-
-for($n = 0; $n < 2; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 4; $i++) {
- $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0) + 1;
- }
-
- $plot = new BarPlot($x, $n+1, 2);
- $plot->barBorder->setColor(new Color(0, 0, 0, 30));
-
- $plot->setBarPadding(0.1, 0.1);
- $plot->setBarSpace(5);
-
- $plot->barShadow->setSize(3);
- $plot->barShadow->setPosition(Shadow::RIGHT_TOP);
- $plot->barShadow->setColor(new Color(180, 180, 180, 10));
- $plot->barShadow->smooth(TRUE);
-
- $plot->label->set($x);
- $plot->label->move(0, -6);
- $plot->label->setFont(new Tuffy(7));
- $plot->label->setAngle(90);
- $plot->label->setAlign(NULL, Label::TOP);
- $plot->label->setPadding(3, 1, 0, 6);
- $plot->label->setCallbackFunction("labelFormat");
-
- $plot->setBarColor($colors[$n]);
-
- $plot->setYAxis($axis[$n]);
-
- $group->add($plot);
-
-}
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/bar-005.php b/artichow/examples/site/bar-005.php
deleted file mode 100644
index 1a025c7..0000000
--- a/artichow/examples/site/bar-005.php
+++ /dev/null
@@ -1,82 +0,0 @@
-setAntiAliasing(TRUE);
-$graph->border->hide();
-
-$group = new PlotGroup;
-$group->grid->hide(TRUE);
-$group->setSpace(2, 2, 20, 0);
-$group->setPadding(30, 10, NULL, NULL);
-
-$colors = array(
- new Orange(25),
- new LightBlue(10)
-);
-
-for($n = 0; $n < 2; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 3 - $n * 3; $i++) {
- $x[] = NULL;
- }
-
- for($i = 3 - ($n * 3); $i < 12 - ($n * 3); $i++) {
- $x[] = cos($i * M_PI / 100) * mt_rand(800, 1200) / 1000 * (((1 - $n) * 5 + 10) / 10);
- }
-
- for($i = 0; $i < $n * 3; $i++) {
- $x[] = NULL;
- }
-
- $plot = new BarPlot($x, 1, 1, (1 - $n) * 6);
-
-// $plot->setBarPadding(2, 2);
-
- $plot->barShadow->setSize(2);
- $plot->barShadow->setPosition(Shadow::RIGHT_TOP);
- $plot->barShadow->setColor(new Color(160, 160, 160, 10));
- $plot->barShadow->smooth(TRUE);
-
- $plot->setBarColor($colors[$n]);
-
- $group->add($plot);
- $group->legend->add($plot, $n + date('Y'), Legend::BACKGROUND);
-
-}
-
-function setPc($value) {
- return round($value * 10).'%';
-}
-
-$group->axis->left->label->setCallbackFunction('setPc');
-
-$months = array(
- "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
-);
-
-$group->axis->bottom->setLabelText($months);
-$group->axis->bottom->hideTicks(TRUE);
-
-$group->legend->shadow->setSize(0);
-$group->legend->setAlign(Legend::CENTER);
-$group->legend->setSpace(6);
-$group->legend->setTextFont(new Tuffy(8));
-$group->legend->setPosition(0.50, 0.10);
-$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
-$group->legend->setColumns(2);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/canvas-001.php b/artichow/examples/site/canvas-001.php
deleted file mode 100644
index 9bba02b..0000000
--- a/artichow/examples/site/canvas-001.php
+++ /dev/null
@@ -1,68 +0,0 @@
-getDriver();
-
-$driver->filledRectangle(
- new Color(230, 230, 230, 0),
- new Line(
- new Point(10, 10),
- new Point(200, 150)
- )
-);
-
-for($i = 7; $i < 400; $i += 15) {
- $driver->line(
- new Color(0, 0, 0),
- new Line(
- new Point($i, 0 + 50),
- new Point($i, 30 + 50)
- )
- );
-}
-
-for($i = 7; $i < 30; $i += 15) {
- $driver->line(
- new Color(0, 0, 0),
- new Line(
- new Point(0, $i + 50),
- new Point(400, $i + 50)
- )
- );
-}
-
-$driver->filledRectangle(
- new Color(0, 100, 200, 50),
- new Line(
- new Point(100, 100),
- new Point(280, 180)
- )
-);
-
-$debut = new Color(230, 250, 0);
-$fin = new Color(255, 255, 255, 100);
-
-$driver->filledEllipse(
- new RadialGradient(
- $debut,
- $fin
- ),
- new Point(105, 135),
- 90, 90
-);
-
-$text = new Text(
- "Artichow !",
- new Tuffy(15),
- new Color(0, 0, 80),
- 45
-);
-
-$driver->string($text, new Point(210, 75));
-
-$graph->draw();
-
-?>
diff --git a/artichow/examples/site/impulse-001.php b/artichow/examples/site/impulse-001.php
deleted file mode 100644
index 9ffc027..0000000
--- a/artichow/examples/site/impulse-001.php
+++ /dev/null
@@ -1,36 +0,0 @@
-title->set('Impulses');
-$graph->shadow->setSize(4);
-
-$y = array();
-for($i = 0; $i < 40; $i++) {
- $y[] = cos($i / 15 * 2 * M_PI) / (0.8 + $i / 15) * 4;
-}
-
-$plot = new ScatterPlot($y);
-$plot->setPadding(25, 15, 35, 15);
-$plot->setBackgroundColor(new Color(230, 230, 255));
-$plot->setSpace(2, 2);
-
-// Set impulses
-$plot->setImpulse(new DarkBlue);
-
-$plot->grid->hideVertical();
-$plot->grid->setType(Line::DASHED);
-
-// Hide ticks
-$plot->xAxis->hideTicks();
-$plot->xAxis->label->hide();
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setSize(4);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-001.php b/artichow/examples/site/line-001.php
deleted file mode 100644
index 98a8f42..0000000
--- a/artichow/examples/site/line-001.php
+++ /dev/null
@@ -1,71 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 3, 1, 5, 6, 3, 8, 6
-);
-
-$plot = new LinePlot($x);
-
-$plot->grid->setNoBackground();
-
-$plot->title->set("Filled line and marks");
-$plot->title->setFont(new Tuffy(10));
-$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
-$plot->title->border->show();
-$plot->title->setPadding(3, 3, 3, 3);
-$plot->title->move(-20, 25);
-
-$plot->setSpace(4, 4, 10, 0);
-$plot->setPadding(25, 15, 10, 18);
-
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(255, 255, 255),
- 0
- )
-);
-
-$plot->setColor(new Color(0, 0, 150, 20));
-
-$plot->setFillGradient(
- new LinearGradient(
- new Color(150, 150, 210),
- new Color(245, 245, 245),
- 0
- )
-);
-
-$plot->mark->setType(Mark::CIRCLE);
-$plot->mark->border->show();
-
-$y = array(
- 'Lundi',
- 'Mardi',
- 'Mercredi',
- 'Jeudi',
- 'Vendredi',
- 'Samedi',
- 'Dimanche'
-);
-
-$plot->xAxis->setLabelText($y);
-$plot->xAxis->label->setFont(new Tuffy(7));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-002.php b/artichow/examples/site/line-002.php
deleted file mode 100644
index 3fcb668..0000000
--- a/artichow/examples/site/line-002.php
+++ /dev/null
@@ -1,62 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 4, 3, 1, 0, -2, 1, 3, 2, 3, 5, 4, 1
-);
-
-$plot = new LinePlot($x);
-$plot->setXAxisZero(FALSE);
-
-$plot->grid->hide(TRUE);
-
-$plot->title->set("Using dashed line and legend");
-$plot->title->setFont(new TuffyItalic(9));
-$plot->title->setBackgroundColor(new Color(255, 255, 255, 50));
-$plot->title->setPadding(3, 3, 3, 3);
-$plot->title->move(0, 20);
-
-$plot->setSpace(6, 6, 10, 10);
-$plot->setPadding(30, 10, 15, 25);
-
-$plot->setBackgroundColor(
- new Color(245, 245, 245)
-);
-
-$plot->setStyle(Line::DASHED);
-$plot->setColor(new Color(0, 150, 0, 20));
-
-$plot->setFillGradient(
- new LinearGradient(
- new Color(220, 220, 150, 40),
- new Color(255, 255, 210, 30),
- 0
- )
-);
-
-$graph->shadow->setSize(4);
-$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
-$graph->shadow->smooth(TRUE);
-
-$plot->legend->add($plot, "Apples");
-$plot->legend->shadow->setSize(0);
-$plot->legend->setAlign(Legend::CENTER, Legend::TOP);
-$plot->legend->setPosition(0.75, 0.60);
-$plot->legend->setTextFont(new Tuffy(8));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-003.php b/artichow/examples/site/line-003.php
deleted file mode 100644
index 6c283d3..0000000
--- a/artichow/examples/site/line-003.php
+++ /dev/null
@@ -1,70 +0,0 @@
-setBackgroundColor(
- new Color(240, 240, 240)
-);
-
-$plot->setPadding(40, 15, 15, 15);
-
-$plot->setColor(
- new Color(60, 60, 150)
-);
-
-$plot->setFillColor(
- new Color(120, 175, 80, 47)
-);
-
-$plot->grid->setType(Line::DASHED);
-
-$plot->yAxis->setLabelNumber(6);
-$plot->yAxis->setLabelPrecision(1);
-$plot->yAxis->setNumberByTick('minor', 'major', 1);
-$plot->yAxis->label->setCallbackFunction('format');
-$plot->yAxis->label->setFont(new Tuffy(7));
-
-$plot->xAxis->setNumberByTick('minor', 'major', 3);
-$plot->xAxis->label->hideFirst(TRUE);
-$plot->xAxis->setLabelInterval(50);
-$plot->xAxis->label->setFont(new Tuffy(7));
-
-$plot->grid->setInterval(1, 50);
-
-$graph->shadow->setSize(4);
-$graph->shadow->setPosition(Shadow::RIGHT_BOTTOM);
-$graph->shadow->smooth(TRUE);
-
-$plot->label->set($x);
-$plot->label->setInterval(25);
-$plot->label->hideFirst(TRUE);
-$plot->label->setPadding(1, 1, 1, 1);
-$plot->label->setCallbackFunction('format');
-$plot->label->setBackgroundColor(
- new Color(227, 223, 241, 15)
-);
-$plot->label->setFont(new Tuffy(7));
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-004.php b/artichow/examples/site/line-004.php
deleted file mode 100644
index b6ed59b..0000000
--- a/artichow/examples/site/line-004.php
+++ /dev/null
@@ -1,104 +0,0 @@
-setBackgroundColor(new Color(0xF4, 0xF4, 0xF4));
-$graph->shadow->setSize(3);
-
-$graph->title->set("Evolution");
-$graph->title->setFont(new Tuffy(15));
-$graph->title->setColor(new Color(0x00, 0x00, 0x8B));
-
-
-$group = new PlotGroup;
-$group->setSize(0.82, 1);
-$group->setCenter(0.41, 0.5);
-$group->setPadding(35, 26, 40, 27);
-$group->setSpace(2, 2);
-
-$group->grid->setColor(new Color(0xC4, 0xC4, 0xC4));
-$group->grid->setType(Line::DASHED);
-$group->grid->hideVertical(TRUE);
-$group->grid->setBackgroundColor(new White);
-
-$group->axis->left->setColor(new DarkGreen);
-$group->axis->left->label->setFont(new Font2);
-
-$group->axis->right->setColor(new DarkBlue);
-$group->axis->right->label->setFont(new Font2);
-
-$group->axis->bottom->label->setFont(new Font2);
-
-$group->legend->setPosition(1.18);
-$group->legend->setTextFont(new Tuffy(8));
-$group->legend->setSpace(10);
-
-// Add a bar plot
-$x = array(16, 16, 12, 13, 11, 18, 10, 12, 11, 12, 11, 16);
-
-$plot = new BarPlot($x, 1, 2);
-$plot->setBarColor(new MidYellow);
-$plot->setBarPadding(0.15, 0.15);
-$plot->barShadow->setSize(3);
-$plot->barShadow->smooth(TRUE);
-$plot->barShadow->setColor(new Color(200, 200, 200, 10));
-$plot->move(1, 0);
-
-$group->legend->add($plot, "Yellow bar", Legend::BACKGROUND);
-$group->add($plot);
-
-// Add a bar plot
-$x = array(20, 25, 20, 18, 16, 25, 29, 12, 15, 18, 21, 26);
-
-$plot = new BarPlot($x, 2, 2);
-$plot->setBarColor(new Color(120, 175, 80, 10));
-$plot->setBarPadding(0.15, 0.15);
-$plot->barShadow->setSize(3);
-$plot->barShadow->smooth(TRUE);
-$plot->barShadow->setColor(new Color(200, 200, 200, 10));
-
-$group->legend->add($plot, "Green bar", Legend::BACKGROUND);
-$group->add($plot);
-
-// Add a second bar plot
-$x = array(12, 14, 10, 9, 10, 16, 12, 8, 8, 10, 12, 13);
-
-$plot = new BarPlot($x, 2, 2);
-$plot->setBarColor(new Orange);
-$plot->setBarPadding(0.15, 0.15);
-
-$group->legend->add($plot, "Orange bar", Legend::BACKGROUND);
-$group->add($plot);
-
-// Add a line plot
-$x = array(6, 5, 6, 5.5, 4.5, 4, 4.5, 4, 5, 4, 5, 5.5);
-
-$plot = new LinePlot($x, LinePlot::MIDDLE);
-$plot->setColor(new DarkBlue);
-$plot->setThickness(5);
-$plot->setYAxis(Plot::RIGHT);
-$plot->setYMax(12);
-
-$plot->mark->setType(Mark::CIRCLE);
-$plot->mark->setSize(6);
-$plot->mark->setFill(new LightBlue);
-$plot->mark->border->show();
-
-$group->legend->add($plot, "Blue line", Legend::MARK);
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-006.php b/artichow/examples/site/line-006.php
deleted file mode 100644
index 23e29fa..0000000
--- a/artichow/examples/site/line-006.php
+++ /dev/null
@@ -1,58 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- -4, -5, -2, -8, -3, 1, 4, 9, 5, 6, 2
-);
-
-$plot = new LinePlot($x);
-$plot->setStyle(Line::DASHED);
-
-$plot->setSpace(4, 4, 10, 0);
-$plot->setPadding(25, 15, 10, 18);
-
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(230, 230, 230),
- new Color(255, 255, 255),
- 90
- )
-);
-
-$plot->setFilledArea(7, 9, new Red(25));
-$plot->setFilledArea(1, 4, new Yellow(25));
-
-$plot->setColor(new Color(0, 0, 150, 20));
-
-$plot->grid->setColor(new VeryLightGray);
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setSize(4);
-$plot->mark->setFill(new VeryDarkGreen(30));
-$plot->mark->border->show();
-$plot->mark->border->setColor(new DarkBlue(60));
-
-$plot->xAxis->label->hide(TRUE);
-$plot->xAxis->setNumberByTick('minor', 'major', 3);
-
-$plot->yAxis->setLabelNumber(8);
-
-$plot->legend->add($plot, "My line");
-$plot->legend->setPosition(0.9, 0.77);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/line-007.php b/artichow/examples/site/line-007.php
deleted file mode 100644
index feaaf04..0000000
--- a/artichow/examples/site/line-007.php
+++ /dev/null
@@ -1,70 +0,0 @@
-setAntiAliasing(TRUE);
-
-$group = new PlotGroup;
-$group->grid->setType(Line::DASHED);
-
-$group->setPadding(40, NULL, 20, NULL);
-
-$group->axis->left->setLabelNumber(8);
-$group->axis->left->setLabelPrecision(1);
-$group->axis->left->setTickStyle(Tick::OUT);
-
-$x = array(2, 4, 8, 16, 32, 48, 56, 60, 62);
-
-$plot = new LinePlot($x);
-$plot->setColor(new Orange());
-$plot->setFillColor(new LightOrange(80));
-
-$plot->mark->setType(Mark::CIRCLE);
-$plot->mark->setFill(new MidRed);
-$plot->mark->setSize(6);
-
-$group->legend->add($plot, "John", Legend::MARK);
-$group->add($plot);
-
-$x = array(NULL, NULL, NULL, 10, 12, 14, 18, 26, 42);
-
-$plot = new LinePlot($x);
-$plot->setColor(new Color(120, 120, 30, 10));
-$plot->setFillColor(new Color(120, 120, 60, 90));
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setFill(new DarkGreen);
-$plot->mark->setSize(5);
-
-$group->add($plot);
-
-function setYear($value) {
- return $value + 2000;
-}
-
-$group->axis->bottom->label->setCallbackFunction('setYear');
-
-function setK($value) {
- return round($value).'K';
-}
-
-$group->axis->left->label->setCallbackFunction('setK');
-
-$group->legend->add($plot, "George", Legend::MARK);
-$group->legend->setPosition(0.45, 0.25);
-$group->legend->shadow->smooth(TRUE);
-
-$graph->add($group);
-
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/logo.php b/artichow/examples/site/logo.php
deleted file mode 100644
index 7c1a4c5..0000000
--- a/artichow/examples/site/logo.php
+++ /dev/null
@@ -1,51 +0,0 @@
-setAntiAliasing(TRUE);
-$graph->border->hide();
-
-$x = array();
-for($i = 0; $i < 20; $i++) {
- $x[] = mt_rand(4, 12);
-}
-
-$plot = new LinePlot($x);
-
-$plot->setSpace(0, 0, 50, 0);
-$plot->setPadding(3, 3, 3, 3);
-
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(230, 230, 230),
- new Color(255, 255, 255),
- 0
- )
-);
-
-$plot->setColor(new Color(0, 0, 180, 20));
-
-$plot->setFillGradient(
- new LinearGradient(
- new Color(220, 220, 230, 25),
- new Color(240, 240, 255, 25),
- 90
- )
-);
-
-$plot->xAxis->hide(TRUE);
-$plot->yAxis->hide(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/math-001.php b/artichow/examples/site/math-001.php
deleted file mode 100644
index 191215a..0000000
--- a/artichow/examples/site/math-001.php
+++ /dev/null
@@ -1,45 +0,0 @@
-setInterval(0.2);
-$plot->setPadding(NULL, NULL, NULL, 20);
-
-$function = new MathFunction('cos');
-$function->setColor(new DarkGreen);
-$function->mark->setType(Mark::SQUARE);
-$function->mark->setSize(3);
-$plot->add($function, "f(x) = cos(x)", Legend::MARK);
-
-$function = new MathFunction('exp');
-$function->setColor(new DarkRed);
-$function->mark->setType(Mark::SQUARE);
-$function->mark->setSize(3);
-$function->mark->setFill(new DarkBlue);
-$plot->add($function, "f(x) = exp(x)", Legend::MARK);
-
-function x2($x) {
- return - $x * $x + 0.5;
-}
-
-$function = new MathFunction('x2');
-$function->setColor(new DarkBlue);
-$plot->add($function, "f(x) = - x * x + 0.5");
-
-$plot->legend->setPosition(0.9, 0.8);
-$plot->legend->setPadding(3, 3, 3, 3, 3);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-001.php b/artichow/examples/site/mini-001.php
deleted file mode 100644
index 8e2c376..0000000
--- a/artichow/examples/site/mini-001.php
+++ /dev/null
@@ -1,60 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 0, 2, 5, 2, 3, 8
-);
-
-$plot = new LinePlot($x);
-$plot->setXAxisZero(FALSE);
-$plot->grid->setNobackground();
-
-$plot->setSpace(6, 6, 10, 10);
-$plot->setPadding(30, 6, 8, 18);
-
-// Set a background gradient
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(255, 255, 255),
- 0
- )
-);
-
-// Change line color
-$plot->setColor(new Color(0, 0, 150, 20));
-
-// Set line background gradient
-$plot->setFillGradient(
- new LinearGradient(
- new Color(150, 150, 210),
- new Color(230, 230, 255),
- 0
- )
-);
-
-// Change mark type
-$plot->mark->setType(Mark::CIRCLE);
-$plot->mark->border->show();
-$plot->mark->setSize(6);
-
-$plot->yAxis->setLabelPrecision(1);
-$plot->yAxis->label->setFont(new Font1);
-$plot->xAxis->label->setFont(new Font1);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-002.php b/artichow/examples/site/mini-002.php
deleted file mode 100644
index 6224f6c..0000000
--- a/artichow/examples/site/mini-002.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
-);
-
-$plot = new LinePlot($x);
-$plot->grid->setNobackground();
-$plot->setPadding(20, 8, 8, 20);
-$plot->setXAxisZero(FALSE);
-
-// Set a background gradient
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(255, 255, 255),
- 0
- )
-);
-
-// Set semi-transparent background gradient
-$plot->setFillGradient(
- new LinearGradient(
- new Color(230, 150, 150, 20),
- new Color(230, 230, 180, 50),
- 90
- )
-);
-
-$plot->xAxis->label->hideFirst(TRUE);
-$plot->xAxis->label->hideLast(TRUE);
-$plot->xAxis->setNumberByTick('minor', 'major', 2);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-003.php b/artichow/examples/site/mini-003.php
deleted file mode 100644
index d988970..0000000
--- a/artichow/examples/site/mini-003.php
+++ /dev/null
@@ -1,56 +0,0 @@
-setPadding(22, 5, 25, 8);
-
-// Hide grid
-$plot->grid->setType(Line::DASHED);
-
-// Change background color
-$plot->setBackgroundColor(new Color(240, 240, 240, 50));
-
-// Set Y on both left and rights sides
-$plot->setYAxis(Plot::BOTH);
-
-// Change line properties
-$plot->setColor(new Color(0, 0, 0));
-$plot->setFillColor(new Color(240, 190, 130, 50));
-
-// Chenge ticks and labels interval
-$plot->xAxis->setTickInterval(2);
-$plot->xAxis->label->hide(TRUE);
-$plot->xAxis->setNumberByTick('minor', 'major', 1);
-
-// Hide first and last values on X axis
-$plot->xAxis->label->hideFirst(TRUE);
-$plot->xAxis->label->hideLast(TRUE);
-
-// Add a title
-$plot->title->set("Random values");
-$plot->title->move(0, 2);
-$plot->title->setFont(new Tuffy(8));
-$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
-$plot->title->border->show();
-$plot->title->setPadding(2, 2, 2, 2);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-004.php b/artichow/examples/site/mini-004.php
deleted file mode 100644
index 9247279..0000000
--- a/artichow/examples/site/mini-004.php
+++ /dev/null
@@ -1,59 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array(
- 1, 2, 5, 4, 2, 3
-);
-
-$plot = new LinePlot($x);
-
-// Change component padding
-$plot->setPadding(10, 12, 12, 7);
-
-// Set a background gradient
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(230, 230, 230),
- new Color(255, 255, 255),
- 0
- )
-);
-
-// Change line background color
-$plot->setFillGradient(
- new LinearGradient(
- new Color(200, 240, 215, 30),
- new Color(150, 190, 165, 30),
- 0
- )
-);
-
-// Hide grid
-$plot->grid->hide(TRUE);
-$plot->grid->setNobackground();
-
-$plot->yAxis->label->hide(TRUE);
-$plot->xAxis->label->hide(TRUE);
-
-$plot->label->set($x);
-$plot->label->setBackgroundColor(new Color(240, 240, 240, 10));
-$plot->label->border->setColor(new Color(255, 0, 0, 15));
-$plot->label->setPadding(3, 2, 0, 0);
-$plot->label->setFont(new Font1);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-005.php b/artichow/examples/site/mini-005.php
deleted file mode 100644
index 00c1bd7..0000000
--- a/artichow/examples/site/mini-005.php
+++ /dev/null
@@ -1,46 +0,0 @@
-setAntiAliasing(TRUE);
-
-$x = array();
-for($i = 0; $i < 10; $i++) {
- $x[] = mt_rand(1, 99) / 10;
-}
-
-$plot = new LinePlot($x);
-$plot->setBackgroundColor(new Color(240, 240, 240));
-$plot->setPadding(30, 8, 8, 20);
-
-$plot->setColor(
- new Color(60, 60, 150)
-);
-$plot->setFillGradient(
- new LinearGradient(
- new Color(120, 175, 80, 47),
- new Color(231, 172, 113, 30),
- 0
- )
-);
-
-$plot->grid->setType(Line::DASHED);
-
-$plot->yAxis->setLabelNumber(2);
-$plot->yAxis->setLabelPrecision(1);
-
-$plot->xAxis->setLabelInterval(2);
-$plot->xAxis->setNumberByTick('minor', 'major', 2);
-
-$graph->add($plot);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/mini-006.php b/artichow/examples/site/mini-006.php
deleted file mode 100644
index c2ef179..0000000
--- a/artichow/examples/site/mini-006.php
+++ /dev/null
@@ -1,53 +0,0 @@
-setAntiAliasing(TRUE);
-
-$group = new PlotGroup;
-$group->setXAxisZero(FALSE);
-$group->setBackgroundColor(new Color(197, 180, 210, 80));
-
-$group->setPadding(25, 10, 10, 20);
-
-$group->axis->left->setLabelNumber(2);
-$group->axis->left->setLabelPrecision(1);
-
-// Display two lines
-for($n = 0; $n < 2; $n++) {
-
- $x = array();
-
- for($i = 0; $i < 10; $i++) {
- $x[] = (cos($i * M_PI / 5)) / ($n + 1);
- }
-
- $plot = new LinePlot($x);
- $plot->setColor(color(10)); // Random line color
- $plot->setFillColor(color(90)); // Random background color
-
- $group->add($plot);
-
-}
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/pie-001.php b/artichow/examples/site/pie-001.php
deleted file mode 100644
index f0937a9..0000000
--- a/artichow/examples/site/pie-001.php
+++ /dev/null
@@ -1,42 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Stats");
-$graph->title->setFont(new TuffyItalic(16));
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values, Pie::EARTH);
-$plot->setCenter(0.4, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-$plot->explode(array(1 => 14, 4 => 20, 0 => 10));
-
-$plot->setLegend(array(
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun'
-));
-
-$plot->legend->setPosition(1.3);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/pie-002.php b/artichow/examples/site/pie-002.php
deleted file mode 100644
index 0c36eb3..0000000
--- a/artichow/examples/site/pie-002.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new White,
- new VeryLightGray(40),
- 0
- )
-);
-$graph->title->set("Horses");
-$graph->shadow->setSize(5);
-$graph->shadow->smooth(TRUE);
-$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
-$graph->shadow->setColor(new DarkGray);
-
-$values = array(8, 4, 6, 2, 5);
-
-$plot = new Pie($values);
-$plot->setCenter(0.35, 0.55);
-$plot->setSize(0.7, 0.6);
-$plot->set3D(10);
-$plot->setLabelPosition(10);
-
-$plot->setLegend(array(
- 'France',
- 'Spain',
- 'Italy',
- 'Germany',
- 'England'
-));
-
-$plot->legend->setPosition(1.40);
-$plot->legend->shadow->setSize(0);
-$plot->legend->setBackgroundColor(new VeryLightGray(30));
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/pie-003.php b/artichow/examples/site/pie-003.php
deleted file mode 100644
index 65080c8..0000000
--- a/artichow/examples/site/pie-003.php
+++ /dev/null
@@ -1,52 +0,0 @@
-setAntiAliasing(TRUE);
-
-$graph->title->set("Customized colors");
-$graph->title->setFont(new Tuffy(12));
-$graph->title->move(80, 10);
-
-$values = array(16, 9, 13, 23);
-$colors = array(
- new LightOrange,
- new LightPurple,
- new LightBlue,
- new LightRed,
- new LightPink
-);
-
-$plot = new Pie($values, $colors);
-$plot->setCenter(0.3, 0.53);
-$plot->setAbsSize(200, 200);
-$plot->setBorderColor(new White);
-$plot->setStartAngle(234);
-
-$plot->setLegend(array(
- 'Arthur',
- 'Abel',
- 'Pascal',
- 'Thamer'
-));
-
-$plot->setLabelPosition(-40);
-$plot->label->setPadding(2, 2, 2, 2);
-$plot->label->setFont(new Tuffy(7));
-$plot->label->setBackgroundColor(new White(60));
-
-$plot->legend->setPosition(1.38);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/pie-004.php b/artichow/examples/site/pie-004.php
deleted file mode 100644
index f8ad530..0000000
--- a/artichow/examples/site/pie-004.php
+++ /dev/null
@@ -1,53 +0,0 @@
-setBackgroundGradient(
- new LinearGradient(
- new VeryLightGray(40),
- new White,
- 90
- )
-);
-$graph->title->set("Arbitrary labels");
-$graph->title->setAngle(90);
-$graph->title->move(120, NULL);
-
-$values = array(8, 4, 6, 2, 5, 3, 4);
-
-$plot = new Pie($values);
-$plot->setCenter(0.45, 0.5);
-$plot->setSize(0.55, 0.55 * 300 / 175);
-
-$plot->label->set(array(
- 'Arthur', 'Abel', 'Bernard', 'Thierry', 'Paul', 'Gaston', 'Joe'
-));
-
-$plot->label->setCallbackFunction(NULL); // We must disable the default callback function
-$plot->setLabelPosition(10);
-
-$plot->setLegend(array(
- 'ABC',
- 'DEF',
- 'GHI',
- 'JKL',
- 'MNO',
- 'PQR',
- 'STU'
-));
-
-$plot->legend->hide(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/pie-005.php b/artichow/examples/site/pie-005.php
deleted file mode 100644
index c3524e2..0000000
--- a/artichow/examples/site/pie-005.php
+++ /dev/null
@@ -1,51 +0,0 @@
-title->set($title);
- $plot->title->setFont(new TuffyBold(9));
- $plot->title->move(NULL, -12);
-
- $plot->label->setFont(new Tuffy(7));
- $plot->legend->hide(TRUE);
- $plot->setLabelPosition(5);
- $plot->setSize(0.48, 0.35);
- $plot->setCenter($x, $y);
- $plot->set3D(8);
- $plot->setBorderColor(new White);
-
- return $plot;
-
-}
-
-$graph = new Graph(280, 350);
-$graph->setAntiAliasing(TRUE);
-
-$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.25, 0.24);
-$graph->add($plot);
-
-$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.75, 0.24);
-$graph->add($plot);
-
-$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.25, 0.65);
-$graph->add($plot);
-
-$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.75, 0.65);
-$plot->legend->setModel(Legend::MODEL_BOTTOM);
-$plot->setLegend(array('plip', 'plop', 'plap', 'plup', 'plep'));
-$plot->legend->hide(FALSE); // We print only one legend
-$plot->legend->setPosition(0, 1.10);
-$graph->add($plot);
-
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/scatter-001.php b/artichow/examples/site/scatter-001.php
deleted file mode 100644
index 173f0db..0000000
--- a/artichow/examples/site/scatter-001.php
+++ /dev/null
@@ -1,69 +0,0 @@
-title->move(-40, 0);
-$graph->title->set('Two circles');
-
-$group = new PlotGroup;
-$group->setBackgroundGradient(
- new LinearGradient(
- new VeryLightGray,
- new Color(245, 245, 245),
- 0
- )
-);
-
-$group->setPadding(25, 20, 40, 15);
-$group->setSpace(5, 5, 5, 5);
-
-$group->legend->setPosition(0.82, 0.1);
-$group->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
-
-function getCircle($size) {
-
- $center = 0;
-
- $x = array();
- $y = array();
-
- for($i = 0; $i <= 20; $i++) {
- $rad = ($i / 20) * 2 * M_PI;
- $x[] = $center + cos($rad) * $size;
- $y[] = $center + sin($rad) * $size;
- }
-
- return array($x, $y);
-
-}
-
-list($x, $y) = getCircle(3);
-
-$plot = new ScatterPlot($y, $x);
-
-$plot->link(TRUE, new DarkBlue);
-
-$plot->mark->setFill(new DarkPink);
-$plot->mark->setType(Mark::CIRCLE, 6);
-
-$group->legend->add($plot, 'Circle #1', Legend::MARK);
-$group->add($plot);
-
-list($x, $y) = getCircle(5);
-
-$plot = new ScatterPlot($y, $x);
-
-$plot->link(TRUE, new DarkGreen);
-
-$plot->mark->setFill(new DarkOrange);
-$plot->mark->setType(Mark::SQUARE, 4);
-
-$group->legend->add($plot, 'Circle #2', Legend::MARK);
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/scatter-002.php b/artichow/examples/site/scatter-002.php
deleted file mode 100644
index 66592a7..0000000
--- a/artichow/examples/site/scatter-002.php
+++ /dev/null
@@ -1,30 +0,0 @@
-title->set('Simple ScatterPlot');
-$graph->shadow->setSize(4);
-
-$y = array(1, 1.3, 1.8, 1.6, 10, 7, 8, 3, 4, 2, 4);
-$x = array(0.5, 0.7, 0.65, 0.9, 0.5, 1.5, 4, 3, 5, 2, 2);
-
-$plot = new ScatterPlot($y, $x);
-$plot->setBackgroundColor(new Color(255, 245, 220));
-
-$plot->mark->setSize(15);
-$plot->mark->setFill(
- new RadialGradient(
- new LightRed,
- new Red
- )
-);
-
-$plot->setSpace(6, 6, 6, 0);
-$plot->setPadding(25, NULL, 40, 20);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/site/scatter-003.php b/artichow/examples/site/scatter-003.php
deleted file mode 100644
index 79d8fac..0000000
--- a/artichow/examples/site/scatter-003.php
+++ /dev/null
@@ -1,34 +0,0 @@
-title->set('Linked ScatterPlot');
-$graph->title->setFont(new TuffyItalic(14));
-$graph->shadow->setSize(4);
-
-$y = array(1, 10, 7, 8, 5, 4, 2, 4);
-$x = array(0.5, 0.5, 1.5, 4, 3, 5, 2, 2);
-
-$plot = new ScatterPlot($y, $x);
-$plot->setBackgroundColor(new Color(235, 235, 235));
-
-$plot->mark->setSize(15);
-$plot->mark->setFill(
- new RadialGradient(
- new LightGreen,
- new DarkGreen
- )
-);
-
-$plot->link(TRUE);
-$plot->setColor(new DarkGreen);
-
-$plot->setSpace(6, 6, 6, 0);
-$plot->setPadding(25, NULL, 40, 20);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/test/error-box.php b/artichow/examples/test/error-box.php
deleted file mode 100644
index 5c13626..0000000
--- a/artichow/examples/test/error-box.php
+++ /dev/null
@@ -1,69 +0,0 @@
-getDriver();
-
-// Display title
-$driver->filledRectangle(
- new White,
- new Line(
- new Point(0, 0),
- new Point($width, $height)
- )
-);
-
-$driver->filledRectangle(
- new Red,
- new Line(
- new Point(0, 0),
- new Point(110, 25)
- )
-);
-
-$text = new Text(
- "Artichow error",
- new Font3,
- new White,
- 0
-);
-
-$driver->string($text, new Point(5, 6));
-
-// Display red box
-$driver->rectangle(
- new Red,
- new Line(
- new Point(0, 25),
- new Point($width - 90, $height - 1)
- )
-);
-
-// Display error image
-$image = new FileImage('error.png');
-$driver->copyImage($image, new Point($width - 81, $height - 81), new Point($width - 1, $height - 1));
-
-// Draw message
-$text = new Text(
- $message,
- new Font2,
- new Black,
- 0
-);
-
-$driver->string($text, new Point(10, 40));
-
-$graph->draw();
-
-?>
diff --git a/artichow/examples/test/error.png b/artichow/examples/test/error.png
deleted file mode 100644
index e5addb1..0000000
Binary files a/artichow/examples/test/error.png and /dev/null differ
diff --git a/artichow/examples/test/multi-line-text.php b/artichow/examples/test/multi-line-text.php
deleted file mode 100644
index 70a8d80..0000000
--- a/artichow/examples/test/multi-line-text.php
+++ /dev/null
@@ -1,37 +0,0 @@
-getDriver();
-
-$driver->filledRectangle(
- new Red,
- new Line(
- new Point(200, 0),
- new Point(200, 600)
- )
-);
-
-$text = new Text(
- "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean gravida quam semper nibh. Sed orci. Aenean ullamcorper magna eget odio. Sed nonummy ante sit amet sapien.\nPhasellus nulla dui, aliquet vel, adipiscing vel, vulputate sed, velit.\nSed at neque vel ipsum commodo hendrerit.\nA. Nonyme",
- new Tuffy(mt_rand(10, 15)),
- new Color(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)),
- 0
-);
-
-$driver->string($text, new Point(0, 0), 200);
-
-$text = new Text(
- "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean gravida quam semper nibh. Sed orci. Aenean ullamcorper magna eget odio. Sed nonummy ante sit amet sapien.\nPhasellus nulla dui, aliquet vel, adipiscing vel, vulputate sed, velit.\nSed at neque vel ipsum commodo hendrerit.\nA. Nonyme",
- new Font(mt_rand(2, 4)),
- new Color(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)),
- 0
-);
-
-$driver->string($text, new Point(0, 400), 200);
-
-$graph->draw();
-
-?>
diff --git a/artichow/examples/test/set-label-text-error.php b/artichow/examples/test/set-label-text-error.php
deleted file mode 100644
index f99cf22..0000000
--- a/artichow/examples/test/set-label-text-error.php
+++ /dev/null
@@ -1,58 +0,0 @@
-setAntiAliasing(TRUE);
-
-$values = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0);
-
-$plot = new BarPlot($values);
-$plot->setBarColor(
- new Color(234, 236, 255)
-);
-$plot->setSpace(5, 5, NULL, NULL);
-
-$plot->barShadow->setSize(3);
-$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
-$plot->barShadow->setColor(new Color(180, 180, 180, 10));
-$plot->barShadow->smooth(TRUE);
-
-
-$mois = array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc');
-$label = array ();
-foreach ($mois as $m) { $label []= $m; }
-$label []= ' ';
-foreach ($mois as $m) { $label []= $m; }
-
-
-$plot->xAxis->setLabelText($label);
-
-/* ICI */
-
- $max = array_max($values);
- $yValues = array();
- for($i=0; $i<= $max; $i++) {
- $yValues[]=$i;
- }
- $plot->yAxis->setLabelText($yValues);
-
- // Image::drawError(var_export($yValues, TRUE));
-$plot->yAxis->setLabelText($yValues);
-
-$plot->setPadding(30,5,20,15);
-
-$labelAvant = new Label("2005");
-$labelAvant->setFont (new TTFFont(ARTICHOW_FONT.'/TuffyBold.ttf', 12));
-$labelAvant->move (180,10);
-
-$labelMaintenant = new Label("2006");
-$labelMaintenant->setFont (new TTFFont(ARTICHOW_FONT.'/TuffyBold.ttf', 12));
-$labelMaintenant->move (450,10);
-
-$graph->add($plot);
-$graph->addLabel($labelAvant, 0, 0);
-$graph->addLabel($labelMaintenant, 0, 0);
-
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/AntiSpam/form.php b/artichow/examples/tutorials/AntiSpam/form.php
deleted file mode 100644
index f242a76..0000000
--- a/artichow/examples/tutorials/AntiSpam/form.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/artichow/examples/tutorials/AntiSpam/spam.php b/artichow/examples/tutorials/AntiSpam/spam.php
deleted file mode 100644
index 051f032..0000000
--- a/artichow/examples/tutorials/AntiSpam/spam.php
+++ /dev/null
@@ -1,18 +0,0 @@
-setRand(5);
-
-// On assigne un nom à cette image pour vérifier
-// ultérieurement la valeur fournie par l'utilisateur
-$object->save('example');
-
-// On affiche l'image à l'écran
-$object->draw();
-
-?>
diff --git a/artichow/examples/tutorials/AntiSpam/valid.php b/artichow/examples/tutorials/AntiSpam/valid.php
deleted file mode 100644
index e2f5ef7..0000000
--- a/artichow/examples/tutorials/AntiSpam/valid.php
+++ /dev/null
@@ -1,11 +0,0 @@
-check('example', $_GET['code'])) {
- echo "Good value :-)";
-} else {
- echo "Bad value :-(";
-}
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/bar-Bars.php b/artichow/examples/tutorials/bar-Bars.php
deleted file mode 100644
index e2788a7..0000000
--- a/artichow/examples/tutorials/bar-Bars.php
+++ /dev/null
@@ -1,47 +0,0 @@
-setAntiAliasing(TRUE);
-
-$blue = new Color(0, 0, 200);
-$red = new Color(200, 0, 0);
-
-$group = new PlotGroup;
-$group->setPadding(40, 40);
-$group->setBackgroundColor(
- new Color(240, 240, 240)
-);
-
-$values = array(12, 8, 20, 32, 15, 5);
-
-$plot = new BarPlot($values, 1, 2);
-$plot->setBarColor($blue);
-$plot->setYAxis(Plot::LEFT);
-
-$group->add($plot);
-$group->axis->left->setColor($blue);
-$group->axis->left->title->set("Blue bars");
-
-$values = array(6, 12, 14, 2, 11, 7);
-
-$plot = new BarPlot($values, 2, 2);
-$plot->setBarColor($red);
-$plot->setYAxis(Plot::RIGHT);
-
-$group->add($plot);
-$group->axis->right->setColor($red);
-$group->axis->right->title->set("Red bars");
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/bar-Simple.php b/artichow/examples/tutorials/bar-Simple.php
deleted file mode 100644
index 54576d0..0000000
--- a/artichow/examples/tutorials/bar-Simple.php
+++ /dev/null
@@ -1,31 +0,0 @@
-setAntiAliasing(TRUE);
-
-$values = array(19, 42, 15, -25, 3);
-$plot = new BarPlot($values);
-$plot->setBarColor(
- new Color(250, 230, 180)
-);
-$plot->setSpace(5, 5, NULL, NULL);
-
-$plot->barShadow->setSize(4);
-$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
-$plot->barShadow->setColor(new Color(180, 180, 180, 10));
-$plot->barShadow->smooth(TRUE);
-
-$graph->add($plot);
-$graph->draw();
-
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/base-Color.php b/artichow/examples/tutorials/base-Color.php
deleted file mode 100644
index 94dd008..0000000
--- a/artichow/examples/tutorials/base-Color.php
+++ /dev/null
@@ -1,40 +0,0 @@
-border->hide();
-
-$driver = $graph->getDriver();
-
-for($i = 7; $i < 400; $i += 15) {
- $driver->line(
- new Color(0, 0, 0),
- new Line(
- new Point($i, 0),
- new Point($i, 30)
- )
- );
-}
-
-for($i = 7; $i < 30; $i += 15) {
- $driver->line(
- new Color(0, 0, 0),
- new Line(
- new Point(0, $i),
- new Point(400, $i)
- )
- );
-}
-
-$driver->filledRectangle(
- new Color(0, 100, 200, 50),
- new Line(
- new Point(0, 0),
- new Point(400, 30)
- )
-);
-
-$graph->draw();
-
-?>
diff --git a/artichow/examples/tutorials/base-Gradient-linear.php b/artichow/examples/tutorials/base-Gradient-linear.php
deleted file mode 100644
index 326aa1e..0000000
--- a/artichow/examples/tutorials/base-Gradient-linear.php
+++ /dev/null
@@ -1,25 +0,0 @@
-border->hide();
-
-$driver = $graph->getDriver();
-
-$driver->filledRectangle(
- new LinearGradient(
- new Black,
- new White,
- 0
- ),
- new Line(
- new Point(0, 0),
- new Point(400, 30)
- )
-);
-
-$graph->draw();
-
-?>
diff --git a/artichow/examples/tutorials/base-Gradient-radial.php b/artichow/examples/tutorials/base-Gradient-radial.php
deleted file mode 100644
index b9761cc..0000000
--- a/artichow/examples/tutorials/base-Gradient-radial.php
+++ /dev/null
@@ -1,24 +0,0 @@
-border->hide();
-
-$driver = $graph->getDriver();
-
-$start = new Color(125, 250, 0);
-$end = new Color(0, 125, 125);
-
-// On dessine le dégradé radial dans un cercle
-$driver->filledEllipse(
- new RadialGradient(
- $start,
- $end
- ),
- new Point(125, 125),
- 250, 250
-);
-
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/line-Customize.php b/artichow/examples/tutorials/line-Customize.php
deleted file mode 100644
index 0212ffe..0000000
--- a/artichow/examples/tutorials/line-Customize.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setAntiAliasing(TRUE);
-
-$values = array(1, 7, 3, 2.5, 5, -4.5, -5);
-$plot = new LinePlot($values);
-$plot->setBackgroundColor(new Color(245, 245, 245));
-
-$plot->hideLine(TRUE);
-$plot->setFillColor(new Color(180, 180, 180, 75));
-
-$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
-
-$plot->yAxis->setLabelPrecision(2);
-$plot->yAxis->setLabelNumber(6);
-
-$days = array(
- 'Lundi',
- 'Mardi',
- 'Mercredi',
- 'Jeudi',
- 'Vendredi',
- 'Samedi',
- 'Dimanche'
-);
-$plot->xAxis->setLabelText($days);
-
-$plot->setSpace(6, 6, 10, 10);
-
-$plot->mark->setType(Mark::IMAGE);
-$plot->mark->setImage(new FileImage("smiley.png"));
-
-$plot->label->set($values);
-$plot->label->move(0, -23);
-$plot->label->setBackgroundGradient(
- new LinearGradient(
- new Color(250, 250, 250, 10),
- new Color(255, 200, 200, 30),
- 0
- )
-);
-$plot->label->border->setColor(new Color(20, 20, 20, 20));
-$plot->label->setPadding(3, 1, 1, 0);
-
-$graph->add($plot);
-$graph->draw();
-?>
diff --git a/artichow/examples/tutorials/line-Lines.php b/artichow/examples/tutorials/line-Lines.php
deleted file mode 100644
index 41b95e1..0000000
--- a/artichow/examples/tutorials/line-Lines.php
+++ /dev/null
@@ -1,49 +0,0 @@
-setAntiAliasing(TRUE);
-
-$blue = new Color(0, 0, 200);
-$red = new Color(200, 0, 0);
-
-$group = new PlotGroup;
-$group->setBackgroundColor(
- new Color(240, 240, 240)
-);
-$group->setPadding(40, 40);
-
-$values = array(12, 5, 20, 32, 15, 4, 16);
-
-$plot = new LinePlot($values);
-$plot->setColor($blue);
-$plot->setYAxis(Plot::LEFT);
-
-$group->add($plot);
-
-$group->axis->left->setColor($blue);
-$group->axis->left->title->set("Blue line");
-
-$values = array(6, 12, 14, 2, 11, 5, 21);
-
-$plot = new LinePlot($values);
-$plot->setColor($red);
-$plot->setYAxis(Plot::RIGHT);
-
-$group->add($plot);
-
-$group->axis->right->setColor($red);
-$group->axis->right->title->set("Red line");
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/line-Simple.php b/artichow/examples/tutorials/line-Simple.php
deleted file mode 100644
index 7aeb88b..0000000
--- a/artichow/examples/tutorials/line-Simple.php
+++ /dev/null
@@ -1,22 +0,0 @@
-setAntiAliasing(FALSE);
-
-$values = array(1, 4, 5, -2.5, 3);
-$plot = new LinePlot($values);
-$plot->setBackgroundGradient(
- new LinearGradient(
- new Color(210, 210, 210),
- new Color(250, 250, 250),
- 0
- )
-);
-$plot->yAxis->setLabelPrecision(1);
-$plot->setSpace(5, 5, NULL, NULL);
-
-$graph->add($plot);
-$graph->draw();
-?>
diff --git a/artichow/examples/tutorials/plot-More.php b/artichow/examples/tutorials/plot-More.php
deleted file mode 100644
index ec4300b..0000000
--- a/artichow/examples/tutorials/plot-More.php
+++ /dev/null
@@ -1,47 +0,0 @@
-setAntiAliasing(TRUE);
-
-$blue = new Color(150, 150, 230, 50);
-$red = new Color(240, 50, 50, 25);
-
-$group = new PlotGroup;
-$group->setSpace(5, 5, 5, 0);
-$group->setBackgroundColor(
- new Color(240, 240, 240)
-);
-
-$values = array(18, 12, 14, 21, 11, 7, 9, 16, 7, 23);
-
-$plot = new BarPlot($values);
-$plot->setBarColor($red);
-
-$group->add($plot);
-
-$values = array(12, 8, 6, 12, 7, 5, 4, 9, 3, 12);
-
-$plot = new LinePlot($values, LinePlot::MIDDLE);
-$plot->setFillColor($blue);
-
-$plot->mark->setType(Mark::SQUARE);
-$plot->mark->setSize(7);
-$plot->mark->setFill(new Color(255, 255, 255));
-$plot->mark->border->show();
-
-$group->add($plot);
-
-$graph->add($group);
-$graph->draw();
-?>
\ No newline at end of file
diff --git a/artichow/examples/tutorials/smiley.png b/artichow/examples/tutorials/smiley.png
deleted file mode 100644
index 454a82f..0000000
Binary files a/artichow/examples/tutorials/smiley.png and /dev/null differ
diff --git a/artichow/font/Tuffy.ttf b/artichow/font/Tuffy.ttf
deleted file mode 100644
index 8151817..0000000
Binary files a/artichow/font/Tuffy.ttf and /dev/null differ
diff --git a/artichow/font/TuffyBold.ttf b/artichow/font/TuffyBold.ttf
deleted file mode 100644
index 2f45b4f..0000000
Binary files a/artichow/font/TuffyBold.ttf and /dev/null differ
diff --git a/artichow/font/TuffyBoldItalic.ttf b/artichow/font/TuffyBoldItalic.ttf
deleted file mode 100644
index 554faf2..0000000
Binary files a/artichow/font/TuffyBoldItalic.ttf and /dev/null differ
diff --git a/artichow/font/TuffyItalic.ttf b/artichow/font/TuffyItalic.ttf
deleted file mode 100644
index 5f972ec..0000000
Binary files a/artichow/font/TuffyItalic.ttf and /dev/null differ
diff --git a/artichow/images/book.png b/artichow/images/book.png
deleted file mode 100644
index da18851..0000000
Binary files a/artichow/images/book.png and /dev/null differ
diff --git a/artichow/images/error.png b/artichow/images/error.png
deleted file mode 100644
index e5addb1..0000000
Binary files a/artichow/images/error.png and /dev/null differ
diff --git a/artichow/images/errors/missing-anti-aliasing.png b/artichow/images/errors/missing-anti-aliasing.png
deleted file mode 100644
index f020d26..0000000
Binary files a/artichow/images/errors/missing-anti-aliasing.png and /dev/null differ
diff --git a/artichow/images/errors/missing-gd2.png b/artichow/images/errors/missing-gd2.png
deleted file mode 100644
index cac144c..0000000
Binary files a/artichow/images/errors/missing-gd2.png and /dev/null differ
diff --git a/artichow/images/paperclip.png b/artichow/images/paperclip.png
deleted file mode 100644
index 12188f9..0000000
Binary files a/artichow/images/paperclip.png and /dev/null differ
diff --git a/artichow/images/star.png b/artichow/images/star.png
deleted file mode 100644
index 4acf003..0000000
Binary files a/artichow/images/star.png and /dev/null differ
diff --git a/artichow/inc/Axis.class.php b/artichow/inc/Axis.class.php
deleted file mode 100644
index cbb12b7..0000000
--- a/artichow/inc/Axis.class.php
+++ /dev/null
@@ -1,769 +0,0 @@
- 'toProportionalValue',
- 'toPosition' => 'toProportionalPosition'
- );
-
- /**
- * Build the axis
- *
- * @param float $min Begin of the range of the axis
- * @param float $max End of the range of the axis
- */
- public function __construct($min = NULL, $max = NULL) {
-
- $this->line = new awVector(
- new awPoint(0, 0),
- new awPoint(0, 0)
- );
-
- $this->label = new awLabel;
- $this->padding = new awSide;
-
- $this->title = new awLabel(
- NULL,
- NULL,
- NULL,
- 0
- );
-
- $this->setColor(new awBlack);
-
- if($min !== NULL and $max !== NULL) {
- $this->setRange($min, $max);
- }
-
- }
-
- /**
- * Enable/disable auto-scaling mode
- *
- * @param bool $auto
- */
- public function auto($auto) {
- $this->auto = (bool)$auto;
- }
-
- /**
- * Get auto-scaling mode status
- *
- * @return bool
- */
- public function isAuto() {
- return $this->auto;
- }
-
- /**
- * Hide axis
- *
- * @param bool $hide
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show axis
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = !(bool)$show;
- }
-
- /**
- * Return a tick object from its name
- *
- * @param string $name Tick object name
- * @return Tick
- */
- public function tick($name) {
-
- return array_key_exists($name, $this->ticks) ? $this->ticks[$name] : NULL;
-
- }
-
- /**
- * Add a tick object
- *
- * @param string $name Tick object name
- * @param awTick $tick Tick object
- */
- public function addTick($name, awTick $tick) {
-
- $this->ticks[$name] = $tick;
-
- }
-
- /**
- * Delete a tick object
- *
- * @param string $name Tick object name
- */
- public function deleteTick($name) {
- if(array_key_exists($name, $this->ticks)) {
- unset($this->ticks[$name]);
- }
- }
-
- /**
- * Hide all ticks
- *
- * @param bool $hide Hide or not ?
- */
- public function hideTicks($hide = TRUE) {
-
- foreach($this->ticks as $tick) {
- $tick->hide($hide);
- }
-
- }
-
- /**
- * Change ticks style
- *
- * @param int $style Ticks style
- */
- public function setTickStyle($style) {
-
- foreach($this->ticks as $tick) {
- $tick->setStyle($style);
- }
-
- }
-
- /**
- * Change ticks interval
- *
- * @param int $interval Ticks interval
- */
- public function setTickInterval($interval) {
-
- foreach($this->ticks as $tick) {
- $tick->setInterval($interval);
- }
-
- }
-
- /**
- * Change number of ticks relative to others ticks
- *
- * @param awTick $to Change number of theses ticks
- * @param awTick $from Ticks reference
- * @param float $number Number of ticks by the reference
- */
- public function setNumberByTick($to, $from, $number) {
- $this->ticks[$to]->setNumberByTick($this->ticks[$from], $number);
- }
-
- /**
- * Reverse ticks style
- */
- public function reverseTickStyle() {
-
- foreach($this->ticks as $tick) {
- if($tick->getStyle() === awTick::IN) {
- $tick->setStyle(awTick::OUT);
- } else if($tick->getStyle() === awTick::OUT) {
- $tick->setStyle(awTick::IN);
- }
- }
-
- }
-
- /**
- * Change interval of labels
- *
- * @param int $interval Interval
- */
- public function setLabelInterval($interval) {
- $this->auto(FALSE);
- $this->setTickInterval($interval);
- $this->label->setInterval($interval);
- }
-
- /**
- * Change number of labels
- *
- * @param int $number Number of labels to display (can be NULL)
- */
- public function setLabelNumber($number) {
- $this->auto(FALSE);
- $this->labelNumber = is_null($number) ? NULL : (int)$number;
- }
-
- /**
- * Get number of labels
- *
- * @return int
- */
- public function getLabelNumber() {
- return $this->labelNumber;
- }
-
- /**
- * Change precision of labels
- *
- * @param int $precision Precision
- */
- public function setLabelPrecision($precision) {
- $this->auto(FALSE);
- $function = 'axis'.time().'_'.(microtime() * 1000000);
- eval('function '.$function.'($value) {
- return sprintf("%.'.(int)$precision.'f", $value);
- }');
- $this->label->setCallbackFunction($function);
- }
-
- /**
- * Change text of labels
- *
- * @param array $texts Some texts
- */
- public function setLabelText($texts) {
- if(is_array($texts)) {
- $this->auto(FALSE);
- $function = 'axis'.time().'_'.(microtime() * 1000000);
- eval('function '.$function.'($value) {
- $texts = '.var_export($texts, TRUE).';
- return isset($texts[$value]) ? $texts[$value] : \'?\';
- }');
- $this->label->setCallbackFunction($function);
- }
- }
-
- /**
- * Get the position of a point
- *
- * @param awAxis $xAxis X axis
- * @param awAxis $yAxis Y axis
- * @param awPoint $p Position of the point
- * @return Point Position on the axis
- */
- public static function toPosition(awAxis $xAxis, awAxis $yAxis, awPoint $p) {
-
- $p1 = $xAxis->getPointFromValue($p->x);
- $p2 = $yAxis->getPointFromValue($p->y);
-
- return new awPoint(
- round($p1->x),
- round($p2->y)
- );
-
- }
-
- /**
- * Change title alignment
- *
- * @param int $alignment New Alignment
- */
- public function setTitleAlignment($alignment) {
-
- switch($alignment) {
-
- case awLabel::TOP :
- $this->setTitlePosition(1);
- $this->title->setAlign(NULL, awLabel::BOTTOM);
- break;
-
- case awLabel::BOTTOM :
- $this->setTitlePosition(0);
- $this->title->setAlign(NULL, awLabel::TOP);
- break;
-
- case awLabel::LEFT :
- $this->setTitlePosition(0);
- $this->title->setAlign(awLabel::LEFT);
- break;
-
- case awLabel::RIGHT :
- $this->setTitlePosition(1);
- $this->title->setAlign(awLabel::RIGHT);
- break;
-
- }
-
- }
-
- /**
- * Change title position on the axis
- *
- * @param float $position A new awposition between 0 and 1
- */
- public function setTitlePosition($position) {
- $this->titlePosition = (float)$position;
- }
-
- /**
- * Change axis and axis title color
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- $this->title->setColor($color);
- }
-
- /**
- * Change axis padding
- *
- * @param int $left Left padding in pixels
- * @param int $right Right padding in pixels
- */
- public function setPadding($left, $right) {
- $this->padding->set($left, $right);
- }
-
- /**
- * Get axis padding
- *
- * @return Side
- */
- public function getPadding() {
- return $this->padding;
- }
-
- /**
- * Change axis range
- *
- * @param float $min
- * @param float $max
- */
- public function setRange($min, $max) {
- if($min !== NULL) {
- $this->range[0] = (float)$min;
- }
- if($max !== NULL) {
- $this->range[1] = (float)$max;
- }
- }
-
- /**
- * Get axis range
- *
- * @return array
- */
- public function getRange() {
- return $this->range;
- }
-
- /**
- * Change axis range callback function
- *
- * @param string $toValue Transform a position between 0 and 1 to a value
- * @param string $toPosition Transform a value to a position between 0 and 1 on the axis
- */
- public function setRangeCallback($toValue, $toPosition) {
- $this->rangeCallback = array(
- 'toValue' => (string)$toValue,
- 'toPosition' => (string)$toPosition
- );
- }
-
- /**
- * Center X values of the axis
- *
- * @param awAxis $axis An axis
- * @param float $value The reference value on the axis
- */
- public function setXCenter(awAxis $axis, $value) {
-
- // Check vector angle
- if($this->line->isVertical() === FALSE) {
- awImage::drawError("Class Axis: setXCenter() can only be used on vertical axes.");
- }
-
- $p = $axis->getPointFromValue($value);
-
- $this->line->setX(
- $p->x,
- $p->x
- );
-
- }
-
- /**
- * Center Y values of the axis
- *
- * @param awAxis $axis An axis
- * @param float $value The reference value on the axis
- */
- public function setYCenter(awAxis $axis, $value) {
-
- // Check vector angle
- if($this->line->isHorizontal() === FALSE) {
- awImage::drawError("Class Axis: setYCenter() can only be used on horizontal axes.");
- }
-
- $p = $axis->getPointFromValue($value);
-
- $this->line->setY(
- $p->y,
- $p->y
- );
-
- }
-
- /**
- * Get the distance between to values on the axis
- *
- * @param float $from The first value
- * @param float $to The last value
- * @return Point
- */
- public function getDistance($from, $to) {
-
- $p1 = $this->getPointFromValue($from);
- $p2 = $this->getPointFromValue($to);
-
- return $p1->getDistance($p2);
-
- }
-
- /**
- * Get a point on the axis from a value
- *
- * @param float $value
- * @return Point
- */
- protected function getPointFromValue($value) {
-
- $callback = $this->rangeCallback['toPosition'];
-
- list($min, $max) = $this->range;
- $position = $callback($value, $min, $max);
-
- return $this->getPointFromPosition($position);
-
- }
-
- /**
- * Get a point on the axis from a position
- *
- * @param float $position A position between 0 and 1
- * @return Point
- */
- protected function getPointFromPosition($position) {
-
- $vector = $this->getVector();
-
- $angle = $vector->getAngle();
- $size = $vector->getSize();
-
- return $vector->p1->move(
- cos($angle) * $size * $position,
- -1 * sin($angle) * $size * $position
- );
-
- }
-
- /**
- * Draw axis
- *
- * @param awDriver $driver A driver
- */
- public function draw(awDriver $driver) {
-
- if($this->hide) {
- return;
- }
-
- $vector = $this->getVector();
-
- // Draw axis ticks
- $this->drawTicks($driver, $vector);
-
- // Draw axis line
- $this->line($driver);
-
- // Draw labels
- $this->drawLabels($driver);
-
- // Draw axis title
- $p = $this->getPointFromPosition($this->titlePosition);
- $this->title->draw($driver, $p);
-
- }
-
- public function autoScale() {
-
- if($this->isAuto() === FALSE) {
- return;
- }
-
- list($min, $max) = $this->getRange();
- $interval = $max - $min;
-
- if($interval > 0) {
- $partMax = $max / $interval;
- $partMin = $min / $interval;
- } else {
- $partMax = 0;
- $partMin = 0;
- }
-
- $difference = log($interval) / log(10);
- $difference = floor($difference);
-
- $pow = pow(10, $difference);
-
- if($pow > 0) {
- $intervalNormalize = $interval / $pow;
- } else {
- $intervalNormalize = 0;
- }
-
- if($difference <= 0) {
-
- $precision = $difference * -1 + 1;
-
- if($intervalNormalize > 2) {
- $precision--;
- }
-
- } else {
- $precision = 0;
- }
-
- if($min != 0 and $max != 0) {
- $precision++;
- }
-
- if($this->label->getCallbackFunction() === NULL) {
- $this->setLabelPrecision($precision);
- }
-
- if($intervalNormalize <= 1.5) {
- $intervalReal = 1.5;
- $labelNumber = 4;
- } else if($intervalNormalize <= 2) {
- $intervalReal = 2;
- $labelNumber = 5;
- } else if($intervalNormalize <= 3) {
- $intervalReal = 3;
- $labelNumber = 4;
- } else if($intervalNormalize <= 4) {
- $intervalReal = 4;
- $labelNumber = 5;
- } else if($intervalNormalize <= 5) {
- $intervalReal = 5;
- $labelNumber = 6;
- } else if($intervalNormalize <= 8) {
- $intervalReal = 8;
- $labelNumber = 5;
- } else if($intervalNormalize <= 10) {
- $intervalReal = 10;
- $labelNumber = 6;
- }
-
- if($min == 0) {
-
- $this->setRange(
- $min,
- $intervalReal * $pow
- );
-
- } else if($max == 0) {
-
- $this->setRange(
- $intervalReal * $pow * -1,
- 0
- );
-
- }
-
- $this->setLabelNumber($labelNumber);
-
- }
-
- protected function line(awDriver $driver) {
-
- $driver->line(
- $this->color,
- $this->line
- );
-
- }
-
- protected function drawTicks(awDriver $driver, awVector $vector) {
-
- foreach($this->ticks as $tick) {
- $tick->setColor($this->color);
- $tick->draw($driver, $vector);
- }
-
- }
-
- protected function drawLabels($driver) {
-
- if($this->labelNumber !== NULL) {
- list($min, $max) = $this->range;
- $number = $this->labelNumber - 1;
- if($number < 1) {
- return;
- }
- $function = $this->rangeCallback['toValue'];
- $labels = array();
- for($i = 0; $i <= $number; $i++) {
- $labels[] = $function($i / $number, $min, $max);
- }
- $this->label->set($labels);
- }
-
- $labels = $this->label->count();
-
- for($i = 0; $i < $labels; $i++) {
-
- $p = $this->getPointFromValue($this->label->get($i));
- $this->label->draw($driver, $p, $i);
-
- }
-
- }
-
- protected function getVector() {
-
- $angle = $this->line->getAngle();
-
- // Compute paddings
- $vector = new awVector(
- $this->line->p1->move(
- cos($angle) * $this->padding->left,
- -1 * sin($angle) * $this->padding->left
- ),
- $this->line->p2->move(
- -1 * cos($angle) * $this->padding->right,
- -1 * -1 * sin($angle) * $this->padding->right
- )
- );
-
- return $vector;
-
- }
-
- public function __clone() {
-
- $this->label = clone $this->label;
- $this->line = clone $this->line;
- $this->title = clone $this->title;
-
- foreach($this->ticks as $name => $tick) {
- $this->ticks[$name] = clone $tick;
- }
-
- }
-
-}
-
-registerClass('Axis');
-
-function toProportionalValue($position, $min, $max) {
- return $min + ($max - $min) * $position;
-}
-
-function toProportionalPosition($value, $min, $max) {
- if($max - $min == 0) {
- return 0;
- }
- return ($value - $min) / ($max - $min);
-}
-?>
\ No newline at end of file
diff --git a/artichow/inc/Border.class.php b/artichow/inc/Border.class.php
deleted file mode 100644
index 56182f0..0000000
--- a/artichow/inc/Border.class.php
+++ /dev/null
@@ -1,198 +0,0 @@
-setStyle($style);
-
- if($color instanceof awColor) {
- $this->setColor($color);
- } else {
- $this->setColor(new awBlack);
- }
-
- }
-
- /**
- * Change border color
- * This method automatically shows the border if it is hidden
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- $this->show();
- }
-
- /**
- * Change border style
- *
- * @param int $style
- */
- public function setStyle($style) {
- $this->style = (int)$style;
- }
-
- /**
- * Hide border ?
- *
- * @param bool $hide
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show border ?
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = (bool)!$show;
- }
-
- /**
- * Is the border visible ?
- *
- * @return bool
- */
- public function visible() {
- return !$this->hide;
- }
-
- /**
- * Draw border as a rectangle
- *
- * @param awDriver $driver
- * @param awPoint $p1 Top-left corner
- * @param awPoint $p2 Bottom-right corner
- */
- public function rectangle(awDriver $driver, awPoint $p1, awPoint $p2) {
-
- // Border is hidden
- if($this->hide) {
- return;
- }
-
- $line = new awLine;
- $line->setStyle($this->style);
- $line->setLocation($p1, $p2);
-
- $driver->rectangle($this->color, $line);
-
- }
-
- /**
- * Draw border as an ellipse
- *
- * @param awDriver $driver
- * @param awPoint $center Ellipse center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- */
- public function ellipse(awDriver $driver, awPoint $center, $width, $height) {
-
- // Border is hidden
- if($this->hide) {
- return;
- }
-
- switch($this->style) {
-
- case awLine::SOLID :
- $driver->ellipse($this->color, $center, $width, $height);
- break;
-
- default :
- awImage::drawError("Class Border: Dashed and dotted borders and not yet implemented on ellipses.");
- break;
-
- }
-
-
- }
-
- /**
- * Draw border as a polygon
- *
- * @param awDriver $driver A Driver object
- * @param awPolygon $polygon A Polygon object
- */
- public function polygon(awDriver $driver, awPolygon $polygon) {
-
- // Border is hidden
- if($this->hide) {
- return;
- }
-
- $polygon->setStyle($this->style);
- $driver->polygon($this->color, $polygon);
-
- // In case of Line::SOLID, Driver::polygon() uses imagepolygon()
- // which automatically closes the shape. In any other case,
- // we have to do it manually here.
- if($this->style !== Line::SOLID) {
- $this->closePolygon($driver, $polygon);
- }
- }
-
- /**
- * Draws the last line of a Polygon, between the first and last point
- *
- * @param awDriver $driver A Driver object
- * @param awPolygon $polygon The polygon object to close
- */
- private function closePolygon(awDriver $driver, awPolygon $polygon) {
- $first = $polygon->get(0);
- $last = $polygon->get($polygon->count() - 1);
-
- $line = new awLine($first, $last, $this->style, $polygon->getThickness());
- $driver->line($this->color, $line);
- }
-
-}
-
-registerClass('Border');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Color.class.php b/artichow/inc/Color.class.php
deleted file mode 100644
index f8a75f1..0000000
--- a/artichow/inc/Color.class.php
+++ /dev/null
@@ -1,165 +0,0 @@
-red = (int)$red;
- $this->green = (int)$green;
- $this->blue = (int)$blue;
- $this->alpha = (int)round($alpha * 127 / 100);
-
- }
-
- /**
- * Get RGB and alpha values of your color
- *
- * @return array
- */
- public function getColor() {
- return $this->rgba();
- }
-
- /**
- * Change color brightness
- *
- * @param int $brightness Add this intensity to the color (betweeen -255 and +255)
- */
- public function brightness($brightness) {
-
- $brightness = (int)$brightness;
-
- $this->red = min(255, max(0, $this->red + $brightness));
- $this->green = min(255, max(0, $this->green + $brightness));
- $this->blue = min(255, max(0, $this->blue + $brightness));
-
- }
-
- /**
- * Get RGB and alpha values of your color
- *
- * @return array
- */
- public function rgba() {
-
- return array($this->red, $this->green, $this->blue, $this->alpha);
-
- }
-
-}
-
-registerClass('Color');
-
-$colors = array(
- 'Black' => array(0, 0, 0),
- 'AlmostBlack' => array(48, 48, 48),
- 'VeryDarkGray' => array(88, 88, 88),
- 'DarkGray' => array(128, 128, 128),
- 'MidGray' => array(160, 160, 160),
- 'LightGray' => array(195, 195, 195),
- 'VeryLightGray' => array(220, 220, 220),
- 'White' => array(255, 255, 255),
- 'VeryDarkRed' => array(64, 0, 0),
- 'DarkRed' => array(128, 0, 0),
- 'MidRed' => array(192, 0, 0),
- 'Red' => array(255, 0, 0),
- 'LightRed' => array(255, 192, 192),
- 'VeryDarkGreen' => array(0, 64, 0),
- 'DarkGreen' => array(0, 128, 0),
- 'MidGreen' => array(0, 192, 0),
- 'Green' => array(0, 255, 0),
- 'LightGreen' => array(192, 255, 192),
- 'VeryDarkBlue' => array(0, 0, 64),
- 'DarkBlue' => array(0, 0, 128),
- 'MidBlue' => array(0, 0, 192),
- 'Blue' => array(0, 0, 255),
- 'LightBlue' => array(192, 192, 255),
- 'VeryDarkYellow' => array(64, 64, 0),
- 'DarkYellow' => array(128, 128, 0),
- 'MidYellow' => array(192, 192, 0),
- 'Yellow' => array(255, 255, 2),
- 'LightYellow' => array(255, 255, 192),
- 'VeryDarkCyan' => array(0, 64, 64),
- 'DarkCyan' => array(0, 128, 128),
- 'MidCyan' => array(0, 192, 192),
- 'Cyan' => array(0, 255, 255),
- 'LightCyan' => array(192, 255, 255),
- 'VeryDarkMagenta' => array(64, 0, 64),
- 'DarkMagenta' => array(128, 0, 128),
- 'MidMagenta' => array(192, 0, 192),
- 'Magenta' => array(255, 0, 255),
- 'LightMagenta' => array(255, 192, 255),
- 'DarkOrange' => array(192, 88, 0),
- 'Orange' => array(255, 128, 0),
- 'LightOrange' => array(255, 168, 88),
- 'VeryLightOrange' => array(255, 220, 168),
- 'DarkPink' => array(192, 0, 88),
- 'Pink' => array(255, 0, 128),
- 'LightPink' => array(255, 88, 168),
- 'VeryLightPink' => array(255, 168, 220),
- 'DarkPurple' => array(88, 0, 192),
- 'Purple' => array(128, 0, 255),
- 'LightPurple' => array(168, 88, 255),
- 'VeryLightPurple' => array(220, 168, 255),
-);
-
-
-
-$php = '';
-
-foreach($colors as $name => $color) {
-
- list($red, $green, $blue) = $color;
-
- $php .= '
- class aw'.$name.' extends awColor {
-
- public function __construct($alpha = 0) {
- parent::__construct('.$red.', '.$green.', '.$blue.', $alpha);
- }
-
- }
- ';
-
- if(ARTICHOW_PREFIX !== 'aw') {
- $php .= '
- class '.ARTICHOW_PREFIX.$name.' extends aw'.$name.' {
-
- }
- ';
- }
-
-}
-
-eval($php);
-
-
-
-?>
diff --git a/artichow/inc/Driver.class.php b/artichow/inc/Driver.class.php
deleted file mode 100644
index dfdd75f..0000000
--- a/artichow/inc/Driver.class.php
+++ /dev/null
@@ -1,725 +0,0 @@
-phpFontDriver = new awPHPFontDriver();
- $this->fileFontDriver = new awFileFontDriver();
- }
-
- /**
- * Initialize the driver for a particular awImage object
- *
- * @param awImage $image
- */
- abstract public function init(awImage $image);
-
- /**
- * Initialize the Driver for a particular FileImage object
- *
- * @param awFileImage $fileImage The FileImage object to work on
- * @param string $file Image filename
- */
- abstract public function initFromFile(awFileImage $fileImage, $file);
-
- /**
- * Change the image size
- *
- * @param int $width Image width
- * @param int $height Image height
- */
- abstract public function setImageSize($width, $height);
-
- /**
- * Inform the driver of the position of your image
- *
- * @param float $x Position on X axis of the center of the component
- * @param float $y Position on Y axis of the center of the component
- */
- abstract public function setPosition($x, $y);
-
- /**
- * Inform the driver of the position of your image
- * This method need absolutes values
- *
- * @param int $x Left-top corner X position
- * @param int $y Left-top corner Y position
- */
- abstract public function setAbsPosition($x, $y);
-
- /**
- * Move the position of the image
- *
- * @param int $x Add this value to X axis
- * @param int $y Add this value to Y axis
- */
- abstract public function movePosition($x, $y);
-
- /**
- * Inform the driver of the size of your image
- * Height and width must be between 0 and 1.
- *
- * @param int $w Image width
- * @param int $h Image height
- * @return array Absolute width and height of the image
- */
- abstract public function setSize($w, $h);
-
- /**
- * Inform the driver of the size of your image
- * You can set absolute size with this method.
- *
- * @param int $w Image width
- * @param int $h Image height
- */
- abstract public function setAbsSize($w, $h);
-
- /**
- * Get the size of the component handled by the driver
- *
- * @return array Absolute width and height of the component
- */
- abstract public function getSize();
-
- /**
- * Turn antialiasing on or off
- *
- * @var bool $bool
- */
- abstract public function setAntiAliasing($bool);
-
- /**
- * When passed a Color object, returns the corresponding
- * color identifier (driver dependant).
- *
- * @param awColor $color A Color object
- * @return int $rgb A color identifier representing the color composed of the given RGB components
- */
- abstract public function getColor(awColor $color);
-
- /**
- * Draw an image here
- *
- * @param awImage $image Image
- * @param int $p1 Image top-left point
- * @param int $p2 Image bottom-right point
- */
- abstract public function copyImage(awImage $image, awPoint $p1, awPoint $p2);
-
- /**
- * Draw an image here
- *
- * @param awImage $image Image
- * @param int $d1 Destination top-left position
- * @param int $d2 Destination bottom-right position
- * @param int $s1 Source top-left position
- * @param int $s2 Source bottom-right position
- * @param bool $resample Resample image ? (default to TRUE)
- */
- abstract public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE);
-
- /**
- * Draw a string
- *
- * @var awText $text Text to print
- * @param awPoint $point Draw the text at this point
- * @param int $width Text max width
- */
- abstract public function string(awText $text, awPoint $point, $width = NULL);
-
- /**
- * Draw a pixel
- *
- * @param awColor $color Pixel color
- * @param awPoint $p
- */
- abstract public function point(awColor $color, awPoint $p);
-
- /**
- * Draw a colored line
- *
- * @param awColor $color Line color
- * @param awLine $line
- * @param int $thickness Line tickness
- */
- abstract public function line(awColor $color, awLine $line);
-
- /**
- * Draw a color arc
-
- * @param awColor $color Arc color
- * @param awPoint $center Point center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- * @param int $from Start angle
- * @param int $to End angle
- */
- abstract public function arc(awColor $color, awPoint $center, $width, $height, $from, $to);
-
- /**
- * Draw an arc with a background color
- *
- * @param awColor $color Arc background color
- * @param awPoint $center Point center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- * @param int $from Start angle
- * @param int $to End angle
- */
- abstract public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to);
-
- /**
- * Draw a colored ellipse
- *
- * @param awColor $color Ellipse color
- * @param awPoint $center Ellipse center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- */
- abstract public function ellipse(awColor $color, awPoint $center, $width, $height);
-
- /**
- * Draw an ellipse with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param awPoint $center Ellipse center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- */
- abstract public function filledEllipse($background, awPoint $center, $width, $height);
-
- /**
- * Draw a colored rectangle
- *
- * @param awColor $color Rectangle color
- * @param awLine $line Rectangle diagonale
- * @param awPoint $p2
- */
- abstract public function rectangle(awColor $color, awLine $line);
-
- /**
- * Draw a rectangle with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param awLine $line Rectangle diagonale
- */
- abstract public function filledRectangle($background, awLine $line);
-
- /**
- * Draw a polygon
- *
- * @param awColor $color Polygon color
- * @param Polygon A polygon
- */
- abstract public function polygon(awColor $color, awPolygon $polygon);
-
- /**
- * Draw a polygon with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param Polygon A polygon
- */
- abstract public function filledPolygon($background, awPolygon $polygon);
-
- /**
- * Sends the image, as well as the correct HTTP headers, to the browser
- *
- * @param awImage $image The Image object to send
- */
- abstract public function send(awImage $image);
-
- /**
- * Get the image as binary data
- *
- * @param awImage $image
- */
- abstract public function get(awImage $image);
-
- /**
- * Return the width of some text
- *
- * @param awText $text
- */
- abstract public function getTextWidth(awText $text);
-
- /**
- * Return the height of some text
- *
- * @param awText $text
- */
- abstract public function getTextHeight(awText $text);
-
- /**
- * Return the string representing the type of driver
- *
- * @return string
- */
- public function getDriverString() {
- return $this->driverString;
- }
-
- /**
- * Returns whether or not the driver is compatible with the given font type
- *
- * @param awFont $font
- * @return bool
- */
- abstract protected function isCompatibleWithFont(awFont $font);
-
-// abstract private function drawImage(awImage $image, $return = FALSE, $header = TRUE);
-
-}
-
-registerClass('Driver', TRUE);
-
-/**
- * Abstract class for font drivers.
- * Those are used to do all the grunt work on fonts.
- *
- * @package Artichow
- */
-
-abstract class awFontDriver {
-
- public function __construct() {
-
- }
-
- /**
- * Draw the actual text.
- *
- * @param awDriver $driver The Driver object to draw upon
- * @param awText $text The Text object
- * @param awPoint $point Where to draw the text
- * @param float $width The width of the area containing the text
- */
- abstract public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL);
-
- /**
- * Calculate the width of a given Text.
- *
- * @param awText $text The Text object
- * @param awDriver $driver The awDriver object used to draw the graph
- */
- abstract public function getTextWidth(awText $text, awDriver $driver);
-
- /**
- * Calculate the height of a given Text.
- *
- * @param awText $text The Text object
- * @param awDriver $driver The awDriver object used to draw the graph
- */
- abstract public function getTextHeight(awText $text, awDriver $driver);
-
-}
-
-registerClass('FontDriver', TRUE);
-
-/**
- * Class to handle calculations on PHPFont objects
- *
- * @package Artichow
- */
-class awPHPFontDriver extends awFontDriver {
-
- public function __construct() {
- parent::__construct();
- }
-
- public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL) {
-
- switch ($driver->getDriverString()) {
- case 'gd':
- $this->gdString($driver, $text, $point, $width);
- break;
-
- default:
- awImage::drawError('Class PHPFontDriver: Incompatibility between driver and font - You should never see this error message: have you called awDriver::isCompatibleWithFont() properly?');
- break;
-
- }
- }
-
- /**
- * Draw a string onto a GDDriver object
- *
- * @param awGDDriver $driver The GDDriver to draw the text upon
- * @param awText $text The awText object containing the string to draw
- * @param awPoint $point Where to draw the text
- * @param float $width The width of the text
- */
- private function gdString(awGDDriver $driver, awText $text, awPoint $point, $width = NULL) {
-
- $angle = $text->getAngle();
- if($angle !== 90 and $angle !== 0) {
- awImage::drawError("Class PHPFontDriver: You can only use 0° and 90° angles.");
- }
-
- if($angle === 90) {
- $function = 'imagestringup';
- $addAngle = $this->getGDTextHeight($text);
- } else {
- $function = 'imagestring';
- $addAngle = 0;
- }
-
- $color = $text->getColor();
- $rgb = $driver->getColor($color);
-
- $textString = $text->getText();
- $textString = str_replace("\r", "", $textString);
-
- $textHeight = $this->getGDTextHeight($text);
-
- // Split text if needed
- if($width !== NULL) {
-
- $characters = floor($width / ($this->getGDTextWidth($text) / strlen($textString)));
-
- if($characters > 0) {
- $textString = wordwrap($textString, $characters, "\n", TRUE);
- }
-
- }
-
- $font = $text->getFont();
- $lines = explode("\n", $textString);
-
- foreach($lines as $i => $line) {
-
- // Line position handling
- if($angle === 90) {
- $addX = $i * $textHeight;
- $addY = 0;
- } else {
- $addX = 0;
- $addY = $i * $textHeight;
- }
-
- $function(
- $driver->resource,
- $font->font,
- $driver->x + $point->x + $addX,
- $driver->y + $point->y + $addY + $addAngle,
- $line,
- $rgb
- );
-
- }
- }
-
- public function getTextWidth(awText $text, awDriver $driver) {
-
- switch ($driver->getDriverString()) {
- case 'gd':
- return $this->getGDTextWidth($text);
-
- default:
- awImage::drawError('Class PHPFontDriver: Cannot get text width - incompatibility between driver and font');
- break;
- }
-
- }
-
- public function getTextHeight(awText $text, awDriver $driver) {
-
- switch ($driver->getDriverString()) {
- case 'gd':
- return $this->getGDTextHeight($text);
-
- default:
- awImage::drawError('Class PHPFontDriver: Cannot get text height - incompatibility between driver and font');
- break;
- }
-
- }
-
- /**
- * Return the width of a text for a GDDriver
- *
- * @param awText $text
- * @return int $fontWidth
- */
- private function getGDTextWidth(awText $text) {
- $font = $text->getFont();
-
- if($text->getAngle() === 90) {
- $text->setAngle(45);
- return $this->getGDTextHeight($text);
- } else if($text->getAngle() === 45) {
- $text->setAngle(90);
- }
-
- $fontWidth = imagefontwidth($font->font);
-
- if($fontWidth === FALSE) {
- awImage::drawError("Class PHPFontDriver: Unable to get font size.");
- }
-
- return (int)$fontWidth * strlen($text->getText());
- }
-
- /**
- * Return the height of a text for a GDDriver
- *
- * @param awText $text
- * @return int $fontHeight
- */
- private function getGDTextHeight(awText $text) {
- $font = $text->getFont();
-
- if($text->getAngle() === 90) {
- $text->setAngle(45);
- return $this->getGDTextWidth($text);
- } else if($text->getAngle() === 45) {
- $text->setAngle(90);
- }
-
- $fontHeight = imagefontheight($font->font);
-
- if($fontHeight === FALSE) {
- awImage::drawError("Class PHPFontDriver: Unable to get font size.");
- }
-
- return (int)$fontHeight;
- }
-}
-
-registerClass('PHPFontDriver');
-
-/**
- * Class to handle calculations on FileFont objects
- *
- * @package Artichow
- */
-class awFileFontDriver extends awFontDriver {
-
- public function __construct() {
- parent::__construct();
- }
-
- public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL) {
-
- switch ($driver->getDriverString()) {
- case 'gd':
- $this->gdString($driver, $text, $point, $width);
- break;
-
- default:
- awImage::drawError('Class fileFontDriver: Incompatibility between driver and font - You should never see this error message: have you called awDriver::isCompatibleWithFont() properly?');
- break;
- }
- }
-
- /**
- * Draw an awFileFont object on a GD ressource
- *
- * @param awGDDriver $driver The awGDDriver object containing the ressource to draw upon
- * @param awText $text The awText object containing the string to draw
- * @param awPoint $point Where to draw the string from
- * @param float $width The width of the area containing the text
- */
- private function gdString(awGDDriver $driver, awText $text, awPoint $point, $width = NULL) {
- // Make easier font positionment
- $text->setText($text->getText()." ");
-
- $font = $text->getFont();
- if($font instanceof awTTFFont === FALSE and $font->getExtension() === NULL) {
- $font->setExtension('ttf');
- }
-
- $filePath = $font->getName().'.'.$font->getExtension();
-
- $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText());
- $textHeight = - $box[5];
-
- $box = imagettfbbox($font->getSize(), 90, $filePath, $text->getText());
- $textWidth = abs($box[6] - $box[2]);
-
- // Restore old text
- $text->setText(substr($text->getText(), 0, strlen($text->getText()) - 1));
-
- $textString = $text->getText();
-
- // Split text if needed
- if($width !== NULL) {
-
- $characters = floor($width / $this->getGDAverageWidth($font));
- $textString = wordwrap($textString, $characters, "\n", TRUE);
-
- }
-
- $color = $text->getColor();
- $rgb = $driver->getColor($color);
-
- imagettftext(
- $driver->resource,
- $font->getSize(),
- $text->getAngle(),
- $driver->x + $point->x + $textWidth * sin($text->getAngle() / 180 * M_PI),
- $driver->y + $point->y + $textHeight,
- $rgb,
- $filePath,
- $textString
- );
- }
-
- public function getTextWidth(awText $text, awDriver $driver) {
- switch ($driver->getDriverString()) {
- case 'gd':
- return $this->getGDTextWidth($text);
-
- default:
- awImage::drawError('Class FileFontDriver: Cannot get text width - incompatibility between driver and font');
- break;
- }
- }
-
- public function getTextHeight(awText $text, awDriver $driver) {
- switch ($driver->getDriverString()) {
- case 'gd':
- return $this->getGDTextHeight($text);
-
- default:
- awImage::drawError('Class FileFontDriver: Cannot get text height - incompatibility between driver and font');
- break;
- }
- }
-
- private function getGDTextWidth(awText $text) {
- $font = $text->getFont();
- if($font->getExtension() === NULL) {
- $font->setExtension('ttf');
- }
-
- $filePath = $font->getName().'.'.$font->getExtension();
-
- $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText());
-
- if($box === FALSE) {
- awImage::drawError("Class FileFontDriver: Unable to get font width (GD).");
- }
-
- list(, , $x2, , , , $x1, ) = $box;
-
- return abs($x2 - $x1);
- }
-
- private function getGDTextHeight(awText $text) {
- $font = $text->getFont();
- if($font->getExtension() === NULL) {
- $font->setExtension('ttf');
- }
-
- $filePath = $font->getName().'.'.$font->getExtension();
-
- $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText());
-
- if($box === FALSE) {
- awImage::drawError("Class FileFontDriver: Unable to get font height (GD).");
- }
-
- list(, , , $y2, , , , $y1) = $box;
-
- return abs($y2 - $y1);
- }
-
- private function getGDAverageWidth(awFileFont $font) {
-
- $text = "azertyuiopqsdfghjklmmmmmmmwxcvbbbn,;:!?.";
-
- $box = imagettfbbox($font->getSize(), 0, $font->getName().'.'.$font->getExtension(), $text);
-
- if($box === FALSE) {
- awImage::drawError("Class FileFontDriver: Unable to get font average width.");
- }
-
- list(, , $x2, $y2, , , $x1, $y1) = $box;
-
- return abs($x2 - $x1) / strlen($text);
-
- }
-
-}
-
-registerClass('FileFontDriver');
-
-// Include ARTICHOW_DRIVER by default to preserve backward compatibility.
-require_once dirname(__FILE__).'/drivers/'.ARTICHOW_DRIVER.'.class.php';
-
-?>
\ No newline at end of file
diff --git a/artichow/inc/Font.class.php b/artichow/inc/Font.class.php
deleted file mode 100644
index 50db8f6..0000000
--- a/artichow/inc/Font.class.php
+++ /dev/null
@@ -1,263 +0,0 @@
-string($this, $text, $point, $width);
-
- }
-
-}
-
-registerClass('Font', TRUE);
-
-/**
- * Class for fonts that cannot be transformed,
- * like the built-in PHP fonts for example.
- *
- * @package Artichow
- */
-class awPHPFont extends awFont {
-
- /**
- * The used font identifier
- *
- * @var int
- */
- public $font;
-
- public function __construct($font = NULL) {
- parent::__construct();
-
- if($font !== NULL) {
- $this->font = (int)$font;
- }
- }
-
-}
-
-registerClass('PHPFont');
-
-/**
- * Class for fonts that can be transformed (rotated, skewed, etc.),
- * like TTF or FDB fonts for example.
- *
- * @package Artichow
- */
-class awFileFont extends awFont {
-
- /**
- * The name of the font, without the extension
- *
- * @var string
- */
- protected $name;
-
- /**
- * The size of the font
- *
- * @var int
- */
- protected $size;
-
- /**
- * The font filename extension
- *
- * @var string
- */
- protected $extension;
-
- public function __construct($name, $size) {
- parent::__construct();
-
- $this->setName($name);
- $this->setSize($size);
- }
-
- /**
- * Set the name of the font. The $name variable can contain the full path,
- * or just the filename. Artichow will try to do The Right Thing,
- * as well as set the extension property correctly if possible.
- *
- * @param string $name
- */
- public function setName($name) {
- $fontInfo = pathinfo((string)$name);
-
- if(strpos($fontInfo['dirname'], '/') !== 0) {
- // Path is not absolute, use ARTICHOW_FONT
- $name = ARTICHOW_FONT.DIRECTORY_SEPARATOR.$fontInfo['basename'];
- $fontInfo = pathinfo($name);
- }
-
- $this->name = $fontInfo['dirname'].DIRECTORY_SEPARATOR.$fontInfo['basename'];
-
- if(array_key_exists('extension', $fontInfo) and $fontInfo['extension'] !== '') {
- $this->setExtension($fontInfo['extension']);
- }
- }
-
- /**
- * Return the name of the font, i.e. the absolute path and the filename, without the extension.
- *
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Set the size of the font, in pixels
- *
- * @param int $size
- */
- public function setSize($size) {
- $this->size = (int)$size;
- }
-
- /**
- * Return the size of the font, in pixels
- *
- * @return int
- */
- public function getSize() {
- return $this->size;
- }
-
- /**
- * Set the extension, without the dot
- *
- * @param string $extension
- */
- public function setExtension($extension) {
- $this->extension = (string)$extension;
- }
-
- /**
- * Get the filename extension for that font
- *
- * @return string
- */
- public function getExtension() {
- return $this->extension;
- }
-
-}
-
-registerClass('FileFont');
-
-/**
- * Class representing TTF fonts
- *
- * @package Artichow
- */
-class awTTFFont extends awFileFont {
-
- public function __construct($name, $size) {
- parent::__construct($name, $size);
-
- if($this->getExtension() === NULL) {
- $this->setExtension('ttf');
- }
- }
-
-}
-
-registerClass('TTFFont');
-
-
-
-$php = '';
-
-for($i = 1; $i <= 5; $i++) {
-
- $php .= '
- class awFont'.$i.' extends awPHPFont {
-
- public function __construct() {
- parent::__construct('.$i.');
- }
-
- }
- ';
-
- if(ARTICHOW_PREFIX !== 'aw') {
- $php .= '
- class '.ARTICHOW_PREFIX.'Font'.$i.' extends awFont'.$i.' {
- }
- ';
- }
-
-}
-
-eval($php);
-
-$php = '';
-
-foreach($fonts as $font) {
-
- $php .= '
- class aw'.$font.' extends awFileFont {
-
- public function __construct($size) {
- parent::__construct(\''.$font.'\', $size);
- }
-
- }
- ';
-
- if(ARTICHOW_PREFIX !== 'aw') {
- $php .= '
- class '.ARTICHOW_PREFIX.$font.' extends aw'.$font.' {
- }
- ';
- }
-
-}
-
-eval($php);
-
-
-
-/*
- * Environment modification for GD2 and TTF fonts
- */
-if(function_exists('putenv')) {
- putenv('GDFONTPATH='.ARTICHOW_FONT);
-}
-
-?>
\ No newline at end of file
diff --git a/artichow/inc/Gradient.class.php b/artichow/inc/Gradient.class.php
deleted file mode 100644
index b6e1855..0000000
--- a/artichow/inc/Gradient.class.php
+++ /dev/null
@@ -1,135 +0,0 @@
-from = $from;
- $this->to = $to;
-
- }
-
-}
-
-registerClass('Gradient', TRUE);
-
-
-/**
- * Create a linear gradient
- *
- * @package Artichow
- */
-class awLinearGradient extends awGradient {
-
- /**
- * Gradient angle
- *
- * @var int
- */
- public $angle;
-
- /**
- * Build the linear gradient
- *
- * @param awColor $from From color
- * @param awColor $to To color
- * @param int $angle Gradient angle
- */
- public function __construct($from, $to, $angle) {
-
- parent::__construct(
- $from, $to
- );
-
- $this->angle = (int)$angle;
-
- }
-
-}
-
-registerClass('LinearGradient');
-
-
-/**
- * Create a bilinear gradient
- *
- * @package Artichow
- */
-class awBilinearGradient extends awLinearGradient {
-
- /**
- * Gradient center
- *
- * @var float Center between 0 and 1
- */
- public $center;
-
- /**
- * Build the bilinear gradient
- *
- * @param awColor $from From color
- * @param awColor $to To color
- * @param int $angle Gradient angle
- * @param int $center Gradient center
- */
- public function __construct($from, $to, $angle, $center = 0.5) {
-
- parent::__construct(
- $from, $to, $angle
- );
-
- $this->center = (float)$center;
-
- }
-
-}
-
-registerClass('BilinearGradient');
-
-/**
- * Create a radial gradient
- *
- * @package Artichow
- */
-class awRadialGradient extends awGradient {
-
-}
-
-registerClass('RadialGradient');
-?>
diff --git a/artichow/inc/Grid.class.php b/artichow/inc/Grid.class.php
deleted file mode 100644
index 1e8152c..0000000
--- a/artichow/inc/Grid.class.php
+++ /dev/null
@@ -1,291 +0,0 @@
-color = new awColor(210, 210, 210);
- $this->background = new awColor(255, 255, 255, 100);
-
- }
-
- /**
- * Hide grid ?
- *
- * @param bool $hide
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Hide horizontal lines ?
- *
- * @param bool $hideHorizontal
- */
- public function hideHorizontal($hide = TRUE) {
- $this->hideHorizontal = (bool)$hide;
- }
-
- /**
- * Hide vertical lines ?
- *
- * @param bool $hideVertical
- */
- public function hideVertical($hide = TRUE) {
- $this->hideVertical = (bool)$hide;
- }
-
- /**
- * Change grid color
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- }
-
- /**
- * Remove grid background
- */
- public function setNoBackground() {
- $this->background = NULL;
- }
-
- /**
- * Change grid background color
- *
- * @param awColor $color
- */
- public function setBackgroundColor(awColor $color) {
- $this->background = $color;
- }
-
- /**
- * Change line type
- *
- * @param int $type
- */
- public function setType($type) {
- $this->type = (int)$type;
- }
-
- /**
- * Change grid interval
- *
- * @param int $hInterval
- * @param int $vInterval
- */
- public function setInterval($hInterval, $vInterval) {
- $this->interval = array((int)$hInterval, (int)$vInterval);
- }
-
- /**
- * Set grid space
- *
- * @param int $left Left space in pixels
- * @param int $right Right space in pixels
- * @param int $top Top space in pixels
- * @param int $bottom Bottom space in pixels
- */
- public function setSpace($left, $right, $top, $bottom) {
- $this->space = array((int)$left, (int)$right, (int)$top, (int)$bottom);
- }
-
- /**
- * Change the current grid
- *
- * @param array $xgrid Vertical lines
- * @param array $ygrid Horizontal lines
- */
- public function setGrid($xgrid, $ygrid) {
-
- if(empty($this->xgrid)) {
- $this->xgrid = $xgrid;
- }
- if(empty($this->ygrid)) {
- $this->ygrid = $ygrid;
- }
-
- }
-
- /**
- * Draw grids
- *
- * @param awDriver $driver A driver object
- * @param int $x1
- * @param int $y1
- * @param int $x2
- * @param int $y2
- */
- public function draw(awDriver $driver, $x1, $y1, $x2, $y2) {
-
- if($this->background instanceof awColor) {
-
- // Draw background color
- $driver->filledRectangle(
- $this->background,
- awLine::build($x1, $y1, $x2, $y2)
- );
-
- }
-
- if($this->hide === FALSE) {
-
- $this->drawGrid(
- $driver,
- $this->color,
- $this->hideVertical ? array() : $this->xgrid,
- $this->hideHorizontal ? array() : $this->ygrid,
- $x1, $y1, $x2, $y2,
- $this->type,
- $this->space,
- $this->interval[0],
- $this->interval[1]
- );
-
- }
-
- }
-
- private function drawGrid(
- awDriver $driver, awColor $color,
- $nx, $ny, $x1, $y1, $x2, $y2,
- $type, $space, $hInterval, $vInterval
- ) {
-
- list($left, $right, $top, $bottom) = $space;
-
- $width = $x2 - $x1 - $left - $right;
- $height = $y2 - $y1 - $top - $bottom;
-
- foreach($nx as $key => $n) {
-
- if(($key % $vInterval) === 0) {
-
- $pos = (int)round($x1 + $left + $n * $width);
- $driver->line(
- $color,
- new awLine(
- new awPoint($pos, $y1),
- new awPoint($pos, $y2),
- $type
- )
- );
-
- }
-
- }
-
- foreach($ny as $key => $n) {
-
- if(($key % $hInterval) === 0) {
-
- $pos = (int)round($y1 + $top + $n * $height);
- $driver->line(
- $color,
- new awLine(
- new awPoint($x1, $pos),
- new awPoint($x2, $pos),
- $type
- )
- );
-
- }
-
- }
-
- }
-
-}
-
-registerClass('Grid');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Label.class.php b/artichow/inc/Label.class.php
deleted file mode 100644
index 169f106..0000000
--- a/artichow/inc/Label.class.php
+++ /dev/null
@@ -1,588 +0,0 @@
-set($label);
- } else if(is_string($label)) {
- $this->set(array($label));
- }
-
- if($font === NULL) {
- $font = new awFont2;
- }
-
- $this->setFont($font);
- $this->setAngle($angle);
-
- if($color instanceof awColor) {
- $this->setColor($color);
- } else {
- $this->setColor(new awColor(0, 0, 0));
- }
-
- $this->move = new awPoint(0, 0);
-
- $this->border = new awBorder;
- $this->border->hide();
-
- }
-
- /**
- * Get an element of the label from its key
- *
- * @param int $key Element key
- * @return string A value
- */
- public function get($key) {
- return array_key_exists($key, $this->texts) ? $this->texts[$key] : NULL;
- }
-
- /**
- * Get all labels
- *
- * @return array
- */
- public function all() {
- return $this->texts;
- }
-
- /**
- * Set one or several labels
- *
- * @param array $labels Array of string or a string
- */
- public function set($labels) {
-
- if(is_array($labels)) {
- $this->texts = $labels;
- } else {
- $this->texts = array((string)$labels);
- }
-
- }
-
- /**
- * Count number of texts in the label
- *
- * @return int
- */
- public function count() {
- return is_array($this->texts) ? count($this->texts) : 0;
- }
-
- /**
- * Set a callback function for labels
- *
- * @param string $function
- */
- public function setCallbackFunction($function) {
- $this->function = is_null($function) ? $function : (string)$function;
- }
-
- /**
- * Return the callback function for labels
- *
- * @return string
- */
- public function getCallbackFunction() {
- return $this->function;
- }
-
- /**
- * Change labels format
- *
- * @param string $format New format (printf style: %.2f for example)
- */
- public function setFormat($format) {
- $function = 'label'.time().'_'.(microtime() * 1000000);
- eval('function '.$function.'($value) {
- return sprintf("'.addcslashes($format, '"').'", $value);
- }');
- $this->setCallbackFunction($function);
- }
-
- /**
- * Change font for label
- *
- * @param awFont $font New font
- * @param awColor $color Font color (can be NULL)
- */
- public function setFont(awFont $font, $color = NULL) {
- $this->font = $font;
- if($color instanceof awColor) {
- $this->setColor($color);
- }
- }
-
- /**
- * Change font angle
- *
- * @param int $angle New angle
- */
- public function setAngle($angle) {
- $this->angle = (int)$angle;
- }
-
- /**
- * Change font color
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- }
-
- /**
- * Change text background
- *
- * @param mixed $background
- */
- public function setBackground($background) {
- $this->background = $background;
- }
-
- /**
- * Change text background color
- *
- * @param Color
- */
- public function setBackgroundColor(awColor $color) {
- $this->background = $color;
- }
-
- /**
- * Change text background gradient
- *
- * @param Gradient
- */
- public function setBackgroundGradient(awGradient $gradient) {
- $this->background = $gradient;
- }
-
- /**
- * Change padding
- *
- * @param int $left Left padding
- * @param int $right Right padding
- * @param int $top Top padding
- * @param int $bottom Bottom padding
- */
- public function setPadding($left, $right, $top, $bottom) {
- $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom);
- }
-
- /**
- * Hide all labels ?
- *
- * @param bool $hide
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show all labels ?
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = (bool)!$show;
- }
-
- /**
- * Hide a key
- *
- * @param int $key The key to hide
- */
- public function hideKey($key) {
- $this->hideKey[$key] = TRUE;
- }
-
- /**
- * Hide a value
- *
- * @param int $value The value to hide
- */
- public function hideValue($value) {
- $this->hideValue[] = $value;
- }
-
- /**
- * Hide first label
- *
- * @param bool $hide
- */
- public function hideFirst($hide) {
- $this->hideFirst = (bool)$hide;
- }
-
- /**
- * Hide last label
- *
- * @param bool $hide
- */
- public function hideLast($hide) {
- $this->hideLast = (bool)$hide;
- }
-
- /**
- * Set label interval
- *
- * @param int
- */
- public function setInterval($interval) {
-
- $this->interval = (int)$interval;
-
- }
-
- /**
- * Change label position
- *
- * @param int $x Add this interval to X coord
- * @param int $y Add this interval to Y coord
- */
- public function move($x, $y) {
-
- $this->move = $this->move->move($x, $y);
-
- }
-
- /**
- * Change alignment
- *
- * @param int $h Horizontal alignment
- * @param int $v Vertical alignment
- */
- public function setAlign($h = NULL, $v = NULL) {
- if($h !== NULL) {
- $this->hAlign = (int)$h;
- }
- if($v !== NULL) {
- $this->vAlign = (int)$v;
- }
- }
-
- /**
- * Get a text from the labele
- *
- * @param mixed $key Key in the array text
- * @return Text
- */
- public function getText($key) {
-
- if(is_array($this->texts) and array_key_exists($key, $this->texts)) {
-
- $value = $this->texts[$key];
-
- if(is_string($this->function)) {
- $value = call_user_func($this->function, $value);
- }
-
- $text = new awText($value);
- $text->setFont($this->font);
- $text->setAngle($this->angle);
- $text->setColor($this->color);
-
- if($this->background instanceof awColor) {
- $text->setBackgroundColor($this->background);
- } else if($this->background instanceof awGradient) {
- $text->setBackgroundGradient($this->background);
- }
-
- $text->border = $this->border;
-
- if($this->padding !== NULL) {
- call_user_func_array(array($text, 'setPadding'), $this->padding);
- }
-
- return $text;
-
- } else {
- return NULL;
- }
-
- }
-
- /**
- * Get max width of all texts
- *
- * @param awDriver $driver A driver
- * @return int
- */
- public function getMaxWidth(awDriver $driver) {
-
- return $this->getMax($driver, 'getTextWidth');
-
- }
-
- /**
- * Get max height of all texts
- *
- * @param awDriver $driver A driver
- * @return int
- */
- public function getMaxHeight(awDriver $driver) {
-
- return $this->getMax($driver, 'getTextHeight');
-
- }
-
- /**
- * Draw the label
- *
- * @param awDriver $driver
- * @param awPoint $p Label center
- * @param int $key Text position in the array of texts (default to zero)
- */
- public function draw(awDriver $driver, awPoint $p, $key = 0) {
-
- if(($key % $this->interval) !== 0) {
- return;
- }
-
- // Hide all labels
- if($this->hide) {
- return;
- }
-
- // Key is hidden
- if(array_key_exists($key, $this->hideKey)) {
- return;
- }
-
- // Hide first label
- if($key === 0 and $this->hideFirst) {
- return;
- }
-
- // Hide last label
- if($key === count($this->texts) - 1 and $this->hideLast) {
- return;
- }
-
- $text = $this->getText($key);
-
- if($text !== NULL) {
-
- // Value must be hidden
- if(in_array($text->getText(), $this->hideValue)) {
- return;
- }
-
- $x = $p->x;
- $y = $p->y;
-
- // Get padding
- list($left, $right, $top, $bottom) = $text->getPadding();
-
-// $font = $text->getFont();
- $width = $driver->getTextWidth($text);
- $height = $driver->getTextHeight($text);
-
- switch($this->hAlign) {
-
- case awLabel::RIGHT :
- $x -= ($width + $right);
- break;
-
- case awLabel::CENTER :
- $x -= ($width - $left + $right) / 2;
- break;
-
- case awLabel::LEFT :
- $x += $left;
- break;
-
- }
-
- switch($this->vAlign) {
-
- case awLabel::TOP :
- $y -= ($height + $bottom);
- break;
-
- case awLabel::MIDDLE :
- $y -= ($height - $top + $bottom) / 2;
- break;
-
- case awLabel::BOTTOM :
- $y += $top;
- break;
-
- }
-
- $driver->string($text, $this->move->move($x, $y));
-
- }
-
- }
-
- protected function getMax(awDriver $driver, $function) {
-
- $max = NULL;
-
- foreach($this->texts as $key => $text) {
-
- $text = $this->getText($key);
- $font = $text->getFont();
-
- if(is_null($max)) {
- $max = $font->{$function}($text);
- } else {
- $max = max($max, $font->{$function}($text));
- }
-
- }
-
- return $max;
-
- }
-
-}
-
-registerClass('Label');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Legend.class.php b/artichow/inc/Legend.class.php
deleted file mode 100644
index c7e26a5..0000000
--- a/artichow/inc/Legend.class.php
+++ /dev/null
@@ -1,710 +0,0 @@
-shadow = new awShadow(awShadow::LEFT_BOTTOM);
- $this->border = new awBorder;
-
- $this->textMargin = new awSide(4);
- $this->setModel($model);
-
- }
-
- /**
- * Set a predefined model for the legend
- *
- * @param int $model
- */
- public function setModel($model) {
-
- $this->setBackgroundColor(new awColor(255, 255, 255, 15));
- $this->setPadding(8, 8, 8, 8);
- $this->setTextFont(new awFont2);
- $this->shadow->setSize(3);
-
- switch($model) {
-
- case awLegend::MODEL_RIGHT :
-
- $this->setColumns(1);
- $this->setAlign(awLegend::RIGHT, awLegend::MIDDLE);
- $this->setPosition(0.96, 0.50);
-
- break;
-
- case awLegend::MODEL_BOTTOM :
-
- $this->setRows(1);
- $this->setAlign(awLegend::CENTER, awLegend::TOP);
- $this->setPosition(0.50, 0.92);
-
- break;
-
- default :
-
- $this->setPosition(0.5, 0.5);
-
- break;
-
- }
-
- }
-
- /**
- * Hide legend ?
- *
- * @param bool $hide TRUE to hide legend, FALSE otherwise
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show legend ?
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = (bool)!$show;
- }
-
-
- /**
- * Add a Legendable object to the legend
- *
- * @param awLegendable $legendable
- * @param string $title Legend title
- * @param int $type Legend type (default to awLegend::LINE)
- */
- public function add(awLegendable $legendable, $title, $type = awLegend::LINE) {
-
- $legend = array($legendable, $title, $type);
-
- $this->legends[] = $legend;
-
- }
-
- /**
- * Change legend padding
- *
- * @param int $left
- * @param int $right
- * @param int $top
- * @param int $bottom
- */
- public function setPadding($left, $right, $top, $bottom) {
- $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom);
- }
-
- /**
- * Change space between each legend
- *
- * @param int $space
- */
- public function setSpace($space) {
- $this->space = (int)$space;
- }
-
- /**
- * Change alignment
- *
- * @param int $h Horizontal alignment
- * @param int $v Vertical alignment
- */
- public function setAlign($h = NULL, $v = NULL) {
- if($h !== NULL) {
- $this->hAlign = (int)$h;
- }
- if($v !== NULL) {
- $this->vAlign = (int)$v;
- }
- }
-
- /**
- * Change number of columns
- *
- * @param int $columns
- */
- public function setColumns($columns) {
- $this->rows = NULL;
- $this->columns = (int)$columns;
- }
-
- /**
- * Change number of rows
- *
- * @param int $rows
- */
- public function setRows($rows) {
- $this->columns = NULL;
- $this->rows = (int)$rows;
- }
-
- /**
- * Change legend position
- * X and Y positions must be between 0 and 1.
- *
- * @param float $x
- * @param float $y
- */
- public function setPosition($x = NULL, $y = NULL) {
- $x = (is_null($x) and !is_null($this->position)) ? $this->position->x : $x;
- $y = (is_null($y) and !is_null($this->position)) ? $this->position->y : $y;
-
- $this->position = new awPoint($x, $y);
- }
-
- /**
- * Get legend position
- *
- * @return Point
- */
- public function getPosition() {
- return $this->position;
- }
-
- /**
- * Change text font
- *
- * @param awFont $font
- */
- public function setTextFont(awFont $font) {
- $this->textFont = $font;
- }
-
- /**
- * Change text margin
- *
- * @param int $left
- * @param int $right
- */
- public function setTextMargin($left, $right) {
- $this->textMargin->set($left, $right);
- }
-
- /**
- * Change text color
- *
- * @param awColor $color
- */
- public function setTextColor(awColor $color) {
- $this->textColor = $color;
- }
-
- /**
- * Change background
- *
- * @param mixed $background
- */
- public function setBackground($background) {
- $this->background = $background;
- }
-
- /**
- * Change background color
- *
- * @param awColor $color
- */
- public function setBackgroundColor(awColor $color) {
- $this->background = $color;
- }
-
- /**
- * Change background gradient
- *
- * @param awGradient $gradient
- */
- public function setBackgroundGradient(awGradient $gradient) {
- $this->background = $gradient;
- }
-
- /**
- * Count the number of Legendable objects in the legend
- *
- * @return int
- */
- public function count() {
- return count($this->legends);
- }
-
- public function draw(awDriver $driver) {
-
- if($this->hide) {
- return;
- }
-
- $count = $this->count();
-
- // No legend to print
- if($count === 0) {
- return;
- }
-
- // Get text widths and heights of each element of the legend
- $widths = array();
- $heights = array();
- $texts = array();
- for($i = 0; $i < $count; $i++) {
- list(, $title, ) = $this->legends[$i];
- $text = new awText(
- $title,
- $this->textFont,
- $this->textColor,
- 0
- );
-// $font = $text->getFont();
- $widths[$i] = $driver->getTextWidth($text) + $this->textMargin->left + $this->textMargin->right;
- $heights[$i] = $driver->getTextHeight($text);
- $texts[$i] = $text;
- }
-
- // Maximum height of the font used
- $heightMax = array_max($heights);
-
- // Get number of columns
- if($this->columns !== NULL) {
- $columns = $this->columns;
- } else if($this->rows !== NULL) {
- $columns = ceil($count / $this->rows);
- } else {
- $columns = $count;
- }
-
- // Number of rows
- $rows = (int)ceil($count / $columns);
-
- // Get maximum with of each column
- $widthMax = array();
- for($i = 0; $i < $count; $i++) {
- // Get column width
- $column = $i % $columns;
- if(array_key_exists($column, $widthMax) === FALSE) {
- $widthMax[$column] = $widths[$i];
- } else {
- $widthMax[$column] = max($widthMax[$column], $widths[$i]);
- }
- }
-
- $width = $this->padding[0] + $this->padding[1] - $this->space;
- for($i = 0; $i < $columns; $i++) {
- $width += $this->space + 5 + 10 + $widthMax[$i];
- }
-
- $height = ($heightMax + $this->space) * $rows - $this->space + $this->padding[2] + $this->padding[3];
-
- // Look for legends position
- list($x, $y) = $driver->getSize();
-
- $p = new awPoint(
- $this->position->x * $x,
- $this->position->y * $y
- );
-
- switch($this->hAlign) {
-
- case awLegend::CENTER :
- $p->x -= $width / 2;
- break;
-
- case awLegend::RIGHT :
- $p->x -= $width;
- break;
-
- }
-
- switch($this->vAlign) {
-
- case awLegend::MIDDLE :
- $p->y -= $height / 2;
- break;
-
- case awLegend::BOTTOM :
- $p->y -= $height;
- break;
-
- }
-
- // Draw legend shadow
- $this->shadow->draw(
- $driver,
- $p,
- $p->move($width, $height),
- awShadow::OUT
- );
-
- // Draw legends base
- $this->drawBase($driver, $p, $width, $height);
-
- // Draw each legend
- for($i = 0; $i < $count; $i++) {
-
- list($component, $title, $type) = $this->legends[$i];
-
- $column = $i % $columns;
- $row = (int)floor($i / $columns);
-
- // Get width of all previous columns
- $previousColumns = 0;
- for($j = 0; $j < $column; $j++) {
- $previousColumns += $this->space + 10 + 5 + $widthMax[$j];
- }
-
- // Draw legend text
- $driver->string(
- $texts[$i],
- $p->move(
- $this->padding[0] + $previousColumns + 10 + 5 + $this->textMargin->left,
- $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - $heights[$i] / 2
- )
- );
-
- // Draw legend icon
- switch($type) {
-
- case awLegend::LINE :
- case awLegend::MARK :
- case awLegend::MARKONLY :
-
- // Get vertical position
- $x = $this->padding[0] + $previousColumns;
- $y = $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - $component->getLegendLineThickness();
-
- // Draw two lines
- if($component->getLegendLineColor() !== NULL) {
-
- $color = $component->getLegendLineColor();
-
- if($color instanceof awColor and $type !== awLegend::MARKONLY) {
-
- $driver->line(
- $color,
- new awLine(
- $p->move(
- $x, // YaPB ??
- $y + $component->getLegendLineThickness() / 2
- ),
- $p->move(
- $x + 10,
- $y + $component->getLegendLineThickness() / 2
- ),
- $component->getLegendLineStyle(),
- $component->getLegendLineThickness()
- )
- );
-
- unset($color);
-
- }
-
- }
-
- if($type === awLegend::MARK or $type === awLegend::MARKONLY) {
-
- $mark = $component->getLegendMark();
-
- if($mark !== NULL) {
- $mark->draw(
- $driver,
- $p->move(
- $x + 5.5,
- $y + $component->getLegendLineThickness() / 2
- )
- );
- }
-
- unset($mark);
-
- }
-
- break;
-
- case awLegend::BACKGROUND :
-
- // Get vertical position
- $x = $this->padding[0] + $previousColumns;
- $y = $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - 5;
-
- $from = $p->move(
- $x,
- $y
- );
-
- $to = $p->move(
- $x + 10,
- $y + 10
- );
-
- $background = $component->getLegendBackground();
-
- if($background !== NULL) {
-
- $driver->filledRectangle(
- $component->getLegendBackground(),
- new awLine($from, $to)
- );
-
- // Draw rectangle border
- $this->border->rectangle(
- $driver,
- $from->move(0, 0),
- $to->move(0, 0)
- );
-
- }
-
- unset($background, $from, $to);
-
- break;
-
- }
-
- }
-
- }
-
- private function drawBase(awDriver $driver, awPoint $p, $width, $height) {
-
- $this->border->rectangle(
- $driver,
- $p,
- $p->move($width, $height)
- );
-
- $size = $this->border->visible() ? 1 : 0;
-
- $driver->filledRectangle(
- $this->background,
- new awLine(
- $p->move($size, $size),
- $p->move($width - $size, $height - $size)
- )
- );
-
- }
-
-}
-
-registerClass('Legend');
-
-/**
- * You can add a legend to components which implements this interface
- *
- * @package Artichow
- */
-interface awLegendable {
-
- /**
- * Get the line type
- *
- * @return int
- */
- public function getLegendLineStyle();
-
- /**
- * Get the line thickness
- *
- * @return int
- */
- public function getLegendLineThickness();
-
- /**
- * Get the color of line
- *
- * @return Color
- */
- public function getLegendLineColor();
-
- /**
- * Get the background color or gradient of an element of the component
- *
- * @return Color, Gradient
- */
- public function getLegendBackground();
-
- /**
- * Get a Mark object
- *
- * @return Mark
- */
- public function getLegendMark();
-
-}
-
-registerInterface('Legendable');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Mark.class.php b/artichow/inc/Mark.class.php
deleted file mode 100644
index 5cf042f..0000000
--- a/artichow/inc/Mark.class.php
+++ /dev/null
@@ -1,490 +0,0 @@
-fill = new awColor(255, 0, 0, 0);
- $this->border = new awBorder;
- $this->border->hide();
-
- $this->move = new awPoint(0, 0);
-
- }
-
- /**
- * Change mark position
- *
- * @param int $x Add this interval to X coord
- * @param int $y Add this interval to Y coord
- */
- public function move($x, $y) {
-
- $this->move = $this->move->move($x, $y);
-
- }
-
- /**
- * Hide marks ?
- *
- * @param bool $hide TRUE to hide marks, FALSE otherwise
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show marks ?
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = (bool)!$show;
- }
-
- /**
- * Change mark type
- *
- * @param int $size Size in pixels
- */
- public function setSize($size) {
- $this->size = (int)$size;
- }
-
- /**
- * Change mark type
- *
- * @param int $type New mark type
- * @param int $size Mark size (can be NULL)
- */
- public function setType($type, $size = NULL) {
- $this->type = (int)$type;
- if($size !== NULL) {
- $this->setSize($size);
- }
- }
-
- /**
- * Fill the mark with a color or a gradient
- *
- * @param mixed $fill A color or a gradient
- */
- public function setFill($fill) {
- if($fill instanceof awColor or $fill instanceof awGradient) {
- $this->fill = $fill;
- }
- }
-
- /**
- * Set an image
- * Only for awMark::IMAGE type.
- *
- * @param Image An image
- */
- public function setImage(awImage $image) {
- $this->image = $image;
- }
-
- /**
- * Draw the mark
- *
- * @param awDriver $driver
- * @param awPoint $point Mark center
- */
- public function draw(awDriver $driver, awPoint $point) {
-
- // Hide marks ?
- if($this->hide) {
- return;
- }
-
- // Check if we can print marks
- if($this->type !== NULL) {
-
- $this->driver = $driver;
- $realPoint = $this->move->move($point->x, $point->y);
-
- switch($this->type) {
-
- case awMark::CIRCLE :
- $this->drawCircle($realPoint);
- break;
-
- case awMark::SQUARE :
- $this->drawSquare($realPoint);
- break;
-
- case awMark::TRIANGLE :
- $this->drawTriangle($realPoint);
- break;
-
- case awMark::INVERTED_TRIANGLE :
- $this->drawTriangle($realPoint, TRUE);
- break;
-
- case awMark::RHOMBUS :
- $this->drawRhombus($realPoint);
- break;
-
- case awMark::CROSS :
- $this->drawCross($realPoint);
- break;
-
- case awMark::PLUS :
- $this->drawCross($realPoint, TRUE);
- break;
-
- case awMark::IMAGE :
- $this->drawImage($realPoint);
- break;
-
- case awMark::STAR :
- $this->changeType('star');
- $this->draw($driver, $point);
- break;
-
- case awMark::PAPERCLIP :
- $this->changeType('paperclip');
- $this->draw($driver, $point);
- break;
-
- case awMark::BOOK :
- $this->changeType('book');
- $this->draw($driver, $point);
- break;
-
- }
-
- }
-
- }
-
- protected function changeType($image) {
- $this->setType(awMARK::IMAGE);
- $this->setImage(new awFileImage(ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.$image.'.png'));
- }
-
- protected function drawCircle(awPoint $point) {
-
- $this->driver->filledEllipse(
- $this->fill,
- $point,
- $this->size, $this->size
- );
-
- $this->border->ellipse(
- $this->driver,
- $point,
- $this->size, $this->size
- );
-
- }
-
- protected function drawSquare(awPoint $point) {
-
- list($x, $y) = $point->getLocation();
-
- $x1 = (int)($x - $this->size / 2);
- $x2 = $x1 + $this->size;
- $y1 = (int)($y - $this->size / 2);
- $y2 = $y1 + $this->size;
-
- $this->border->rectangle($this->driver, new awPoint($x1, $y1), new awPoint($x2, $y2));
-
- $size = $this->border->visible() ? 1 : 0;
-
- $this->driver->filledRectangle(
- $this->fill,
- new awLine(
- new awPoint($x1 + $size, $y1 + $size),
- new awPoint($x2 - $size, $y2 - $size)
- )
- );
-
- }
-
- protected function drawTriangle(awPoint $point, $inverted = FALSE) {
-
- list($x, $y) = $point->getLocation();
-
- $size = $this->size;
-
- $triangle = new awPolygon;
- // Set default style and thickness
- $triangle->setStyle(awPolygon::SOLID);
- $triangle->setThickness(1);
-
- if($inverted === TRUE) {
- // Bottom of the triangle
- $triangle->append(new awPoint($x, $y + $size / sqrt(3)));
-
- // Upper left corner
- $triangle->append(new awPoint($x - $size / 2, $y - $size / (2 * sqrt(3))));
-
- // Upper right corner
- $triangle->append(new awPoint($x + $size / 2, $y - $size / (2 * sqrt(3))));
- } else {
- // Top of the triangle
- $triangle->append(new awPoint($x, $y - $size / sqrt(3)));
-
- // Lower left corner
- $triangle->append(new awPoint($x - $size / 2, $y + $size / (2 * sqrt(3))));
-
- // Lower right corner
- $triangle->append(new awPoint($x + $size / 2, $y + $size / (2 * sqrt(3))));
- }
-
- $this->driver->filledPolygon($this->fill, $triangle);
-
- if($this->border->visible()) {
- $this->border->polygon($this->driver, $triangle);
- }
- }
-
- protected function drawRhombus(awPoint $point) {
-
- list($x, $y) = $point->getLocation();
-
- $rhombus = new awPolygon;
- // Set default style and thickness
- $rhombus->setStyle(awPolygon::SOLID);
- $rhombus->setThickness(1);
-
- // Top of the rhombus
- $rhombus->append(new awPoint($x, $y - $this->size / 2));
-
- // Right of the rhombus
- $rhombus->append(new awPoint($x + $this->size / 2, $y));
-
- // Bottom of the rhombus
- $rhombus->append(new awPoint($x, $y + $this->size / 2));
-
- // Left of the rhombus
- $rhombus->append(new awPoint($x - $this->size / 2, $y));
-
- $this->driver->filledPolygon($this->fill, $rhombus);
-
- if($this->border->visible()) {
- $this->border->polygon($this->driver, $rhombus);
- }
- }
-
- protected function drawCross(awPoint $point, $upright = FALSE) {
-
- list($x, $y) = $point->getLocation();
-
- if($upright === TRUE) {
- $x11 = (int)($x);
- $y11 = (int)($y - $this->size / 2);
- $x12 = (int)($x);
- $y12 = (int)($y + $this->size / 2);
-
- $y21 = (int)($y);
- $y22 = (int)($y);
- } else {
- $x11 = (int)($x - $this->size / 2);
- $y11 = (int)($y + $this->size / 2);
- $x12 = (int)($x + $this->size / 2);
- $y12 = (int)($y - $this->size / 2);
-
- $y21 = (int)($y - $this->size / 2);
- $y22 = (int)($y + $this->size / 2);
- }
-
- $x21 = (int)($x - $this->size / 2);
- $x22 = (int)($x + $this->size / 2);
-
- $this->driver->line(
- $this->fill,
- new awLine(
- new awPoint($x11, $y11),
- new awPoint($x12, $y12)
- )
- );
-
- $this->driver->line(
- $this->fill,
- new awLine(
- new awPoint($x21, $y21),
- new awPoint($x22, $y22)
- )
- );
- }
-
- protected function drawImage(awPoint $point) {
-
- if($this->image instanceof awImage) {
-
- $width = $this->image->width;
- $height = $this->image->height;
-
- list($x, $y) = $point->getLocation();
-
- $x1 = (int)($x - $width / 2);
- $x2 = $x1 + $width;
- $y1 = (int)($y - $width / 2);
- $y2 = $y1 + $height;
-
- $this->border->rectangle($this->driver, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1));
-
- $this->driver->copyImage($this->image, new awPoint($x1, $y1), new awPoint($x2, $y2));
-
- }
-
- }
-
-}
-
-registerClass('Mark');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Math.class.php b/artichow/inc/Math.class.php
deleted file mode 100644
index a3d84ef..0000000
--- a/artichow/inc/Math.class.php
+++ /dev/null
@@ -1,832 +0,0 @@
-style = (int)$style;
- }
-
- /**
- * Return shape style
- *
- * @return int
- */
- public function getStyle() {
- return $this->style;
- }
-
- /**
- * Change shape thickness
- *
- * @param int $thickness Shape thickness in pixels
- */
- public function setThickness($thickness) {
- $this->thickness = (int)$thickness;
- }
-
- /**
- * Return shape thickness
- *
- * @return int
- */
- public function getThickness() {
- return $this->thickness;
- }
-
- /**
- * Hide the shape
- *
- * @param bool $hide
- */
- public function hide($hide) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show the shape
- *
- * @param bool $shape
- */
- public function show($shape) {
- $this->hide = (bool)!$shape;
- }
-
- /**
- * Is the line hidden ?
- *
- * @return bool
- */
- public function isHidden() {
- return $this->hide;
- }
-
-}
-
-registerClass('Shape', TRUE);
-
-/**
- * Describe a point
- *
- * @package Artichow
- */
-class awPoint extends awShape {
-
- /**
- * X coord
- *
- * @var float
- */
- public $x;
-
- /**
- * Y coord
- *
- * @var float
- */
- public $y;
-
- /**
- * Build a new awpoint
- *
- * @param float $x
- * @param float $y
- */
- public function __construct($x, $y) {
-
- $this->setLocation($x, $y);
-
- }
-
- /**
- * Change X value
- *
- * @param float $x
- */
- public function setX($x) {
- $this->x = (float)$x;
- }
-
- /**
- * Change Y value
- *
- * @param float $y
- */
- public function setY($y) {
- $this->y = (float)$y;
- }
-
- /**
- * Change point location
- *
- * @param float $x
- * @param float $y
- */
- public function setLocation($x, $y) {
- $this->setX($x);
- $this->setY($y);
- }
-
- /**
- * Get point location
- *
- * @param array Point location
- */
- public function getLocation() {
- return array($this->x, $this->y);
- }
-
- /**
- * Get distance to another point
- *
- * @param awPoint $p A point
- * @return float
- */
- public function getDistance(awPoint $p) {
-
- return sqrt(pow($p->x - $this->x, 2) + pow($p->y - $this->y, 2));
-
- }
-
- /**
- * Move the point to another location
- *
- * @param Point A Point with the new awlocation
- */
- public function move($x, $y) {
-
- return new awPoint(
- $this->x + $x,
- $this->y + $y
- );
-
- }
-
-}
-
-registerClass('Point');
-
-
-/**
- * Describe a line
- *
- * @package Artichow
- */
-class awLine extends awShape {
-
- /**
- * Line first point
- *
- * @param Point
- */
- public $p1;
-
- /**
- * Line second point
- *
- * @param Point
- */
- public $p2;
-
- /**
- * The line slope (the m in y = mx + p)
- *
- * @param float
- */
- private $slope;
-
- /**
- * The y-intercept value of the line (the p in y = mx + p)
- *
- * @param float
- */
- private $origin;
-
- /**
- * Build a new awline
- *
- * @param awPoint $p1 First point
- * @param awPoint $p2 Second point
- * @param int $type Style of line (default to solid)
- * @param int $thickness Line thickness (default to 1)
- */
- public function __construct($p1 = NULL, $p2 = NULL, $type = awLine::SOLID, $thickness = 1) {
-
- $this->setLocation($p1, $p2);
- $this->setStyle($type);
- $this->setThickness($thickness);
-
- }
-
- /**
- * Build a line from 4 coords
- *
- * @param int $x1 Left position
- * @param int $y1 Top position
- * @param int $x2 Right position
- * @param int $y2 Bottom position
- */
- public static function build($x1, $y1, $x2, $y2) {
-
- return new awLine(
- new awPoint($x1, $y1),
- new awPoint($x2, $y2)
- );
-
- }
-
- /**
- * Change X values of the line
- *
- * @param int $x1 Begin value
- * @param int $x2 End value
- */
- public function setX($x1, $x2) {
- $this->p1->setX($x1);
- $this->p2->setX($x2);
-
- // Resets slope and origin values so they are
- // recalculated when and if needed.
- $this->slope = NULL;
- $this->origin = NULL;
- }
-
- /**
- * Change Y values of the line
- *
- * @param int $y1 Begin value
- * @param int $y2 End value
- */
- public function setY($y1, $y2) {
- $this->p1->setY($y1);
- $this->p2->setY($y2);
-
- // Resets slope and origin values so they are
- // recalculated when and if needed.
- $this->slope = NULL;
- $this->origin = NULL;
- }
-
- /**
- * Change line location
- *
- * @param awPoint $p1 First point
- * @param awPoint $p2 Second point
- */
- public function setLocation($p1, $p2) {
- if(is_null($p1) or $p1 instanceof awPoint) {
- $this->p1 = $p1;
- }
- if(is_null($p2) or $p2 instanceof awPoint) {
- $this->p2 = $p2;
- }
-
- // Resets slope and origin values so they are
- // recalculated when and if needed.
- $this->slope = NULL;
- $this->origin = NULL;
- }
-
- /**
- * Get line location
- *
- * @param array Line location
- */
- public function getLocation() {
- return array($this->p1, $this->p2);
- }
-
- /**
- * Get the line size
- *
- * @return float
- */
- public function getSize() {
-
- $square = pow($this->p2->x - $this->p1->x, 2) + pow($this->p2->y - $this->p1->y, 2);
- return sqrt($square);
-
- }
-
- /**
- * Calculate the line slope
- *
- */
- private function calculateSlope() {
- if($this->isHorizontal()) {
- $this->slope = 0;
- } else {
- $slope = ($this->p1->y - $this->p2->y) / ($this->p1->x - $this->p2->x);
-
- $this->slope = $slope;
- }
- }
-
- /**
- * Calculate the y-intercept value of the line
- *
- */
- private function calculateOrigin() {
- if($this->isHorizontal()) {
- $this->origin = $this->p1->y; // Or p2->y
- } else {
- $y1 = $this->p1->y;
- $y2 = $this->p2->y;
- $x1 = $this->p1->x;
- $x2 = $this->p2->x;
-
- $origin = ($y2 * $x1 - $y1 * $x2) / ($x1 - $x2);
-
- $this->origin = $origin;
- }
- }
-
- /**
- * Calculate the slope and y-intercept value of the line
- *
- */
- private function calculateEquation() {
- $this->calculateSlope();
- $this->calculateOrigin();
- }
-
- /**
- * Get the line slope value
- *
- * @return float
- */
- public function getSlope() {
- if($this->isVertical()) {
- return NULL;
- } elseif($this->slope !== NULL) {
- return $this->slope;
- } else {
- $this->calculateSlope();
- return $this->slope;
- }
- }
-
- /**
- * Get the line y-intercept value
- *
- * @return float
- */
- public function getOrigin() {
- if($this->isVertical()) {
- return NULL;
- } elseif($this->origin !== NULL) {
- return $this->origin;
- } else {
- $this->calculateOrigin();
- return $this->origin;
- }
- }
-
- /**
- * Get the line equation
- *
- * @return array An array containing the slope and y-intercept value of the line
- */
- public function getEquation() {
- $slope = $this->getSlope();
- $origin = $this->getOrigin();
-
- return array($slope, $origin);
- }
-
- /**
- * Return the x coordinate of a point on the line
- * given its y coordinate.
- *
- * @param float $y The y coordinate of the Point
- * @return float $x The corresponding x coordinate
- */
- public function getXFrom($y) {
- $x = NULL;
-
- if($this->isVertical()) {
- list($p, ) = $this->getLocation();
- $x = $p->x;
- } else {
- list($slope, $origin) = $this->getEquation();
-
- if($slope !== 0) {
- $y = (float)$y;
- $x = ($y - $origin) / $slope;
- }
- }
-
- return $x;
- }
-
- /**
- * Return the y coordinate of a point on the line
- * given its x coordinate.
- *
- * @param float $x The x coordinate of the Point
- * @return float $y The corresponding y coordinate
- */
- public function getYFrom($x) {
- $y = NULL;
-
- if($this->isHorizontal()) {
- list($p, ) = $this->getLocation();
- $y = $p->y;
- } else {
- list($slope, $origin) = $this->getEquation();
-
- if($slope !== NULL) {
- $x = (float)$x;
- $y = $slope * $x + $origin;
- }
- }
-
- return $y;
- }
-
- /**
- * Test if the line can be considered as a point
- *
- * @return bool
- */
- public function isPoint() {
- return ($this->p1->x === $this->p2->x and $this->p1->y === $this->p2->y);
- }
-
- /**
- * Test if the line is a vertical line
- *
- * @return bool
- */
- public function isVertical() {
- return ($this->p1->x === $this->p2->x);
- }
-
- /**
- * Test if the line is an horizontal line
- *
- * @return bool
- */
- public function isHorizontal() {
- return ($this->p1->y === $this->p2->y);
- }
-
- /**
- * Returns TRUE if the line is going all the way from the top
- * to the bottom of the polygon surrounding box.
- *
- * @param $polygon Polygon A Polygon object
- * @return bool
- */
- public function isTopToBottom(awPolygon $polygon) {
- list($xMin, $xMax) = $polygon->getBoxXRange();
- list($yMin, $yMax) = $polygon->getBoxYRange();
-
- if($this->isHorizontal()) {
- return FALSE;
- } else {
- if($this->p1->y < $this->p2->y) {
- $top = $this->p1;
- $bottom = $this->p2;
- } else {
- $top = $this->p2;
- $bottom = $this->p1;
- }
-
- return (
- $this->isOnBoxTopSide($top, $xMin, $xMax, $yMin)
- and
- $this->isOnBoxBottomSide($bottom, $xMin, $xMax, $yMax)
- );
- }
- }
-
- /**
- * Returns TRUE if the line is going all the way from the left side
- * to the right side of the polygon surrounding box.
- *
- * @param $polygon Polygon A Polygon object
- * @return bool
- */
- public function isLeftToRight(awPolygon $polygon) {
- list($xMin, $xMax) = $polygon->getBoxXRange();
- list($yMin, $yMax) = $polygon->getBoxYRange();
-
- if($this->isVertical()) {
- return FALSE;
- } else {
- if($this->p1->x < $this->p2->x) {
- $left = $this->p1;
- $right = $this->p2;
- } else {
- $left = $this->p2;
- $right = $this->p1;
- }
- }
-
- return (
- $this->isOnBoxLeftSide($left, $yMin, $yMax, $xMin)
- and
- $this->isOnBoxRightSide($right, $yMin, $yMax, $xMax)
- );
- }
-
- private function isOnBoxTopSide(awPoint $point, $xMin, $xMax, $yMin) {
- if(
- $point->y === $yMin
- and
- $point->x >= $xMin
- and
- $point->x <= $xMax
- ) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- private function isOnBoxBottomSide(awPoint $point, $xMin, $xMax, $yMax) {
- if(
- $point->y === $yMax
- and
- $point->x >= $xMin
- and
- $point->x <= $xMax
- ) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- private function isOnBoxLeftSide(awPoint $point, $yMin, $yMax, $xMin) {
- if(
- $point->x === $xMin
- and
- $point->y >= $yMin
- and
- $point->y <= $yMax
- ) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- private function isOnBoxRightSide(awPoint $point, $yMin, $yMax, $xMax) {
- if(
- $point->x === $xMax
- and
- $point->y >= $yMin
- and
- $point->y <= $yMax
- ) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
-}
-
-registerClass('Line');
-
-/**
- * A vector is a type of line
- * The sense of the vector goes from $p1 to $p2.
- *
- * @package Artichow
- */
-class awVector extends awLine {
-
- /**
- * Get vector angle in radians
- *
- * @return float
- */
- public function getAngle() {
-
- if($this->isPoint()) {
- return 0.0;
- }
-
- $size = $this->getSize();
-
- $width = ($this->p2->x - $this->p1->x);
- $height = ($this->p2->y - $this->p1->y) * -1;
-
- if($width >= 0 and $height >= 0) {
- return acos($width / $size);
- } else if($width <= 0 and $height >= 0) {
- return acos($width / $size);
- } else {
- $height *= -1;
- if($width >= 0 and $height >= 0) {
- return 2 * M_PI - acos($width / $size);
- } else if($width <= 0 and $height >= 0) {
- return 2 * M_PI - acos($width / $size);
- }
- }
-
- }
-
-}
-
-registerClass('Vector');
-
-
-/**
- * Describe a polygon
- *
- * @package Artichow
- */
-class awPolygon extends awShape {
-
- /**
- * Polygon points
- *
- * @var array
- */
- protected $points = array();
-
- /**
- * Set a point in the polygon
- *
- * @param int $pos Point position
- * @param awPoint $point
- */
- public function set($pos, $point) {
- if(is_null($point) or $point instanceof awPoint) {
- $this->points[$pos] = $point;
- }
- }
-
- /**
- * Add a point at the end of the polygon
- *
- * @param awPoint $point
- */
- public function append($point) {
- if(is_null($point) or $point instanceof awPoint) {
- $this->points[] = $point;
- }
- }
-
- /**
- * Get a point at a position in the polygon
- *
- * @param int $pos Point position
- * @return Point
- */
- public function get($pos) {
- return $this->points[$pos];
- }
-
- /**
- * Count number of points in the polygon
- *
- * @return int
- */
- public function count() {
- return count($this->points);
- }
-
- /**
- * Returns all points in the polygon
- *
- * @return array
- */
- public function all() {
- return $this->points;
- }
-
- /**
- * Returns the different lines formed by the polygon vertices
- *
- * @return array
- */
- public function getLines() {
- $lines = array();
- $count = $this->count();
-
- for($i = 0; $i < $count - 1; $i++) {
- $lines[] = new Line($this->get($i), $this->get($i + 1));
- }
-
- // "Close" the polygon
- $lines[] = new Line($this->get($count - 1), $this->get(0));
-
- return $lines;
- }
-
- /**
- * Get the upper-left and lower-right points
- * of the bounding box around the polygon
- *
- * @return array An array of two Point objects
- */
- public function getBoxPoints() {
- $count = $this->count();
- $x = $y = array();
-
- for($i = 0; $i < $count; $i++) {
- $point = $this->get($i);
-
- list($x[], $y[]) = $point->getLocation();
- }
-
- $upperLeft = new Point(min($x), min($y));
- $lowerRight = new Point(max($x), max($y));
-
- return array($upperLeft, $lowerRight);
- }
-
- /**
- * Return the range of the polygon on the y axis,
- * i.e. the minimum and maximum y value of any point in the polygon
- *
- * @return array
- */
- public function getBoxYRange() {
- list($p1, $p2) = $this->getBoxPoints();
-
- list(, $yMin) = $p1->getLocation();
- list(, $yMax) = $p2->getLocation();
-
- return array($yMin, $yMax);
- }
-
- /**
- * Return the range of the polygon on the x axis,
- * i.e. the minimum and maximum x value of any point in the polygon
- *
- * @return array
- */
- public function getBoxXRange() {
- list($p1, $p2) = $this->getBoxPoints();
-
- list($xMin, ) = $p1->getLocation();
- list($xMax, ) = $p2->getLocation();
-
- return array($xMin, $xMax);
- }
-
-}
-
-registerClass('Polygon');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Shadow.class.php b/artichow/inc/Shadow.class.php
deleted file mode 100644
index c04103e..0000000
--- a/artichow/inc/Shadow.class.php
+++ /dev/null
@@ -1,406 +0,0 @@
-setPosition($position);
- }
-
- /**
- * Hide shadow ?
- *
- * @param bool $hide
- */
- public function hide($hide = TRUE) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Show shadow ?
- *
- * @param bool $show
- */
- public function show($show = TRUE) {
- $this->hide = (bool)!$show;
- }
-
- /**
- * Change shadow size
- *
- * @param int $size
- * @param bool $smooth Smooth the shadow (facultative argument)
- */
- public function setSize($size, $smooth = NULL) {
- $this->size = (int)$size;
- if($smooth !== NULL) {
- $this->smooth($smooth);
- }
- }
-
- /**
- * Change shadow color
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- }
-
- /**
- * Change shadow position
- *
- * @param int $position
- */
- public function setPosition($position) {
- $this->position = (int)$position;
- }
-
- /**
- * Smooth shadow ?
- *
- * @param bool $smooth
- */
- public function smooth($smooth) {
- $this->smooth = (bool)$smooth;
- }
-
- /**
- * Get the space taken by the shadow
- *
- * @return Side
- */
- public function getSpace() {
-
- return new awSide(
- ($this->position === awShadow::LEFT_TOP or $this->position === awShadow::LEFT_BOTTOM) ? $this->size : 0,
- ($this->position === awShadow::RIGHT_TOP or $this->position === awShadow::RIGHT_BOTTOM) ? $this->size : 0,
- ($this->position === awShadow::LEFT_TOP or $this->position === awShadow::RIGHT_TOP) ? $this->size : 0,
- ($this->position === awShadow::LEFT_BOTTOM or $this->position === awShadow::RIGHT_BOTTOM) ? $this->size : 0
- );
-
- }
-
- /**
- * Draw shadow
- *
- * @param awDriver $driver
- * @param awPoint $p1 Top-left point
- * @param awPoint $p2 Right-bottom point
- * @param int Drawing mode
- */
- public function draw(awDriver $driver, awPoint $p1, awPoint $p2, $mode) {
-
- if($this->hide) {
- return;
- }
-
- if($this->size <= 0) {
- return;
- }
-
- $driver = clone $driver;
-
- $color = ($this->color instanceof awColor) ? $this->color : new awColor(125, 125, 125);
-
- switch($this->position) {
-
- case awShadow::RIGHT_BOTTOM :
-
- if($mode === awShadow::OUT) {
- $t1 = $p1->move(0, 0);
- $t2 = $p2->move($this->size + 1, $this->size + 1);
- } else { // PHP 4 compatibility
- $t1 = $p1->move(0, 0);
- $t2 = $p2->move(0, 0);
- }
-
- $width = $t2->x - $t1->x;
- $height = $t2->y - $t1->y;
-
- $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($width - $this->size, $this->size),
- new awPoint($width - 1, $height - 1)
- )
- );
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($this->size, $height - $this->size),
- new awPoint($width - $this->size - 1, $height - 1)
- )
- );
-
- $this->smoothPast($driver, $color, $width, $height);
-
- break;
-
- case awShadow::LEFT_TOP :
-
- if($mode === awShadow::OUT) {
- $t1 = $p1->move(- $this->size, - $this->size);
- $t2 = $p2->move(0, 0);
- } else { // PHP 4 compatibility
- $t1 = $p1->move(0, 0);
- $t2 = $p2->move(0, 0);
- }
-
- $width = $t2->x - $t1->x;
- $height = $t2->y - $t1->y;
-
- $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
-
- $height = max($height + 1, $this->size);
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint(0, 0),
- new awPoint($this->size - 1, $height - $this->size - 1)
- )
- );
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($this->size, 0),
- new awPoint($width - $this->size - 1, $this->size - 1)
- )
- );
-
- $this->smoothPast($driver, $color, $width, $height);
-
- break;
-
- case awShadow::RIGHT_TOP :
-
- if($mode === awShadow::OUT) {
- $t1 = $p1->move(0, - $this->size);
- $t2 = $p2->move($this->size + 1, 0);
- } else { // PHP 4 compatibility
- $t1 = $p1->move(0, 0);
- $t2 = $p2->move(0, 0);
- }
-
- $width = $t2->x - $t1->x;
- $height = $t2->y - $t1->y;
-
- $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
-
- $height = max($height + 1, $this->size);
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($width - $this->size, 0),
- new awPoint($width - 1, $height - $this->size - 1)
- )
- );
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($this->size, 0),
- new awPoint($width - $this->size - 1, $this->size - 1)
- )
- );
-
- $this->smoothFuture($driver, $color, $width, $height);
-
- break;
-
- case awShadow::LEFT_BOTTOM :
-
- if($mode === awShadow::OUT) {
- $t1 = $p1->move(- $this->size, 0);
- $t2 = $p2->move(0, $this->size + 1);
- } else { // PHP 4 compatibility
- $t1 = $p1->move(0, 0);
- $t2 = $p2->move(0, 0);
- }
-
- $width = $t2->x - $t1->x;
- $height = $t2->y - $t1->y;
-
- $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint(0, $this->size),
- new awPoint($this->size - 1, $height - 1)
- )
- );
-
- $driver->filledRectangle(
- $color,
- new awLine(
- new awPoint($this->size, $height - $this->size),
- new awPoint($width - $this->size - 1, $height - 1)
- )
- );
-
- $this->smoothFuture($driver, $color, $width, $height);
-
- break;
-
- }
-
- }
-
- private function smoothPast(awDriver $driver, awColor $color, $width, $height) {
-
- if($this->smooth) {
-
- for($i = 0; $i < $this->size; $i++) {
- for($j = 0; $j <= $i; $j++) {
- $driver->point(
- $color,
- new awPoint($i, $j + $height - $this->size)
- );
- }
- }
-
- for($i = 0; $i < $this->size; $i++) {
- for($j = 0; $j <= $i; $j++) {
- $driver->point(
- $color,
- new awPoint($width - $this->size + $j, $i)
- );
- }
- }
-
- }
-
- }
-
- private function smoothFuture(awDriver $driver, awColor $color, $width, $height) {
-
- if($this->smooth) {
-
- for($i = 0; $i < $this->size; $i++) {
- for($j = 0; $j <= $i; $j++) {
- $driver->point(
- $color,
- new awPoint($i, $this->size - $j - 1)
- );
- }
- }
-
- for($i = 0; $i < $this->size; $i++) {
- for($j = 0; $j <= $i; $j++) {
- $driver->point(
- $color,
- new awPoint($width - $this->size + $j, $height - $i - 1)
- );
- }
- }
-
- }
- }
-
-}
-
-registerClass('Shadow');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Text.class.php b/artichow/inc/Text.class.php
deleted file mode 100644
index a0ab4b5..0000000
--- a/artichow/inc/Text.class.php
+++ /dev/null
@@ -1,233 +0,0 @@
-setText($text);
- $this->setFont($font);
-
- // Set default color to black
- if($color === NULL) {
- $color = new awColor(0, 0, 0);
- }
-
- $this->setColor($color);
- $this->setAngle($angle);
-
- $this->border = new awBorder;
- $this->border->hide();
-
- }
-
- /**
- * Get text
- *
- * @return string
- */
- public function getText() {
- return $this->text;
- }
-
- /**
- * Change text
- *
- * @param string $text New text
- */
- public function setText($text) {
- $this->text = (string)$text;
- $this->text = str_replace("\r", "", $text);
- }
-
- /**
- * Change text font
- *
- * @param Font
- */
- public function setFont(awFont $font) {
- $this->font = $font;
- }
-
- /**
- * Get text font
- *
- * @return int
- */
- public function getFont() {
- return $this->font;
- }
-
- /**
- * Change text angle
- *
- * @param int
- */
- public function setAngle($angle) {
- $this->angle = (int)$angle;
- }
-
- /**
- * Get text angle
- *
- * @return int
- */
- public function getAngle() {
- return $this->angle;
- }
-
- /**
- * Change text color
- *
- * @param Color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- }
-
- /**
- * Get text color
- *
- * @return Color
- */
- public function getColor() {
- return $this->color;
- }
-
- /**
- * Change text background
- *
- * @param mixed $background
- */
- public function setBackground($background) {
- if($background instanceof awColor) {
- $this->setBackgroundColor($background);
- } elseif($background instanceof awGradient) {
- $this->setBackgroundGradient($background);
- }
- }
-
- /**
- * Change text background color
- *
- * @param awColor $color
- */
- public function setBackgroundColor(awColor $color) {
- $this->background = $color;
- }
-
- /**
- * Change text background gradient
- *
- * @param awGradient $gradient
- */
- public function setBackgroundGradient(awGradient $gradient) {
- $this->background = $gradient;
- }
-
- /**
- * Get text background
- *
- * @return Color, Gradient
- */
- public function getBackground() {
- return $this->background;
- }
-
- /**
- * Change padding
- *
- * @param int $left Left padding
- * @param int $right Right padding
- * @param int $top Top padding
- * @param int $bottom Bottom padding
- */
- public function setPadding($left, $right, $top, $bottom) {
- $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom);
- }
-
- /**
- * Get current padding
- *
- * @return array
- */
- public function getPadding() {
- return $this->padding;
- }
-
-}
-
-registerClass('Text');
-?>
diff --git a/artichow/inc/Tick.class.php b/artichow/inc/Tick.class.php
deleted file mode 100644
index 928f4f7..0000000
--- a/artichow/inc/Tick.class.php
+++ /dev/null
@@ -1,344 +0,0 @@
-setSize($size);
- $this->setNumber($number);
- $this->setColor(new awBlack);
- $this->style = awTick::IN;
-
- }
-
- /**
- * Change ticks style
- *
- * @param int $style
- */
- public function setStyle($style) {
- $this->style = (int)$style;
- }
-
- /**
- * Get ticks style
- *
- * @return int
- */
- public function getStyle() {
- return $this->style;
- }
-
- /**
- * Change ticks color
- *
- * @param awColor $color
- */
- public function setColor(awColor $color) {
- $this->color = $color;
- }
-
- /**
- * Change ticks size
- *
- * @param int $size
- */
- public function setSize($size) {
- $this->size = (int)$size;
- }
-
- /**
- * Change interval of ticks
- *
- * @param int $interval
- */
- public function setInterval($interval) {
- $this->interval = (int)$interval;
- }
-
- /**
- * Get interval between each tick
- *
- * @return int
- */
- public function getInterval() {
- return $this->interval;
- }
-
- /**
- * Change number of ticks
- *
- * @param int $number
- */
- public function setNumber($number) {
- $this->number = (int)$number;
- }
-
- /**
- * Get number of ticks
- *
- * @return int
- */
- public function getNumber() {
- return $this->number;
- }
-
- /**
- * Change number of ticks relative to others ticks
- *
- * @param awTick $tick Ticks reference
- * @param int $number Number of ticks
- */
- public function setNumberByTick(awTick $tick, $number) {
-
- $this->numberByTick = array($tick, (int)$number);
-
- }
-
- /**
- * Hide ticks
- *
- * @param bool $hide
- */
- public function hide($hide) {
- $this->hide = (bool)$hide;
- }
-
- /**
- * Hide first tick
- *
- * @param bool $hide
- */
- public function hideFirst($hide) {
- $this->hideFirst = (bool)$hide;
- }
-
- /**
- * Hide last tick
- *
- * @param bool $hide
- */
- public function hideLast($hide) {
- $this->hideLast = (bool)$hide;
- }
-
- /**
- * Draw ticks on a vector
- *
- * @param awDriver $driver A driver
- * @param awVector $vector A vector
- */
- public function draw(awDriver $driver, awVector $vector) {
-
- if($this->numberByTick !== NULL) {
- list($tick, $number) = $this->numberByTick;
- $this->number = 1 + ($tick->getNumber() - 1) * ($number + 1);
- $this->interval = $tick->getInterval();
- }
-
- if($this->number < 2 or $this->hide) {
- return;
- }
-
- $angle = $vector->getAngle();
- // echo "INIT:".$angle." ";
- switch($this->style) {
-
- case awTick::IN :
- $this->drawTicks($driver, $vector, NULL, $angle + M_PI / 2);
- break;
-
- case awTick::OUT :
- $this->drawTicks($driver, $vector, $angle + 3 * M_PI / 2, NULL);
- break;
-
- default :
- $this->drawTicks($driver, $vector, $angle + M_PI / 2, $angle + 3 * M_PI / 2);
- break;
-
- }
-
- }
-
- protected function drawTicks(awDriver $driver, awVector $vector, $from, $to) {
-
- // Draw last tick
- if($this->hideLast === FALSE) {
-
- //echo '';
- if(($this->number - 1) % $this->interval === 0) {
- $this->drawTick($driver, $vector->p2, $from, $to);
- }
- //echo '';
-
- }
-
- $number = $this->number - 1;
- $size = $vector->getSize();
-
- // Get tick increment in pixels
- $inc = $size / $number;
-
- // Check if we must hide the first tick
- $start = $this->hideFirst ? $inc : 0;
- $stop = $inc * $number;
-
- $position = 0;
-
- for($i = $start; round($i, 6) < $stop; $i += $inc) {
-
- if($position % $this->interval === 0) {
- $p = $vector->p1->move(
- round($i * cos($vector->getAngle()), 6),
- round($i * sin($vector->getAngle() * -1), 6)
- );
- $this->drawTick($driver, $p, $from, $to);
- }
-
- $position++;
-
- }
- //echo '
';
- }
-
- protected function drawTick(awDriver $driver, awPoint $p, $from, $to) {
-// echo $this->size.':'.$angle.'|'.cos($angle).'/';
- // The round avoid some errors in the calcul
- // For example, 12.00000008575245 becomes 12
- $p1 = $p;
- $p2 = $p;
-
- if($from !== NULL) {
- $p1 = $p1->move(
- round($this->size * cos($from), 6),
- round($this->size * sin($from) * -1, 6)
- );
- }
-
- if($to !== NULL) {
- $p2 = $p2->move(
- round($this->size * cos($to), 6),
- round($this->size * sin($to) * -1, 6)
- );
- }
- //echo $p1->x.':'.$p2->x.'('.$p1->y.':'.$p2->y.')'.'/';
- $vector = new awVector(
- $p1, $p2
- );
-
- $driver->line(
- $this->color,
- $vector
- );
-
- }
-
-}
-
-registerClass('Tick');
-?>
\ No newline at end of file
diff --git a/artichow/inc/Tools.class.php b/artichow/inc/Tools.class.php
deleted file mode 100644
index de23307..0000000
--- a/artichow/inc/Tools.class.php
+++ /dev/null
@@ -1,175 +0,0 @@
-set($left, $right, $top, $bottom);
- }
-
-
- /**
- * Change side values
- *
- * @param mixed $left
- * @param mixed $right
- * @param mixed $top
- * @param mixed $bottom
- */
- public function set($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) {
-
- if($left !== NULL) {
- $this->left = (float)$left;
- }
- if($right !== NULL) {
- $this->right = (float)$right;
- }
- if($top !== NULL) {
- $this->top = (float)$top;
- }
- if($bottom !== NULL) {
- $this->bottom = (float)$bottom;
- }
-
- }
-
-
- /**
- * Add values to each side
- *
- * @param mixed $left
- * @param mixed $right
- * @param mixed $top
- * @param mixed $bottom
- */
- public function add($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) {
-
- if($left !== NULL) {
- $this->left += (float)$left;
- }
- if($right !== NULL) {
- $this->right += (float)$right;
- }
- if($top !== NULL) {
- $this->top += (float)$top;
- }
- if($bottom !== NULL) {
- $this->bottom += (float)$bottom;
- }
-
- }
-
-}
-
-registerClass('Side');
-?>
\ No newline at end of file
diff --git a/artichow/inc/drivers/gd.class.php b/artichow/inc/drivers/gd.class.php
deleted file mode 100644
index eca48a9..0000000
--- a/artichow/inc/drivers/gd.class.php
+++ /dev/null
@@ -1,1336 +0,0 @@
-driverString = 'gd';
- }
-
- public function init(awImage $image) {
-
- if($this->resource === NULL) {
-
- $this->setImageSize($image->width, $image->height);
-
- // Create image
- $this->resource = imagecreatetruecolor($this->imageWidth, $this->imageHeight);
- if(!$this->resource) {
- awImage::drawError("Class Image: Unable to create a graph.");
- }
-
- imagealphablending($this->resource, TRUE);
-
- // Antialiasing is now handled by the Driver object
- $this->setAntiAliasing($image->getAntiAliasing());
-
- // Original color
- $this->filledRectangle(
- new awWhite,
- new awLine(
- new awPoint(0, 0),
- new awPoint($this->imageWidth, $this->imageHeight)
- )
- );
-
- $shadow = $image->shadow;
- if($shadow !== NULL) {
- $shadow = $shadow->getSpace();
- $p1 = new awPoint($shadow->left, $shadow->top);
- $p2 = new awPoint($this->imageWidth - $shadow->right - 1, $this->imageHeight - $shadow->bottom - 1);
-
-
- // Draw image background
- $this->filledRectangle($image->getBackground(), new awLine($p1, $p2));
-
- // Draw image border
- $image->border->rectangle($this, $p1, $p2);
- }
-
- }
- }
-
- public function initFromFile(awFileImage $fileImage, $file) {
-
- $image = @getimagesize((string)$file);
-
- if($image and in_array($image[2], array(2, 3))) {
-
- $fileImage->setSize($image[0], $image[1]);
-
- switch($image[2]) {
-
- case 2 :
- $this->resource = imagecreatefromjpeg($file);
- break;
-
- case 3 :
- $this->resource = imagecreatefrompng($file);
- break;
-
- }
-
- $this->setImageSize($fileImage->width, $fileImage->height);
- } else {
- awImage::drawError("Class FileImage: Artichow does not support the format of this image (must be in PNG or JPEG)");
- }
- }
-
- public function setImageSize($width, $height) {
-
- $this->imageWidth = $width;
- $this->imageHeight = $height;
-
- }
-
- public function setPosition($x, $y) {
-
- // Calculate absolute position
- $this->x = round($x * $this->imageWidth - $this->w / 2);
- $this->y = round($y * $this->imageHeight - $this->h / 2);
-
- }
-
- public function setAbsPosition($x, $y) {
-
- $this->x = $x;
- $this->y = $y;
-
- }
-
- public function movePosition($x, $y) {
-
- $this->x += (int)$x;
- $this->y += (int)$y;
-
- }
-
- public function setSize($w, $h) {
-
- // Calcul absolute size
- $this->w = round($w * $this->imageWidth);
- $this->h = round($h * $this->imageHeight);
-
- return $this->getSize();
-
- }
-
- public function setAbsSize($w, $h) {
-
- $this->w = $w;
- $this->h = $h;
-
- return $this->getSize();
-
- }
-
- public function getSize() {
-
- return array($this->w, $this->h);
-
- }
-
- public function setAntiAliasing($bool) {
-
- if(function_exists('imageantialias')) {
- imageantialias($this->resource, (bool)$bool);
-
- $this->antiAliasing = (bool)$bool;
- } else {
- awImage::drawErrorFile('missing-anti-aliasing');
- }
- }
-
- public function getColor(awColor $color) {
-
- if($color->alpha === 0 or function_exists('imagecolorallocatealpha') === FALSE) {
- $gdColor = imagecolorallocate($this->resource, $color->red, $color->green, $color->blue);
- } else {
- $gdColor = imagecolorallocatealpha($this->resource, $color->red, $color->green, $color->blue, $color->alpha);
- }
-
- return $gdColor;
- }
-
- public function copyImage(awImage $image, awPoint $p1, awPoint $p2) {
-
- list($x1, $y1) = $p1->getLocation();
- list($x2, $y2) = $p2->getLocation();
-
- $driver = $image->getDriver();
- imagecopy($this->resource, $driver->resource, $this->x + $x1, $this->y + $y1, 0, 0, $x2 - $x1, $y2 - $y1);
-
- }
-
- public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE) {
-
- if($resample) {
- $function = 'imagecopyresampled';
- } else {
- $function = 'imagecopyresized';
- }
-
- $driver = $image->getDriver();
-
- $function(
- $this->resource,
- $driver->resource,
- $this->x + $d1->x, $this->y + $d1->y,
- $s1->x, $s1->y,
- $d2->x - $d1->x, $d2->y - $d1->y,
- $s2->x - $s1->x, $s2->y - $s1->y
- );
-
- }
-
- public function string(awText $text, awPoint $point, $width = NULL) {
-
- $font = $text->getFont();
-
- // Can we deal with that font?
- if($this->isCompatibleWithFont($font) === FALSE) {
- awImage::drawError('Class GDDriver: Incompatible font type (\''.get_class($font).'\')');
- }
-
- // Check which FontDriver to use
- if($font instanceof awPHPFont) {
- $fontDriver = $this->phpFontDriver;
- } else {
- $fontDriver = $this->fileFontDriver;
- }
-
- if($text->getBackground() !== NULL or $text->border->visible()) {
-
- list($left, $right, $top, $bottom) = $text->getPadding();
-
- $textWidth = $fontDriver->getTextWidth($text, $this);
- $textHeight = $fontDriver->getTextHeight($text, $this);
-
- $x1 = floor($point->x - $left);
- $y1 = floor($point->y - $top);
- $x2 = $x1 + $textWidth + $left + $right;
- $y2 = $y1 + $textHeight + $top + $bottom;
-
- $this->filledRectangle(
- $text->getBackground(),
- awLine::build($x1, $y1, $x2, $y2)
- );
-
- $text->border->rectangle(
- $this,
- new awPoint($x1 - 1, $y1 - 1),
- new awPoint($x2 + 1, $y2 + 1)
- );
-
- }
-
- $fontDriver->string($this, $text, $point, $width);
-
- }
-
- public function point(awColor $color, awPoint $p) {
-
- if($p->isHidden() === FALSE) {
- $rgb = $this->getColor($color);
- imagesetpixel($this->resource, $this->x + round($p->x), $this->y + round($p->y), $rgb);
- }
-
- }
-
- public function line(awColor $color, awLine $line) {
-
- if($line->thickness > 0 and $line->isHidden() === FALSE) {
-
- $rgb = $this->getColor($color);
- $thickness = $line->thickness;
-
- list($p1, $p2) = $line->getLocation();
-
- $this->startThickness($thickness);
-
- switch($line->getStyle()) {
-
- case awLine::SOLID :
- imageline($this->resource, $this->x + round($p1->x), $this->y + round($p1->y), $this->x + round($p2->x), $this->y + round($p2->y), $rgb);
- break;
-
- case awLine::DOTTED :
- $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2));
- $cos = ($p2->x - $p1->x) / $size;
- $sin = ($p2->y - $p1->y) / $size;
- for($i = 0; $i <= $size; $i += 2) {
- $p = new awPoint(
- round($i * $cos + $p1->x),
- round($i * $sin + $p1->y)
- );
- $this->point($color, $p);
- }
- break;
-
- case awLine::DASHED :
- $width = $p2->x - $p1->x;
- $height = $p2->y - $p1->y;
- $size = sqrt(pow($height, 2) + pow($width, 2));
-
- if($size == 0) {
- return;
- }
-
- $cos = $width / $size;
- $sin = $height / $size;
-
- $functionX = ($width > 0) ? 'min' : 'max';
- $functionY = ($height > 0) ? 'min' : 'max';
-
- for($i = 0; $i <= $size; $i += 6) {
-
- $t1 = new awPoint(
- round($i * $cos + $p1->x),
- round($i * $sin + $p1->y)
- );
-
- $t2 = new awPoint(
- round($functionX(($i + 3) * $cos, $width) + $p1->x),
- round($functionY(($i + 3) * $sin, $height) + $p1->y)
- );
-
- $this->line($color, new awLine($t1, $t2));
-
- }
- break;
-
- }
-
- $this->stopThickness($thickness);
-
- }
-
- }
-
- public function arc(awColor $color, awPoint $center, $width, $height, $from, $to) {
-
- imagefilledarc(
- $this->resource,
- $this->x + $center->x, $this->y + $center->y,
- $width, $height,
- $from, $to,
- $this->getColor($color),
- IMG_ARC_EDGED | IMG_ARC_NOFILL
- );
-
- }
-
- public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to) {
-
- imagefilledarc(
- $this->resource,
- $this->x + $center->x, $this->y + $center->y,
- $width, $height,
- $from, $to,
- $this->getColor($color),
- IMG_ARC_PIE
- );
-
- }
-
- public function ellipse(awColor $color, awPoint $center, $width, $height) {
-
- list($x, $y) = $center->getLocation();
-
- $rgb = $this->getColor($color);
- imageellipse(
- $this->resource,
- $this->x + $x,
- $this->y + $y,
- $width,
- $height,
- $rgb
- );
-
- }
-
- public function filledEllipse($background, awPoint $center, $width, $height) {
-
- if($background instanceof awColor) {
-
- list($x, $y) = $center->getLocation();
-
- $rgb = $this->getColor($background);
-
- imagefilledellipse(
- $this->resource,
- $this->x + $x,
- $this->y + $y,
- $width,
- $height,
- $rgb
- );
-
- } else if($background instanceof awGradient) {
-
- list($x, $y) = $center->getLocation();
-
- $x1 = $x - round($width / 2);
- $y1 = $y - round($height / 2);
- $x2 = $x1 + $width;
- $y2 = $y1 + $height;
-
- $gradientDriver = new awGDGradientDriver($this);
- $gradientDriver->filledEllipse(
- $background,
- $x1, $y1,
- $x2, $y2
- );
-
- }
-
- }
-
- public function rectangle(awColor $color, awLine $line) {
-
- list($p1, $p2) = $line->getLocation();
-
- switch($line->getStyle()) {
-
- case awLine::SOLID :
- $thickness = $line->getThickness();
- $this->startThickness($thickness);
- $rgb = $this->getColor($color);
- imagerectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb);
- $this->stopThickness($thickness);
- break;
-
- default :
-
- $side = clone $line;
-
-
-
- // Top side
- $side->setLocation(
- new awPoint($p1->x, $p1->y),
- new awPoint($p2->x, $p1->y)
- );
- $this->line($color, $side);
-
- // Right side
- $side->setLocation(
- new awPoint($p2->x, $p1->y),
- new awPoint($p2->x, $p2->y)
- );
- $this->line($color, $side);
-
- // Bottom side
- $side->setLocation(
- new awPoint($p1->x, $p2->y),
- new awPoint($p2->x, $p2->y)
- );
- $this->line($color, $side);
-
- // Left side
- $side->setLocation(
- new awPoint($p1->x, $p1->y),
- new awPoint($p1->x, $p2->y)
- );
- $this->line($color, $side);
-
- break;
-
- }
-
- }
-
- public function filledRectangle($background, awLine $line) {
-
- $p1 = $line->p1;
- $p2 = $line->p2;
-
- if($background instanceof awColor) {
- $rgb = $this->getColor($background);
- imagefilledrectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb);
- } else if($background instanceof awGradient) {
- $gradientDriver = new awGDGradientDriver($this);
- $gradientDriver->filledRectangle($background, $p1, $p2);
- }
-
- }
-
- public function polygon(awColor $color, awPolygon $polygon) {
-
- switch($polygon->getStyle()) {
-
- case awPolygon::SOLID :
- $thickness = $polygon->getThickness();
- $this->startThickness($thickness);
- $points = $this->getPolygonPoints($polygon);
- $rgb = $this->getColor($color);
- imagepolygon($this->resource, $points, $polygon->count(), $rgb);
- $this->stopThickness($thickness);
- break;
-
- default :
-
- if($polygon->count() > 1) {
-
- $prev = $polygon->get(0);
-
- $line = new awLine;
- $line->setStyle($polygon->getStyle());
- $line->setThickness($polygon->getThickness());
-
- for($i = 1; $i < $polygon->count(); $i++) {
- $current = $polygon->get($i);
- $line->setLocation($prev, $current);
- $this->line($color, $line);
- $prev = $current;
- }
-
- // Close the polygon
- $line->setLocation($prev, $polygon->get(0));
- $this->line($color, $line);
-
- }
-
- }
-
- }
-
- public function filledPolygon($background, awPolygon $polygon) {
-
- if($background instanceof awColor) {
-
- $points = $this->getPolygonPoints($polygon);
- $rgb = $this->getColor($background);
-
- imagefilledpolygon($this->resource, $points, $polygon->count(), $rgb);
-
- } else if($background instanceof awGradient) {
-
- $gradientDriver = new awGDGradientDriver($this);
- $gradientDriver->filledPolygon($background, $polygon);
-
- }
-
- }
-
- public function send(awImage $image) {
-
- $this->drawImage($image);
-
- }
-
- public function get(awImage $image) {
-
- return $this->drawImage($image, TRUE, FALSE);
-
- }
-
- public function getTextWidth(awText $text) {
- $font = $text->getFont();
-
- if($font instanceof awPHPFont) {
- $fontDriver = $this->phpFontDriver;
- } else {
- $fontDriver = $this->fileFontDriver;
- }
-
- return $fontDriver->getTextWidth($text, $this);
- }
-
- public function getTextHeight(awText $text) {
- $font = $text->getFont();
-
- if($font instanceof awPHPFont) {
- $fontDriver = $this->phpFontDriver;
- } else {
- $fontDriver = $this->fileFontDriver;
- }
-
- return $fontDriver->getTextHeight($text, $this);
- }
-
- protected function isCompatibleWithFont(awFont $font) {
- if($font instanceof awFDBFont) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
-
- private function drawImage(awImage $image, $return = FALSE, $header = TRUE) {
-
- $format = $image->getFormatString();
-
- // Test if format is available
- if((imagetypes() & $image->getFormat()) === FALSE) {
- awImage::drawError("Class Image: Format '".$format."' is not available on your system. Check that your PHP has been compiled with the good libraries.");
- }
-
- // Get some infos about this image
- switch($format) {
- case 'jpeg' :
- $function = 'imagejpeg';
- break;
- case 'png' :
- $function = 'imagepng';
- break;
- case 'gif' :
- $function = 'imagegif';
- break;
- }
-
- // Send headers to the browser
- if($header === TRUE) {
- $image->sendHeaders();
- }
-
- if($return) {
- ob_start();
- }
-
- $function($this->resource);
-
- if($return) {
- return ob_get_clean();
- }
- }
-
- private function getPolygonPoints(awPolygon $polygon) {
-
- $points = array();
-
- foreach($polygon->all() as $point) {
- $points[] = $point->x + $this->x;
- $points[] = $point->y + $this->y;
- }
-
- return $points;
-
- }
-
- private function startThickness($thickness) {
-
- if($thickness > 1) {
-
- // Beurk :'(
- if($this->antiAliasing and function_exists('imageantialias')) {
- imageantialias($this->resource, FALSE);
- }
- imagesetthickness($this->resource, $thickness);
-
- }
-
- }
-
- private function stopThickness($thickness) {
-
- if($thickness > 1) {
-
- if($this->antiAliasing and function_exists('imageantialias')) {
- imageantialias($this->resource, TRUE);
- }
- imagesetthickness($this->resource, 1);
-
- }
-
- }
-
-
-}
-
-registerClass('GDDriver');
-
-/**
- * To your gradients
- *
- * @package Artichow
- */
-
-class awGDGradientDriver {
-
- /**
- * A driver
- *
- * @var awGDDriver
- */
- protected $driver;
-
- /**
- * Build your GDGradientDriver
- *
- * @var awGDDriver $driver
- */
- public function __construct(awGDDriver $driver) {
-
- $this->driver = $driver;
-
- }
-
- public function drawFilledFlatTriangle(awGradient $gradient, awPoint $a, awPoint $b, awPoint $c) {
-
- if($gradient->angle !== 0) {
- awImage::drawError("Class GDGradientDriver: Flat triangles can only be used with 0 degree gradients.");
- }
-
- // Look for right-angled triangle
- if($a->x !== $b->x and $b->x !== $c->x) {
- awImage::drawError("Class GDGradientDriver: Not right-angled flat triangles are not supported yet.");
- }
-
- if($a->x === $b->x) {
- $d = $a;
- $e = $c;
- } else {
- $d = $c;
- $e = $a;
- }
-
- $this->init($gradient, $b->y - $d->y);
-
- for($i = $c->y + 1; $i < $b->y; $i++) {
-
- $color = $this->color($i - $d->y);
- $pos = ($i - $d->y) / ($b->y - $d->y);
-
- $p1 = new awPoint($e->x, $i);
- $p2 = new awPoint(1 + floor($e->x - $pos * ($e->x - $d->x)), $i);
-
- $this->driver->filledRectangle($color, new awLine($p1, $p2));
-
- unset($color);
-
- }
-
- }
-
- protected function drawFilledTriangle(awGradient $gradient, awPolygon $polygon) {
-
- if($gradient->angle === 0) {
- $this->drawFilledTriangleVertically($gradient, $polygon);
- } elseif($gradient->angle === 90) {
- $this->drawFilledTriangleHorizontally($gradient, $polygon);
- }
-
- }
-
- private function drawFilledTriangleVertically(awGradient $gradient, awPolygon $polygon) {
- list($yMin, $yMax) = $polygon->getBoxYRange();
-
- $this->init($gradient, $yMax - $yMin);
-
- // Get the triangle line we will draw our lines from
- $fromLine = NULL;
- $lines = $polygon->getLines();
-
- $count = count($lines);
-
- // Pick the side of the triangle going from the top
- // to the bottom of the surrounding box
- for($i = 0; $i < $count; $i++) {
- if($lines[$i]->isTopToBottom($polygon)) {
- list($fromLine) = array_splice($lines, $i, 1);
- break;
- }
- }
-
- // If for some reason the three points are aligned,
- // $fromLine will still be NULL
- if($fromLine === NULL) {
- return;
- }
-
- $fillLine = NULL;
- for($y = round($yMin); $y < round($yMax); $y++) {
-
- $fromX = $fromLine->getXFrom($y);
-
- $toX = array();
- foreach($lines as $line) {
- $xValue = $line->getXFrom($y);
-
- if(!is_null($xValue)) {
- $toX[] = $xValue;
- }
- }
-
- if(count($toX) === 1) {
- $fillLine = new Line(
- new Point($fromX, $y),
- new Point($toX[0], $y)
- );
- } else {
-
- $line1 = new Line(
- new Point($fromX, $y),
- new Point($toX[0], $y)
- );
- $line2 = new Line(
- new Point($fromX, $y),
- new Point($toX[1], $y)
- );
-
- if($line1->getSize() < $line2->getSize()) {
- $fillLine = $line1;
- } else {
- $fillLine = $line2;
- }
- }
-
- if(!$fillLine->isPoint()) {
- $color = $this->color($y - $yMin);
- $this->driver->line($color, $fillLine);
-
- unset($color);
- }
- }
-
- }
-
- private function drawFilledTriangleHorizontally(awGradient $gradient, awPolygon $polygon) {
- list($xMin, $xMax) = $polygon->getBoxXRange();
-
- $this->init($gradient, $xMax - $xMin);
-
- // Get the triangle line we will draw our lines from
- $fromLine = NULL;
- $lines = $polygon->getLines();
-
- $count = count($lines);
-
- // Pick the side of the triangle going all the way
- // from the left side to the right side of the surrounding box
- for($i = 0; $i < $count; $i++) {
- if($lines[$i]->isLeftToRight($polygon)) {
- list($fromLine) = array_splice($lines, $i, 1);
- break;
- }
- }
-
- // If for some reason the three points are aligned,
- // $fromLine will still be NULL
- if($fromLine === NULL) {
- return;
- }
-
- $fillLine = NULL;
- for($x = round($xMin); $x < round($xMax); $x++) {
-
- $fromY = floor($fromLine->getYFrom($x));
-
- $toY = array();
- foreach($lines as $line) {
- $yValue = $line->getYFrom($x);
-
- if(!is_null($yValue)) {
- $toY[] = floor($yValue);
- }
- }
-
- if(count($toY) === 1) {
- $fillLine = new Line(
- new Point($x, $fromY),
- new Point($x, $toY[0])
- );
- } else {
-
- $line1 = new Line(
- new Point($x, $fromY),
- new Point($x, $toY[0])
- );
- $line2 = new Line(
- new Point($x, $fromY),
- new Point($x, $toY[1])
- );
-
- if($line1->getSize() < $line2->getSize()) {
- $fillLine = $line1;
- } else {
- $fillLine = $line2;
- }
- }
-
- $color = $this->color($x - $xMin);
- if($fillLine->isPoint()) {
- $this->driver->point($color, $fillLine->p1);
- } elseif($fillLine->getSize() >= 1) {
- $this->driver->line($color, $fillLine);
- }
- unset($color);
- }
-
- }
-
- public function filledRectangle(awGradient $gradient, awPoint $p1, awPoint $p2) {
-
- list($x1, $y1) = $p1->getLocation();
- list($x2, $y2) = $p2->getLocation();
-
- if($y1 < $y2) {
- $y1 ^= $y2 ^= $y1 ^= $y2;
- }
-
- if($x2 < $x1) {
- $x1 ^= $x2 ^= $x1 ^= $x2;
- }
-
- if($gradient instanceof awLinearGradient) {
- $this->rectangleLinearGradient($gradient, new awPoint($x1, $y1), new awPoint($x2, $y2));
- } else {
- awImage::drawError("Class GDGradientDriver: This gradient is not supported by rectangles.");
- }
-
- }
-
- public function filledPolygon(awGradient $gradient, awPolygon $polygon) {
-
- if($gradient instanceof awLinearGradient) {
- $this->polygonLinearGradient($gradient, $polygon);
- } else {
- awImage::drawError("Class GDGradientDriver: This gradient is not supported by polygons.");
- }
-
- }
-
- protected function rectangleLinearGradient(awLinearGradient $gradient, awPoint $p1, awPoint $p2) {
-
- list($x1, $y1) = $p1->getLocation();
- list($x2, $y2) = $p2->getLocation();
-
- if($y1 - $y2 > 0) {
-
- if($gradient->angle === 0) {
-
- $this->init($gradient, $y1 - $y2);
-
- for($i = $y2; $i <= $y1; $i++) {
-
- $color = $this->color($i - $y2);
-
- $p1 = new awPoint($x1, $i);
- $p2 = new awPoint($x2, $i);
-
- $this->driver->filledRectangle($color, new awLine($p1, $p2));
-
- unset($color);
-
- }
-
- } else if($gradient->angle === 90) {
-
- $this->init($gradient, $x2 - $x1);
-
- for($i = $x1; $i <= $x2; $i++) {
-
- $color = $this->color($i - $x1);
-
- $p1 = new awPoint($i, $y2);
- $p2 = new awPoint($i, $y1);
-
- $this->driver->filledRectangle($color, new awLine($p1, $p2));
-
- unset($color);
-
- }
-
- }
-
- }
-
- }
-
- public function filledEllipse(awGradient $gradient, $x1, $y1, $x2, $y2) {
-
- if($y1 < $y2) {
- $y1 ^= $y2 ^= $y1 ^= $y2;
- }
-
- if($x2 < $x1) {
- $x1 ^= $x2 ^= $x1 ^= $x2;
- }
-
- if($gradient instanceof awRadialGradient) {
- $this->ellipseRadialGradient($gradient, $x1, $y1, $x2, $y2);
- } else if($gradient instanceof awLinearGradient) {
- $this->ellipseLinearGradient($gradient, $x1, $y1, $x2, $y2);
- } else {
- awImage::drawError("Class GDGradientDriver: This gradient is not supported by ellipses.");
- }
-
- }
-
- protected function ellipseRadialGradient(awGradient $gradient, $x1, $y1, $x2, $y2) {
-
- if($y1 - $y2 > 0) {
-
- if($y1 - $y2 != $x2 - $x1) {
- awImage::drawError("Class GDGradientDriver: Radial gradients are only implemented on circle, not ellipses.");
- }
-
- $c = new awPoint($x1 + ($x2 - $x1) / 2, $y1 + ($y2 - $y1) / 2);
- $r = ($x2 - $x1) / 2;
- $ok = array();
-
- // Init gradient
- $this->init($gradient, $r);
-
- for($i = 0; $i <= $r; $i += 0.45) {
-
- $p = ceil((2 * M_PI * $i));
-
- if($p > 0) {
- $interval = 360 / $p;
- } else {
- $interval = 360;
- }
-
- $color = $this->color($i);
-
- for($j = 0; $j < 360; $j += $interval) {
-
- $rad = ($j / 360) * (2 * M_PI);
-
- $x = round($i * cos($rad));
- $y = round($i * sin($rad));
-
- $l = sqrt($x * $x + $y * $y);
-
- if($l <= $r) {
-
- if(
- array_key_exists((int)$x, $ok) === FALSE or
- array_key_exists((int)$y, $ok[$x]) === FALSE
- ) {
-
- // Print the point
- $this->driver->point($color, new awPoint($c->x + $x, $c->y + $y));
-
- $ok[(int)$x][(int)$y] = TRUE;
-
- }
-
- }
-
- }
-
- unset($color);
-
- }
-
- }
-
- }
-
- protected function ellipseLinearGradient(awGradient $gradient, $x1, $y1, $x2, $y2) {
-
- // Gauche->droite : 90°
-
- if($y1 - $y2 > 0) {
-
- if($y1 - $y2 != $x2 - $x1) {
- awImage::drawError("Class GDGradientDriver: Linear gradients are only implemented on circle, not ellipses.");
- }
-
- $r = ($x2 - $x1) / 2;
-
- // Init gradient
- $this->init($gradient, $x2 - $x1);
-
- for($i = -$r; $i <= $r; $i++) {
-
- $h = sin(acos($i / $r)) * $r;
-
- $color = $this->color($i + $r);
-
- if($gradient->angle === 90) {
-
- // Print the line
- $p1 = new awPoint(
- $x1 + $i + $r,
- round(max($y2 + $r - $h + 1, $y2))
- );
-
- $p2 = new awPoint(
- $x1 + $i + $r,
- round(min($y1 - $r + $h - 1, $y1))
- );
-
- } else {
-
- // Print the line
- $p1 = new awPoint(
- round(max($x1 + $r - $h + 1, $x1)),
- $y2 + $i + $r
- );
-
- $p2 = new awPoint(
- round(min($x2 - $r + $h - 1, $x2)),
- $y2 + $i + $r
- );
-
- }
-
- $this->driver->filledRectangle($color, new awLine($p1, $p2));
-
- unset($color);
-
- }
-
- }
-
- }
-
- protected function polygonLinearGradient(awLinearGradient $gradient, awPolygon $polygon) {
-
- $count = $polygon->count();
-
- if($count >= 4) {
-
- $left = $polygon->get(0);
- $right = $polygon->get($count - 1);
-
- if($gradient->angle === 0) {
-
- // Get polygon maximum and minimum
- $offset = $polygon->get(0);
- $max = $min = $offset->y;
- for($i = 1; $i < $count - 1; $i++) {
- $offset = $polygon->get($i);
- $max = max($max, $offset->y);
- $min = min($min, $offset->y);
- }
-
- $this->init($gradient, $max - $min);
-
- $prev = $polygon->get(1);
-
- $sum = 0;
-
- for($i = 2; $i < $count - 1; $i++) {
-
- $current = $polygon->get($i);
-
- $interval = 1;
-
- if($i !== $count - 2) {
- $current->x -= $interval;
- }
-
- if($current->x - $prev->x > 0) {
-
- // Draw rectangle
- $x1 = $prev->x;
- $x2 = $current->x;
- $y1 = max($prev->y, $current->y);
- $y2 = $left->y;
-
- $gradient = new awLinearGradient(
- $this->color($max - $min - ($y2 - $y1)),
- $this->color($max - $min),
- 0
- );
-
- if($y1 > $y2) {
- $y2 = $y1;
- }
-
- $this->driver->filledRectangle(
- $gradient,
- awLine::build($x1, $y1, $x2, $y2)
- );
-
- $top = ($prev->y < $current->y) ? $current : $prev;
- $bottom = ($prev->y >= $current->y) ? $current : $prev;
-
- $gradient = new awLinearGradient(
- $this->color($bottom->y - $min),
- $this->color($max - $min - ($y2 - $y1)),
- 0
- );
-
-
- $gradientDriver = new awGDGradientDriver($this->driver);
- $gradientDriver->drawFilledFlatTriangle(
- $gradient,
- new awPoint($prev->x, min($prev->y, $current->y)),
- $top,
- new awPoint($current->x, min($prev->y, $current->y))
- );
- unset($gradientDriver);
-
- $sum += $current->x - $prev->x;
-
- }
-
- $prev = $current;
- $prev->x += $interval;
-
- }
-
- } else if($gradient->angle === 90) {
-
- $width = $right->x - $left->x;
- $this->init($gradient, $width);
-
- $pos = 1;
- $next = $polygon->get($pos++);
-
- $this->next($polygon, $pos, $prev, $next);
-
- for($i = 0; $i <= $width; $i++) {
-
- $x = $left->x + $i;
-
- $y1 = round($prev->y + ($next->y - $prev->y) * (($i + $left->x - $prev->x) / ($next->x - $prev->x)));
- $y2 = $left->y;
-
- // Draw line
- $color = $this->color($i);
- // YaPB : PHP does not handle alpha on lines
- $this->driver->filledRectangle($color, awLine::build($x, $y1, $x, $y2));
-
- unset($color);
-
- // Jump to next point
- if($next->x == $i + $left->x) {
-
- $this->next($polygon, $pos, $prev, $next);
-
- }
-
- }
-
- }
-
- } else if($count === 3) {
- $this->drawFilledTriangle(
- $gradient,
- $polygon
- );
- }
-
- }
-
- private function next($polygon, &$pos, &$prev, &$next) {
-
- do {
- $prev = $next;
- $next = $polygon->get($pos++);
- }
- while($next->x - $prev->x == 0 and $pos < $polygon->count());
-
- }
-
- /**
- * Start colors
- *
- * @var int
- */
- private $r1, $g1, $b1, $a1;
-
- /**
- * Stop colors
- *
- * @var int
- */
- private $r2, $g2, $b2, $a2;
-
- /**
- * Gradient size in pixels
- *
- * @var int
- */
- private $size;
-
-
- private function init(awGradient $gradient, $size) {
-
- list(
- $this->r1, $this->g1, $this->b1, $this->a1
- ) = $gradient->from->rgba();
-
- list(
- $this->r2, $this->g2, $this->b2, $this->a2
- ) = $gradient->to->rgba();
-
- $this->size = $size;
- }
-
- private function color($pos) {
-
- return new awColor(
- $this->getRed($pos),
- $this->getGreen($pos),
- $this->getBlue($pos),
- $this->getAlpha($pos)
- );
-
- }
-
-
- private function getRed($pos) {
- if((float)$this->size !== 0.0) {
- return (int)round($this->r1 + ($pos / $this->size) * ($this->r2 - $this->r1));
- } else {
- return 0;
- }
- }
-
- private function getGreen($pos) {
- if((float)$this->size !== 0.0) {
- return (int)round($this->g1 + ($pos / $this->size) * ($this->g2 - $this->g1));
- } else {
- return 0;
- }
- }
-
- private function getBlue($pos) {
- if((float)$this->size !== 0.0) {
- return (int)round($this->b1 + ($pos / $this->size) * ($this->b2 - $this->b1));
- } else {
- return 0;
- }
- }
-
- private function getAlpha($pos) {
- if((float)$this->size !== 0.0) {
- return (int)round(($this->a1 + ($pos / $this->size) * ($this->a2 - $this->a1)) / 127 * 100);
- } else {
- return 0;
- }
- }
-
-}
-
-registerClass('GDGradientDriver');
-
-/*
- * Check for GD2
- */
-if(function_exists('imagecreatetruecolor') === FALSE) {
- awImage::drawErrorFile('missing-gd2');
-}
-
-?>
\ No newline at end of file
diff --git a/artichow/inc/drivers/ming.class.php b/artichow/inc/drivers/ming.class.php
deleted file mode 100644
index 4c2e415..0000000
--- a/artichow/inc/drivers/ming.class.php
+++ /dev/null
@@ -1,774 +0,0 @@
-driverString = 'ming';
-
- // Nice defaults
- ming_setScale(20.0);
- ming_useswfversion(6);
-
- }
-
- /**
- * Initialize the driver for a particular awImage object
- *
- * @param awImage $image
- */
- public function init(awImage $image) {
-
- if($this->movie === NULL) {
- $this->setImageSize($image->width, $image->height);
-
- // Create movie
- $this->movie = new SWFMovie();
- if(!$this->movie) {
- awImage::drawError("Class Image: Unable to create a graph.");
- }
-
- $this->movie->setDimension($image->width, $image->height);
-
- $this->setAntiAliasing($image->getAntiAliasing());
-
- // Original color
- $this->filledRectangle(
- new awWhite,
- new awLine(
- new awPoint(0, 0),
- new awPoint($this->imageWidth, $this->imageHeight)
- )
- );
-
- $shadow = $image->shadow;
- if($shadow !== NULL) {
- $shadow = $shadow->getSpace();
- $p1 = new awPoint($shadow->left, $shadow->top);
- $p2 = new awPoint($this->imageWidth - $shadow->right - 1, $this->imageHeight - $shadow->bottom - 1);
-
- // Draw image background
- $this->filledRectangle($image->getBackground(), new awLine($p1, $p2));
-
- // Draw image border
- $image->border->rectangle($this, $p1, $p2);
- }
- }
- }
-
- /**
- * Initialize the Driver for a particular FileImage object
- *
- * @param awFileImage $fileImage The FileImage object to work on
- * @param string $file Image filename
- */
- public function initFromFile(awFileImage $fileImage, $file) {
-
- }
-
- /**
- * Change the image size
- *
- * @param int $width Image width
- * @param int $height Image height
- */
- public function setImageSize($width, $height) {
- $this->imageWidth = $width;
- $this->imageHeight = $height;
- }
-
- /**
- * Inform the driver of the position of your image
- *
- * @param float $x Position on X axis of the center of the component
- * @param float $y Position on Y axis of the center of the component
- */
- public function setPosition($x, $y) {
- // Calculate absolute position
- $this->x = round($x * $this->imageWidth - $this->w / 2);
- $this->y = round($y * $this->imageHeight - $this->h / 2);
- }
-
- /**
- * Inform the driver of the position of your image
- * This method need absolutes values
- *
- * @param int $x Left-top corner X position
- * @param int $y Left-top corner Y position
- */
- public function setAbsPosition($x, $y) {
- $this->x = $x;
- $this->y = $y;
- }
-
- /**
- * Move the position of the image
- *
- * @param int $x Add this value to X axis
- * @param int $y Add this value to Y axis
- */
- public function movePosition($x, $y) {
- $this->x += (int)$x;
- $this->y += (int)$y;
- }
-
- /**
- * Inform the driver of the size of your image
- * Height and width must be between 0 and 1.
- *
- * @param int $w Image width
- * @param int $h Image height
- * @return array Absolute width and height of the image
- */
- public function setSize($w, $h) {
-
- // Calcul absolute size
- $this->w = round($w * $this->imageWidth);
- $this->h = round($h * $this->imageHeight);
-
- return $this->getSize();
-
- }
-
- /**
- * Inform the driver of the size of your image
- * You can set absolute size with this method.
- *
- * @param int $w Image width
- * @param int $h Image height
- */
- public function setAbsSize($w, $h) {
- $this->w = $w;
- $this->h = $h;
-
- return $this->getSize();
- }
-
- /**
- * Get the size of the component handled by the driver
- *
- * @return array Absolute width and height of the component
- */
- public function getSize() {
- return array($this->w, $this->h);
- }
-
- /**
- * Turn antialiasing on or off
- *
- * @var bool $bool
- */
- public function setAntiAliasing($bool) {
- if($this->movie !== NULL) {
-
- $actionscript = '
- _quality = "%s";
- ';
-
- if((bool)$bool) {
- $actionscript = sprintf($actionscript, 'high');
- } else {
- $actionscript = sprintf($actionscript, 'low');
- }
-
- $this->movie->add(new SWFAction(str_replace("\r", "", $actionscript)));
- }
- }
-
- /**
- * When passed a Color object, returns the corresponding
- * color identifier (driver dependant).
- *
- * @param awColor $color A Color object
- * @return array $rgba A color identifier representing the color composed of the given RGB components
- */
- public function getColor(awColor $color) {
-
- // Ming simply works with R, G, B and Alpha values.
- list($red, $green, $blue, $alpha) = $color->rgba();
-
- // However, the Ming alpha channel ranges from 255 (opaque) to 0 (transparent),
- // while the awColor alpha channel ranges from 0 (opaque) to 100 (transparent).
- // First, we convert from 0-100 to 0-255.
- $alpha = (int)($alpha * 255 / 100);
-
- // Then from 0-255 to 255-0.
- $alpha = abs($alpha - 255);
-
- return array($red, $green, $blue, $alpha);
- }
-
- /**
- * Draw an image here
- *
- * @param awImage $image Image
- * @param int $p1 Image top-left point
- * @param int $p2 Image bottom-right point
- */
- public function copyImage(awImage $image, awPoint $p1, awPoint $p2) {
-
- }
-
- /**
- * Draw an image here
- *
- * @param awImage $image Image
- * @param int $d1 Destination top-left position
- * @param int $d2 Destination bottom-right position
- * @param int $s1 Source top-left position
- * @param int $s2 Source bottom-right position
- * @param bool $resample Resample image ? (default to TRUE)
- */
- public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE) {
-
- }
-
- /**
- * Draw a string
- *
- * @var awText $text Text to print
- * @param awPoint $point Draw the text at this point
- * @param int $width Text max width
- */
- public function string(awText $text, awPoint $point, $width = NULL) {
- $font = $text->getFont();
-
- // Can we deal with that font?
- if($this->isCompatibleWithFont($font) === FALSE) {
- awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')');
- }
-
- // Ming can only work with awFileFont objects for now
- // (i.e. awFDBFont, or awTuffy et al.)
- $fontDriver = $this->fileFontDriver;
-
- if($text->getBackground() !== NULL or $text->border->visible()) {
-
- list($left, $right, $top, $bottom) = $text->getPadding();
-
- $textWidth = $fontDriver->getTextWidth($text, $this);
- $textHeight = $fontDriver->getTextHeight($text, $this);
-
- $x1 = floor($point->x - $left);
- $y1 = floor($point->y - $top);
- $x2 = $x1 + $textWidth + $left + $right;
- $y2 = $y1 + $textHeight + $top + $bottom;
-
- $this->filledRectangle(
- $text->getBackground(),
- awLine::build($x1, $y1, $x2, $y2)
- );
-
- $text->border->rectangle(
- $this,
- new awPoint($x1 - 1, $y1 - 1),
- new awPoint($x2 + 1, $y2 + 1)
- );
-
- }
-
- $fontDriver->string($this, $text, $point, $width);
- }
-
- /**
- * Draw a pixel
- *
- * @param awColor $color Pixel color
- * @param awPoint $p
- */
- public function point(awColor $color, awPoint $p) {
- if($p->isHidden() === FALSE) {
- list($red, $green, $blue, $alpha) = $this->getColor($color);
-
- $point = new SWFShape();
- $point->setLine(1, $red, $green, $blue, $alpha);
- $point->movePenTo($this->x + round($p->x), $this->y + round($p->y));
- $point->drawLine(0.5, 0.5);
- $point->movePen(-0.5, 0);
- $point->drawLine(0.5, -0.5);
-
- $this->movie->add($point);
- }
- }
-
- /**
- * Draw a colored line
- *
- * @param awColor $color Line color
- * @param awLine $line
- * @param int $thickness Line tickness
- */
- public function line(awColor $color, awLine $line) {
- if($line->getThickness() > 0 and $line->isHidden() === FALSE) {
-
- list($red, $green, $blue, $alpha) = $this->getColor($color);
-
- $mingLine = new SWFShape();
- $mingLine->setLine($line->getThickness(), $red, $green, $blue, $alpha);
-
- list($p1, $p2) = $line->getLocation();
-
- $mingLine->movePenTo($this->x + round($p1->x), $this->y + round($p1->y));
-
- switch($line->getStyle()) {
-
- case awLine::SOLID :
- $mingLine->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
- $this->movie->add($mingLine);
- break;
-
- case awLine::DOTTED :
- $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2));
- $cos = ($p2->x - $p1->x) / $size;
- $sin = ($p2->y - $p1->y) / $size;
-
- for($i = 0; $i <= $size; $i += 2) {
- $p = new awPoint(
- round($i * $cos + $p1->x),
- round($i * $sin + $p1->y)
- );
- $this->point($color, $p);
- }
-
- break;
-
- case awLine::DASHED :
- $width = $p2->x - $p1->x;
- $height = $p2->y - $p1->y;
- $size = sqrt(pow($height, 2) + pow($width, 2));
-
- if($size == 0) {
- return;
- }
-
- $cos = $width / $size;
- $sin = $height / $size;
-
- $functionX = ($width > 0) ? 'min' : 'max';
- $functionY = ($height > 0) ? 'min' : 'max';
-
- for($i = 0; $i <= $size; $i += 6) {
-
- $t1 = new awPoint(
- round($i * $cos + $p1->x),
- round($i * $sin + $p1->y)
- );
-
- $t2 = new awPoint(
- round($functionX(($i + 3) * $cos, $width) + $p1->x),
- round($functionY(($i + 3) * $sin, $height) + $p1->y)
- );
-
- $this->line($color, new awLine($t1, $t2));
-
- }
-
- break;
-
- }
-
- }
-
- }
-
- /**
- * Draw a color arc
-
- * @param awColor $color Arc color
- * @param awPoint $center Point center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- * @param int $from Start angle
- * @param int $to End angle
- */
- public function arc(awColor $color, awPoint $center, $width, $height, $from, $to) {
-
- }
-
- /**
- * Draw an arc with a background color
- *
- * @param awColor $color Arc background color
- * @param awPoint $center Point center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- * @param int $from Start angle
- * @param int $to End angle
- */
- public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to) {
-
- }
-
- /**
- * Draw a colored ellipse
- *
- * @param awColor $color Ellipse color
- * @param awPoint $center Ellipse center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- */
- public function ellipse(awColor $color, awPoint $center, $width, $height) {
-
- }
-
- /**
- * Draw an ellipse with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param awPoint $center Ellipse center
- * @param int $width Ellipse width
- * @param int $height Ellipse height
- */
- public function filledEllipse($background, awPoint $center, $width, $height) {
-
- }
-
- /**
- * Draw a colored rectangle
- *
- * @param awColor $color Rectangle color
- * @param awLine $line Rectangle diagonale
- * @param awPoint $p2
- */
- public function rectangle(awColor $color, awLine $line) {
- list($p1, $p2) = $line->getLocation();
-
- // Get Red, Green, Blue and Alpha values for the line
- list($r, $g, $b, $a) = $this->getColor($color);
-
- // Calculate the coordinates of the two other points of the rectangle
- $p3 = new Point($p1->x, $p2->y);
- $p4 = new Point($p2->x, $p1->y);
-
-
- $side = clone $line;
-
-
-
- // Draw the four sides of the rectangle, clockwise
- if(
- ($p1->x <= $p2->x and $p1->y <= $p2->y)
- or
- ($p1->x >= $p2->x and $p1->y >= $p2->y)
- ) {
- $side->setLocation($p1, $p4);
- $this->line($color, $side);
-
- $side->setLocation($p4, $p2);
- $this->line($color, $side);
-
- $side->setLocation($p2, $p3);
- $this->line($color, $side);
-
- $side->setLocation($p3, $p1);
- $this->line($color, $side);
- } else {
- $side->setLocation($p1, $p3);
- $this->line($color, $side);
-
- $side->setLocation($p3, $p2);
- $this->line($color, $side);
-
- $side->setLocation($p2, $p4);
- $this->line($color, $side);
-
- $side->setLocation($p4, $p1);
- $this->line($color, $side);
- }
- }
-
- /**
- * Draw a rectangle with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param awLine $line Rectangle diagonale
- */
- public function filledRectangle($background, awLine $line) {
- list($p1, $p2) = $line->getLocation();
-
- // Common shape settings
- $shape = new SWFShape();
- $shape->setLine(0);
-
- if($background instanceof awColor) {
-
- // Get the Red, Green, Blue and Alpha values
- list($r, $g, $b, $a) = $this->getColor($background);
- $shape->setRightFill($r, $g, $b, $a);
-
- } else if($background instanceof awGradient) {
-
- // Get the Gradient object as an SWFGradient one
- list($flashGradient, $style) = $this->getGradient($background);
-
- $fill = $shape->addFill($flashGradient, $style);
-
- // Angles between Artichow and Ming don't match.
- // Don't use abs() or vertical gradients get inverted.
- $angle = $background->angle - 90;
- $fill->rotateTo($angle);
-
- // Move the gradient based on the position of the rectangle we're drawing
- $centerX = min($p1->x, $p2->y) + abs($p1->x - $p2->x) / 2;
- $centerY = min($p1->y, $p2->y) + abs($p1->y - $p2->y) / 2;
- $fill->moveTo($centerX, $centerY);
-
- // Ming draws its gradients on a 1600x1600 image,
- // so we have to resize it.
- if($angle === -90) {
- $ratio = abs($p1->y - $p2->y) / 1600;
- } else {
- $ratio = abs($p1->x - $p2->x) / 1600;
- }
- $fill->scaleTo($ratio);
-
- $shape->setRightFill($fill);
-
- }
-
- // Set starting position
- $shape->movePenTo($this->x + round($p1->x), $this->y + round($p1->y));
-
- // Depending on the points' relative positions,
- // we have two drawing possibilities
- if(
- ($p1->x <= $p2->x and $p1->y <= $p2->y)
- or
- ($p1->x >= $p2->x and $p1->y >= $p2->y)
- ) {
- $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y));
- $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
- $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y));
- $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y));
- } else {
- $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y));
- $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
- $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y));
- $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y));
- }
-
- $this->movie->add($shape);
- }
-
- /**
- * Draw a polygon
- *
- * @param awColor $color Polygon color
- * @param Polygon A polygon
- */
- public function polygon(awColor $color, awPolygon $polygon) {
- $points = $polygon->all();
- $count = count($points);
-
- if($count > 1) {
-
- $side = new awLine;
- $side->setStyle($polygon->getStyle());
- $side->setThickness($polygon->getThickness());
-
- $prev = $points[0];
-
- for($i = 1; $i < $count; $i++) {
- $current = $points[$i];
- $side->setLocation($prev, $current);
- $this->line($color, $side);
- $prev = $current;
- }
-
- // Close the polygon
- $side->setLocation($prev, $points[0]);
- $this->line($color, $side);
- }
- }
-
- /**
- * Draw a polygon with a background
- *
- * @param mixed $background Background (can be a color or a gradient)
- * @param Polygon A polygon
- */
- public function filledPolygon($background, awPolygon $polygon) {
- $shape = new SWFShape();
-
- if($background instanceof awColor) {
- list($red, $green, $blue, $alpha) = $this->getColor($background);
-
- $shape->setRightFill($red, $green, $blue, $alpha);
- } elseif($background instanceof awGradient) {
- list($flashGradient, $style) = $this->getGradient($background);
-
- $fill = $shape->addFill($flashGradient, $style);
-
- list($xMin, $xMax) = $polygon->getBoxXRange();
- list($yMin, $yMax) = $polygon->getBoxYRange();
-
- if($background->angle === 0) {
- $fill->scaleTo(($yMax - $yMin) / 1600);
- } else {
- $fill->scaleTo(($xMax - $xMin) / 1600);
- }
- $fill->moveTo($xMin + ($xMax - $xMin) / 2, $yMin + ($yMax - $yMin) / 2);
-
- $shape->setRightFill($fill);
- }
-
- $points = $polygon->all();
- $count = count($points);
-
- if($count > 1) {
-
- $prev = $points[0];
-
- $shape->movePenTo($prev->x, $prev->y);
-
- for($i = 1; $i < $count; $i++) {
- $current = $points[$i];
- $shape->drawLineTo($current->x, $current->y);
- }
-
- // Close the polygon
- $shape->drawLineTo($prev->x, $prev->y);
-
- $this->movie->add($shape);
-
- }
- }
-
- /**
- * Sends the image, as well as the correct HTTP headers, to the browser
- *
- * @param awImage $image The Image object to send
- */
- public function send(awImage $image) {
- $this->drawImage($image);
- }
-
- /**
- * Get the image as binary data
- *
- * @param awImage $image
- */
- public function get(awImage $image) {
- return $this->drawImage($image, TRUE, FALSE);
- }
-
- public function getTextWidth(awText $text) {
- $font = $text->getFont();
- if($this->isCompatibleWithFont($font) === FALSE) {
- awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')');
- }
-
- // Ming only supports FileFont
- $fontDriver = $this->fileFontDriver;
-
- return $fontDriver->getTextWidth($text, $this);
- }
-
- public function getTextHeight(awText $text) {
- $font = $text->getFont();
- if($this->isCompatibleWithFont($font) === FALSE) {
- awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')');
- }
-
- // Ming only supports FileFont
- $fontDriver = $this->fileFontDriver;
-
- return $fontDriver->getTextHeight($text, $this);
- }
-
- protected function isCompatibleWithFont(awFont $font) {
- if($font instanceof awTTFFont or $font instanceof awPHPFont) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
-
- private function drawImage(awImage $image, $return = FALSE, $header = TRUE) {
-
- // Send headers to the browser
- if($header === TRUE) {
- $image->sendHeaders();
- }
-
- if($return) {
- ob_start();
- }
-
- $this->movie->output();
-
- if($return) {
- return ob_get_clean();
- }
- }
-
- /**
- * Convert an awGradient object to an SWFGradient one.
- * Returns an object as well as the style of the Flash gradient.
- *
- * @param awGradient $gradient The awGradient object to convert
- * @return array
- */
- private function getGradient(awGradient $gradient) {
- $flashGradient = new SWFGradient();
-
- // Get RGBA values for the gradient boundaries
- list($r1, $g1, $b1, $a1) = $this->getColor($gradient->from);
- list($r2, $g2, $b2, $a2) = $this->getColor($gradient->to);
-
- $flashGradient->addEntry(0, $r1, $g1, $b1, $a1);
-
- if($gradient instanceof awBilinearGradient) {
-
- $flashGradient->addEntry($gradient->center, $r2, $g2, $b2, $a2);
- $flashGradient->addEntry(1, $r1, $g1, $b1, $a1);
-
- return array($flashGradient, SWFFILL_LINEAR_GRADIENT);
- } else {
-
- $flashGradient->addEntry(1, $r2, $g2, $b2, $a2);
-
- if($gradient instanceof awLinearGradient) {
- return array($flashGradient, SWFFILL_LINEAR_GRADIENT);
- } else {
- return array($flashGradient, SWFFILL_RADIAL_GRADIENT);
- }
- }
- }
-// abstract private function getPolygonPoints(awPolygon $polygon);
-
-}
-
-registerClass('MingDriver');
-
-/*
- * Check for ming presence
- */
-if(function_exists('ming_useswfversion') === FALSE) {
- awImage::drawErrorFile('missing-ming');
-}
-
-?>
\ No newline at end of file
diff --git a/artichow/patterns/BarDepth.php b/artichow/patterns/BarDepth.php
deleted file mode 100644
index 5d040b7..0000000
--- a/artichow/patterns/BarDepth.php
+++ /dev/null
@@ -1,85 +0,0 @@
-barShadow->setSize(2);
- $plot->barShadow->smooth(TRUE);
- $plot->barShadow->setColor(new Color(160, 160, 160, 10));
-
- return $plot;
-
- }
-
- public function create() {
-
- $group = new PlotGroup;
- $group->setSpace(2, 2, 2, 0);
- $group->setPadding(30, 10, NULL, NULL);
-
- $group->grid->hideVertical(TRUE);
- $group->grid->setType(Line::DASHED);
-
- $yForeground = $this->getArg('yForeground');
- $yBackground = $this->getArg('yBackground');
-
- $legendForeground = $this->getArg('legendForeground');
- $legendBackground = $this->getArg('legendBackground');
-
- $colorForeground = $this->getArg('colorForeground', new LightBlue(10));
- $colorBackground = $this->getArg('colorBackground', new Orange(25));
-
- if($yForeground === NULL) {
- awImage::drawError("Class BarDepthPattern: Argument 'yForeground' must not be NULL.");
- }
-
- // Background
- if($yBackground !== NULL) {
-
- $plot = $this->getPlot($yBackground, 6);
- $plot->setBarColor($colorBackground);
-
- $group->add($plot);
- if($legendBackground !== NULL) {
- $group->legend->add($plot, $legendBackground, Legend::BACKGROUND);
- }
-
- }
-
- // Foreground
- $plot = $this->getPlot($yForeground, 0);
- $plot->setBarColor($colorForeground);
-
- $group->add($plot);
- if($legendForeground !== NULL) {
- $group->legend->add($plot, $legendForeground, Legend::BACKGROUND);
- }
-
- $group->axis->bottom->hideTicks(TRUE);
-
- $group->legend->shadow->setSize(0);
- $group->legend->setAlign(Legend::CENTER);
- $group->legend->setSpace(6);
- $group->legend->setTextFont(new Tuffy(8));
- $group->legend->setPosition(0.50, 0.10);
- $group->legend->setBackgroundColor(new Color(255, 255, 255, 10));
- $group->legend->setColumns(2);
-
- return $group;
-
- }
-
-}
-?>
\ No newline at end of file
diff --git a/artichow/patterns/LightLine.php b/artichow/patterns/LightLine.php
deleted file mode 100644
index a132d9e..0000000
--- a/artichow/patterns/LightLine.php
+++ /dev/null
@@ -1,50 +0,0 @@
-getArg('legend');
-
- $y = $this->getArg('y');
-
- if($y === NULL) {
- awImage::drawError("Class LightLinePattern: Argument 'y' must not be NULL.");
- }
-
- $plot = new LinePlot($y);
- $plot->setSize(0.7, 1);
- $plot->setCenter(0.35, 0.5);
- $plot->setPadding(35, 15, 35, 30);
- $plot->setColor(new Orange());
- $plot->setFillColor(new LightOrange(80));
-
- $plot->grid->setType(Line::DASHED);
-
- $plot->mark->setType(Mark::CIRCLE);
- $plot->mark->setFill(new MidRed);
- $plot->mark->setSize(6);
-
- $plot->legend->setPosition(1, 0.5);
- $plot->legend->setAlign(Legend::LEFT);
- $plot->legend->shadow->smooth(TRUE);
-
- if($legend !== NULL) {
- $plot->legend->add($plot, $legend, Legend::MARK);
- }
-
- return $plot;
-
- }
-
-}
-?>
\ No newline at end of file
diff --git a/game/Aflottes.php b/game/Aflottes.php
new file mode 100644
index 0000000..1638d46
--- /dev/null
+++ b/game/Aflottes.php
@@ -0,0 +1,374 @@
+connexion();
+$queryFlottes = $bdd->query("SELECT * FROM $table_flottes WHERE id_user = '$id_user' OR (end_galaxie = '$Hgalaxie' AND end_ss = '$Hss' AND end_position = '$Hposition');");
+$bdd->deconnexion();
+$nbFlottes = $bdd->num_rows;
+for ($i = 0; $i < $nbFlottes; $i++) {
+ //Récupération des principales variables de la flotte
+ $id_flotte = $queryFlottes[$i]['id'];
+ $mission = $queryFlottes[$i]['mission'];
+ $end_galaxie = $queryFlottes[$i]['end_galaxie'];
+ $end_ss = $queryFlottes[$i]['end_ss'];
+ $end_position = $queryFlottes[$i]['end_position'];
+ $end_time = $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'];
+ //On vérifie que la planète cible existe
+
+ $bdd->connexion();
+ $queryEN = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
+ if (!$queryEN && $mission != 3 && $mission != 6 && time() > $end_time) {
+ $bdd->query("UPDATE $table_flottes SET effectue = '1', mission = '6', ret_time = '".($end_time + $queryFlottes[$i]['end_time'])."' WHERE id = $id_flotte;");
+ $titreA = 'Impossible d\'effectuer la mission';
+ $bdd->escape($titreA);
+ $rapportA = 'La flotte '.$queryFlottes[$i]['nom_flotte'].' n\'a pas pu effectuer sa mission correctement car lorsqu\'elle est arrivée sur place, la planète était déserte.';
+ $bdd->escape($rapportA);
+ $db->query("INSERT INTO $table_mail (destinataire, expediteur, sujet, contenu, temps) VALUES(".$queryFlottes[$i]['id_user'].", '', '$titreA', '$rapportA', '".$end_time."')");
+ $bdd->deconnexion();
+ continue;
+ }
+ elseif (!$queryEN && $mission != 3 && $queryFlottes[$i]['effectue'] != 1) {
+ $bdd->deconnexion();
+ continue;
+ }
+ $bdd->deconnexion();
+ $ENidPlan = $queryEN['id'];
+
+ //La flotte est prête a effectuer une action
+ if ($queryFlottes[$i]['effectue'] != 1 && time() >= $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'] && !empty($queryFlottes[$i]['end_time'])) {
+ //Mission Attaquer
+ if ($mission == 1) {
+ require_once(_FCORE."../game/Class/class.combat.php");
+ $bdd->connexion();
+ //On regarde si le combat a déjà commencé
+ if ($queryFlottes[$i]['effectue'] == 2) {
+ if ($queryCombat = $bdd->unique_query("SELECT * FROM $table_flottes_combats WHERE refflotte = '$id_flotte';")) {
+ //On vérifie si on lance le tour suivant ou non
+ if (time() >= $queryCombat['timestamp']) {
+ //On modifie le timestamp pour ne pas que le combat se déroule deux fois
+ $timebloque = time() + 5;
+ $bdd->query("UPDATE $table_flottes_combats SET timestamp = '$timebloque' WHERE refflotte = '$id_flotte';");
+
+ //Récupération du combat
+ $combat = unserialize($queryCombat['serialize']);
+ //Mise à jour des tactiques
+ if (!empty($queryFlottes[$i]['tactiqueAT'])) $combat->changerTactiqueAT($queryFlottes[$i]['tactiqueAT']);
+ if (!empty($queryFlottes[$i]['tactiqueEN'])) $combat->changerTactiqueEN($queryFlottes[$i]['tactiqueEN']);
+ }
+ else continue;
+ }
+ else {
+ $time = time();
+ $bdd->query("UPDATE $table_flottes SET effectue = '1', ret_time = end_time + $time WHERE id = '$id_flotte';");
+ file_log("Erreur dans le script de combat, la flotte de ".trouvNom($queryFlottes[$i]['id_user'])."(".$queryFlottes[$i]['id_user'].") a été renvoyé au point de départ.", 1);
+ header('Location: ./?erreurcombat');
+ exit;
+ }
+ }
+ else {
+ //On génére un nouveau combat
+ $combat = new Combat($queryFlottes[$i], $queryEN, $queryEN, array(trouvInfo($queryFlottes[$i]['id_user'], 'blindage'), trouvInfo($queryEN['id_user'], 'blindage')));
+ $bdd->query("UPDATE $table_flottes SET effectue = '2' WHERE id = '$id_flotte';");
+ }
+ $bdd->deconnexion();
+
+ while($combat->timestamp <= time()) {
+ //Préparation du rapport
+ $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $combat->timestamp);
+
+ $combat->Ntour++;
+ $rapport->addInfo($combat->ATvais, 0);
+ $rapport->addInfo($combat->ENvais, 1);
+ $rapport->addInfo($combat->ENdef, 2);
+ $rapport->addInfo($combat->Ntour, 3);
+ $rapport->addInfo($queryEN, 4);
+ $rapport->addInfo($queryFlottes[$i], 5);
+
+ //Récupération des paramètres de la tactique de l'attaquant
+ $arraytactique = tactique($combat->ATtactique);
+ //On régénére les boucliers de l'attaquant et on calcul l'attaque de l'attaquant
+ $ATattaque = $combat->calcAttaque($arraytactique[2] + $combat->regenereBC($arraytactique[1], true, !$arraytactique[3], trouvInfo($queryFlottes[$i]['id_user'], 'blindage')), true, trouvInfo($queryFlottes[$i]['id_user'], 'armement'));
+
+ //Récupération des paramètres de la tactique du défenseur
+ $arraytactique = tactique($combat->ENtactique);
+ //On régénére les boucliers de l'attaquant et on calcul l'attaque de l'attaquant
+ $ENattaque = $combat->calcAttaque($arraytactique[2] + $combat->regenereBC($arraytactique[1], false, !$arraytactique[3], trouvInfo($queryEN['id_user'], 'blindage')), false, trouvInfo($queryEN['id_user'], 'armement'));
+
+ //On lance l'attaque
+ @$ATresult = $combat->attaquerVais($ATattaque, true);
+ @$ENresult = $combat->attaquerVais($ENattaque, false);
+
+ if (!$ATresult && $ENresult) { //Attaquant vainqueur
+ $combat->ENres['metal'] = $queryEN['metal'];
+ $combat->ENres['cristal'] = $queryEN['cristal'];
+ $combat->ENres['hydrogene'] = $queryEN['hydrogene'];
+
+ $exportAT = $combat->exportAT(true); $ret_time = $combat->timestamp;
+ $exportEN = $combat->exportEN(); $pillm = $combat->pillage[0]; $pillc = $combat->pillage[1]; $pillh = $combat->pillage[2];
+ $bdd->connexion();
+ $bdd->query("UPDATE $table_flottes SET $exportAT, effectue = '1', ret_time = '$ret_time' + end_time WHERE id = '$id_flotte';");
+ $bdd->query("UPDATE $table_planete SET $exportEN, metal = metal - '$pillm', cristal = cristal - '$pillc', hydrogene = hydrogene - '$pillh' WHERE id = '$ENidPlan';");
+ $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
+ $bdd->deconnexion();
+ $rapport->addInfo(array(true, true, false), 6);
+ }
+ elseif ($ATresult && !$ENresult) { //Défenseur vainqueur
+ $exportEN = $combat->exportEN();
+ $bdd->connexion();
+ $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
+ $bdd->query("DELETE FROM $table_flottes WHERE id = '$id_flotte';");
+ $bdd->query("UPDATE $table_planete SET $exportEN WHERE id = '$ENidPlan';");
+ $bdd->deconnexion();
+ $rapport->addInfo(array(true, false, false), 6);
+ }
+ elseif (!$ATresult && !$ENresult) { //Match nul
+ $exportEN = $combat->exportEN();
+ $bdd->connexion();
+ $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
+ $bdd->query("DELETE FROM $table_flottes WHERE id = '$id_flotte';");
+ $bdd->query("UPDATE $table_planete SET $exportEN WHERE id = '$ENidPlan';");
+ $bdd->deconnexion();
+ $rapport->addInfo(array(true, false, true), 6);
+ }
+ elseif ($combat->Ntour >= 250) { //Match nul
+ $exportAT = $combat->exportAT(false); $ret_time = $combat->timestamp;
+ $exportEN = $combat->exportEN(); $pillm = $combat->pillage[0]; $pillc = $combat->pillage[1]; $pillh = $combat->pillage[2];
+ $bdd->connexion();
+ $bdd->query("UPDATE $table_flottes SET $exportAT, effectue = '1', ret_time = '$ret_time' + end_time WHERE id = '$id_flotte';");
+ $bdd->query("UPDATE $table_planete SET $exportEN, metal = metal - '$pillm', cristal = cristal - '$pillc', hydrogene = hydrogene - '$pillh' WHERE id = '$ENidPlan';");
+ $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
+ $bdd->deconnexion();
+ $rapport->addInfo(array(true, false, true), 6);
+ }
+ else $rapport->addInfo(array(false, false, false), 6);
+
+ $rapport->addInfo($combat->ATvais, 7);
+ $rapport->addInfo($combat->ENvais, 8);
+ $rapport->addInfo($combat->ENdef, 9);
+
+ //Prévision du prochain tour
+ $combat->timestamp += 300;
+ $rapport->addInfo($combat->timestamp, 10);
+ $rapport->addInfo($combat->pillage, 11);
+
+ //On envoie les rapports aux joueurs concernés
+ $rapport->send();
+
+ //On arrête la boucle si le combat est terminé
+ if ($rapport->var[6][0]) break;
+ }
+ $debriM = $combat->debriM + $queryEN['debris_met'];
+ $debriC = $combat->debriC + $queryEN['debris_cri'];
+
+ $bdd->connexion();
+ $bdd->escape($debriM);
+ $bdd->escape($debriC);
+
+ $bdd->query("UPDATE $table_planete SET debris_met = $debriM, debris_cri = $debriC WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
+
+ $combat->debriM = 0;
+ $combat->debriC = 0;
+ if (!$rapport->var[6][0]) { //Si le combat n'est pas terminé
+ //On sérialise la classe pour l'exporter
+ $serialise = serialize($combat);
+ $bdd->escape($serialise);
+
+ //On enregistre le combat dans la base de données
+ $timesuite = $combat->timestamp;
+ $idFleet = $queryFlottes[$i]['id'];
+ if ($queryFlottes[$i]['effectue']) $bdd->query("UPDATE $table_flottes_combats SET serialize = '$serialise', tactiqueAT = '0', tactiqueEN = '0', timestamp = '$timesuite' WHERE refflotte = '$id_flotte';");
+ else $bdd->query("INSERT INTO $table_flottes_combats (refflotte, timestamp, serialize, tactiqueAT, tactiqueEN) VALUES('$idFleet', '$timesuite', '$serialise', '0', '0');");
+ }
+ $bdd->deconnexion();
+ }
+ //Mission Transporter
+ elseif ($mission == 2) {
+ $Cmetal = $queryFlottes[$i]['contenu_metal'];
+ $Ccristal = $queryFlottes[$i]['contenu_cristal'];
+ $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
+ $bdd->connexion();
+ $bdd->query("UPDATE $table_planete SET metal = metal + '$Cmetal', cristal = cristal + '$Ccristal', hydrogene = hydrogene + '$Chydrogene' WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
+ $bdd->query("UPDATE $table_flottes SET effectue = '1', contenu_metal = '0', contenu_cristal = '0', contenu_hydrogene = '0' WHERE id = '$id_flotte';");
+ $bdd->deconnexion();
+
+ $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $end_time);
+ $rapport->addInfo($queryEN, 0);
+ $rapport->addInfo(array($queryFlottes[$i]['contenu_metal'], $queryFlottes[$i]['contenu_cristal'], $queryFlottes[$i]['contenu_hydrogene']), 1);
+ $rapport->send();
+ }
+ //Mission Coloniser
+ elseif ($mission == 3) {
+ $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], 0, $end_time);
+ $rapport->addInfo(array($end_galaxie, $end_ss, $end_position), 0);
+
+ $rapport->addInfo(true, 1);
+ $time = time();
+ $cases = mt_rand(125,222);
+ $image = mt_rand(1,15);
+ $Cmetal = $queryFlottes[$i]['contenu_metal'] + 1000;
+ $Ccristal = $queryFlottes[$i]['contenu_cristal'] + 700;
+ $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
+
+ //Calcul de l'isolement
+ $nbPlan = count($queryPlanetes);
+ if ($nbPlan >= 11) {
+ switch($nbPlan){
+ case 11: $tps = 2; break;
+ case 12: $tps = 4; break;
+ case 13: $tps = 6; break;
+ case 14: $tps = 8; break;
+ case 15: $tps = 12; break;
+ case 16: $tps = 16; break;
+ case 17: $tps = 20; break;
+ default: $tps = 24;
+ }
+ }
+ else $tps = 0;
+ $debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
+ $fin = $debut + $tps * 3600;
+
+ $idFlo = $queryFlottes[$i]['id_user'];
+ $bdd->connexion();
+ if ($bdd->query("INSERT INTO $table_planete (id_user, isolement, nom_planete, galaxie, ss, position, image, cases, timestamp, metal, cristal, hydrogene, hash_planete) VALUES ('$idFlo', '$debut $fin', 'Planète colonisée', '$end_galaxie', '$end_ss', '$end_position', '$image', '$cases', '$time', '$Cmetal', '$Ccristal', '$Chydrogene', SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)));") === false) {
+ $rapport->addInfo(false, 1);
+ $bdd->query("UPDATE $table_flottes SET effectue = 1 WHERE id = $id_flotte;");
+ $bdd->deconnexion();
+ }
+ else {
+ if ($queryFlottes[$i]['nb_vais'] == 1) {
+ $queryFlottes[$i]['nb_vais'] = -1;
+ $bdd->query("DELETE FROM $table_flottes WHERE id = $id_flotte");
+ }
+ else $bdd->query("UPDATE $table_flottes SET effectue = 1, vaisseau_3 = vaisseau_3 - 1, nb_vais = nb_vais - 1, contenu_metal = 0, contenu_cristal = 0, contenu_hydrogene = 0 WHERE id = $id_flotte;");
+ $bdd->deconnexion();
+ }
+ $rapport->send();
+ }
+ //Mission Recycler
+ elseif ($mission == 4) {
+ $capacite = $queryFlottes[$i]['contenu_max'] - (vais_conso($queryFlottes[$i]['end_time'], count($queryFlottes[$i]['nb_vais']))*$queryFlottes[$i]['vitesse']*5) + $queryFlottes[$i]['contenu_metal'] + $queryFlottes[$i]['contenu_cristal'] + $queryFlottes[$i]['contenu_hydrogene'];
+
+ $debris_met = $queryEN['debris_met'];
+ $debris_cri = $queryEN['debris_cri'];
+
+ if ($debris_met+$debris_cri > $capacite) {
+ $a = floor($capacite/2);
+ $b = floor($capacite/2);
+ if ($a > $debris_met && $b > $debris_cri) {
+ $a = $debris_met;
+ $b = $debris_cri;
+ }
+ else if ($a > $debris_met) {
+ $a = $debris_met;
+ $b = ($capacite - $a);
+ if ($b > $debris_cri) $b = $debris_cri;
+ }
+ else if ($b > $debris_cri) {
+ $b = $debris_cri;
+ $a = ($capacite - $b);
+ if ($a > $debris_met) $a = $debris_met;
+ }
+ }
+ else {
+ $a = $debris_met;
+ $b = $debris_cri;
+ }
+ $Cmetal = $a + $queryFlottes[$i]['contenu_metal'];
+ $Ccristal = $b + $queryFlottes[$i]['contenu_cristal'];
+
+ $bdd->connexion();
+ $bdd->query("UPDATE $table_flottes SET effectue = '1', contenu_metal = '$Cmetal', contenu_cristal = '$Ccristal' WHERE id = '$id_flotte';");
+ $bdd->query("UPDATE $table_planete SET debris_met = debris_met - '$a', debris_cri = debris_cri - '$b' WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
+ $bdd->deconnexion();
+
+ $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $end_time);
+ $rapport->addInfo($queryEN, 0);
+ $rapport->addInfo(array($a, $b), 1);
+ $rapport->send();
+ }
+ //Mission Espionnage
+ elseif ($mission == 5) {
+ $nbsondes = $queryFlottes[$i]['vaisseau_3'];
+ $id_userT = $queryEN['id_user'];
+ $id_att = $queryFlottes[$i]['id_user'];
+
+ $bdd->connexion();
+ $bdd->query("UPDATE $table_flottes SET effectue = 1 WHERE id = $id_flotte;");
+ $resultatUD = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_userT;");
+ $resultatUA = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_att;");
+ $bdd->deconnexion();
+
+ $diffNiveau = $resultatUA['detection'] - $resultatUD['detection'] + floor($nbsondes/2);
+ $rapport = new Rapport($mission, $id_att, $id_userT, $end_time);
+
+ if ($diffNiveau < 0) {
+ $rapport->addInfo($queryEN, 0);
+ $rapport->addInfo(false, 1);
+ }
+ if ($diffNiveau >= 0) $rapport->addInfo($queryEN, 0);
+ if ($diffNiveau >= 1) $rapport->addInfo(true, 1);
+ if ($diffNiveau >= 2) $rapport->addInfo(true, 2);
+ if ($diffNiveau >= 3) $rapport->addInfo(true, 3);
+ if ($diffNiveau >= 4) $rapport->addInfo($resultatUD, 4);
+ if ($diffNiveau >= 5) $rapport->addInfo(true, 5);
+
+ $rapport->send();
+ }
+ }
+
+ //Si la flotte a terminé son retour
+ if (($queryFlottes[$i]['mission'] == 0 && $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'] <= time()) || ($queryFlottes[$i]['effectue'] == 1 && ((!empty($queryFlottes[$i]['ret_time']) && $queryFlottes[$i]['ret_time'] <= time()) || ($queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time']*2 <= time())))) {
+ if ($queryFlottes[$i]['mission'] == 0) {
+ $fin_galaxie = $queryFlottes[$i]['end_galaxie'];
+ $fin_systeme = $queryFlottes[$i]['end_ss'];
+ $fin_potision = $queryFlottes[$i]['end_position'];
+ }
+ elseif (!empty($queryFlottes[$i]['ret_position'])) {
+ $fin_galaxie = $queryFlottes[$i]['ret_galaxie'];
+ $fin_systeme = $queryFlottes[$i]['ret_ss'];
+ $fin_potision = $queryFlottes[$i]['ret_position'];
+ }
+ else {
+ $fin_galaxie = $queryFlottes[$i]['start_galaxie'];
+ $fin_systeme = $queryFlottes[$i]['start_ss'];
+ $fin_potision = $queryFlottes[$i]['start_position'];
+ }
+
+ $bdd->connexion();
+ if ($bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = '$fin_galaxie' AND ss = '$fin_systeme' AND position = '$fin_potision';")) {
+ $export = '';
+ $nbvais = 12;
+ for($j = 1; $j <= $nbvais; $j++) {
+ $export .= ', vaisseau_'.$j.' = vaisseau_'.$j.' + '.$queryFlottes[$i]['vaisseau_'.$j];
+ }
+ $Cmetal = $queryFlottes[$i]['contenu_metal'];
+ $Ccristal = $queryFlottes[$i]['contenu_cristal'];
+ $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
+ $bdd->query("UPDATE $table_planete SET metal = metal + '$Cmetal', cristal = cristal + '$Ccristal', hydrogene = hydrogene + '$Chydrogene'$export WHERE galaxie = '$fin_galaxie' AND ss = '$fin_systeme' AND position = '$fin_potision';");
+ }
+ $idUserFlotte = $queryFlottes[$i]['id_user'];
+ $bdd->query("DELETE FROM $table_flottes WHERE id_user = '$idUserFlotte' AND id = '$id_flotte';");
+ $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
+ $bdd->deconnexion();
+ }
+}
+?>
\ No newline at end of file
diff --git a/game/Class/class.alliance.php b/game/Class/class.alliance.php
index bb007c8..dce9aa8 100644
--- a/game/Class/class.alliance.php
+++ b/game/Class/class.alliance.php
@@ -8,7 +8,7 @@
*
*
***************************************************************************/
-class Alliance extends File{
+class Alliance extends Surface{
var $id,
$race,
$fondateur,
@@ -24,12 +24,7 @@ class Alliance extends File{
$credits,
$metal,
$cristal,
- $hydrogene,
- $file_abat,
- $file_vais,
- $alli_batiments = array(),
- $vaisseaux = array(),
- $modif = array();
+ $hydrogene;
/**
* Constructeur
@@ -66,7 +61,7 @@ class Alliance extends File{
$this->hydrogene = $alli["hydrogene"];
foreach($alli_batimentVAR as $bat){
- $this->alli_batiments[] = $alli[$bat];
+ $this->batiments[] = $alli[$bat];
}
$this->file_bat = unserialize($alli["file_bat"]);
diff --git a/game/Class/class.asteroide.php b/game/Class/class.asteroide.php
new file mode 100644
index 0000000..0457b30
--- /dev/null
+++ b/game/Class/class.asteroide.php
@@ -0,0 +1,691 @@
+connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
+ $bdd->deconnexion();
+ }
+ elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
+ {
+ $bdd->connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
+ $bdd->deconnexion();
+ }
+ else
+ die('Erreur #04 : Format de recherche d\'asteroide incorrect !');
+
+ if (!empty($plan))
+ {
+ $this->id = $plan["id"];
+ parent::User($sess->values['id']); //On utilise le numéro d'utilisateur enregistré en session
+ $this->galaxie = $plan["galaxie"];
+ $this->ss = $plan["ss"];
+ $this->image = $plan["image"];
+ $this->debris_met = $plan["debris_met"];
+ $this->debris_cri = $plan["debris_cri"];
+ $this->metal = $plan["metal"];
+ $this->cristal = $plan["cristal"];
+ $this->hydrogene = $plan["hydrogene"];
+
+ foreach($alli_batimentVAR as $bat)
+ $this->alli_batiments[] = $plan[$bat];
+ if (!empty($plan["file_bat"]))
+ $this->file_bat = unserialize($plan["file_bat"]);
+ else
+ $this->file_bat = array();
+
+ foreach($nomvaisnVAR as $vais)
+ $this->vaisseaux[] = $plan[$vais];
+ if (!empty($plan["file_vais"]))
+ $this->file_vais = unserialize($plan["file_vais"]);
+ else
+ $this->file_vais = array();
+
+ }
+ }
+ }
+
+ /**
+ * Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
+ *
+ * @return void
+ * @access public
+ */
+ function actualiser($actuFile = true, $first = false)
+ {
+ //Actualisation des files d'attentes
+ if ($actuFile)
+ {
+ $this->file_ready("batiments");
+ $this->file_readyTechno("technologies");
+ $this->file_ready("casernes");
+ $this->file_ready("terrestres");
+ $this->file_ready("vaisseaux");
+ }
+
+ //Calcul de la capacité de stockage maximale
+ if (!empty($timestamp_lastSilo))
+ {
+ $this->cap = pow(2, $this->batiments[10]-1) * 100000;
+ $capnouv = pow(2, $this->batiments[10]) * 100000;
+ }
+ else
+ $this->cap = pow(2, $this->batiments[10]) * 100000;
+
+ //Calcul du temps écoulé depuis la dernière mise à jour de la planète
+ $temps_ecoule = time() - $this->timestamp;
+ $ressources = $this->production($temps_ecoule);
+ if ($this->metal + $ressources[0] < $this->cap)
+ $this->metal += $ressources[0];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->metal + $ressources[0] < $capnouv)
+ $this->metal += $ressources[0];
+ }
+ else
+ {
+ $this->alert_ressources[0] = true;
+ $this->metal = $this->cap;
+ }
+ }
+ if ($this->cristal + $ressources[1] < $this->cap)
+ $this->cristal += $ressources[1];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->cristal + $ressources[1] < $capnouv)
+ $this->cristal += $ressources[1];
+ }
+ else
+ {
+ $this->alert_ressources[1] = true;
+ $this->cristal = $this->cap;
+ }
+ }
+ if ($this->hydrogene + $ressources[2] < $this->cap)
+ $this->hydrogene += $ressources[2];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->hydrogene + $ressources[2] < $capnouv)
+ $this->hydrogene += $ressources[2];
+ }
+ else
+ {
+ $this->alert_ressources[2] = true;
+ $this->hydrogene = $this->cap;
+ }
+ }
+
+ //Vérification de la date pour faire les actions journalières
+ if (date('zya') != date('zya', $this->timestamp))
+ {
+ //On évalue le moral
+ $this->evalMoral($first);
+
+ //Si la population est à 0, on ajoute des habitants
+ if ($this->population <= 0)
+ $this->population = 1000;
+
+ $popPlus = $this->population * 0.0153^max(1, floor((time()-$this->timestamp)/86400));
+
+ if ($this->politique == 2)
+ $popPlus *= 1.1; //Communisme : 10 % de population qui arrive en plus.
+ elseif ($this->politique == 3)
+ $popPlus *= 1.05; //Démocratie : 5 % de population qui arrive en plus.
+
+ if ($this->technologies[2] & 4)
+ $popPlus *= 1.15;
+ elseif ($this->technologies[2] & 2)
+ $popPlus *= 1.10;
+ elseif ($this->technologies[2] & 1)
+ $popPlus *= 1.05;
+
+ $this->population += $popPlus;
+ $this->credits += $this->population/100*exp(0.01)*25;
+ $this->modif[] = 'population';
+ }
+
+ $this->timestamp = time();
+
+
+ //Calcul du nombre de cases restantes
+ $this->casesRest = $this->cases;
+ foreach($this->batiments as $bat)
+ $this->casesRest -= $bat;
+ }
+
+ function setMoral($difference)
+ {
+ $this->moral += $difference;
+
+ //Ajustement du moral
+ if ($this->moral > 1)
+ $this->moral = 1;
+ elseif ($this->moral < 0)
+ $this->moral = 0;
+
+ if (!in_array("moral", $this->modif))
+ $this->modif[] = "moral";
+ }
+
+ function evalMoral($first = false)
+ {
+ //Cas de sous-production
+ if (($this->coeff_bat[0] + $this->coeff_bat[1] + $this->coeff_bat[2])/3 < 0.9)
+ {
+ if ($this->politique == 2)
+ $this->moral -= 0.10; //Communisme : démoralise 2x plus
+ else
+ $this->moral -= 0.05;
+ if (!in_array('moral', $this->modif))
+ $this->modif[] = 'moral';
+ }
+
+ //Surpopulation
+
+ //Surlogement
+
+ //Ajustement du moral en fonction de la politique
+ if ($this->politique == 1 && $this->moral > 0.7)
+ $this->moral = 0.7;
+
+ //On vérifie qu'on ne dépasse pas le maximum
+ if ($this->moral > 1)
+ $this->moral = 1;
+ if ($this->moral < 0)
+ $this->moral = 0;
+
+ //Isolement si besoin
+ if ($this->moral < 0.1)
+ {
+ //On vérifie qu'il ne s'agit pas de la planète mère
+ global $bdd, $table_planete;
+ $bdd->connexion();
+ $res = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id LIMIT 1;");
+ $bdd->deconnexion();
+ if ($res['id'] != $this->id)
+ {
+ if ($this->moral <= 0.01 || $this->moral <= 0.04)
+ {
+ if ($this->moral <= 0.01)
+ $rand = rand(0,4);
+ else
+ $rand = rand(0,20);
+ //Perte de la planète
+ if ($rand == 1)
+ {
+ $bdd->connexion();
+ $bdd->query("DELETE FROM $table_planete WHERE id = ".$this->id.";");
+ $bdd->deconnexion();
+ send_mp($this->id_user, 'Perte de contrôle de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a renversé votre gouvernement en tuant tous vos gouverneurs. Vous perdez donc définitivement le contrôle de cette planète.");
+ if (!$first)
+ {
+ $sess->values['idPlan'] = $res['id'];
+ erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révolté contre vous. Vous ne contrôlez plus cette planète.');
+ }
+ }
+ }
+ elseif ($this->moral <= 0.06 || $this->moral <= 0.1)
+ {
+ if ($this->moral <= 0.06)
+ $rand = rand(0,2);
+ else
+ $rand = rand(0,10);
+ //Perte de contrôle temporaire
+ if ($rand == 1)
+ {
+ $debut = time() - rand(0, 3600)*4;
+ $fin = $debut + 86400;
+ $this->isolement = array($debut, $fin);
+ if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
+
+ send_mp($this->id_user, 'Perte de contrôle temporaire de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a pris le contrôle de votre planète. Vous perdez le contrôle de cette planète le temps que vos gouverneurs reprennent le pouvoir.");
+ if (!$first)
+ {
+ $sess->values['idPlan'] = $res['id'];
+ erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révoltée contre vous. Vous perdez temporairement le contrôle de cette planète.');
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Vérifie si la planète est isolée ou non
+ *
+ * @return boolean
+ * @access public
+ */
+ function isolement()
+ {
+ $return = false;
+
+ global $var___db, $config, $table_planete;
+ $bdd = new BDD();
+ $bdd->connexion();
+ $plan = $bdd->query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id;");
+ $bdd->deconnexion();
+
+ $numP = 0;
+ foreach ($plan as $key => $p)
+ {
+ if ($p['id'] == $this->id)
+ $numP = $key + 1;
+ }
+
+ if ($numP >= 11)
+ {
+ if (!isset($this->isolement[0]) || (time() > $this->isolement[0] && (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0])))))
+ {
+ switch($numP)
+ {
+ case 11:
+ $tps = 2;
+ break;
+ case 12:
+ $tps = 4;
+ break;
+ case 13:
+ $tps = 6;
+ break;
+ case 14:
+ $tps = 8;
+ break;
+ case 15:
+ $tps = 12;
+ break;
+ case 16:
+ $tps = 16;
+ break;
+ case 17:
+ $tps = 20;
+ break;
+ default:
+ $tps = 24;
+ }
+ $debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
+ $fin = $debut + $tps * 3600;
+
+ $this->isolement[0] = $debut;
+ if (time() > $this->isolement[0])
+ $this->isolement[1] = $fin;
+ if (!in_array('isolement', $this->modif))
+ $this->modif[] = 'isolement';
+ }
+ if (isset($this->isolement[1]) && time() < $this->isolement[1])
+ $return = true;
+ }
+ elseif (!isset($this->isolement[0]))
+ {
+ $this->isolement = array(0,0);
+ if (!in_array('isolement', $this->modif))
+ $this->modif[] = 'isolement';
+ }
+
+ return $return;
+ }
+
+ /**
+ * Calcul les ressources produites en fonction de $temps_ecoule
+ * @param int $temps_ecoule Temps écoulé depuis la dernière actualisation
+ *
+ * @return array
+ * @access public
+ */
+ function production($temps_ecoule, $retarray = false)
+ {
+ //Accélération de la production
+ $temps_ecoule *= VITESSE;
+
+ //Calcul de la consomation d'énergie
+ if ($this->batiments[0] > 0)
+ $energie_m = ceil(exp(0.28*$this->batiments[0])*10);
+ else
+ $energie_m = 0;
+ if ($this->batiments[1] > 0)
+ $energie_c = ceil(exp(0.28*$this->batiments[1])*10);
+ else
+ $energie_c = 0;
+ if ($this->batiments[2] > 0)
+ $energie_h = ceil(exp(0.2849*$this->batiments[2])*13);
+ else
+ $energie_h = 0;
+ if ($this->batiments[3] > 0)
+ $energie_s = ceil(exp(0.28*$this->batiments[3])*22);
+ else
+ $energie_s = 0;
+ if ($this->batiments[4] > 0)
+ $energie_f = ceil(exp(0.297*$this->batiments[4])*25);
+ else
+ $energie_f = 0;
+
+ //Calcul de la consomation d'énergie
+ $this->energieConso = $energie_m * $this->coeff_bat[0] + $energie_c * $this->coeff_bat[1] + $energie_h * $this->coeff_bat[2];
+ $nrjmx = $energie_m + $energie_c + $energie_h;
+
+ //Calcul de la production d'énergie
+ $this->energie = $energie_s * $this->coeff_bat[3] + $energie_f * $this->coeff_bat[4];
+
+ if ($this->energieConso == 0)
+ $coeff = 0;
+ else
+ $coeff = $this->energie / $this->energieConso;
+
+ if ($coeff < 0)
+ $coeff = 0;
+ elseif ($coeff > 1)
+ $coeff = 1;
+
+ $Ncoeff = array();
+ for($i = 0; $i < 3; $i++)
+ {
+ $Ncoeff[$i] = $coeff * $this->coeff_bat[$i];
+ if ($Ncoeff[$i] > 1)
+ $Ncoeff[$i] = 1;
+ if ($Ncoeff[$i] < $this->coeff_bat[$i] && $this->batiments[$i] != 0)
+ {
+ $this->coeff_bat[$i] = $Ncoeff[$i];
+ if (!in_array('coeff_bat', $this->modif))
+ $this->modif[] = 'coeff_bat';
+ }
+ }
+
+ //Calcul de la consomation d'hydrogène
+ if ($this->batiments[4] > 0)
+ $conso_h = ((ceil(pow(1.34,($this->batiments[4]-1))*9)/3600)*$temps_ecoule) * $this->coeff_bat[4];
+ else
+ $conso_h = 0;
+
+ //Calcul des production de ressources
+ if ($this->batiments[0] <= 0 || $this->batiments[3] <= 0)
+ $prod_met = 0.011 * $temps_ecoule;
+ else
+ $prod_met = ((ceil(pow(1.1, $this->batiments[0]) * 35 * $this->batiments[0]) / 3600) * $temps_ecoule) * $this->coeff_bat[0] * 1.5;
+
+ if ($this->batiments[1] <= 0 || $this->batiments[3] <= 0)
+ $prod_cri = 0.0055 * $temps_ecoule;
+ else
+ $prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 23 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1] * 1.5;
+
+ if ($this->batiments[2] <= 0)
+ $prod_hy = 0;
+ else
+ $prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 14 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2] * 1.5;
+
+ //Augmentation de la production en fonction des technologies
+ if ($this->technologies[0] &4)
+ {
+ $prod_met *= 1.15;
+ $prod_cri *= 1.15;
+ $prod_hy *= 1.15;
+ }
+ elseif ($this->technologies[0] &2)
+ {
+ $prod_met *= 1.10;
+ $prod_cri *= 1.10;
+ $prod_hy *= 1.10;
+ }
+ elseif ($this->technologies[0] &1)
+ {
+ $prod_met *= 1.05;
+ $prod_cri *= 1.05;
+ $prod_hy *= 1.05;
+ }
+
+ //Augmentation de la production en fonction du moral
+ if ($this->moral > 0.9)
+ {
+ $prod_met *= 1.05;
+ $prod_cri *= 1.05;
+ $prod_hy *= 1.05;
+ }
+ elseif ($this->moral > 0.75)
+ {
+ $prod_met *= 1.02;
+ $prod_cri *= 1.02;
+ $prod_hy *= 1.02;
+ }
+ elseif ($this->moral < 0.45)
+ {
+ $prod_met *= 0.97;
+ $prod_cri *= 0.97;
+ $prod_hy *= 0.97;
+ }
+ elseif ($this->moral < 0.25)
+ {
+ $prod_met *= 0.94;
+ $prod_cri *= 0.94;
+ $prod_hy *= 0.94;
+ }
+
+ //Augmentation de la production en fonction de la politique
+ if ($this->politique == 2)
+ {
+ $prod_met *= 1.10;
+ $prod_cri *= 1.10;
+ $prod_hy *= 1.10;
+ }
+
+ //On enlève la consomation d'hydrogène
+ $prod_hy -= $conso_h;
+
+ if ($retarray)
+ return array(array(ceil($this->coeff_bat[0]*100), ceil($this->coeff_bat[1]*100), ceil($this->coeff_bat[2]*100), ceil($this->coeff_bat[3]*100), ceil($this->coeff_bat[4]*100)), array($prod_met, $prod_cri, $prod_hy + $conso_h, $energie_s*$this->coeff_bat[3], $energie_f*$this->coeff_bat[4]), array($energie_m*$this->coeff_bat[0], $energie_c*$this->coeff_bat[1], $energie_h*$this->coeff_bat[2], $conso_h, ($energie_s*$this->coeff_bat[3] + $energie_f*$this->coeff_bat[4])-($energie_m*$this->coeff_bat[0] + $energie_c*$this->coeff_bat[1] + $energie_h*$this->coeff_bat[2])));
+ else
+ return array($prod_met, $prod_cri, $prod_hy);
+ }
+
+ function creer($id_user)
+ {
+ //Définition des paramètres de l'utilisateur pour la planète
+ $this->id_user = $id_user;
+
+ //Génération du nombre de case et de l'image en fonction de la position dans le système
+ if ($this->position > MAX_PLANETE*0.75)
+ {
+ $this->cases = mt_rand(200,255);
+ $this->image = mt_rand(1,19);
+ }
+ elseif ($this->position > MAX_PLANETE/2)
+ {
+ $this->cases = mt_rand(250,300);
+ $this->image = mt_rand(1,19);
+ }
+ elseif ($this->position > MAX_PLANETE/4)
+ {
+ $this->cases = mt_rand(175,260);
+ $this->image = mt_rand(1,19);
+ }
+ else
+ {
+ $this->cases = mt_rand(150,220);
+ $this->image = mt_rand(1,19);
+ }
+
+ //Définition des principaux paramètres de la planète
+ $this->nom_planete = 'Planète colonisée';
+ $this->timestamp = time();
+ $this->metal = 1000;
+ $this->cristal = 700;
+ $this->hydrogene = 0;
+
+ $this->modif = array("id_user", "nom_planete", "galaxie", "ss", "position", "image", "cases", "timestamp", "metal", "cristal", "hydrogene");
+ }
+
+ /**
+ * Destructeur
+ *
+ * @return void
+ * @access public
+ */
+ function __destruct()
+ {
+ if (empty($this->ss) || empty($this->id_user))
+ return;
+ if ($this->id_user == 1)
+ var_dump($this);
+
+ global $var___db, $config, $table_planete;
+ if (empty($this->id))
+ {
+ $out1 = array(); $out2 = array();
+ $bdd = new bdd();
+ $bdd->connexion();
+ foreach($this->modif as $modif)
+ {
+ if (!is_array($this->{$modif}))
+ {
+ $bdd->escape($this->{$modif});
+ $out1[] = $modif;
+ if (is_int($this->{$modif}) || is_float($this->{$modif}))
+ $out2[] = $this->{$modif};
+ else
+ $out2[] = "'".$this->{$modif}."'";
+ }
+ else
+ {
+ if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
+ {
+ $prep = serialize($this->{$modif});
+ $bdd->escape($prep);
+ $out1[] = $modif;
+ $out2[] = "'$prep'";
+ }
+ else
+ {
+ if ($modif == "batiments")
+ $calc = "batiment";
+ elseif ($modif == "technologies")
+ $calc = "technolo";
+ elseif ($modif == "casernes")
+ $calc = "casernen";
+ elseif ($modif == "terrestres")
+ $calc = "nomterrn";
+ elseif ($modif == "vaisseaux")
+ $calc = "nomvaisn";
+ elseif ($modif == "coeff_bat")
+ $calc = "coeff";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ foreach($this->{$modif} as $j => $value)
+ {
+ $out1[] = ${$calc.'VAR'}[$j];
+ $out2[] = $value;
+ }
+ }
+ }
+ }
+ $bdd->query("INSERT INTO $table_planete (".implode(', ', $out1).", hash_planete) VALUES (".implode(', ', $out2).", SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)))");
+ $bdd->deconnexion();
+ }
+ else
+ {
+ $nb = count($this->modif);
+ $out = array();
+ $bdd = new bdd();
+ $bdd->connexion();
+ for($i = 0; $i < $nb; $i++)
+ {
+ if ($this->modif[$i] == 'technologies')
+ $this->modifUser[] = $this->modif[$i];
+ elseif (!is_array($this->{$this->modif[$i]}))
+ {
+ $bdd->escape($this->{$this->modif[$i]});
+ if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]}))
+ $out[] = $this->modif[$i]." = ".$this->{$this->modif[$i]};
+ else
+ $out[] = $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
+ }
+ else
+ {
+ if (is_array($this->{$this->modif[$i]}) && $this->modif[$i] != "coeff_bat" && $this->modif[$i] != "vaisseaux" && $this->modif[$i] != "terrestres" && $this->modif[$i] != "casernes" && $this->modif[$i] != "technologies" && $this->modif[$i] != "batiments")
+ {
+ $prep = serialize($this->{$this->modif[$i]});
+ $bdd->escape($prep);
+ $out[] = $this->modif[$i]." = '$prep'";
+ }
+ else
+ {
+ if ($this->modif[$i] == "batiments")
+ $calc = "batiment";
+ elseif ($this->modif[$i] == "technologies")
+ $calc = "technolo";
+ elseif ($this->modif[$i] == "casernes")
+ $calc = "casernen";
+ elseif ($this->modif[$i] == "terrestres")
+ $calc = "nomterrn";
+ elseif ($this->modif[$i] == "vaisseaux")
+ $calc = "nomvaisn";
+ elseif ($this->modif[$i] == "coeff_bat")
+ $calc = "coeff";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ $nombr = count(${$calc.'VAR'});
+ for($j = 0; $j < $nombr; $j++)
+ {
+ $bdd->escape($this->{$this->modif[$i]}[$j]);
+ $out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
+ }
+ }
+ }
+ }
+ if (!empty($out))
+ $plan = $bdd->query("UPDATE $table_planete SET ".implode(', ', $out)." WHERE id = ".$this->id.";");
+
+ $bdd->deconnexion();
+ parent::__destruct();
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/game/Class/class.file.php b/game/Class/class.file.php
index 385838b..940dc83 100644
--- a/game/Class/class.file.php
+++ b/game/Class/class.file.php
@@ -8,411 +8,651 @@
*
*
***************************************************************************/
-class File{
- var $file;
+class File
+ {
+ var $file;
- function File($file){
- $this->file = unserialize($file);
- }
-
- function reajusteVacances($timeVac){
- if (isset($this->file[0])) {
- $this->file[0] += time() - $timeVac;
- }
-
- return serialize($this->file);
- }
-
- /**
- * Ajoute $nombre objets $objet dans la file $file
- * @param int $file Nom de la file d'attente
- * @param int $objet Id de l'objet à ajouter
- * @param int $nombre = 1 Nombre d'objet $objet à ajouter à la file
- *
- * @return int Numéro de l'erreur
- * @access public
- */
- function file_addObjet($file, $objet, $nombre = 1){
- $planete = $this;
-
- if ($nombre > 99999) erreur('Dépacement de capacité ! Vous ne pouvez pas mettre autant d\'unités en file d\'attente en une seule fois.');
-
- switch($file){
- case "alli_batiments": $court = "abat"; $calc = "alli_batiment"; global ${$calc.'LIMIT'}; $exist = $this->file_exist($objet, "file_".$court); break;
- case "batiments": $court = "bat"; $calc = "batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "technologies": $court = "tech"; $calc = "technolo"; $exist = $this->file_exist($objet, $nombre); break;
- case "casernes": $court = "cas"; $calc = "casernen"; $exist = false; break;
- case "terrestres": $court = "ter"; $calc = "nomterrn"; $exist = false; break;
- case "vaisseaux": $court = "vais"; $calc = "nomvaisn"; $exist = false; break;
- default: return 1;
- }
-
- //On vérifie la taille maximale de la file d'attente
- if (!empty($this->technologies['techno_inge'])) {
- if (($this->technologies['techno_inge'] & 131072) == 131072) $max = 5;
- elseif (($this->technologies['techno_inge'] & 65536) == 65536) $max = 4;
- elseif (($this->technologies['techno_inge'] & 32768) == 32768) $max = 3;
- else $max = 2;
- }
- else $max = 3;
-
- if ($file == "technologies") {
- global ${$file.'CALC'};
-
- $file_tech = $nombre;
- $nombre = 1;
-
- if (empty($technologiesCALC[$file_tech][$objet])) return 1;
-
- //Vérification des conditions de recherche
- if (!(($this->technologies[$file_tech] & $technologiesCALC[$file_tech][$objet][1]) == $technologiesCALC[$file_tech][$objet][1] && !($this->technologies[$file_tech] & $technologiesCALC[$file_tech][$objet][0] && $this->technologies[$file_tech] != 0))) return 1;
- }
- else {
- global ${$calc}, ${$calc.'CALC'}, ${$calc.'TECH'};
-
- //Vérification des conditions de construction
- if (empty(${$calc}[$objet]) || !requestDeblok(${$calc.'TECH'}[$objet], $this)) return 1;
-
- //Vérification que l'on ait pas dépassé le nombre maximal de niveau
- if (!empty(${$calc.'LIMIT'}[$objet]) && ${$file}[$objet] >= ${$calc.'LIMIT'}[$objet]) return 1;
-
- //Calcul du prochain niveau de l'objet
- $n = $this->{$file}[$objet] + 1;
- }
-
- //Vérification qu'il n'y ait pas déjà une instance de l'objet déjà en construction
- if ($exist) return 2;
-
- //Vérification que le nombre ne soit pas négatif
- if ($nombre < 0 && ($file != "batiments" || $nombre < -1)) return 5;
-
- //Actualisation du temps s'il n'y a pas d'objet en file
- if (count($this->{"file_".$court}) < 2) $this->{"file_".$court}[0] = time();
-
-
- if ($nombre > 0) {
- if ($file == "alli_batiments" || $file == "batiments") {
- eval(${$calc.'CALC'}[$objet][0]);
- eval(${$calc.'CALC'}[$objet][1]);
- eval(${$calc.'CALC'}[$objet][2]);
- $d = 0;
+ function File($file)
+ {
+ $this->file = unserialize($file);
}
- elseif ($file == "technologies") {
+
+ function reajusteVacances($timeVac)
+ {
+ if (isset($this->file[0]))
+ $this->file[0] += time() - $timeVac;
+
+ return serialize($this->file);
+ }
+
+ /**
+ * Ajoute $nombre objets $objet dans la file $file
+ * @param int $file Nom de la file d'attente
+ * @param int $objet Id de l'objet à ajouter
+ * @param int $nombre = 1 Nombre d'objet $objet à ajouter à la file
+ *
+ * @return int Numéro de l'erreur
+ * @access public
+ */
+ function file_addObjet($file, $objet, $nombre = 1)
+ {
+ $planete = $this;
+
+ switch($file)
+ {
+ case "alli_batiments":
+ $court = "abat";
+ $calc = "alli_batiment";
+ global ${$calc.'LIMIT'};
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "batiments":
+ $court = "bat";
+ $calc = "batiment";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "technologies":
+ 1/0;
+ die('Erreur dans la file d\'attente ! #43, veuillez contacter un administrateur.');
+ break;
+
+ case "casernes":
+ $court = "cas";
+ $calc = "casernen";
+ $exist = false;
+ break;
+
+ case "terrestres":
+ $court = "ter";
+ $calc = "nomterrn";
+ $exist = false;
+ break;
+
+ case "vaisseaux":
+ $court = "vais";
+ $calc = "nomvaisn";
+ $exist = false;
+ break;
+
+ default:
+ return 1;
+ }
+
+ //On calcul la taille maximale de la file d'attente
+ if (!empty($this->technologies['techno_inge']))
+ {
+ if (($this->technologies['techno_inge'] &131072) == 131072) $max = 5;
+ elseif (($this->technologies['techno_inge'] &65536) == 65536) $max = 4;
+ elseif (($this->technologies['techno_inge'] &32768) == 32768) $max = 3;
+ else $max = 2;
+ }
+ else $max = 3; //Au cas où il n'y ait pas de technologie sur le lieu, on fixe la taille de la file d'attente
+
+ //Load the global variables for the line
+ global ${$calc}, ${$calc.'CALC'}, ${$calc.'TECH'};
+
+ //Check the conditions of building
+ if (empty(${$calc}[$objet]) || !requestDeblok(${$calc.'TECH'}[$objet], $this))
+ return 1;
+
+ //Check that we have not overtake the maximum level
+ if (!empty(${$calc.'LIMIT'}[$objet]) && ${$file}[$objet] >= ${$calc.'LIMIT'}[$objet])
+ return 1;
+
+ //Calculate next object's level
+ $n = $this->{$file}[$objet] + 1;
+
+ //Check that there isn't another object's entreaties yet building
+ if ($exist)
+ return 2;
+
+ //Check the sended number, it mustn't be negativ
+ if ($nombre < 0 && ($file != "batiments" || $nombre < -1))
+ return 5;
+
+ //Refresh time if no object in the line
+ if (count($this->{"file_".$court}) < 2)
+ $this->{"file_".$court}[0] = time();
+
+
+ if ($nombre > 0)
+ {
+ if ($file == "alli_batiments" || $file == "batiments")
+ {
+ eval(${$calc.'CALC'}[$objet][0]);
+ eval(${$calc.'CALC'}[$objet][1]);
+ eval(${$calc.'CALC'}[$objet][2]);
+ $d = 0;
+ }
+ elseif ($file == "technologies")
+ {
+ $a = $b = $c = 0;
+ $d = $technologiesCALC[$branch][$objet][2];
+ }
+ else
+ {
+ $a = ${$calc.'CALC'}[$objet][0];
+ $b = ${$calc.'CALC'}[$objet][1];
+ $c = ${$calc.'CALC'}[$objet][2];
+ $d = 0;
+ }
+
+ //Apply policy bonus for time and cost
+ if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux"))
+ {
+ $a *= 0.9;
+ $b *= 0.9;
+ $c *= 0.9;
+ }
+ //Apply bonus from technology for the mines
+ if ($file == "batiments" && $objet < 4 && isset($this->technologies))
+ {
+ if ($this->technologies[0] &262144)
+ {
+ $a *= 0.85;
+ $b *= 0.85;
+ $c *= 0.85;
+ }
+ elseif ($this->technologies[0] &131072)
+ {
+ $a *= 0.9;
+ $b *= 0.9;
+ $c *= 0.9;
+ }
+ elseif ($this->technologies[0] &65536)
+ {
+ $a *= 0.95;
+ $b *= 0.95;
+ $c *= 0.95;
+ }
+ }
+
+ //Check maximum number unity building on this planet with means
+ if ($nombre > 1)
+ {
+ if ($a) $nombre = min(floor($this->metal/$a), $nombre);
+ if ($b) $nombre = min(floor($this->cristal/$b), $nombre);
+ if ($c) $nombre = min(floor($this->hydrogene/$c), $nombre);
+ if ($d) $nombre = min(floor($this->credits/$d), $nombre);
+ }
+ }
+ else
+ {
+ $a = 0;
+ $b = 0;
+ $c = 0;
+ $d = 0;
+ }
+
+ //Check means on the planet
+ if ($this->metal < $a * $nombre || $this->cristal < $b * $nombre || $this->hydrogene < $c * $nombre || $this->credits < $d * $nombre)
+ return 3;
+ else
+ {
+ //Line generate
+ $nb = count($this->{"file_".$court});
+
+ //If the last object is similar as this one
+ if ($file == "technologies" && $max <= count($this->{"file_".$court}))
+ return 4; //Check height line
+ elseif ($file == "technologies")
+ $this->{"file_".$court}[] = array($objet, $branch);
+ elseif ($nombre > 99999 || ($nb > 1 && $objet == $this->{"file_".$court}[$nb-1][0] && $this->{"file_".$court}[$nb-1][1] + $nombre > 99999))
+ erreur('Dépacement de capacité ! Vous ne pouvez pas mettre autant d\'unités en file d\'attente en une seule fois.');
+ elseif ($nb > 1 && $objet == $this->{"file_".$court}[$nb-1][0])
+ $this->{"file_".$court}[$nb-1][1] += $nombre;
+ elseif ($max <= count($this->{"file_".$court}))
+ return 4; //Check height line
+ else
+ $this->{"file_".$court}[] = array($objet, $nombre);
+
+ //Update means on the planet after building
+ $this->metal -= $a * $nombre;
+ $this->cristal -= $b * $nombre;
+ $this->hydrogene -= $c * $nombre;
+ $this->credits -= $d * $nombre;
+
+ if (!in_array("file_".$court, $this->modif))
+ $this->modif[] = "file_".$court;
+
+ return 0;
+ }
+ }
+
+ /**
+ * Ajoute à la file d'attente technologique la technologie $technology dans la branche $branch
+ * @param int $branch Branche technologique dans laquel se trouve la technologie
+ * @param int $technology ID de la technologie à ajouter
+ *
+ * @return int Numéro de l'erreur
+ * @access public
+ */
+ function file_addTechno($branch, $technology)
+ {
+ $planete = $this;
+
+ //Calculate maximum height line
+ if (!empty($this->technologies['techno_inge']))
+ {
+ if (($this->technologies['techno_inge'] &131072) == 131072) $max = 5;
+ elseif (($this->technologies['techno_inge'] &65536) == 65536) $max = 4;
+ elseif (($this->technologies['techno_inge'] &32768) == 32768) $max = 3;
+ else $max = 2;
+ }
+ else $max = 3;
+
+ //Load globals variables
+ global $technologiesCALC;
+
+ //Check branch and technology
+ if (empty($technologiesCALC[$branch][$technology]))
+ return 1;
+
+ //Check search conditions
+ if (!(($this->technologies[$branch] &$technologiesCALC[$branch][$technology][1]) == $technologiesCALC[$branch][$technology][1] && !($this->technologies[$branch] &$technologiesCALC[$branch][$technology][0] && $this->technologies[$branch] != 0)))
+ return 1;
+
+ //Check that there isn't another object's entreaties yet building
+ //TODO
+ if ($this->file_existTech($branch, $technology))
+ return 2;
+
+ //Refresh time if that is the first search
+ if (count($this->file_tech) < 2)
+ $this->file_tech[0] = time();
+
+ //Calculate cost and time
$a = $b = $c = 0;
- $d = $technologiesCALC[$file_tech][$objet][2];
- }
- else {
- $a = ${$calc.'CALC'}[$objet][0];
- $b = ${$calc.'CALC'}[$objet][1];
- $c = ${$calc.'CALC'}[$objet][2];
- $d = 0;
+ $d = $technologiesCALC[$branch][$technology][2];
+
+ //Check means on planet
+ if ($this->metal < $a || $this->cristal < $b || $this->hydrogene < $c || $this->credits < $d) return 3;
+ else
+ {
+ if ($max <= count($this->file_tech))
+ return 4; //Vérification de la taille de la file d'attente
+ else
+ $this->file_tech[] = array($technology, $branch);
+
+ //Update means on the planet after start searching
+ $this->metal -= $a;
+ $this->cristal -= $b;
+ $this->hydrogene -= $c;
+ $this->credits -= $d;
+
+ if (!in_array("file_tech", $this->modif))
+ $this->modif[] = "file_tech";
+
+ return 0;
+ }
}
- //On applique les bonus politiques aux temps et coûts
- if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
- $a *= 0.9;
- $b *= 0.9;
- $c *= 0.9;
+
+ function file_delObjet($file, $objet, $nombre = 1, $w = 99)
+ {
+ $planete = $this;
+
+ switch($file)
+ {
+ case "alli_batiments":
+ $court = "abat";
+ $calc = "alli_batiment";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "batiments":
+ $court = "bat";
+ $calc = "batiment";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "technologies":
+ 1/0;
+ die('Erreur dans la file d\'attent : #273. Contactez un administrateur.');
+ break;
+
+ case "casernes":
+ $court = "cas";
+ $calc = "casernen";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "terrestres":
+ $court = "ter";
+ $calc = "nomterrn";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ case "vaisseaux":
+ $court = "vais";
+ $calc = "nomvaisn";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
+
+ default:
+ return false;
+ }
+
+ //Si l'objet n'est pas dans la file d'attente, on annule la suite
+ if (!$exist)
+ return 0;
+
+ if ($w == 99)
+ $w = count($this->{"file_".$court})-1;
+
+ global ${$calc}, ${$calc.'CALC'};
+
+ for($i = $w; $i > 0; $i--)
+ {
+ if($this->{"file_".$court}[$i][0] == $objet)
+ {
+ $nombre = min(abs($nombre), $this->{"file_".$court}[$i][1]);
+
+ if($this->{"file_".$court}[$i][1] <= $nombre)
+ {
+ unset($this->{"file_".$court}[$i]);
+ $this->{"file_".$court} = array_merge($this->{"file_".$court});
+ if ($i == 1)
+ $this->{"file_".$court}[0] = time();
+ }
+ else
+ $this->{"file_".$court}[$i][1] -= $nombre;
+
+ break;
+ }
+ }
+
+ //Calcul du prochain niveau de l'objet
+ $n = $this->{$file}[$objet] + 1;
+
+
+ if (!in_array("file_".$court, $this->modif))
+ $this->modif[] = "file_".$court;
+
+ if ($nombre > 0)
+ {
+ if ($file == "batiments")
+ {
+ eval(${$calc.'CALC'}[$objet][0]);
+ eval(${$calc.'CALC'}[$objet][1]);
+ eval(${$calc.'CALC'}[$objet][2]);
+ $d = 0;
+ }
+ else
+ {
+ $a = ${$calc.'CALC'}[$objet][0];
+ $b = ${$calc.'CALC'}[$objet][1];
+ $c = ${$calc.'CALC'}[$objet][2];
+ $d = 0;
+ }
+
+ //On applique les bonus politiques aux temps et coûts
+ if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux"))
+ {
+ $a *= 0.9;
+ $b *= 0.9;
+ $c *= 0.9;
+ }
+
+ //Mise à jour des ressources de la planète en conséquence à la construction
+ $this->metal += $a * $nombre;
+ $this->cristal += $b * $nombre;
+ $this->hydrogene += $c * $nombre;
+ $this->credits += $d * $nombre;
+ }
+
+ return $nombre;
}
- //Vérification du nombre maximum d'entraînement possible de cette unité sur cette planète
- if ($nombre > 1) {
- if ($a) $nombre = min(floor($this->metal/$a), $nombre);
- if ($b) $nombre = min(floor($this->cristal/$b), $nombre);
- if ($c) $nombre = min(floor($this->hydrogene/$c), $nombre);
- if ($d) $nombre = min(floor($this->credits/$d), $nombre);
+ function file_delTechno($id)
+ {
+ $planete = $this;
+
+ //Si l'objet n'est pas dans la file d'attente, on annule la suite
+ //TODO
+ if (!isset($this->file_tech[$id+1]))
+ return 0;
+ else
+ {
+ global $technologiesCALC;
+ //On réinitialise le temps si c'est la première série de la liste
+ if ($id == 0)
+ $this->file_tech[0] = time();
+
+ $d = $technologiesCALC[$this->file_tech[$id+1][1]][$this->file_tech[$id+1][0]][2];
+
+ unset($this->file_tech[$id+1]);
+ $this->file_tech = array_merge($this->file_tech);
+ }
+
+
+ if (!in_array("file_tech", $this->modif))
+ $this->modif[] = "file_tech";
+
+ $a = $b = $c = 0;
+
+ //Mise à jour des ressources de la planète en conséquence à la construction
+ $this->metal += $a;
+ $this->cristal += $b;
+ $this->hydrogene += $c;
+ $this->credits += $d;
+
+ return 1;
}
- }
- else {
- $a = 0;
- $b = 0;
- $c = 0;
- $d = 0;
- }
- //Vérification des ressources de la planète
- if ($this->metal < $a * $nombre) return 3;
- elseif ($this->cristal < $b * $nombre) return 3;
- elseif ($this->hydrogene < $c * $nombre) return 3;
- elseif ($this->credits < $d * $nombre) return 3;
- else {
- //Génération de la file d'attente
- $nb = count($this->{"file_".$court});
-
- //Si le dernier objet est identique à celui que l'on veut construire
- if ($file == "technologies" && $max <= count($this->{"file_".$court})) return 4; //Vérification de la taille de la file d'attente
- elseif ($file == "technologies") $this->{"file_".$court}[] = array($objet, $file_tech);
- elseif ($nb > 1 && $objet == $this->{"file_".$court}[$nb-1][0]) {
- $this->{"file_".$court}[$nb-1][1] += $nombre;
+ /**
+ * Vérifie l'existance dans la file $file d'attente de $objet
+ * @param int $objet ID à vérifier
+ * @param string $file Nom de la file d'attente
+ *
+ * @return boolean
+ * @access public
+ */
+ function file_exist($objet, $file)
+ {
+ //On traite le cas d'une file type arbre
+ if (is_numeric($file)) {
+ 1/0;
+ die('A corriger, File d\'attente : #422. Contacter un administrateur');
+ }
+ else {
+ if (count($this->$file) <= 1) return false;
+ foreach($this->$file as $key => $bout){
+ if ($key == 0) continue;
+ if($objet == $bout[0]) return true;
+ }
+ }
+ return false;
}
- elseif ($max <= count($this->{"file_".$court})) return 4; //Vérification de la taille de la file d'attente
- else $this->{"file_".$court}[] = array($objet, $nombre);
- //Mise à jour des ressources de la planète en conséquence à la construction
- $this->metal -= $a * $nombre;
- $this->cristal -= $b * $nombre;
- $this->hydrogene -= $c * $nombre;
- $this->credits -= $d * $nombre;
+ function file_existTech($branch, $technology)
+ {
+ foreach($this->file_tech as $key => $part){
+ if ($key == 0) continue;
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
- return 0;
- }
- }
+ if($technology == $part[0] && $branch == $part[1]) return true;
+ }
- function file_delObjet($file, $objet, $nombre = 1, $w = 99) {
- $planete = $this;
- switch($file){
- case "alli_batiments": $court = "abat"; $calc = "alli_batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "batiments": $court = "bat"; $calc = "batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "technologies": $court = "tech"; $calc = "technolo"; $exist = true; break;
- case "casernes": $court = "cas"; $calc = "casernen"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "terrestres": $court = "ter"; $calc = "nomterrn"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "vaisseaux": $court = "vais"; $calc = "nomvaisn"; $exist = $this->file_exist($objet, "file_".$court); break;
- default: return false;
- }
+ return false;
+ }
- //Si l'objet n'est pas dans la file d'attente, on annule la suite
- if (!$exist) return 0;
+ /**
+ * Actualise la file $file en terminant les constructions/entraînements.
+ * @param string $file Nom de la file d'attente
+ *
+ * @return boolean
+ * @access public
+ */
+ function file_ready($file)
+ {
+ $planete = $this;
- if ($w == 99) $w = count($this->{"file_".$court})-1;
+ switch($file)
+ {
+ case "alli_batiments":
+ $court = "abat";
+ $calc = "alli_batiment";
+ $exist = $this->file_exist($objet, "file_".$court);
+ break;
- //On gère les files de type arbre
- if ($file == "technologies") {
- if (isset($this->{"file_".$court}[$objet+1])) {
- global ${$file.'CALC'};
- //On réinitialise le temps si c'est la première
- if ($objet == 0) $this->{"file_".$court}[0] = time();
+ case "batiments":
+ $court = "bat";
+ $calc = "batiment";
+ break;
- $i = $objet;
- $filearbre = $this->{"file_".$court}[$objet+1][1];
- $objet = $this->{"file_".$court}[$objet+1][0];
+ case "technologies":
+ die('Erreur dans la file d\'attente : #449. Veuillez contacter un administrateur.');
+ break;
- if (!$this->file_exist($objet, $filearbre)) return 0;
+ case "casernes":
+ $court = "cas";
+ $calc = "casernen";
+ break;
- unset($this->{"file_".$court}[$i+1]);
+ case "terrestres":
+ $court = "ter";
+ $calc = "nomterrn";
+ break;
+
+ case "vaisseaux":
+ $court = "vais";
+ $calc = "nomvaisn";
+ break;
+
+ default:
+ return false;
+ }
+
+ if (empty($this->{"file_".$court}[0]))
+ return false;
+
+ //Calcul du temps écoulé depuis le dernier entrainement validé
+ $tps = time() - $this->{"file_".$court}[0];
+
+ global ${$calc}, ${$calc.'CALC'};
+
+ foreach($this->{"file_".$court} as $key => $bout)
+ {
+ if ($key == 0) continue;
+
+ if ($bout[1] < 0) $n = $this->{$file}[$bout[0]]; //Extraction du niveau en cours
+ else $n = $this->{$file}[$bout[0]] + 1; //Extraction du niveau en cours
+ eval(${$calc.'CALC'}[$bout[0]][3]); //Récupération du temps de construction
+
+ //On applique le bonus de temps des ingénieurs et des centrales informatiques
+ if ($file == "batiments" && $bout[0] != 11) $sec /= pow(1.23,$this->batiments[11]) + 0.0025*$this->casernes[7];
+
+
+ //Accélération du temps de construction
+ $sec /= VITESSE;
+
+ if ($bout[1] < 0)
+ {
+ $sec *= 0.6;
+
+ if ($sec < $tps)
+ {
+ eval(${$calc.'CALC'}[$bout[0]][0]);
+ eval(${$calc.'CALC'}[$bout[0]][1]);
+ eval(${$calc.'CALC'}[$bout[0]][2]);
+
+ //On reçoit 70% des ressources en bonus
+ $this->metal += $a * 0.7;
+ $this->cristal += $b * 0.7;
+ $this->hydrogene += $c * 0.7;
+
+ $this->{$file}[$bout[0]]--;
+ $this->{"file_".$court}[0] += $bout[1] * $sec;
+ $tps -= $sec;
+ unset($this->{"file_".$court}[$key]);
+
+ if (!in_array($file, $this->modif)) $this->modif[] = $file;
+ if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
+ }
+ }
+ elseif ($sec * $bout[1] < $tps && $bout[1] > 0)
+ {
+ //S'il s'agit d'un silo, on sauvegarde le temps pour utilisation par le script de production
+ if ($file == "batiments" && $bout[0] == 10) $timestamp_lastSilo = $this->{"file_".$court}[0];
+ if ($file == "batiments" && $bout[0] == 0) $timestamp_mineM = $this->{"file_".$court}[0];
+ if ($file == "batiments" && $bout[0] == 1) $timestamp_mineC = $this->{"file_".$court}[0];
+ if ($file == "batiments" && $bout[0] == 2) $timestamp_mineH = $this->{"file_".$court}[0];
+
+ $this->{$file}[$bout[0]] += $bout[1];
+ $this->{"file_".$court}[0] += $bout[1] * $sec;
+ $tps -= $bout[1] * $sec;
+ unset($this->{"file_".$court}[$key]);
+
+ if (!in_array($file, $this->modif)) $this->modif[] = $file;
+ if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
+ }
+ elseif ($sec < time() - $this->{"file_".$court}[0] && $bout[1] > 0)
+ {
+ $j = floor($tps/$sec);
+
+ $this->{"file_".$court}[$key][1] -= $j;
+ $this->{$file}[$bout[0]] += $j;
+ $this->{"file_".$court}[0] += $j * $sec;
+ $tps -= $j * $sec;
+
+ if (!in_array($file, $this->modif)) $this->modif[] = $file;
+ if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
+
+ //Comme la première attente n'est pas terminée, on stoppe le tout
+ break;
+ }
+ else break;
+ }
+ //On actualise seulement s'il y a eu une modification de faite
+ if (in_array($file, $this->modif)) $this->actualiser(false);
$this->{"file_".$court} = array_merge($this->{"file_".$court});
}
- }
- else {
- global ${$calc}, ${$calc.'CALC'};
- for($i = $w; $i > 0; $i--) {
- if($this->{"file_".$court}[$i][0] == $objet){
- $nombre = min(abs($nombre), $this->{"file_".$court}[$i][1]);
+ function file_readyTechno($file)
+ {
+ $planete = $this;
- if($this->{"file_".$court}[$i][1] <= $nombre) {
- unset($this->{"file_".$court}[$i]);
- $this->{"file_".$court} = array_merge($this->{"file_".$court});
+ $court = "tech"; $calc = "technolo";
+
+ if (empty($this->file_tech[0])) return false;
+
+ //Calcul du temps écoulé depuis le dernier entrainement validé
+ $tps = time() - $this->file_tech[0];
+
+ global $technologiesCALC;
+
+ foreach($this->file_tech as $key => $bout)
+ {
+ if ($key == 0) continue;
+
+ //Récupération du temps de recherche
+ $sec = $technologiesCALC[$bout[1]][$bout[0]][3] / (1 + $this->batiments[6] * 0.01);
+
+ //Accélération du temps de construction en fonction de la vitesse du serveur
+ $sec /= VITESSE;
+
+ if ($sec < $tps)
+ {
+ $this->technologies[$bout[1]] |= $technologiesCALC[$bout[1]][$bout[0]][0];
+ $this->file_tech[0] += $sec;
+ $tps -= $sec;
+ unset($this->file_tech[$key]);
+ $this->file_tech = array_merge($this->file_tech);
+
+ //La déouverte de technologie est bénéfique pour le moral de la population
+ if ($this->moral) {
+ if ($this->politique == 3) $this->setMoral(0.1); //Démocratie : Découvrir une nouvelle technologie a plus d'effet bénéfique sur le moral
+ else $this->setMoral(0.05);
+ }
+
+ if (!in_array("technologies", $this->modifUser)) $this->modifUser[] = "technologies";
+ if (!in_array("file_tech", $this->modif)) $this->modif[] = "file_tech";
+ }
+ else break;
}
- else $this->{"file_".$court}[$i][1] -= $nombre;
-
- if ($i == 1) $this->{"file_".$court}[0] = time();
- break;
- }
+ if (in_array("file_tech", $this->modif)) $this->actualiser(false);
}
-
- //Calcul du prochain niveau de l'objet
- $n = $this->{$file}[$objet] + 1;
- }
-
-
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
-
- if ($nombre > 0) {
- if ($file == "batiments") {
- eval(${$calc.'CALC'}[$objet][0]);
- eval(${$calc.'CALC'}[$objet][1]);
- eval(${$calc.'CALC'}[$objet][2]);
- $d = 0;
- }
- elseif ($file == "technologies") {
- $a = $b = $c = 0;
- $d = $technologiesCALC[$filearbre][$objet][2];
- }
- else {
- $a = ${$calc.'CALC'}[$objet][0];
- $b = ${$calc.'CALC'}[$objet][1];
- $c = ${$calc.'CALC'}[$objet][2];
- $d = 0;
- }
-
- //On applique les bonus politiques aux temps et coûts
- if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
- $a *= 0.9;
- $b *= 0.9;
- $c *= 0.9;
- }
-
- //Mise à jour des ressources de la planète en conséquence à la construction
- $this->metal += $a * $nombre;
- $this->cristal += $b * $nombre;
- $this->hydrogene += $c * $nombre;
- $this->credits += $d * $nombre;
- }
-
- return $nombre;
}
-
- /**
- * Vérifie l'existance dans la file $file d'attente de $objet
- * @param int $objet ID à vérifier
- * @param string $file Nom de la file d'attente
- *
- * @return boolean
- * @access public
- */
- function file_exist($objet, $file){
- //On traite le cas d'une file type arbre
- if (is_numeric($file)) {
- foreach($this->file_tech as $key => $bout){
- if ($key == 0) continue;
- if($objet == $bout[0] && $file == $bout[1]) return true;
- }
- }
- else {
- if (count($this->$file) <= 1) return false;
- foreach($this->$file as $key => $bout){
- if ($key == 0) continue;
- if($objet == $bout[0]) return true;
- }
- }
- return false;
- }
-
- /**
- * Actualise la file $file en terminant les constructions/entraînements.
- * @param string $file Nom de la file d'attente
- *
- * @return boolean
- * @access public
- */
- function file_pret($file){
- $planete = $this;
- switch($file){
- case "alli_batiments": $court = "abat"; $calc = "alli_batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
- case "batiments": $court = "bat"; $calc = "batiment"; break;
- case "technologies": $court = "tech"; $calc = "technolo"; break;
- case "casernes": $court = "cas"; $calc = "casernen"; break;
- case "terrestres": $court = "ter"; $calc = "nomterrn"; break;
- case "vaisseaux": $court = "vais"; $calc = "nomvaisn"; break;
- default: return false;
- }
-
- if (empty($this->{"file_".$court}[0])) return false;
-
- //Calcul du temps écoulé depuis le dernier entrainement validé
- $tps = time() - $this->{"file_".$court}[0];
-
- if ($file == "technologies") {
- global ${$file.'CALC'};
-
- foreach($this->{"file_".$court} as $key => $bout) {
- if ($key == 0) continue;
-
- //Récupération du temps de recherche
- $sec = $technologiesCALC[$bout[1]][$bout[0]][3] / (1 + $this->batiments[6] * 0.01);
-
- //On applique les bonus politiques aux temps et coûts
- if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
- $sec *= 0.9;
- }
-
- //Accélération du temps de construction
- $sec /= VITESSE;
-
- if ($sec < $tps) {
- $this->{$file}[$bout[1]] += $technologiesCALC[$bout[1]][$bout[0]][0];
- $this->{"file_".$court}[0] += $sec;
- $tps -= $sec;
- unset($this->{"file_".$court}[$key]);
- $this->{"file_".$court} = array_merge($this->{"file_".$court});
-
- //La déouverte de technologie est bénéfique pour le moral de la population
- if ($this->moral) {
- if ($this->politique == 3) $this->setMoral(0.1); //Démocratie : Découvrir une nouvelle technologie a plus d'effet bénéfique sur le moral
- else $this->setMoral(0.05);
- }
-
- if (!in_array($file, $this->modifUser)) $this->modifUser[] = $file;
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
- }
- else break;
- }
- if (in_array("file_".$court, $this->modif)) $this->actualiser(false);
- }
- else {
- global ${$calc}, ${$calc.'CALC'};
-
- foreach($this->{"file_".$court} as $key => $bout) {
- if ($key == 0) continue;
-
- $n = $this->{$file}[$bout[0]] + 1; //Extraction du niveau en cours
- eval(${$calc.'CALC'}[$bout[0]][3]); //Récupération du temps de construction
-
- //var_dump($bout[0], $n);
-
- //Accélération du temps de construction
- $sec = floor($sec/VITESSE);
-
- if ($bout[1] < 0) {
- $n--;
- eval(${$calc.'CALC'}[$bout[0]][3]);
- $sec = floor($sec*0.6/VITESSE);
-
- if ($sec < $tps) {
- eval(${$calc.'CALC'}[$bout[0]][0]);
- eval(${$calc.'CALC'}[$bout[0]][1]);
- eval(${$calc.'CALC'}[$bout[0]][2]);
-
- //On reçoit 70% des ressources en bonus
- $this->metal += $a * 0.7;
- $this->cristal += $b * 0.7;
- $this->hydrogene += $c * 0.7;
-
- $this->{$file}[$bout[0]]--;
- $this->{"file_".$court}[0] += $bout[1] * $sec;
- $tps -= $sec;
- unset($this->{"file_".$court}[$key]);
-
- if (!in_array($file, $this->modif)) $this->modif[] = $file;
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
- }
- }
- elseif ($sec * $bout[1] < $tps && $bout[1] > 0) {
- //S'il s'agit d'un silo, on sauvegarde le temps pour utilisation par le script de production
- if ($file == "batiments" && $bout[0] == 10) $timestamp_lastSilo = $this->{"file_".$court}[0];
- if ($file == "batiments" && $bout[0] == 0) $timestamp_mineM = $this->{"file_".$court}[0];
- if ($file == "batiments" && $bout[0] == 1) $timestamp_mineC = $this->{"file_".$court}[0];
- if ($file == "batiments" && $bout[0] == 2) $timestamp_mineH = $this->{"file_".$court}[0];
- $this->{$file}[$bout[0]] += $bout[1];
- $this->{"file_".$court}[0] += $bout[1] * $sec;
- $tps -= $bout[1] * $sec;
- unset($this->{"file_".$court}[$key]);
-
- if (!in_array($file, $this->modif)) $this->modif[] = $file;
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
- }
- elseif ($sec < time() - $this->{"file_".$court}[0] && $bout[1] > 0) {
- //TODO Trouver plus simple que la ligne en dessous
- for($j=0 ; $j * $sec < $tps ; $j++) {}
- $j--;
- $this->{"file_".$court}[$key][1] -= $j;
- $this->{$file}[$bout[0]] += $j;
- $this->{"file_".$court}[0] += $j * $sec;
- $tps -= $j * $sec;
-
- if (!in_array($file, $this->modif)) $this->modif[] = $file;
- if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
-
- //Comme la première attente n'est pas terminée, on stoppe la vérification
- break;
- }
- else break;
- }
- //On actualise seulement s'il y a eu une modification de faite
- if (in_array($file, $this->modif)) $this->actualiser(false);
- $this->{"file_".$court} = array_merge($this->{"file_".$court});
- }
- }
-}
?>
\ No newline at end of file
diff --git a/game/Class/class.flotte.php b/game/Class/class.flotte.php
index 6b05574..c796d49 100644
--- a/game/Class/class.flotte.php
+++ b/game/Class/class.flotte.php
@@ -1,4 +1,5 @@
connexion();
- $bdd->escape($id);
- $flotte = $bdd->unique_query("SELECT * FROM $table_flottes WHERE id = $id;");
- $bdd->query("UPDATE $table_flottes SET last = ".time()." WHERE id = $id;"); //Obtention d'un vérrou de 10 seconde sur la flotte
- $bdd->deconnexion();
- if (!empty($flotte)) {
- $this->id_flotte = $flotte["id"];
- $this->nom = $flotte["nom"];
- $this->start_planete = $flotte["start_planete"];
- $this->start_time = $flotte["start_time"];
- $this->end_planete = $flotte["end_planete"];
- $this->end_time = $flotte["end_time"];
- $this->ret_planete = $flotte["ret_planete"];
- $this->ret_time = $flotte["ret_time"];
- $this->tactique = $flotte["tactique"];
- $this->mission = $flotte["mission"];
- $this->statut = $flotte["statut"];
- $this->last = $flotte["last"];
- $this->nb_vais = $flotte["nb_vais"];
+ /**
+ * Constructeur
+ * @param int $id id de la flotte à importer
+ *
+ * @return void
+ * @access public
+ */
+ function Flotte($id = 0)
+ {
+ if (!empty($id))
+ {
+ global $var___db, $config, $table_flottes;
+ global $nomvaisnVAR, $ressoVAR;
+ $bdd = new bdd();
+ $bdd->connexion();
+ $bdd->escape($id);
+ $flotte = $bdd->unique_query("SELECT * FROM $table_flottes WHERE id = $id;");
+ $bdd->query("UPDATE $table_flottes SET last = ".time()." WHERE id = $id;"); //Obtention d'un vérrou de 10 seconde sur la flotte
+ $bdd->deconnexion();
+ if (!empty($flotte))
+ {
+ $this->id_flotte = $flotte["id"];
+ $this->nom = $flotte["nom"];
+ $this->start_planete = $flotte["start_planete"];
+ $this->start_time = $flotte["start_time"];
+ $this->end_planete = $flotte["end_planete"];
+ $this->end_time = $flotte["end_time"];
+ $this->ret_planete = $flotte["ret_planete"];
+ $this->ret_time = $flotte["ret_time"];
+ $this->tactique = $flotte["tactique"];
+ $this->mission = $flotte["mission"];
+ $this->vitesse = $flotte["vitesse"];
+ $this->statut = $flotte["statut"];
+ $this->last = $flotte["last"];
+ $this->nb_vais = $flotte["nb_vais"];
- foreach($nomvaisnVAR as $vais){
- $this->vaisseaux[] = $flotte[$vais];
- }
+ foreach($nomvaisnVAR as $vais)
+ $this->vaisseaux[] = $flotte[$vais];
- $this->contenu = array($flotte["contenu_metal"], $flotte["contenu_cristal"], $flotte["contenu_hydrogene"]);
+ $this->contenu = array($flotte["contenu_metal"], $flotte["contenu_cristal"], $flotte["contenu_hydrogene"]);
- $this->calculer();
- }
- }
- }
-
- function calculer(){
- global $nomvais_rs;
-
- $this->nb_vais = 0;
-
- //Calcul de la capacité maximale d'embarquement de la flotte
- foreach($this->vaisseaux as $key => $vais){
- $this->nb_vais += $vais;
- $this->contenuMax += $nomvais_rs[$key] * $vais;
- }
- }
-
- function load_planete(){
- if (is_numeric($this->start_planete) && !empty($this->start_planete)) {
- $this->start_planete = new Planete($this->start_planete);
- }
- if (is_numeric($this->end_planete) && !empty($this->end_planete)) {
- $this->end_planete = new Planete($this->end_planete);
- }
- if (is_numeric($this->ret_planete) && !empty($this->ret_planete)) {
- $this->ret_planete = new Planete($this->ret_planete);
- }
- }
-
- function calc_deplacement($start_galaxie, $start_systeme, $start_position, $end_galaxie, $end_systeme, $end_position, $vitesse, $returnArray = false, $returnConso = false){
- //Si la planète de départ n'est pas chargée, on charge les planètes
- if (is_numeric($this->start_planete)) $this->load_planete();
- global $config, $nomvais_vitesseP, $nomvais_vitesseS, $nomvais_vitesseG, $nomvais_rs;
- $this->vitesse = $vitesse;
-
- //Calcul de la longueur du déplacement
- $diff_galaxie = abs($start_galaxie - $end_galaxie);
- $diff_systeme = abs($start_systeme - $end_systeme);
- $diff_position = abs($start_position - $end_position);
-
- $diff_centre_position_start = abs(ceil($config['nb_amas']/2) - $start_position);
- $diff_centre_systeme_start = abs(ceil($config['nb_systeme']/2) - $start_systeme);
-
- $diff_centre_position_end = abs(ceil($config['nb_amas']/2) - $end_position);
- $diff_centre_systeme_end = abs(ceil($config['nb_systeme']/2) - $end_systeme);
-
- //Calcul du temps de déplacement pour chaque vaisseau
- $temps = array(); $conso = array(0, 0, 0);
- foreach($this->vaisseaux as $key => $vais){
- //S'il n'y a pas de vaisseaux de ce type, on ne calcul pas leur vitesse
- if ($vais == 0) continue;
-
- //Calcul du temps de déplacement entre planètes
- if ($start_systeme == $end_systeme && $start_galaxie == $end_galaxie) {
- $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * $diff_position);
- $temps[1][$key] = $temps[2][$key] = 0;
- }
- //Calcul du temps de déplacement entre système
- elseif ($start_galaxie == $end_galaxie) {
- $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
- $temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * $diff_systeme);
- $temps[2][$key] = 0;
- }
- //Calcul du temps de déplacement entre galaxies
- else {
- $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
- $temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * ($diff_centre_systeme_start + $diff_centre_systeme_end));
- $temps[2][$key] = (50/$nomvais_vitesseG[$key]) * (2 + 1.5 * $diff_galaxie);
- }
-
- //Calcul du bonus pour le réacteur à combustion
- $techR = $this->start_planete->technologies[1];
- if ($techR & 56) $bonus = 0.7;
- elseif ($techR & 24) $bonus = 0.8;
- elseif ($techR & 8) $bonus = 0.9;
- else $bonus = 1;
- $temps[0][$key] *= $bonus * 1/$vitesse;
- $conso[0] += $vais * $temps[0][$key] * $bonus / exp($vitesse/5);
-
- //Calcul du bonus pour le réacteur à fusion
- $techR = $this->start_planete->technologies[1];
- if ($techR & 448) $bonus = 0.7;
- elseif ($techR & 192) $bonus = 0.8;
- elseif ($techR & 64) $bonus = 0.9;
- else $bonus = 1;
- $temps[1][$key] *= $bonus * 1/$vitesse;
- $conso[1] += $vais * $temps[1][$key] * $bonus / exp($vitesse/7.5);
-
- //Calcul du bonus pour le réacteur à fusion de type II
- $techR = $this->start_planete->technologies[1];
- if ($techR & 3584) $bonus = 0.7;
- elseif ($techR & 1536) $bonus = 0.8;
- elseif ($techR & 512) $bonus = 0.9;
- else $bonus = 1;
- $temps[2][$key] *= $bonus * 1/$vitesse;
- $conso[2] += $vais * $temps[2][$key] * $bonus / exp($vitesse/10);
- }
-
- if (!isset($this->vaisseaux[4])) $this->vaisseaux[4] = 0;
- if (!isset($this->vaisseaux[5])) $this->vaisseaux[5] = 0;
-
- //Si les chasseurs peuvent rentrer dans les cales des vaisseaux, on les enlèves
- if ($this->contenuMax - ($this->contenu[0] + $this->contenu[1] + $this->contenu[2]) - ($this->vaisseaux[4] * $nomvais_rs[4] + $this->vaisseaux[5] * $nomvais_rs[5]) >= ($this->vaisseaux[4] + $this->vaisseaux[5]) * 200) {
- $temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
- }
-
- //On calcul le temps de déplacement maximal
- if ($returnArray) return $temps;
- elseif ($returnConso) return array(max($temps[0]) + max($temps[1]) + max($temps[2]), ceil($conso[0]+$conso[1]+$conso[2]));
- else return (max($temps[0]) + max($temps[1]) + max($temps[2]));
- }
-
- function check_mission(){
- //On vérifie qu'un calcul ne soit pas déjà en cours
- if ($this->last >= time() - 10) return false;
- elseif ($this->start_time + $this->end_time < time()) return false;
- elseif ($this->statut == 1 && ($this->ret_time > time() || $this->start_time + $this->end_time * 2 >= time())) return $this->retourner();
-
- switch($this->mission){
- case 0:
- case 5:
- return $this->stationner();
- break;
- case 1:
- return $this->transporter();
- break;
- case 2:
- return $this->coloniser();
- break;
- case 3:
- return $this->espionner();
- break;
- case 4:
- return $this->attaquer();
- break;
- }
- }
-
- function rappeler(){
- if ($this->start_time + $this->end_time >= time()) return false;
- else {
- $this->end_time = time() - $this->start_time + 10;
- $this->mission = 5;
- if (!in_array('mission', $this->modifFlotte)) $this->modifFlotte[] = 'mission';
- if (!in_array('end_time', $this->modifFlotte)) $this->modifFlotte[] = 'end_time';
- return true;
- }
- }
-
- function retourner(){
- //Si la planète de départ n'est pas chargée, on charge les planètes
- if (is_numeric($this->start_planete)) $this->load_planete();
-
- //Si on a demandé une planète particulière au retour
- if (!empty($this->ret_time) && !empty($this->ret_planete) && !is_numeric($this->ret_planete)) {
- foreach($this->vaisseaux as $key => $vais){
- $this->ret_planete->vaisseaux[$key] += $vais;
- }
- }
- //Si le retour se fait sur la planète source
- else {
- foreach($this->vaisseaux as $key => $vais){
- $this->start_planete->vaisseaux[$key] += $vais;
- }
- }
- $this->modifFlotte = "DELETE";
- }
-
- /**
- * Destructeur
- *
- * @return void
- * @access public
- */
- function __destruct(){
- global $var___db, $config, $table_flottes;
- $nb = count($this->modifFlotte);
- $out = array();
- $bdd = new bdd();
- $bdd->connexion();
- if ($this->modifFlotte === "DELETE") $bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
- else {
- if (empty($this->id_flotte)) {
- if ($this->modifFlotte === "INSERT") {
- $out1 = ''; $out2 = '';
- global $nomvaisnVAR;
- foreach ($this->vaisseaux as $key => $vais){
- $out1 .= ', '.$nomvaisnVAR[$key];
- $out2 .= ', '.$vais;
+ $this->calculer();
+ }
}
- $sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_planete, end_time, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nbvais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom.", ".$nb_vais."'$out2);";
- //var_dump($sql);
- $bdd->query($sql);
- }
}
- else {
- for($i = 0; $i < $nb; $i++){
- if (!is_array($this->{$this->modifFlotte[$i]})) {
- $bdd->escape($this->{$this->modifFlotte[$i]});
- if (is_int($this->{$this->modifFlotte[$i]}) || is_float($this->{$this->modifFlotte[$i]})) $out[] .= $this->modifFlotte[$i]." = ".$this->{$this->modifFlotte[$i]};
- else $out[] .= $this->modifFlotte[$i]." = '".$this->{$this->modifFlotte[$i]}."'";
- }
- else {
- if ($this->modifFlotte[$i] == "contenu") $calc = "resso";
- elseif ($this->modifFlotte[$i] == "vaisseaux") $calc = "nomvaisn";
- if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
- $nombr = count(${$calc.'VAR'});
- for($j = 0; $j < $nombr; $j++){
- $bdd->escape($this->{$this->modifFlotte[$i]}[$j]);
- $out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modifFlotte[$i]}[$j];
- }
+ function calculer()
+ {
+ global $nomvais_rs;
+
+ $this->nb_vais = 0;
+
+ //Calcul de la capacité maximale d'embarquement de la flotte
+ foreach($this->vaisseaux as $key => $vais)
+ {
+ $this->nb_vais += $vais;
+ $this->contenuMax += $nomvais_rs[$key] * $vais;
}
- }
- if (!empty($out)) $bdd->query("UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";");
- else $bdd->query("UPDATE $table_flottes SET last = 0 WHERE id = ".$this->id_flotte.";");
}
- }
- $bdd->deconnexion();
+
+
+ function load_planete()
+ {
+ if (is_numeric($this->start_planete) && !empty($this->start_planete))
+ {
+ global $planete;
+ //Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
+ if ($planete->id == $this->start_planete)
+ $this->start_planete = $planete;
+ else
+ $this->start_planete = new Planete($this->start_planete);
+ }
+ if (is_numeric($this->end_planete) && !empty($this->end_planete))
+ {
+ global $planete;
+ //Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
+ if ($planete->id == $this->end_planete)
+ $this->end_planete = $planete;
+ else
+ $this->end_planete = new Planete($this->end_planete);
+ }
+ if (is_numeric($this->ret_planete) && !empty($this->ret_planete))
+ {
+ global $planete;
+ //Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
+ if ($planete->id == $this->ret_planete)
+ $this->ret_planete = $planete;
+ else
+ $this->ret_planete = new Planete($this->ret_planete);
+ }
+ }
+
+
+ function calc_deplacement($start_galaxie, $start_systeme, $start_position, $end_galaxie, $end_systeme, $end_position, $vitesse, $returnArray = false, $returnConso = false)
+ {
+ //Si la planète de départ n'est pas chargée, on charge les planètes
+ if (is_numeric($this->start_planete))
+ $this->load_planete();
+ global $config, $nomvais_vitesseP, $nomvais_vitesseS, $nomvais_vitesseG, $nomvais_rs;
+ $this->vitesse = $vitesse;
+
+ //Calcul de la longueur du déplacement
+ $diff_galaxie = abs($start_galaxie - $end_galaxie);
+ $diff_systeme = abs($start_systeme - $end_systeme);
+ $diff_position = abs($start_position - $end_position);
+
+ $diff_centre_position_start = abs(ceil($config['nb_amas']/2) - $start_position);
+ $diff_centre_systeme_start = abs(ceil($config['nb_systeme']/2) - $start_systeme);
+
+ $diff_centre_position_end = abs(ceil($config['nb_amas']/2) - $end_position);
+ $diff_centre_systeme_end = abs(ceil($config['nb_systeme']/2) - $end_systeme);
+
+ //Calcul du temps de déplacement pour chaque vaisseau
+ $temps = array(); $conso = array(0, 0, 0);
+ foreach($this->vaisseaux as $key => $vais)
+ {
+ //S'il n'y a pas de vaisseaux de ce type, on ne calcul pas leur vitesse
+ if ($vais == 0)
+ continue;
+
+ //Calcul du temps de déplacement entre planètes
+ if ($start_systeme == $end_systeme && $start_galaxie == $end_galaxie)
+ {
+ $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * $diff_position);
+ $temps[1][$key] = $temps[2][$key] = 0;
+ }
+ //Calcul du temps de déplacement entre système
+ elseif ($start_galaxie == $end_galaxie)
+ {
+ $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
+ $temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * $diff_systeme);
+ $temps[2][$key] = 0;
+ }
+ //Calcul du temps de déplacement entre galaxies
+ else
+ {
+ $temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
+ $temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * ($diff_centre_systeme_start + $diff_centre_systeme_end));
+ $temps[2][$key] = (50/$nomvais_vitesseG[$key]) * (2 + 1.5 * $diff_galaxie);
+ }
+
+ //Calcul du bonus pour le réacteur à combustion
+ $techR = $this->start_planete->technologies[1];
+ if ($techR & 56)
+ $bonus = 0.7;
+ elseif ($techR & 24)
+ $bonus = 0.8;
+ elseif ($techR & 8)
+ $bonus = 0.9;
+ else
+ $bonus = 1;
+ $temps[0][$key] *= $bonus * 1/$vitesse;
+ $conso[0] += $vais * $temps[0][$key] * $bonus / exp($vitesse/5);
+
+ //Calcul du bonus pour le réacteur à fusion
+ $techR = $this->start_planete->technologies[1];
+ if ($techR &448)
+ $bonus = 0.7;
+ elseif ($techR &192)
+ $bonus = 0.8;
+ elseif ($techR &64)
+ $bonus = 0.9;
+ else
+ $bonus = 1;
+ $temps[1][$key] *= $bonus * 1/$vitesse;
+ $conso[1] += $vais * $temps[1][$key] * $bonus / exp($vitesse/7.5);
+
+ //Calcul du bonus pour le réacteur à fusion de type II
+ $techR = $this->start_planete->technologies[1];
+ if ($techR &3584)
+ $bonus = 0.7;
+ elseif ($techR &1536)
+ $bonus = 0.8;
+ elseif ($techR &512)
+ $bonus = 0.9;
+ else
+ $bonus = 1;
+ $temps[2][$key] *= $bonus * 1/$vitesse;
+ $conso[2] += $vais * $temps[2][$key] * $bonus / exp($vitesse/10);
+ }
+
+ if (!isset($this->vaisseaux[4]))
+ $this->vaisseaux[4] = 0;
+ if (!isset($this->vaisseaux[5]))
+ $this->vaisseaux[5] = 0;
+
+ //Si les chasseurs peuvent rentrer dans les cales des vaisseaux, on les enlèves
+ if ($this->contenuMax - ($this->contenu[0] + $this->contenu[1] + $this->contenu[2]) - ($this->vaisseaux[4] * $nomvais_rs[4] + $this->vaisseaux[5] * $nomvais_rs[5]) >= ($this->vaisseaux[4] + $this->vaisseaux[5]) * 200)
+ $temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
+
+ //On calcul le temps de déplacement maximal
+ if ($returnArray)
+ return $temps;
+ elseif ($returnConso)
+ return array(max($temps[0]) + max($temps[1]) + max($temps[2]), ceil($conso[0]+$conso[1]+$conso[2]));
+ else
+ return (max($temps[0]) + max($temps[1]) + max($temps[2]));
+ }
+
+
+ function check_mission()
+ {
+ //On vérifie qu'un calcul ne soit pas déjà en cours
+ if ($this->last >= time() - 10)
+ return false;
+ elseif ($this->start_time + $this->end_time > time())
+ return false;
+
+ if ($this->statut == 0)
+ {
+ switch($this->mission)
+ {
+ case 0:
+ return $this->stationner();
+ break;
+ case 1:
+ return $this->transporter();
+ break;
+ case 2:
+ return $this->coloniser();
+ break;
+ case 3:
+ return $this->attaquer();
+ break;
+ case 4:
+ return $this->recycler();
+ break;
+ case 5:
+ return $this->espionner();
+ break;
+ }
+ }
+
+ if ($this->statut == 1 && ($this->ret_time > time() || $this->start_time + $this->end_time * 2 <= time()))
+ return $this->retourner();
+ }
+
+
+ function stationner()
+ {
+ //On décharge les ressources éventuellement contenue
+ $this->decharger();
+
+ //On fait atterir les vaisseaux
+ foreach ($this->vaisseaux as $key => $vais)
+ $this->end_planete->vaisseaux[$key] += $vais;
+
+ if (!in_array("vaisseaux", $this->end_planete->modif))
+ $this->end_planete->modif[] = "vaisseaux";
+ $this->modifFlotte = "DELETE";
+ }
+
+
+ function transporter()
+ {
+ $max = $this->decharger();
+
+ //Envoie du MP de confirmation au joueur
+ $send = new Rapport(2, $this->start_planete->id_user, $this->end_planete->id_user, $this->start_time + $this->end_time);
+ $send->addInfo(array($this->end_planete->nom_planete, $this->end_planete->galaxie, $this->end_planete->ss, $this->end_planete->position), 0);
+ $send->addInfo($max, 1);
+
+ $this->statut = 1;
+ if (!in_array('statut', $this->modifFlotte))
+ $this->modifFlotte[] = 'statut';
+ }
+
+
+ function coloniser()
+ {
+ //On vérifie que les coordonnées de la planètes sont bien enregistrée
+ if (empty($this->end_planete) || is_object($this->end_planete) || !preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $this->end_planete))
+ {
+ $this->load_planete();
+ file_log("Erreur de colonisation de la planète : ".$this->end_planete." pour le joueur : ".$this->start_planete->id_user, 2);
+ send_mp($this->start_planete->id_user, "Erreur de colonisation [F#01]", "Une erreur s'est produite lors de la tentative de colonisation de votre flotte, elle a fait demi-tour.");
+ $this->rappeler();
+ }
+
+ //On vérifie que la planète ne soit pas déjà colonisée
+ global $var___db, $config, $table_planete;
+ $bdd = new bdd();
+ preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $this->end_planete, $position);
+ $bdd->connexion();
+ $p = $bdd->query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
+ $bdd->deconnexion();
+
+ if ($p)
+ {
+ $this->load_planete();
+
+ $rapport = new Rapport(2, $this->start_planete->id_user, 0, $this->start_time + $this->end_time);
+ $rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
+ $rapport->addInfo(false, 1);
+ $rapport->send();
+ }
+ else
+ {
+ $this->load_planete();
+
+ //On crée la planète
+ $this->end_planete = new Planete();
+ $this->end_planete->galaxie = $position[1];
+ $this->end_planete->ss = $position[2];
+ $this->end_planete->position = $position[3];
+ $this->end_planete->creer($this->start_planete->id_user);
+
+ //Rembousement du carburant non utilisé (la colonisation prévois au départ un allé/retour)
+ $conso = $this->calc_deplacement($this->start_planete->galaxie, $this->start_planete->ss, $this->start_planete->position, $position[1], $position[2], $position[3], $this->vitesse, false, true);
+ $this->end_planete->hydrogene += $conso[1];
+
+ //On définit la limite de ressources pour permettre le déchargement de celles contenues dans les vaisseaux
+ $this->end_planete->cap = 100000;
+
+ //On enlève un vaisseau de colonisation de la liste
+ $this->vaisseaux[2]--;
+
+ //On fait atterir les vaisseaux et décharger les ressources
+ $this->decharger();
+ $this->atterir();
+
+ //On envoie un rapport
+ $rapport = new Rapport(2, $this->start_planete->id_user, 0, $this->start_time + $this->end_time);
+ $rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
+ $rapport->addInfo(true, 1);
+ $rapport->send();
+ }
+ }
+
+
+ function recycler()
+ {
+ //Si la planète d'arrivé n'est pas chargée, on charge les planètes
+ if (is_numeric($this->end_planete))
+ $this->load_planete();
+
+ $coeff = ($this->contenuMax - $this->contenu[0] - $this->contenu[1] - $this->contenu[2])/($this->end_planete->debris_met + $this->end_planete->debris_cri);
+ if ($coeff > 1)
+ $coeff = 1;
+
+ $a = floor($this->end_planete->debris_met * $coeff);
+ $b = floor($this->end_planete->debris_cri * $coeff);
+
+ $this->contenu[0] += $a;
+ $this->contenu[1] += $b;
+ if (!in_array('contenu', $this->modifFlotte))
+ $this->modifFlotte[] = 'contenu';
+
+ $this->end_planete->debris_met -= $a;
+ $this->end_planete->debris_cri -= $b;
+ if (!in_array('debris_met', $this->end_planete->modif))
+ $this->end_planete->modif[] = 'debris_met';
+ if (!in_array('debris_cri', $this->end_planete->modif))
+ $this->end_planete->modif[] = 'debris_cri';
+
+ //Send link
+ $rapport = new Rapport(4, $this->start_planete->id_user, 0, $this->start_time + $this->end_time);
+ $rapport->addInfo($this->end_planete, 0);
+ $rapport->addInfo(array($a, $b), 1);
+ $rapport->send();
+
+ $this->statut = 1;
+ if (!in_array('statut', $this->modifFlotte))
+ $this->modifFlotte[] = 'statut';
+ }
+
+
+ function espionnage()
+ {
+ //Si la planète d'arrivé n'est pas chargée, on charge les planètes
+ if (is_numeric($this->end_planete))
+ $this->load_planete();
+
+
+
+ $this->statut = 1;
+ if (!in_array('statut', $this->modifFlotte))
+ $this->modifFlotte[] = 'statut';
+ }
+
+
+ function decharger()
+ {
+ //Si la planète d'arrivé n'est pas chargée, on charge les planètes
+ if (is_numeric($this->end_planete))
+ $this->load_planete();
+ $max = array(0, 0, 0);
+
+ //Si on dépasse les capacités, on laisse les ressources en trop dans le cargo
+ if ($this->end_planete->metal + $this->contenu[0] > $this->end_planete->cap)
+ {
+ $max[0] = $this->end_planete->cap - $this->end_planete->metal;
+ if ($max[0] < 0) $max[0] = 0;
+ }
+ else
+ $max[0] = $this->contenu[0];
+ $this->end_planete->metal += $max[0];
+ $this->contenu[0] -= $max[0];
+
+ if ($this->end_planete->cristal + $this->contenu[1] > $this->end_planete->cap)
+ {
+ $max[1] = $this->end_planete->cap - $this->end_planete->cristal;
+ if ($max[1] < 0) $max[1] = 0;
+ }
+ else
+ $max[1] = $this->contenu[1];
+ $this->end_planete->cristal += $max[1];
+ $this->contenu[1] -= $max[1];
+
+ if ($this->end_planete->hydrogene + $this->contenu[2] > $this->end_planete->cap)
+ {
+ $max[2] = $this->end_planete->cap - $this->end_planete->hydrogene;
+ if ($max[2] < 0) $max[2] = 0;
+ }
+ else
+ $max[2] = $this->contenu[2];
+ $this->end_planete->hydrogene += $max[2];
+ $this->contenu[2] -= $max[2];
+
+ if (!in_array('contenu', $this->modifFlotte))
+ $this->modifFlotte[] = 'contenu';
+ return $max;
+ }
+
+
+ function atterir($planete = "end_planete")
+ {
+ //Si la planète d'arrivé n'est pas chargée, on charge les planètes
+ if (is_numeric($this->$planete))
+ $this->load_planete();
+
+ if (isset($this->$planete->vaisseaux[0]))
+ {
+ foreach ($this->vaisseaux as $key => $vais)
+ $this->$planete->vaisseaux[$key] += $vais;
+ }
+ else
+ $this->$planete->vaisseaux = $this->vaisseaux;
+
+ if (!in_array("vaisseaux", $this->$planete->modif))
+ $this->$planete->modif[] = "vaisseaux";
+
+ $this->modifFlotte = "DELETE";
+ }
+
+
+ function rappeler()
+ {
+ if ($this->start_time + $this->end_time >= time())
+ return false;
+ else
+ {
+ $this->end_time = time() - $this->start_time + 10;
+ $this->mission = 5;
+ if (!in_array('mission', $this->modifFlotte))
+ $this->modifFlotte[] = 'mission';
+ if (!in_array('end_time', $this->modifFlotte))
+ $this->modifFlotte[] = 'end_time';
+ return true;
+ }
+ }
+
+
+ function retourner()
+ {
+ //Si la planète de départ n'est pas chargée, on charge les planètes
+ if (is_numeric($this->start_planete))
+ $this->load_planete();
+
+ //Si on a demandé une planète particulière au retour
+ if (!empty($this->ret_time) && !empty($this->ret_planete) && !is_numeric($this->ret_planete))
+ {
+ foreach($this->vaisseaux as $key => $vais)
+ $this->ret_planete->vaisseaux[$key] += $vais;
+ }
+ //Si le retour se fait sur la planète source
+ else
+ {
+ foreach($this->vaisseaux as $key => $vais)
+ $this->start_planete->vaisseaux[$key] += $vais;
+ }
+
+ if (!in_array("vaisseaux", $this->start_planete->modif))
+ $this->start_planete->modif[] = "vaisseaux";
+ $this->modifFlotte = "DELETE";
+ }
+
+ /**
+ * Destructeur
+ *
+ * @return void
+ * @access public
+ */
+ function __destruct()
+ {
+ global $var___db, $config, $table_flottes;
+ $nb = count($this->modifFlotte);
+ $out = array();
+ $bdd = new bdd();
+ $bdd->connexion();
+ if ($this->modifFlotte === "DELETE")
+ $bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
+ else
+ {
+ if (empty($this->id_flotte))
+ {
+ if ($this->modifFlotte == "INSERT")
+ {
+ $out1 = ''; $out2 = '';
+ global $nomvaisnVAR;
+ foreach ($this->vaisseaux as $key => $vais)
+ {
+ $out1 .= ', '.$nomvaisnVAR[$key];
+ $out2 .= ', '.$vais;
+ }
+ $sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_planete, end_time, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
+ //var_dump($sql);
+ $bdd->query($sql);
+ }
+ }
+ elseif(isset($this->modifFlotte[0]))
+ {
+ for($i = 0; $i < $nb; $i++)
+ {
+ if (!is_array($this->{$this->modifFlotte[$i]}))
+ {
+ $bdd->escape($this->{$this->modifFlotte[$i]});
+ if (is_int($this->{$this->modifFlotte[$i]}) || is_float($this->{$this->modifFlotte[$i]}))
+ $out[] .= $this->modifFlotte[$i]." = ".$this->{$this->modifFlotte[$i]};
+ else
+ $out[] .= $this->modifFlotte[$i]." = '".$this->{$this->modifFlotte[$i]}."'";
+ }
+ else {
+ if ($this->modifFlotte[$i] == "contenu")
+ $calc = "resso";
+ elseif ($this->modifFlotte[$i] == "vaisseaux")
+ $calc = "nomvaisn";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ $nombr = count(${$calc.'VAR'});
+ for($j = 0; $j < $nombr; $j++)
+ {
+ $bdd->escape($this->{$this->modifFlotte[$i]}[$j]);
+ $out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modifFlotte[$i]}[$j];
+ }
+ }
+ }
+ if (!empty($out))
+ $bdd->query("UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";");
+ else
+ $bdd->query("UPDATE $table_flottes SET last = 0 WHERE id = ".$this->id_flotte.";");
+ }
+ }
+ $bdd->deconnexion();
+ }
}
-}
?>
\ No newline at end of file
diff --git a/game/Class/class.planete.php b/game/Class/class.planete.php
index e755809..dd873ca 100644
--- a/game/Class/class.planete.php
+++ b/game/Class/class.planete.php
@@ -3,481 +3,775 @@
* class.planete.php
* -------------------
* begin : Jeudi 21 août 2008
- * update : Dimanche 7 septembre 2008
+ * update : Dimanche 4 janvier 2008
* email : nemunaire@gmail.com
*
*
***************************************************************************/
-class Planete extends User{
- var $id,
- $galaxie,
- $ss,
- $position,
- $isolement,
- $nom_planete,
- $image,
- $cases,
- $casesRest,
- $debris_met,
- $debris_cri,
- $metal,
- $cristal,
- $hydrogene,
- $population,
- $moral,
- $alert_ressources = array(false, false, false),
- $timestamp,
- $timestamp_lastSilo,
- $timestamp_lastMineM,
- $timestamp_lastMineC,
- $timestamp_lastMineH,
- $energie,
- $energieConso,
- $file_tech,
- $file_bat,
- $file_cas,
- $file_ter,
- $file_vais,
- $coeff_bat = array(),
- $batiments = array(),
- $casernes = array(),
- $terrestres = array(),
- $vaisseaux = array(),
- $modif = array('metal', 'cristal', 'hydrogene', 'timestamp');
+class Planete extends Surface
+ {
+ var $position,
+ $isolement,
+ $nom_planete,
+ $cases,
+ $casesRest,
+ $cap,
+ $population,
+ $population_max,
+ $moral,
+ $timestamp_lastSilo,
+ $timestamp_lastMineM,
+ $timestamp_lastMineC,
+ $timestamp_lastMineH,
+ $energie,
+ $energieConso,
+ $file_tech,
+ $file_cas,
+ $file_ter,
+ $coeff_bat = array(),
+ $casernes = array(),
+ $terrestres = array();
- /**
- * Constructeur
- * @param int $id id de la planète à importer
- *
- * @return void
- * @access public
- */
- function Planete($id = 0, $first = false){
- if (!empty($id)) {
- global $var___db, $config, $table_planete;
- global $batimentVAR, $casernenVAR, $nomterrnVAR, $nomvaisnVAR;
- $bdd = new bdd();
- $bdd->connexion();
- $bdd->escape($id);
- $plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id;");
- $bdd->deconnexion();
- if (!empty($plan)) {
- $this->id = $plan["id"];
- parent::User($plan["id_user"]);
- $this->galaxie = $plan["galaxie"];
- $this->ss = $plan["ss"];
- $this->position = $plan["position"];
- if (!empty($plan["isolement"])) $this->isolement = unserialize($plan["isolement"]);
- else $this->isolement = array();
- $this->nom_planete = $plan["nom_planete"];
- $this->image = $plan["image"];
- $this->cases = $plan["cases"];
- $this->debris_met = $plan["debris_met"];
- $this->debris_cri = $plan["debris_cri"];
- $this->metal = $plan["metal"];
- $this->cristal = $plan["cristal"];
- $this->hydrogene = $plan["hydrogene"];
- $this->population = $plan["population"];
- $this->moral = $plan["moral"];
- $this->timestamp = $plan["timestamp"];
+ /**
+ * Constructeur
+ * @param int $id id de la planète à importer
+ *
+ * @return void
+ * @access public
+ */
+ function Planete($id = 0, $first = false)
+ {
+ if (!empty($id)) {
+ global $securePlanete;
+ global $var___db, $config, $table_planete;
+ global $batimentVAR, $casernenVAR, $nomterrnVAR, $nomvaisnVAR;
+ $actuFile = true;
+ $bdd = new bdd();
- foreach($batimentVAR as $bat){
- $this->batiments[] = $plan[$bat];
+ //On traite le cas où l'on envoie les coordonnées
+ if (is_numeric($id))
+ {
+ $bdd->connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id;");
+ $bdd->deconnexion();
+ }
+ elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
+ {
+ $bdd->connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
+ $bdd->deconnexion();
+ }
+ else
+ die('Erreur #04 : Format de recherche de planete incorrect !');
+
+ if (!empty($plan))
+ {
+ $this->id = $plan["id"];
+ parent::User($plan["id_user"]);
+ $this->galaxie = $plan["galaxie"];
+ $this->ss = $plan["ss"];
+ $this->position = $plan["position"];
+ if (!empty($plan["isolement"])) $this->isolement = unserialize($plan["isolement"]);
+ else $this->isolement = array();
+ $this->nom_planete = $plan["nom_planete"];
+ $this->image = $plan["image"];
+ $this->cases = $plan["cases"];
+ $this->debris_met = $plan["debris_met"];
+ $this->debris_cri = $plan["debris_cri"];
+ $this->metal = $plan["metal"];
+ $this->cristal = $plan["cristal"];
+ $this->hydrogene = $plan["hydrogene"];
+ $this->population = $plan["population"];
+ $this->moral = $plan["moral"];
+ $this->timestamp = $plan["timestamp"];
+
+ foreach($batimentVAR as $bat)
+ $this->batiments[] = $plan[$bat];
+ if (!empty($plan["file_bat"]))
+ $this->file_bat = unserialize($plan["file_bat"]);
+ else
+ $this->file_bat = array();
+
+ $this->coeff_bat = array($plan["coeff_mine_m"], $plan["coeff_mine_c"], $plan["coeff_mine_h"], $plan["coeff_centrale_s"], $plan["coeff_centrale_f"]);
+ for($i = 0; $i < 5; $i++)
+ {
+ if ($this->coeff_bat[$i] > 1)
+ $this->coeff_bat[$i] = 1;
+ elseif ($this->coeff_bat[$i] < 0)
+ $this->coeff_bat[$i] = 0;
+ }
+
+ if (!empty($plan["file_tech"]))
+ $this->file_tech = unserialize($plan["file_tech"]);
+ else
+ $this->file_tech = array();
+ foreach($casernenVAR as $cas)
+ $this->casernes[] = $plan[$cas];
+ if (!empty($plan["file_cas"]))
+ $this->file_cas = unserialize($plan["file_cas"]);
+ else
+ $this->file_cas = array();
+ foreach($nomterrnVAR as $ter)
+ $this->terrestres[] = $plan[$ter];
+ if (!empty($plan["file_ter"]))
+ $this->file_ter = unserialize($plan["file_ter"]);
+ else
+ $this->file_ter = array();
+ foreach($nomvaisnVAR as $vais)
+ $this->vaisseaux[] = $plan[$vais];
+ if (!empty($plan["file_vais"]))
+ $this->file_vais = unserialize($plan["file_vais"]);
+ else
+ $this->file_vais = array();
+
+ //Si une copie de la planète est déjà en cours d'utilisation, on ne modifie rien sur celle là
+ if (in_array($this->id, $securePlanete))
+ $this->modif = array();
+ else
+ {
+ $securePlanete[] = $this->id;
+ $this->actualiser($actuFile, $first);
+ }
+
+ //Calcul de la population logée
+ $population_max = (pow($this->batiments[12],1.5)+pow($this->batiments[13],2.1))*1000+3000;
+
+ $this->modif = array('metal', 'cristal', 'hydrogene', 'timestamp');
+ }
}
- if (!empty($plan["file_bat"])) $this->file_bat = unserialize($plan["file_bat"]);
- else $this->file_bat = array();
-
- $this->coeff_bat = array($plan["coeff_mine_m"], $plan["coeff_mine_c"], $plan["coeff_mine_h"], $plan["coeff_centrale_s"], $plan["coeff_centrale_f"]);
- for($i = 0; $i < 5; $i++){
- if ($this->coeff_bat[$i] > 1) $this->coeff_bat[$i] = 1;
- elseif ($this->coeff_bat[$i] < 0) $this->coeff_bat[$i] = 0;
- }
-
- if (!empty($plan["file_tech"])) $this->file_tech = unserialize($plan["file_tech"]);
- else $this->file_tech = array();
- foreach($casernenVAR as $cas){
- $this->casernes[] = $plan[$cas];
- }
- if (!empty($plan["file_cas"])) $this->file_cas = unserialize($plan["file_cas"]);
- else $this->file_cas = array();
- foreach($nomterrnVAR as $ter){
- $this->terrestres[] = $plan[$ter];
- }
- if (!empty($plan["file_ter"])) $this->file_ter = unserialize($plan["file_ter"]);
- else $this->file_ter = array();
- foreach($nomvaisnVAR as $vais){
- $this->vaisseaux[] = $plan[$vais];
- }
- if (!empty($plan["file_vais"])) $this->file_vais = unserialize($plan["file_vais"]);
- else $this->file_vais = array();
-
- $this->actualiser(true, $first);
}
- }
- }
- /**
- * Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
- *
- * @return void
- * @access public
- */
- function actualiser($actuFile = true, $first = false){
- //Actualisation des files d'attentes
- if ($actuFile) {
- $this->file_pret("batiments");
- $this->file_pret("technologies");
- $this->file_pret("casernes");
- $this->file_pret("terrestres");
- $this->file_pret("vaisseaux");
- }
+ /**
+ * Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
+ *
+ * @return void
+ * @access public
+ */
+ function actualiser($actuFile = true, $first = false)
+ {
+ //Actualisation des files d'attentes
+ if ($actuFile)
+ {
+ $this->file_ready("batiments");
+ $this->file_readyTechno("technologies");
+ $this->file_ready("casernes");
+ $this->file_ready("terrestres");
+ $this->file_ready("vaisseaux");
+ }
- //Calcul de la capacité de stockage maximale
- if (!empty($timestamp_lastSilo)) {
- $cap = pow(2, $this->batiments[10]-1) * 100000;
- $capnouv = pow(2, $this->batiments[10]) * 100000;
- }
- else $cap = pow(2, $this->batiments[10]) * 100000;
+ //Calcul de la capacité de stockage maximale
+ if (!empty($timestamp_lastSilo))
+ {
+ $this->cap = pow(2, $this->batiments[10]-1) * 100000;
+ $capnouv = pow(2, $this->batiments[10]) * 100000;
+ }
+ else
+ $this->cap = pow(2, $this->batiments[10]) * 100000;
- //Calcul du temps écoulé depuis la dernière mise à jour de la planète
- $temps_ecoule = time() - $this->timestamp;
- $ressources = $this->production($temps_ecoule);
- if ($this->metal + $ressources[0] < $cap) $this->metal += $ressources[0];
- else {
- //Si les capacité de stockage ont changé depuis la dernière actualisation
- if (isset($capnouv)) {
- $ressources = $this->production(time() - $this->timestamp_lastSilo);
- if ($this->metal + $ressources[0] < $capnouv) $this->metal += $ressources[0];
+ //Calcul du temps écoulé depuis la dernière mise à jour de la planète
+ $temps_ecoule = time() - $this->timestamp;
+ $ressources = $this->production($temps_ecoule);
+ if ($this->metal + $ressources[0] < $this->cap)
+ $this->metal += $ressources[0];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->metal + $ressources[0] < $capnouv)
+ $this->metal += $ressources[0];
+ }
+ else
+ {
+ $this->alert_ressources[0] = true;
+ $this->metal = $this->cap;
+ }
+ }
+ if ($this->cristal + $ressources[1] < $this->cap)
+ $this->cristal += $ressources[1];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->cristal + $ressources[1] < $capnouv)
+ $this->cristal += $ressources[1];
+ }
+ else
+ {
+ $this->alert_ressources[1] = true;
+ $this->cristal = $this->cap;
+ }
+ }
+ if ($this->hydrogene + $ressources[2] < $this->cap)
+ $this->hydrogene += $ressources[2];
+ else
+ {
+ //Si les capacité de stockage ont changé depuis la dernière actualisation
+ if (isset($capnouv))
+ {
+ $ressources = $this->production(time() - $this->timestamp_lastSilo);
+ if ($this->hydrogene + $ressources[2] < $capnouv)
+ $this->hydrogene += $ressources[2];
+ }
+ else
+ {
+ $this->alert_ressources[2] = true;
+ $this->hydrogene = $this->cap;
+ }
+ }
+
+ //Vérification de la date pour faire les actions journalières
+ if (date('zya') != date('zya', $this->timestamp))
+ {
+ //On évalue le moral
+ $this->evalMoral($first);
+
+ //Si la population est à 0, on ajoute des habitants
+ if ($this->population <= 0)
+ $this->population = 1000;
+
+ $popPlus = $this->population * 0.0153^max(1, floor((time()-$this->timestamp)/86400));
+
+ if ($this->politique == 2)
+ $popPlus *= 1.1; //Communisme : 10 % de population qui arrive en plus.
+ elseif ($this->politique == 3)
+ $popPlus *= 1.05; //Démocratie : 5 % de population qui arrive en plus.
+
+ if ($this->technologies[2] & 4)
+ $popPlus *= 1.15;
+ elseif ($this->technologies[2] & 2)
+ $popPlus *= 1.10;
+ elseif ($this->technologies[2] & 1)
+ $popPlus *= 1.05;
+
+ $this->population += $popPlus;
+ $this->credits += ($this->population/100*exp(0.01)*25) + ($this->population*0.01*$this->batiments[15]); //Première partie : production normale; seconde : batiment commercial
+ $this->modif[] = 'population';
+ }
+
+ $this->timestamp = time();
+
+
+ //Calcul du nombre de cases restantes
+ $this->casesRest = $this->cases;
+ foreach($this->batiments as $bat)
+ $this->casesRest -= $bat;
}
- else {
- $this->alert_ressources[0] = true;
- $this->metal = $cap;
+
+ function setMoral($difference)
+ {
+ $this->moral += $difference;
+
+ //Ajustement du moral
+ if ($this->moral > 1)
+ $this->moral = 1;
+ elseif ($this->moral < 0)
+ $this->moral = 0;
+
+ if (!in_array("moral", $this->modif))
+ $this->modif[] = "moral";
}
- }
- if ($this->cristal + $ressources[1] < $cap) $this->cristal += $ressources[1];
- else {
- //Si les capacité de stockage ont changé depuis la dernière actualisation
- if (isset($capnouv)) {
- $ressources = $this->production(time() - $this->timestamp_lastSilo);
- if ($this->cristal + $ressources[1] < $capnouv) $this->cristal += $ressources[1];
- }
- else {
- $this->alert_ressources[1] = true;
- $this->cristal = $cap;
- }
- }
- if ($this->hydrogene + $ressources[2] < $cap) $this->hydrogene += $ressources[2];
- else {
- //Si les capacité de stockage ont changé depuis la dernière actualisation
- if (isset($capnouv)) {
- $ressources = $this->production(time() - $this->timestamp_lastSilo);
- if ($this->hydrogene + $ressources[2] < $capnouv) $this->hydrogene += $ressources[2];
- }
- else {
- $this->alert_ressources[2] = true;
- $this->hydrogene = $cap;
- }
- }
- //Vérification de la date pour faire les actions journalières
- if (date('zya') != date('zya', $this->timestamp)) {
- //On évalue le moral
- $this->evalMoral($first);
+ function evalMoral($first = false)
+ {
+ $evolution = array();
+ //Cas de sous-production
+ if (($this->coeff_bat[0] + $this->coeff_bat[1] + $this->coeff_bat[2])/3 < 0.9)
+ {
+ if ($this->politique == 2)
+ $this->moral -= 0.10; //Communisme : démoralise 2x plus
+ else
+ $this->moral -= 0.05;
+ if (!in_array('moral', $this->modif))
+ $this->modif[] = 'moral';
+ }
- //Si la population est à 0, on ajoute des habitants
- if ($this->population <= 0) $this->population = 1000;
+ //Surpopulation
- $popPlus = $this->population * 0.0153^max(1, floor((time()-$this->timestamp)/86400));
+ //Surlogement
- if ($this->politique == 2) $popPlus *= 1.1; //Communisme : 10 % de population qui arrive en plus.
- elseif ($this->politique == 3) $popPlus *= 1.05; //Démocratie : 5 % de population qui arrive en plus.
+ //Effets des batiments loisirs et commerces
+ $this->moral += 0.0025*$this->batiments[15] + 0.1*$this->batiments[16];
- if ($this->technologies[2] & 4) $popPlus *= 1.15;
- elseif ($this->technologies[2] & 2) $popPlus *= 1.10;
- elseif ($this->technologies[2] & 1) $popPlus *= 1.05;
+ //Ajustement du moral en fonction de la politique
+ if ($this->politique == 1 && $this->moral > 0.7)
+ $this->moral = 0.7;
- $this->population += $popPlus;
- $this->credits += $this->population/100*exp(0.01)*25;
- $this->modif[] = 'population';
- }
+ //On vérifie qu'on ne dépasse pas le maximum
+ if ($this->moral > 1)
+ $this->moral = 1;
+ if ($this->moral < 0)
+ $this->moral = 0;
- $this->timestamp = time();
-
-
- //Calcul du nombre de cases restantes
- $this->casesRest = $this->cases;
- foreach($this->batiments as $bat){
- $this->casesRest -= $bat;
- }
- }
-
- function setMoral($difference){
- $this->moral += $difference;
-
- //Ajustement du moral
- if ($this->moral > 1) $this->moral = 1;
- elseif ($this->moral < 0) $this->moral = 0;
-
- if (!in_array("moral", $this->modif)) $this->modif[] = "moral";
- }
-
- function evalMoral($first = false){
- //Cas de sous-production
- if (($this->coeff_bat[0] + $this->coeff_bat[1] + $this->coeff_bat[2])/3 < 0.9) {
- if ($this->politique == 2) $this->moral -= 0.10; //Communisme : démoralise 2x plus
- else $this->moral -= 0.05;
- if (!in_array('moral', $this->modif)) $this->modif[] = 'moral';
- }
-
- //Surpopulation
-
- //Surlogement
-
- //Ajustement du moral en fonction de la politique
- if ($this->politique == 1 && $this->moral > 0.7) $this->moral = 0.7;
-
- //Isolement si besoin
- if ($this->moral < 0.1) {
- //On vérifie qu'il ne s'agit pas de la planète mère
- global $bdd, $table_planete;
- $bdd->connexion();
- $res = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id LIMIT 1;");
- $bdd->deconnexion();
- if ($res['id'] != $this->id) {
- if ($this->moral <= 0.01 || $this->moral <= 0.04) {
- if ($this->moral <= 0.01) $rand = rand(0,4);
- else $rand = rand(0,20);
- //Perte de la planète
- if ($rand == 1) {
+ //Isolement si besoin
+ if ($this->moral < 0.1)
+ {
+ //On vérifie qu'il ne s'agit pas de la planète mère
+ global $bdd, $table_planete;
$bdd->connexion();
- $bdd->query("DELETE FROM $table_planete WHERE id = ".$this->id.";");
+ $res = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id LIMIT 1;");
$bdd->deconnexion();
- send_mp($this->id_user, 'Perte de contrôle de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a renversé votre gouvernement en tuant tous vos gouverneurs. Vous perdez donc définitivement le contrôle de cette planète.");
- if (!$first) {
- $sess->values['idPlan'] = $res['id'];
- erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révolté contre vous. Vous ne contrôlez plus cette planète.');
- }
- }
- }
- elseif ($this->moral <= 0.06 || $this->moral <= 0.1) {
- if ($this->moral <= 0.06) $rand = rand(0,2);
- else $rand = rand(0,10);
- //Perte de contrôle temporaire
- if ($rand == 1) {
- $debut = time() - rand(0, 3600)*4;
- $fin = $debut + 86400;
- $this->isolement = array($debut, $fin);
- if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
+ if ($res['id'] != $this->id)
+ {
+ if ($this->moral <= 0.04)
+ {
+ if ($this->moral <= 0.01)
+ $rand = rand(0,4);
+ else
+ $rand = rand(0,20);
+ //Perte de la planète
+ if ($rand == 1)
+ {
+ $bdd->connexion();
+ $bdd->query("DELETE FROM $table_planete WHERE id = ".$this->id.";");
+ $bdd->deconnexion();
+ send_mp($this->id_user, 'Perte de contrôle de '.$this->nom_planete, "Suite à une démoralisation persistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a renversé votre gouvernement en tuant tous vos gouverneurs. Vous perdez donc définitivement le contrôle de cette planète.");
+ if (!$first)
+ {
+ $sess->values['idPlan'] = $res['id'];
+ erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révolté contre vous. Vous ne contrôlez plus cette planète.');
+ }
+ }
+ }
+ elseif ($this->moral <= 0.1)
+ {
+ if ($this->moral <= 0.06)
+ $rand = rand(0,2);
+ else
+ $rand = rand(0,10);
+ //Perte de contrôle temporaire
+ if ($rand == 1)
+ {
+ $debut = time() - rand(0, 3600)*4;
+ $fin = $debut + 86400;
+ $this->isolement = array($debut, $fin);
+ if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
- send_mp($this->id_user, 'Perte de contrôle temporaire de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a pris le contrôle de votre planète. Vous perdez le contrôle de cette planète le temps que vos gouverneurs reprennent le pouvoir.");
- if (!$first) {
- $sess->values['idPlan'] = $res['id'];
- erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révoltée contre vous. Vous perdez temporairement le contrôle de cette planète.');
- }
+ send_mp($this->id_user, 'Perte de contrôle temporaire de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a pris le contrôle de votre planète. Vous perdez le contrôle de cette planète le temps que vos gouverneurs reprennent le pouvoir.");
+ if (!$first)
+ {
+ $sess->values['idPlan'] = $res['id'];
+ erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révoltée contre vous. Vous perdez temporairement le contrôle de cette planète.');
+ }
+ }
+ }
+ }
}
- }
}
- }
- }
- /**
- * Vérifie si la planète est isolée ou non
- *
- * @return boolean
- * @access public
- */
- function isolement(){
- $return = false;
+ /**
+ * Vérifie si la planète est isolée ou non
+ *
+ * @return boolean
+ * @access public
+ */
+ function isolement()
+ {
+ $return = false;
+
+ global $var___db, $config, $table_planete;
+ $bdd = new BDD();
+ $bdd->connexion();
+ $plan = $bdd->query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id;");
+ $bdd->deconnexion();
- if (time() > $this->isolement[0]) {
- if (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0]))) {
- $nbPlan = count($queryPlanetes);
$numP = 0;
- for ($i=0 ; $i<$nbPlan ; $i++) {
- if ($queryPlanetes[$i]['id'] == $queryPlanete['id']) $numP = $i;
- }
- if ($numP > 10) {
- switch($numP){
- case 11: $tps = 2; break;
- case 12: $tps = 4; break;
- case 13: $tps = 6; break;
- case 14: $tps = 8; break;
- case 15: $tps = 12; break;
- case 16: $tps = 16; break;
- case 17: $tps = 20; break;
- default: $tps = 24;
+ foreach ($plan as $key => $p)
+ {
+ if ($p['id'] == $this->id)
+ $numP = $key + 1;
}
- $debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
- $fin = $debut + $tps * 3600;
- $this->isolement[0] = $debut;
- if (time() > $this->isolement[0]) $this->isolement[1] = $fin;
- if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
- }
- }
- $p = gpc('p');
- if (isset($this->isolement[1]) && time() < $this->isolement[1]) {
- $return = true;
- }
- }
+ if ($numP >= 11)
+ {
+ if (!isset($this->isolement[0]) || (time() > $this->isolement[0] && (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0])))))
+ {
+ switch($numP)
+ {
+ case 11:
+ $tps = 2;
+ break;
+ case 12:
+ $tps = 4;
+ break;
+ case 13:
+ $tps = 6;
+ break;
+ case 14:
+ $tps = 8;
+ break;
+ case 15:
+ $tps = 12;
+ break;
+ case 16:
+ $tps = 16;
+ break;
+ case 17:
+ $tps = 20;
+ break;
+ default:
+ $tps = 24;
+ }
+ $debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
+ $fin = $debut + $tps * 3600;
- return $return;
- }
-
- /**
- * Calcul les ressources produites en fonction de $temps_ecoule
- * @param int $temps_ecoule Temps écoulé depuis la dernière actualisation
- *
- * @return array
- * @access public
- */
- function production($temps_ecoule, $retarray = false){
- //Accélération de la production
- $temps_ecoule *= VITESSE;
-
- //Calcul de la consomation d'énergie
- if ($this->batiments[0] > 0) $energie_m = ceil(exp(0.28*$this->batiments[0])*10); else $energie_m = 0;
- if ($this->batiments[1] > 0) $energie_c = ceil(exp(0.28*$this->batiments[1])*10); else $energie_c = 0;
- if ($this->batiments[2] > 0) $energie_h = ceil(exp(0.2849*$this->batiments[2])*13); else $energie_h = 0;
- if ($this->batiments[3] > 0) $energie_s = ceil(exp(0.28*$this->batiments[3])*22); else $energie_s = 0;
- if ($this->batiments[4] > 0) $energie_f = ceil(exp(0.297*$this->batiments[4])*25); else $energie_f = 0;
-
- //Calcul de la consomation d'énergie
- $this->energieConso = $energie_m * $this->coeff_bat[0] + $energie_c * $this->coeff_bat[1] + $energie_h * $this->coeff_bat[2];
- $nrjmx = $energie_m + $energie_c + $energie_h;
-
- //Calcul de la production d'énergie
- $this->energie = $energie_s * $this->coeff_bat[3] + $energie_f * $this->coeff_bat[4];
-
- if ($this->energieConso == 0) $coeff = 0;
- else $coeff = $this->energie / $this->energieConso;
-
- if ($coeff < 0) $coeff = 0;
- elseif ($coeff > 1) $coeff = 1;
-
- $Ncoeff = array();
- for($i = 0; $i < 3; $i++){
- $Ncoeff[$i] = $coeff * $this->coeff_bat[$i];
- if ($Ncoeff[$i] > 1) $Ncoeff[$i] = 1;
- if ($Ncoeff[$i] < $this->coeff_bat[$i] && $this->batiments[$i] != 0) {
- $this->coeff_bat[$i] = $Ncoeff[$i];
- if (!in_array('coeff_bat', $this->modif)) $this->modif[] = 'coeff_bat';
- }
- }
-
- //Calcul de la consomation d'hydrogène
- if ($this->batiments[4] > 0) $conso_h = ((ceil(pow(1.34,($this->batiments[4]-1))*9)/3600)*$temps_ecoule) * $this->coeff_bat[4];
- else $conso_h = 0;
-
- //Calcul des production de ressources
- if ($this->batiments[0] <= 0 || $this->batiments[3] <= 0) $prod_met = 0.011 * $temps_ecoule;
- else $prod_met = ((ceil(pow(1.1, $this->batiments[0]) * 35 * $this->batiments[0]) / 3600) * $temps_ecoule) * $this->coeff_bat[0] * 1.5;
-
- if ($this->batiments[1] <= 0 || $this->batiments[3] <= 0) $prod_cri = 0.0055 * $temps_ecoule;
- else $prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 23 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1] * 1.5;
-
- if ($this->batiments[2] <= 0) $prod_hy = 0;
- else $prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 14 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2] * 1.5;
-
- //Augmentation de la production en fonction des technologies
- if ($this->technologies[0] & 4) {
- $prod_met *= 1.15;
- $prod_cri *= 1.15;
- $prod_hy *= 1.15;
- }
- elseif ($this->technologies[0] & 2) {
- $prod_met *= 1.10;
- $prod_cri *= 1.10;
- $prod_hy *= 1.10;
- }
- elseif ($this->technologies[0] & 1) {
- $prod_met *= 1.05;
- $prod_cri *= 1.05;
- $prod_hy *= 1.05;
- }
-
- //Augmentation de la production en fonction du moral
- if ($this->moral > 0.9) {
- $prod_met *= 1.05;
- $prod_cri *= 1.05;
- $prod_hy *= 1.05;
- }
- elseif ($this->moral > 0.75) {
- $prod_met *= 1.02;
- $prod_cri *= 1.02;
- $prod_hy *= 1.02;
- }
- elseif ($this->moral < 0.45) {
- $prod_met *= 0.97;
- $prod_cri *= 0.97;
- $prod_hy *= 0.97;
- }
- elseif ($this->moral < 0.25) {
- $prod_met *= 0.94;
- $prod_cri *= 0.94;
- $prod_hy *= 0.94;
- }
-
- //Augmentation de la production en fonction de la politique
- if ($this->politique == 2) {
- $prod_met *= 1.10;
- $prod_cri *= 1.10;
- $prod_hy *= 1.10;
- }
-
- //On enlève la consomation d'hydrogène
- $prod_hy -= $conso_h;
-
- if ($retarray) return array(array(ceil($this->coeff_bat[0]*100), ceil($this->coeff_bat[1]*100), ceil($this->coeff_bat[2]*100), ceil($this->coeff_bat[3]*100), ceil($this->coeff_bat[4]*100)), array($prod_met, $prod_cri, $prod_hy + $conso_h, $energie_s*$this->coeff_bat[3], $energie_f*$this->coeff_bat[4]), array($energie_m*$this->coeff_bat[0], $energie_c*$this->coeff_bat[1], $energie_h*$this->coeff_bat[2], $conso_h, ($energie_s*$this->coeff_bat[3] + $energie_f*$this->coeff_bat[4])-($energie_m*$this->coeff_bat[0] + $energie_c*$this->coeff_bat[1] + $energie_h*$this->coeff_bat[2])));
- else return array($prod_met, $prod_cri, $prod_hy);
- }
-
- /**
- * Destructeur
- *
- * @return void
- * @access public
- */
- function __destruct(){
- global $var___db, $config, $table_planete;
- $nb = count($this->modif);
- $out = array();
- $bdd = new bdd();
- $bdd->connexion();
- for($i = 0; $i < $nb; $i++){
- if ($this->modif[$i] == 'technologies') $this->modifUser[] = $this->modif[$i];
- elseif (!is_array($this->{$this->modif[$i]})) {
- $bdd->escape($this->{$this->modif[$i]});
- if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]})) $out[] .= $this->modif[$i]." = ".$this->{$this->modif[$i]};
- else $out[] .= $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
- }
- else {
- if (is_array($this->{$this->modif[$i]}) && $this->modif[$i] != "coeff_bat" && $this->modif[$i] != "vaisseaux" && $this->modif[$i] != "terrestres" && $this->modif[$i] != "casernes" && $this->modif[$i] != "technologies" && $this->modif[$i] != "batiments") {
- $prep = serialize($this->{$this->modif[$i]});
- $bdd->escape($prep);
- $out[] .= $this->modif[$i]." = '$prep'";
- }
- else {
- if ($this->modif[$i] == "batiments") $calc = "batiment";
- elseif ($this->modif[$i] == "technologies") $calc = "technolo";
- elseif ($this->modif[$i] == "casernes")$calc = "casernen";
- elseif ($this->modif[$i] == "terrestres") $calc = "nomterrn";
- elseif ($this->modif[$i] == "vaisseaux") $calc = "nomvaisn";
- elseif ($this->modif[$i] == "coeff_bat") $calc = "coeff";
-
- if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
-
- $nombr = count(${$calc.'VAR'});
- for($j = 0; $j < $nombr; $j++){
- $bdd->escape($this->{$this->modif[$i]}[$j]);
- $out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
+ $this->isolement[0] = $debut;
+ if (time() > $this->isolement[0])
+ $this->isolement[1] = $fin;
+ if (!in_array('isolement', $this->modif))
+ $this->modif[] = 'isolement';
+ }
+ if (isset($this->isolement[1]) && time() < $this->isolement[1])
+ $return = true;
+ }
+ elseif (!isset($this->isolement[0]))
+ {
+ $this->isolement = array(0,0);
+ if (!in_array('isolement', $this->modif))
+ $this->modif[] = 'isolement';
+ }
+
+ return $return;
+ }
+
+ /**
+ * Calcul les ressources produites en fonction de $temps_ecoule
+ * @param int $temps_ecoule Temps écoulé depuis la dernière actualisation
+ *
+ * @return array
+ * @access public
+ */
+ function production($temps_ecoule, $retarray = false)
+ {
+ //Accélération de la production
+ $temps_ecoule *= VITESSE;
+
+ //Calcul de la consomation d'énergie
+ if ($this->batiments[0] > 0)
+ $energie_m = ceil(exp(0.28*$this->batiments[0])*10);
+ else
+ $energie_m = 0;
+ if ($this->batiments[1] > 0)
+ $energie_c = ceil(exp(0.28*$this->batiments[1])*10);
+ else
+ $energie_c = 0;
+ if ($this->batiments[2] > 0)
+ $energie_h = ceil(exp(0.2849*$this->batiments[2])*13);
+ else
+ $energie_h = 0;
+ if ($this->batiments[3] > 0)
+ $energie_s = ceil(exp(0.28*$this->batiments[3])*22);
+ else
+ $energie_s = 0;
+ if ($this->batiments[4] > 0)
+ $energie_f = ceil(exp(0.297*$this->batiments[4])*25);
+ else
+ $energie_f = 0;
+
+ //Calcul de la consomation d'énergie
+ $this->energieConso = $energie_m * $this->coeff_bat[0] + $energie_c * $this->coeff_bat[1] + $energie_h * $this->coeff_bat[2];
+ $nrjmx = $energie_m + $energie_c + $energie_h;
+
+ //Calcul de la production d'énergie
+ $this->energie = $energie_s * $this->coeff_bat[3] + $energie_f * $this->coeff_bat[4];
+
+ if ($this->energieConso == 0)
+ $coeff = 0;
+ else
+ $coeff = $this->energie / $this->energieConso;
+
+ if ($coeff < 0)
+ $coeff = 0;
+ elseif ($coeff > 1)
+ $coeff = 1;
+
+ $Ncoeff = array();
+ for($i = 0; $i < 3; $i++)
+ {
+ $Ncoeff[$i] = $coeff * $this->coeff_bat[$i];
+ if ($Ncoeff[$i] > 1)
+ $Ncoeff[$i] = 1;
+ if ($Ncoeff[$i] < $this->coeff_bat[$i] && $this->batiments[$i] != 0)
+ {
+ $this->coeff_bat[$i] = $Ncoeff[$i];
+ if (!in_array('coeff_bat', $this->modif))
+ $this->modif[] = 'coeff_bat';
+ }
+ }
+
+ //Calcul de la consomation d'hydrogène
+ if ($this->batiments[4] > 0)
+ $conso_h = ((ceil(pow(1.34,($this->batiments[4]-1))*9)/3600)*$temps_ecoule) * $this->coeff_bat[4];
+ else
+ $conso_h = 0;
+
+ //Calcul des production de ressources
+ if ($this->batiments[0] <= 0 || $this->batiments[3] <= 0)
+ $prod_met = 0.011 * $temps_ecoule;
+ else
+ $prod_met = ((ceil(pow(1.1, $this->batiments[0]) * 35 * $this->batiments[0]) / 3600) * $temps_ecoule) * $this->coeff_bat[0] * 1.5;
+
+ if ($this->batiments[1] <= 0 || $this->batiments[3] <= 0)
+ $prod_cri = 0.0055 * $temps_ecoule;
+ else
+ $prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 23 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1] * 1.5;
+
+ if ($this->batiments[2] <= 0)
+ $prod_hy = 0;
+ else
+ $prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 14 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2] * 1.5;
+
+ //Augmentation de la production en fonction des technologies
+ if ($this->technologies[0] &4)
+ {
+ $prod_met *= 1.15;
+ $prod_cri *= 1.15;
+ $prod_hy *= 1.15;
+ }
+ elseif ($this->technologies[0] &2)
+ {
+ $prod_met *= 1.10;
+ $prod_cri *= 1.10;
+ $prod_hy *= 1.10;
+ }
+ elseif ($this->technologies[0] &1)
+ {
+ $prod_met *= 1.05;
+ $prod_cri *= 1.05;
+ $prod_hy *= 1.05;
+ }
+ //Rendement métal
+ if ($this->technologies[0] &64)
+ $prod_met *= 1.3;
+ elseif ($this->technologies[0] &32)
+ $prod_met *= 1.2;
+ elseif ($this->technologies[0] &16)
+ $prod_met *= 1.1;
+ //Rendemant cristal
+ if ($this->technologies[0] &512)
+ $prod_cri *= 1.3;
+ elseif ($this->technologies[0] &256)
+ $prod_cri *= 1.2;
+ elseif ($this->technologies[0] &128)
+ $prod_cri *= 1.1;
+ //Rendement hydrogène
+ if ($this->technologies[0] &4096)
+ $prod_hy *= 1.3;
+ elseif ($this->technologies[0] &2048)
+ $prod_hy *= 1.2;
+ elseif ($this->technologies[0] &1024)
+ $prod_hy *= 1.1;
+
+ //Augmentation de la production en fonction du moral
+ if ($this->moral > 0.9)
+ {
+ $prod_met *= 1.05;
+ $prod_cri *= 1.05;
+ $prod_hy *= 1.05;
+ }
+ elseif ($this->moral > 0.75)
+ {
+ $prod_met *= 1.02;
+ $prod_cri *= 1.02;
+ $prod_hy *= 1.02;
+ }
+ elseif ($this->moral < 0.45)
+ {
+ $prod_met *= 0.97;
+ $prod_cri *= 0.97;
+ $prod_hy *= 0.97;
+ }
+ elseif ($this->moral < 0.25)
+ {
+ $prod_met *= 0.94;
+ $prod_cri *= 0.94;
+ $prod_hy *= 0.94;
+ }
+
+ //Augmentation de la production en fonction de la politique
+ if ($this->politique == 2)
+ {
+ $prod_met *= 1.10;
+ $prod_cri *= 1.10;
+ $prod_hy *= 1.10;
+ }
+
+ //On enlève la consomation d'hydrogène
+ $prod_hy -= $conso_h;
+
+ if ($retarray)
+ return array(array(ceil($this->coeff_bat[0]*100), ceil($this->coeff_bat[1]*100), ceil($this->coeff_bat[2]*100), ceil($this->coeff_bat[3]*100), ceil($this->coeff_bat[4]*100)), array($prod_met, $prod_cri, $prod_hy + $conso_h, $energie_s*$this->coeff_bat[3], $energie_f*$this->coeff_bat[4]), array($energie_m*$this->coeff_bat[0], $energie_c*$this->coeff_bat[1], $energie_h*$this->coeff_bat[2], $conso_h, ($energie_s*$this->coeff_bat[3] + $energie_f*$this->coeff_bat[4])-($energie_m*$this->coeff_bat[0] + $energie_c*$this->coeff_bat[1] + $energie_h*$this->coeff_bat[2])));
+ else
+ return array($prod_met, $prod_cri, $prod_hy);
+ }
+
+ function creer($id_user)
+ {
+ //Définition des paramètres de l'utilisateur pour la planète
+ $this->id_user = $id_user;
+
+ //Génération du nombre de case et de l'image en fonction de la position dans le système
+ if ($this->position > MAX_PLANETE*0.75)
+ {
+ $this->cases = mt_rand(200,255);
+ $this->image = mt_rand(1,19);
+ }
+ elseif ($this->position > MAX_PLANETE/2)
+ {
+ $this->cases = mt_rand(250,300);
+ $this->image = mt_rand(1,19);
+ }
+ elseif ($this->position > MAX_PLANETE/4)
+ {
+ $this->cases = mt_rand(175,260);
+ $this->image = mt_rand(1,19);
+ }
+ else
+ {
+ $this->cases = mt_rand(150,220);
+ $this->image = mt_rand(1,19);
+ }
+
+ //Définition des principaux paramètres de la planète
+ $this->nom_planete = 'Planète colonisée';
+ $this->timestamp = time();
+ $this->metal = 1000;
+ $this->cristal = 700;
+ $this->hydrogene = 0;
+
+ $this->modif = array("id_user", "nom_planete", "galaxie", "ss", "position", "image", "cases", "timestamp", "metal", "cristal", "hydrogene");
+ }
+
+ /**
+ * Destructeur
+ *
+ * @return void
+ * @access public
+ */
+ function __destruct()
+ {
+ if (empty($this->ss) || empty($this->id_user))
+ return;
+ if ($this->id_user == 1)
+ var_dump($this);
+
+ global $var___db, $config, $table_planete;
+ if (empty($this->id))
+ {
+ $out1 = array(); $out2 = array();
+ $bdd = new bdd();
+ $bdd->connexion();
+ foreach($this->modif as $modif)
+ {
+ if (!is_array($this->{$modif}))
+ {
+ $bdd->escape($this->{$modif});
+ $out1[] = $modif;
+ if (is_int($this->{$modif}) || is_float($this->{$modif}))
+ $out2[] = $this->{$modif};
+ else
+ $out2[] = "'".$this->{$modif}."'";
+ }
+ else
+ {
+ if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
+ {
+ $prep = serialize($this->{$modif});
+ $bdd->escape($prep);
+ $out1[] = $modif;
+ $out2[] = "'$prep'";
+ }
+ else
+ {
+ if ($modif == "batiments")
+ $calc = "batiment";
+ elseif ($modif == "technologies")
+ $calc = "technolo";
+ elseif ($modif == "casernes")
+ $calc = "casernen";
+ elseif ($modif == "terrestres")
+ $calc = "nomterrn";
+ elseif ($modif == "vaisseaux")
+ $calc = "nomvaisn";
+ elseif ($modif == "coeff_bat")
+ $calc = "coeff";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ foreach($this->{$modif} as $j => $value)
+ {
+ $out1[] = ${$calc.'VAR'}[$j];
+ $out2[] = $value;
+ }
+ }
+ }
+ }
+ $bdd->query("INSERT INTO $table_planete (".implode(', ', $out1).", hash_planete) VALUES (".implode(', ', $out2).", SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)))");
+ $bdd->deconnexion();
+ }
+ else
+ {
+ $nb = count($this->modif);
+ $out = array();
+ $bdd = new bdd();
+ $bdd->connexion();
+ for($i = 0; $i < $nb; $i++)
+ {
+ if ($this->modif[$i] == 'technologies')
+ $this->modifUser[] = $this->modif[$i];
+ elseif (!is_array($this->{$this->modif[$i]}))
+ {
+ $bdd->escape($this->{$this->modif[$i]});
+ if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]}))
+ $out[] = $this->modif[$i]." = ".$this->{$this->modif[$i]};
+ else
+ $out[] = $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
+ }
+ else
+ {
+ if (is_array($this->{$this->modif[$i]}) && $this->modif[$i] != "coeff_bat" && $this->modif[$i] != "vaisseaux" && $this->modif[$i] != "terrestres" && $this->modif[$i] != "casernes" && $this->modif[$i] != "technologies" && $this->modif[$i] != "batiments")
+ {
+ $prep = serialize($this->{$this->modif[$i]});
+ $bdd->escape($prep);
+ $out[] = $this->modif[$i]." = '$prep'";
+ }
+ else
+ {
+ if ($this->modif[$i] == "batiments")
+ $calc = "batiment";
+ elseif ($this->modif[$i] == "technologies")
+ $calc = "technolo";
+ elseif ($this->modif[$i] == "casernes")
+ $calc = "casernen";
+ elseif ($this->modif[$i] == "terrestres")
+ $calc = "nomterrn";
+ elseif ($this->modif[$i] == "vaisseaux")
+ $calc = "nomvaisn";
+ elseif ($this->modif[$i] == "coeff_bat")
+ $calc = "coeff";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ $nombr = count(${$calc.'VAR'});
+ for($j = 0; $j < $nombr; $j++)
+ {
+ $bdd->escape($this->{$this->modif[$i]}[$j]);
+ $out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
+ }
+ }
+ }
+ }
+ if (!empty($out))
+ $plan = $bdd->query("UPDATE $table_planete SET ".implode(', ', $out)." WHERE id = ".$this->id.";");
+
+ $bdd->deconnexion();
+ parent::__destruct();
}
- }
}
- }
- if (!empty($out)) $plan = $bdd->query("UPDATE $table_planete SET ".implode(', ', $out)." WHERE id = ".$this->id.";");
- $bdd->deconnexion();
- parent::__destruct();
}
-}
?>
\ No newline at end of file
diff --git a/game/Class/class.rapport.php b/game/Class/class.rapport.php
index 6c8d65e..e408676 100644
--- a/game/Class/class.rapport.php
+++ b/game/Class/class.rapport.php
@@ -34,9 +34,9 @@ class Rapport{
}
function send(){
- if ($this->type == '1') $this->sendCombat();
- elseif ($this->type == '2') $this->sendTransport();
- elseif ($this->type == '3') $this->sendColonisation();
+ if ($this->type == '3') $this->sendCombat();
+ elseif ($this->type == '1') $this->sendTransport();
+ elseif ($this->type == '2') $this->sendColonisation();
elseif ($this->type == '4') $this->sendRecyclage();
elseif ($this->type == '5') $this->sendEspionnage();
elseif ($this->type == '6') $this->sendAlliance();
@@ -112,15 +112,15 @@ class Rapport{
function sendTransport(){
global $config;
include_once(_FCORE."../game/function.php");
- $titre = 'Transport vers '.$this->var[0]['nom_planete'].' ['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']';
+ $titre = 'Transport vers '.$this->var[0][0].' ['.$this->var[0][1].':'.$this->var[0][2].':'.$this->var[0][3].']';
- $race = trouvInfo($this->utilA, 'race');
+ $race = trouvInfo($this->utilA, 'race'); //TODO A optimiser
include(_FCORE."../game/noms.php");
- $rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$ressourc[0].', '.$this->var[1][1].' de '.$ressourc[1].' et '.$this->var[1][2].' d\''.$ressourc[2].' sur '.$this->var[0]['nom_planete'].'['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']
';
+ $rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$ressourc[0].', '.$this->var[1][1].' de '.$ressourc[1].' et '.$this->var[1][2].' d\''.$ressourc[2].' sur '.$this->var[0][0].'['.$this->var[0][1].':'.$this->var[0][2].':'.$this->var[0][3].']
';
- $race = trouvInfo($this->utilB, 'race');
+ $race = trouvInfo($this->utilB, 'race'); //TODO A optimiser
include(_FCORE."../game/noms.php");
- $rapportB = 'Les vaisseaux de '.trouvNom($this->utilA).' ont déposé '.$this->var[1][0].' de '.$ressourc[0].', '.$this->var[1][1].' de '.$ressourc[1].' et '.$this->var[1][2].' d\''.$ressourc[2].' sur '.$this->var[0]['nom_planete'].'['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']
';
+ $rapportB = 'Les vaisseaux de '.trouvNom($this->utilA).' ont déposé '.$this->var[1][0].' de '.$ressourc[0].', '.$this->var[1][1].' de '.$ressourc[1].' et '.$this->var[1][2].' d\''.$ressourc[2].' sur '.$this->var[0][0].'['.$this->var[0][1].':'.$this->var[0][2].':'.$this->var[0][3].']
';
$temps = $this->timestamp;
$db = new bdd();
@@ -129,8 +129,8 @@ class Rapport{
$db->escape($rapportA);
$db->escape($rapportB);
- $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA.", '$titre', '$rapportA', '$temps')");
- if ($this->utilA != $this->utilB) $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB.", '$titre', '$rapportB', '$temps')");
+ $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA.", '$titre', '$rapportA', '$temps');");
+ if ($this->utilA != $this->utilB) $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB.", '$titre', '$rapportB', '$temps');");
$db->deconnexion();
}
@@ -150,9 +150,10 @@ class Rapport{
}
function sendRecyclage(){
- include_once(_FCORE."../game/function.php");
- $titre = 'Recyclage de '.$this->var[0]['nom_planete'].' ['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']';
- $rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$ressourc[0].' et '.$this->var[1][1].' de '.$ressourc[1].' sur '.$this->var[0]['nom_planete'].'['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']
';
+ global $ressourc;
+
+ $titre = 'Recyclage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
+ $rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$ressourc[0].' et '.$this->var[1][1].' de '.$ressourc[1].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']
';
$temps = $this->timestamp;
diff --git a/game/Class/class.surface.php b/game/Class/class.surface.php
new file mode 100644
index 0000000..2b65478
--- /dev/null
+++ b/game/Class/class.surface.php
@@ -0,0 +1,30 @@
+
\ No newline at end of file
diff --git a/game/Class/class.tinyplanete.php b/game/Class/class.tinyplanete.php
new file mode 100644
index 0000000..9d034f9
--- /dev/null
+++ b/game/Class/class.tinyplanete.php
@@ -0,0 +1,47 @@
+connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id;");
+ $bdd->deconnexion();
+ }
+ elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position)) {
+ $bdd->connexion();
+ $plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
+ $bdd->deconnexion();
+ }
+ else die('Erreur #04 : Format de recherche de planete incorrect !');
+
+ if (!empty($plan)) {
+ $this->id = $plan["id"];
+ $this->galaxie = $plan["galaxie"];
+ $this->ss = $plan["ss"];
+ $this->position = $plan["position"];
+ $this->nom_planete = $plan["nom_planete"];
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/game/Class/class.user.php b/game/Class/class.user.php
index 108324a..a8a9f59 100644
--- a/game/Class/class.user.php
+++ b/game/Class/class.user.php
@@ -86,40 +86,51 @@ class User extends File{
*/
function __destruct(){
global $var___db, $config, $table_user;
- $nb = count($this->modifUser);
$out = array();
$bdd = new bdd();
$bdd->connexion();
- for($i = 0; $i < $nb; $i++){
- if (!is_array($this->{$this->modifUser[$i]})) {
- $bdd->escape($this->{$this->modifUser[$i]});
- if (is_int($this->{$this->modifUser[$i]}) || is_float($this->{$this->modifUser[$i]})) $out[] .= $this->modifUser[$i]." = ".$this->{$this->modifUser[$i]};
- else $out[] .= $this->modifUser[$i]." = '".$this->{$this->modifUser[$i]}."'";
- }
- else {
- if (ereg('file', $this->modifUser[$i])) {
- $prep = implode(';', $this->{$this->modifUser[$i]});
- $bdd->escape($prep);
- $out[] .= $this->modifUser[$i]." = '$prep'";
- }
- else {
- if ($this->modifUser[$i] == "batiments") $calc = "batiment";
- elseif ($this->modifUser[$i] == "technologies") $calc = "technologies";
- elseif ($this->modifUser[$i] == "casernes")$calc = "casernen";
- elseif ($this->modifUser[$i] == "terrestres") $calc = "nomterrn";
- elseif ($this->modifUser[$i] == "vaisseaux") $calc = "nomvaisn";
-
- if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
-
- $nombr = count(${$calc.'VAR'});
- for($j = 0; $j < $nombr; $j++){
- $bdd->escape($this->{$this->modifUser[$i]}[$j]);
- $out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$this->modifUser[$i]}[$j];
+ foreach($this->modifUser as $key => $modif)
+ {
+ if (!is_array($this->{$modif}))
+ {
+ $bdd->escape($this->{$modif});
+ if (is_int($this->{$modif}) || is_float($this->{$modif})) $out[] .= $modif." = ".$this->{$modif};
+ else $out[] .= $modif." = '".$this->{$modif}."'";
+ }
+ else
+ {
+ if (ereg('file', $modif))
+ {
+ $prep = implode(';', $this->{$modif});
+ $bdd->escape($prep);
+ $out[] .= $modif." = '$prep'";
+ }
+ else
+ {
+ if ($modif == "batiments")
+ $calc = "batiment";
+ elseif ($modif == "technologies")
+ $calc = "technologies";
+ elseif ($modif == "casernes")
+ $calc = "casernen";
+ elseif ($modif == "terrestres")
+ $calc = "nomterrn";
+ elseif ($modif == "vaisseaux")
+ $calc = "nomvaisn";
+
+ if (!isset(${$calc.'VAR'}))
+ global ${$calc.'VAR'};
+
+ $nombr = count(${$calc.'VAR'});
+ for($j = 0; $j < $nombr; $j++){
+ $bdd->escape($this->{$modif}[$j]);
+ $out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$modif}[$j];
+ }
+ }
}
- }
}
- }
- if (!empty($out)) $plan = $bdd->query("UPDATE $table_user SET ".implode(', ', $out)." WHERE id = ".$this->id_user.";");
+ if (!empty($out))
+ $plan = $bdd->query("UPDATE $table_user SET ".implode(', ', $out)." WHERE id = ".$this->id_user.";");
$bdd->deconnexion();
}
}
diff --git a/game/cache/inline.cache b/game/cache/inline.cache
index c227083..56a6051 100644
--- a/game/cache/inline.cache
+++ b/game/cache/inline.cache
@@ -1 +1 @@
-0
\ No newline at end of file
+1
\ No newline at end of file
diff --git a/game/cache/signatures/8..sign b/game/cache/signatures/8..sign
index a7da947..fc37f11 100644
Binary files a/game/cache/signatures/8..sign and b/game/cache/signatures/8..sign differ
diff --git a/game/cron/inactifs.php b/game/cron/inactifs.php
index da41d28..532d466 100644
--- a/game/cron/inactifs.php
+++ b/game/cron/inactifs.php
@@ -2,12 +2,13 @@
if(!defined('CRON')) { header('Location: ../'); exit; }
print '
Début de la gestion des joueurs inactifs ; il est : '.date('d/m/Y H:i:s');
-$limite1 = time() - 7 * 86400;
-$limite2 = time() - 8 * 86400;
-$limiteS = time() - 14 * 86400;
+$limite1 = time() - 10 * 86400;
+$limite2 = $limite1 + 86400;
+$limiteS = time() - 20 * 86400;
$bdd->connexion();
$utils = $bdd->query("SELECT id, pseudo, mail FROM $table_user WHERE last_visite < $limite1 AND last_visite > $limite2 AND mv = 0;");
$utils['nombre'] = $bdd->num_rows;
+var_dump($utils);
for($i = 0; $i < $utils['nombre']; $i++){
send_mail($utils[$i]['mail'], "Compte de jeu inactif", 'Halo-Battle :: Compte de jeu inactif
Bonjour '.$utils[$i]['pseudo'].', Cela fait plus d\'une semaine que vous ne vous êtes pas connecté au jeu Halo-Battle. Pour que vos planètes et vos vaisseaux soient concervés, pensez à mettre votre compte en mode vacances avant qu\'il ne soit définitivement supprimé de nos serveurs.
A bientôt dans Halo-Battle, Le staff
');
print ' Envoie d\'un mail au joueur inactif '.$utils[$i]['pseudo'];
@@ -15,18 +16,20 @@ for($i = 0; $i < $utils['nombre']; $i++){
$utils = $bdd->query("SELECT id, pseudo, mail FROM $table_user WHERE last_visite < $limiteS AND mv = 0;");
$utils['nombre'] = $bdd->num_rows;
+var_dump($utils);
for($i = 0; $i < $utils['nombre']; $i++){
- send_mail($utils[$i]['mail'], "Compte de jeu supprimé", 'Halo-Battle :: Suppression de votre compte
Bonjour '.$utils[$i]['pseudo'].', Cela fait plus de deux semaines que vous ne vous êtes pas connecté au jeu Halo-Battle. Votre compte ainsi que toutes les données personnelles vous concernant viennent d\'être supprimées de notre serveur de jeu, ainsi, vous ne recevrez plus de courriels de notre part.
A bientôt dans Halo-Battle, Le staff
');
-/* $bdd->query("DELETE FROM $table_flottes WHERE id_user = ".$utils[$i]['id']);
+ send_mail($utils[$i]['mail'], "Compte de jeu supprime", 'Halo-Battle :: Suppression de votre compte
Bonjour '.$utils[$i]['pseudo'].', Cela fait plus de deux semaines que vous ne vous êtes pas connecté au jeu Halo-Battle. Votre compte ainsi que toutes les données personnelles vous concernant viennent d\'être supprimées de notre serveur de jeu, ainsi, vous ne recevrez plus de courriels de notre part.
A bientôt dans Halo-Battle, Le staff
');
+ //send_mail($utils[$i]['mail'], "Re: Compte de jeu supprimé", 'Halo-Battle :: Suppression de votre compte
Bonjour '.$utils[$i]['pseudo'].', Vous avez reçu il y a quelques minutes un courriel indiquant la suppression de votre compte de jeu. Cet e-mail n\'était en fait qu\'un simple test effectué par nos serveur afin de tester le script de gestion des joueurs inactifs (dont vous faites parti).
D\'ici la semaine prochaine, il sera mis en application et votre compte risquera d\'être supprimé. Vous pouvez donc toujours profiter de votre compte avant qu\'il ne soit supprimé réellement ;)
A bientôt dans Halo-Battle, Le staff
');
+ $bdd->query("DELETE FROM $table_flottes WHERE id_user = ".$utils[$i]['id']);
//TODO vérifier la suppression desactions du joueur
- $action = new Bourse();
- $action->delUser($utils[$i]['id']);
+// $action = new Bourse();
+// $action->delUser($utils[$i]['id']);
//TODO Ajouter CASCADE !! pour supprimer les combats avec les flottes
$bdd->query("DELETE FROM $table_planete WHERE id_user = ".$utils[$i]['id']);
$bdd->query("DELETE FROM $table_user WHERE id = ".$utils[$i]['id']);
$bdd->query("DELETE FROM $table_mail WHERE destinataire = ".$utils[$i]['pseudo']);
$bdd->query("DELETE FROM $table_mail WHERE expediteur = ".$utils[$i]['pseudo']);
-*/ print ' Envoie d\'un mail et suppression du joueur inactif '.$utils[$i]['pseudo'];
+ print ' Envoie d\'un mail et suppression du joueur inactif '.$utils[$i]['pseudo'];
}
$bdd->deconnexion();
diff --git a/game/cron/sauvebdd.php b/game/cron/sauvebdd.php
index 88f5c36..333bfed 100644
--- a/game/cron/sauvebdd.php
+++ b/game/cron/sauvebdd.php
@@ -44,11 +44,15 @@ else {
$res = $bdd->query('SELECT * FROM '.$nomtable.';');
$bdd->deconnexion();
- fwrite($fp, "
\"\n");
+ fwrite($fp, "
\n");
for($i = 0; $i < $bdd->num_rows; $i++){
- fwrite($fp, "\t\n");
+ if (isset($res[$i]['id'])) $extend = ' id="'.$res[$i]['id'].'"';
+ else $extend = '';
+
+ fwrite($fp, "\t\n");
foreach ($res[$i] as $field_name => $field_value){
- fwrite($fp, "\t\t<$field_name>".htmlentities($field_value)."$field_name>\n");
+ if ($nomtable == 'user' && $field_name == "mdp_var") continue;
+ fwrite($fp, "\t\t<$field_name>".str_replace('<', '$#lt;', utf8_encode(html_entity_decode($field_value)))."$field_name>\n");
}
fwrite($fp, "\t\n");
}
@@ -71,7 +75,7 @@ else {
if ($fp) {
$fwrite($fp, "-- Utilitaire de sauvegarde de base de données de HB\n-- Sauvegarde du ".date('d/m/Y H:i:s')."\n-- Version du jeu : ".$config['version']."\n\n");
- fwrite($fpx, ''."\n\n");
+ fwrite($fpx, ''."\n\n\n");
//Liste des tables à sauvegarder
$list = array('alliances', 'alliances_attente', 'alliances_chat', 'alliances_creation', 'alliances_grade', 'flottes', 'flottes_combats', 'planete', 'user');
@@ -80,6 +84,7 @@ else {
dumpTable($fp, $table);
dumpTableXML($fpx, $table);
}
+ fwrite($fpx, '');
}
if (!function_exists('gzopen')) fclose($fp);
diff --git a/game/flottes.php b/game/flottes.php
index 1638d46..7195da0 100644
--- a/game/flottes.php
+++ b/game/flottes.php
@@ -1,374 +1,17 @@
connexion();
-$queryFlottes = $bdd->query("SELECT * FROM $table_flottes WHERE id_user = '$id_user' OR (end_galaxie = '$Hgalaxie' AND end_ss = '$Hss' AND end_position = '$Hposition');");
+$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE (id_user = ".$planete->id_user." OR end_planete = ".$planete->id.") AND last < ".(time()-10).";");
$bdd->deconnexion();
-$nbFlottes = $bdd->num_rows;
-for ($i = 0; $i < $nbFlottes; $i++) {
- //Récupération des principales variables de la flotte
- $id_flotte = $queryFlottes[$i]['id'];
- $mission = $queryFlottes[$i]['mission'];
- $end_galaxie = $queryFlottes[$i]['end_galaxie'];
- $end_ss = $queryFlottes[$i]['end_ss'];
- $end_position = $queryFlottes[$i]['end_position'];
- $end_time = $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'];
- //On vérifie que la planète cible existe
- $bdd->connexion();
- $queryEN = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
- if (!$queryEN && $mission != 3 && $mission != 6 && time() > $end_time) {
- $bdd->query("UPDATE $table_flottes SET effectue = '1', mission = '6', ret_time = '".($end_time + $queryFlottes[$i]['end_time'])."' WHERE id = $id_flotte;");
- $titreA = 'Impossible d\'effectuer la mission';
- $bdd->escape($titreA);
- $rapportA = 'La flotte '.$queryFlottes[$i]['nom_flotte'].' n\'a pas pu effectuer sa mission correctement car lorsqu\'elle est arrivée sur place, la planète était déserte.';
- $bdd->escape($rapportA);
- $db->query("INSERT INTO $table_mail (destinataire, expediteur, sujet, contenu, temps) VALUES(".$queryFlottes[$i]['id_user'].", '', '$titreA', '$rapportA', '".$end_time."')");
- $bdd->deconnexion();
- continue;
- }
- elseif (!$queryEN && $mission != 3 && $queryFlottes[$i]['effectue'] != 1) {
- $bdd->deconnexion();
- continue;
- }
- $bdd->deconnexion();
- $ENidPlan = $queryEN['id'];
-
- //La flotte est prête a effectuer une action
- if ($queryFlottes[$i]['effectue'] != 1 && time() >= $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'] && !empty($queryFlottes[$i]['end_time'])) {
- //Mission Attaquer
- if ($mission == 1) {
- require_once(_FCORE."../game/Class/class.combat.php");
- $bdd->connexion();
- //On regarde si le combat a déjà commencé
- if ($queryFlottes[$i]['effectue'] == 2) {
- if ($queryCombat = $bdd->unique_query("SELECT * FROM $table_flottes_combats WHERE refflotte = '$id_flotte';")) {
- //On vérifie si on lance le tour suivant ou non
- if (time() >= $queryCombat['timestamp']) {
- //On modifie le timestamp pour ne pas que le combat se déroule deux fois
- $timebloque = time() + 5;
- $bdd->query("UPDATE $table_flottes_combats SET timestamp = '$timebloque' WHERE refflotte = '$id_flotte';");
-
- //Récupération du combat
- $combat = unserialize($queryCombat['serialize']);
- //Mise à jour des tactiques
- if (!empty($queryFlottes[$i]['tactiqueAT'])) $combat->changerTactiqueAT($queryFlottes[$i]['tactiqueAT']);
- if (!empty($queryFlottes[$i]['tactiqueEN'])) $combat->changerTactiqueEN($queryFlottes[$i]['tactiqueEN']);
- }
- else continue;
- }
- else {
- $time = time();
- $bdd->query("UPDATE $table_flottes SET effectue = '1', ret_time = end_time + $time WHERE id = '$id_flotte';");
- file_log("Erreur dans le script de combat, la flotte de ".trouvNom($queryFlottes[$i]['id_user'])."(".$queryFlottes[$i]['id_user'].") a été renvoyé au point de départ.", 1);
- header('Location: ./?erreurcombat');
- exit;
- }
- }
- else {
- //On génére un nouveau combat
- $combat = new Combat($queryFlottes[$i], $queryEN, $queryEN, array(trouvInfo($queryFlottes[$i]['id_user'], 'blindage'), trouvInfo($queryEN['id_user'], 'blindage')));
- $bdd->query("UPDATE $table_flottes SET effectue = '2' WHERE id = '$id_flotte';");
- }
- $bdd->deconnexion();
-
- while($combat->timestamp <= time()) {
- //Préparation du rapport
- $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $combat->timestamp);
-
- $combat->Ntour++;
- $rapport->addInfo($combat->ATvais, 0);
- $rapport->addInfo($combat->ENvais, 1);
- $rapport->addInfo($combat->ENdef, 2);
- $rapport->addInfo($combat->Ntour, 3);
- $rapport->addInfo($queryEN, 4);
- $rapport->addInfo($queryFlottes[$i], 5);
-
- //Récupération des paramètres de la tactique de l'attaquant
- $arraytactique = tactique($combat->ATtactique);
- //On régénére les boucliers de l'attaquant et on calcul l'attaque de l'attaquant
- $ATattaque = $combat->calcAttaque($arraytactique[2] + $combat->regenereBC($arraytactique[1], true, !$arraytactique[3], trouvInfo($queryFlottes[$i]['id_user'], 'blindage')), true, trouvInfo($queryFlottes[$i]['id_user'], 'armement'));
-
- //Récupération des paramètres de la tactique du défenseur
- $arraytactique = tactique($combat->ENtactique);
- //On régénére les boucliers de l'attaquant et on calcul l'attaque de l'attaquant
- $ENattaque = $combat->calcAttaque($arraytactique[2] + $combat->regenereBC($arraytactique[1], false, !$arraytactique[3], trouvInfo($queryEN['id_user'], 'blindage')), false, trouvInfo($queryEN['id_user'], 'armement'));
-
- //On lance l'attaque
- @$ATresult = $combat->attaquerVais($ATattaque, true);
- @$ENresult = $combat->attaquerVais($ENattaque, false);
-
- if (!$ATresult && $ENresult) { //Attaquant vainqueur
- $combat->ENres['metal'] = $queryEN['metal'];
- $combat->ENres['cristal'] = $queryEN['cristal'];
- $combat->ENres['hydrogene'] = $queryEN['hydrogene'];
-
- $exportAT = $combat->exportAT(true); $ret_time = $combat->timestamp;
- $exportEN = $combat->exportEN(); $pillm = $combat->pillage[0]; $pillc = $combat->pillage[1]; $pillh = $combat->pillage[2];
- $bdd->connexion();
- $bdd->query("UPDATE $table_flottes SET $exportAT, effectue = '1', ret_time = '$ret_time' + end_time WHERE id = '$id_flotte';");
- $bdd->query("UPDATE $table_planete SET $exportEN, metal = metal - '$pillm', cristal = cristal - '$pillc', hydrogene = hydrogene - '$pillh' WHERE id = '$ENidPlan';");
- $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
- $bdd->deconnexion();
- $rapport->addInfo(array(true, true, false), 6);
- }
- elseif ($ATresult && !$ENresult) { //Défenseur vainqueur
- $exportEN = $combat->exportEN();
- $bdd->connexion();
- $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
- $bdd->query("DELETE FROM $table_flottes WHERE id = '$id_flotte';");
- $bdd->query("UPDATE $table_planete SET $exportEN WHERE id = '$ENidPlan';");
- $bdd->deconnexion();
- $rapport->addInfo(array(true, false, false), 6);
- }
- elseif (!$ATresult && !$ENresult) { //Match nul
- $exportEN = $combat->exportEN();
- $bdd->connexion();
- $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
- $bdd->query("DELETE FROM $table_flottes WHERE id = '$id_flotte';");
- $bdd->query("UPDATE $table_planete SET $exportEN WHERE id = '$ENidPlan';");
- $bdd->deconnexion();
- $rapport->addInfo(array(true, false, true), 6);
- }
- elseif ($combat->Ntour >= 250) { //Match nul
- $exportAT = $combat->exportAT(false); $ret_time = $combat->timestamp;
- $exportEN = $combat->exportEN(); $pillm = $combat->pillage[0]; $pillc = $combat->pillage[1]; $pillh = $combat->pillage[2];
- $bdd->connexion();
- $bdd->query("UPDATE $table_flottes SET $exportAT, effectue = '1', ret_time = '$ret_time' + end_time WHERE id = '$id_flotte';");
- $bdd->query("UPDATE $table_planete SET $exportEN, metal = metal - '$pillm', cristal = cristal - '$pillc', hydrogene = hydrogene - '$pillh' WHERE id = '$ENidPlan';");
- $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
- $bdd->deconnexion();
- $rapport->addInfo(array(true, false, true), 6);
- }
- else $rapport->addInfo(array(false, false, false), 6);
-
- $rapport->addInfo($combat->ATvais, 7);
- $rapport->addInfo($combat->ENvais, 8);
- $rapport->addInfo($combat->ENdef, 9);
-
- //Prévision du prochain tour
- $combat->timestamp += 300;
- $rapport->addInfo($combat->timestamp, 10);
- $rapport->addInfo($combat->pillage, 11);
-
- //On envoie les rapports aux joueurs concernés
- $rapport->send();
-
- //On arrête la boucle si le combat est terminé
- if ($rapport->var[6][0]) break;
- }
- $debriM = $combat->debriM + $queryEN['debris_met'];
- $debriC = $combat->debriC + $queryEN['debris_cri'];
-
- $bdd->connexion();
- $bdd->escape($debriM);
- $bdd->escape($debriC);
-
- $bdd->query("UPDATE $table_planete SET debris_met = $debriM, debris_cri = $debriC WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
-
- $combat->debriM = 0;
- $combat->debriC = 0;
- if (!$rapport->var[6][0]) { //Si le combat n'est pas terminé
- //On sérialise la classe pour l'exporter
- $serialise = serialize($combat);
- $bdd->escape($serialise);
-
- //On enregistre le combat dans la base de données
- $timesuite = $combat->timestamp;
- $idFleet = $queryFlottes[$i]['id'];
- if ($queryFlottes[$i]['effectue']) $bdd->query("UPDATE $table_flottes_combats SET serialize = '$serialise', tactiqueAT = '0', tactiqueEN = '0', timestamp = '$timesuite' WHERE refflotte = '$id_flotte';");
- else $bdd->query("INSERT INTO $table_flottes_combats (refflotte, timestamp, serialize, tactiqueAT, tactiqueEN) VALUES('$idFleet', '$timesuite', '$serialise', '0', '0');");
- }
- $bdd->deconnexion();
- }
- //Mission Transporter
- elseif ($mission == 2) {
- $Cmetal = $queryFlottes[$i]['contenu_metal'];
- $Ccristal = $queryFlottes[$i]['contenu_cristal'];
- $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
- $bdd->connexion();
- $bdd->query("UPDATE $table_planete SET metal = metal + '$Cmetal', cristal = cristal + '$Ccristal', hydrogene = hydrogene + '$Chydrogene' WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
- $bdd->query("UPDATE $table_flottes SET effectue = '1', contenu_metal = '0', contenu_cristal = '0', contenu_hydrogene = '0' WHERE id = '$id_flotte';");
- $bdd->deconnexion();
-
- $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $end_time);
- $rapport->addInfo($queryEN, 0);
- $rapport->addInfo(array($queryFlottes[$i]['contenu_metal'], $queryFlottes[$i]['contenu_cristal'], $queryFlottes[$i]['contenu_hydrogene']), 1);
- $rapport->send();
- }
- //Mission Coloniser
- elseif ($mission == 3) {
- $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], 0, $end_time);
- $rapport->addInfo(array($end_galaxie, $end_ss, $end_position), 0);
-
- $rapport->addInfo(true, 1);
- $time = time();
- $cases = mt_rand(125,222);
- $image = mt_rand(1,15);
- $Cmetal = $queryFlottes[$i]['contenu_metal'] + 1000;
- $Ccristal = $queryFlottes[$i]['contenu_cristal'] + 700;
- $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
-
- //Calcul de l'isolement
- $nbPlan = count($queryPlanetes);
- if ($nbPlan >= 11) {
- switch($nbPlan){
- case 11: $tps = 2; break;
- case 12: $tps = 4; break;
- case 13: $tps = 6; break;
- case 14: $tps = 8; break;
- case 15: $tps = 12; break;
- case 16: $tps = 16; break;
- case 17: $tps = 20; break;
- default: $tps = 24;
- }
- }
- else $tps = 0;
- $debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
- $fin = $debut + $tps * 3600;
-
- $idFlo = $queryFlottes[$i]['id_user'];
- $bdd->connexion();
- if ($bdd->query("INSERT INTO $table_planete (id_user, isolement, nom_planete, galaxie, ss, position, image, cases, timestamp, metal, cristal, hydrogene, hash_planete) VALUES ('$idFlo', '$debut $fin', 'Planète colonisée', '$end_galaxie', '$end_ss', '$end_position', '$image', '$cases', '$time', '$Cmetal', '$Ccristal', '$Chydrogene', SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)));") === false) {
- $rapport->addInfo(false, 1);
- $bdd->query("UPDATE $table_flottes SET effectue = 1 WHERE id = $id_flotte;");
- $bdd->deconnexion();
- }
- else {
- if ($queryFlottes[$i]['nb_vais'] == 1) {
- $queryFlottes[$i]['nb_vais'] = -1;
- $bdd->query("DELETE FROM $table_flottes WHERE id = $id_flotte");
- }
- else $bdd->query("UPDATE $table_flottes SET effectue = 1, vaisseau_3 = vaisseau_3 - 1, nb_vais = nb_vais - 1, contenu_metal = 0, contenu_cristal = 0, contenu_hydrogene = 0 WHERE id = $id_flotte;");
- $bdd->deconnexion();
- }
- $rapport->send();
- }
- //Mission Recycler
- elseif ($mission == 4) {
- $capacite = $queryFlottes[$i]['contenu_max'] - (vais_conso($queryFlottes[$i]['end_time'], count($queryFlottes[$i]['nb_vais']))*$queryFlottes[$i]['vitesse']*5) + $queryFlottes[$i]['contenu_metal'] + $queryFlottes[$i]['contenu_cristal'] + $queryFlottes[$i]['contenu_hydrogene'];
-
- $debris_met = $queryEN['debris_met'];
- $debris_cri = $queryEN['debris_cri'];
-
- if ($debris_met+$debris_cri > $capacite) {
- $a = floor($capacite/2);
- $b = floor($capacite/2);
- if ($a > $debris_met && $b > $debris_cri) {
- $a = $debris_met;
- $b = $debris_cri;
- }
- else if ($a > $debris_met) {
- $a = $debris_met;
- $b = ($capacite - $a);
- if ($b > $debris_cri) $b = $debris_cri;
- }
- else if ($b > $debris_cri) {
- $b = $debris_cri;
- $a = ($capacite - $b);
- if ($a > $debris_met) $a = $debris_met;
- }
- }
- else {
- $a = $debris_met;
- $b = $debris_cri;
- }
- $Cmetal = $a + $queryFlottes[$i]['contenu_metal'];
- $Ccristal = $b + $queryFlottes[$i]['contenu_cristal'];
-
- $bdd->connexion();
- $bdd->query("UPDATE $table_flottes SET effectue = '1', contenu_metal = '$Cmetal', contenu_cristal = '$Ccristal' WHERE id = '$id_flotte';");
- $bdd->query("UPDATE $table_planete SET debris_met = debris_met - '$a', debris_cri = debris_cri - '$b' WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_position';");
- $bdd->deconnexion();
-
- $rapport = new Rapport($mission, $queryFlottes[$i]['id_user'], $queryEN['id_user'], $end_time);
- $rapport->addInfo($queryEN, 0);
- $rapport->addInfo(array($a, $b), 1);
- $rapport->send();
- }
- //Mission Espionnage
- elseif ($mission == 5) {
- $nbsondes = $queryFlottes[$i]['vaisseau_3'];
- $id_userT = $queryEN['id_user'];
- $id_att = $queryFlottes[$i]['id_user'];
-
- $bdd->connexion();
- $bdd->query("UPDATE $table_flottes SET effectue = 1 WHERE id = $id_flotte;");
- $resultatUD = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_userT;");
- $resultatUA = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_att;");
- $bdd->deconnexion();
-
- $diffNiveau = $resultatUA['detection'] - $resultatUD['detection'] + floor($nbsondes/2);
- $rapport = new Rapport($mission, $id_att, $id_userT, $end_time);
-
- if ($diffNiveau < 0) {
- $rapport->addInfo($queryEN, 0);
- $rapport->addInfo(false, 1);
- }
- if ($diffNiveau >= 0) $rapport->addInfo($queryEN, 0);
- if ($diffNiveau >= 1) $rapport->addInfo(true, 1);
- if ($diffNiveau >= 2) $rapport->addInfo(true, 2);
- if ($diffNiveau >= 3) $rapport->addInfo(true, 3);
- if ($diffNiveau >= 4) $rapport->addInfo($resultatUD, 4);
- if ($diffNiveau >= 5) $rapport->addInfo(true, 5);
-
- $rapport->send();
- }
- }
-
- //Si la flotte a terminé son retour
- if (($queryFlottes[$i]['mission'] == 0 && $queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time'] <= time()) || ($queryFlottes[$i]['effectue'] == 1 && ((!empty($queryFlottes[$i]['ret_time']) && $queryFlottes[$i]['ret_time'] <= time()) || ($queryFlottes[$i]['start_time'] + $queryFlottes[$i]['end_time']*2 <= time())))) {
- if ($queryFlottes[$i]['mission'] == 0) {
- $fin_galaxie = $queryFlottes[$i]['end_galaxie'];
- $fin_systeme = $queryFlottes[$i]['end_ss'];
- $fin_potision = $queryFlottes[$i]['end_position'];
- }
- elseif (!empty($queryFlottes[$i]['ret_position'])) {
- $fin_galaxie = $queryFlottes[$i]['ret_galaxie'];
- $fin_systeme = $queryFlottes[$i]['ret_ss'];
- $fin_potision = $queryFlottes[$i]['ret_position'];
- }
- else {
- $fin_galaxie = $queryFlottes[$i]['start_galaxie'];
- $fin_systeme = $queryFlottes[$i]['start_ss'];
- $fin_potision = $queryFlottes[$i]['start_position'];
- }
-
- $bdd->connexion();
- if ($bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = '$fin_galaxie' AND ss = '$fin_systeme' AND position = '$fin_potision';")) {
- $export = '';
- $nbvais = 12;
- for($j = 1; $j <= $nbvais; $j++) {
- $export .= ', vaisseau_'.$j.' = vaisseau_'.$j.' + '.$queryFlottes[$i]['vaisseau_'.$j];
- }
- $Cmetal = $queryFlottes[$i]['contenu_metal'];
- $Ccristal = $queryFlottes[$i]['contenu_cristal'];
- $Chydrogene = $queryFlottes[$i]['contenu_hydrogene'];
- $bdd->query("UPDATE $table_planete SET metal = metal + '$Cmetal', cristal = cristal + '$Ccristal', hydrogene = hydrogene + '$Chydrogene'$export WHERE galaxie = '$fin_galaxie' AND ss = '$fin_systeme' AND position = '$fin_potision';");
- }
- $idUserFlotte = $queryFlottes[$i]['id_user'];
- $bdd->query("DELETE FROM $table_flottes WHERE id_user = '$idUserFlotte' AND id = '$id_flotte';");
- $bdd->query("DELETE FROM $table_flottes_combats WHERE refflotte = '$id_flotte';");
- $bdd->deconnexion();
+if ($flottes) {
+ foreach($flottes as $flotte) {
+ $flotte = new Flotte($flotte['id']);
+ $flotte->check_mission();
}
}
+
+//Par sécurité, on ferme la dernière classe Flotte inutile
+unset($flotte);
?>
\ No newline at end of file
diff --git a/game/function.php b/game/function.php
index 9c59983..883a94f 100644
--- a/game/function.php
+++ b/game/function.php
@@ -61,7 +61,8 @@ function sec($time) {
if ($value != 1) $output .= ' ';
}
}
- return $output;
+ if (empty($output)) return 'Instantané';
+ else return $output;
}
function readDeblok($tableau, $queryPlanete){
@@ -143,9 +144,9 @@ function requestDeblok($tableau, $queryPlanete){
function txtmission($mission){
if ($mission == 0) return 'Stationner';
- elseif ($mission == 1) return 'Attaquer';
- elseif ($mission == 2) return 'Transporter';
- elseif ($mission == 3) return 'Coloniser';
+ elseif ($mission == 1) return 'Transporter';
+ elseif ($mission == 2) return 'Coloniser';
+ elseif ($mission == 3) return 'Attaquer';
elseif ($mission == 4) return 'Recycler';
elseif ($mission == 5) return 'Espionner';
elseif ($mission == 6) return 'Retour';
@@ -341,4 +342,9 @@ function mdp($nom, $mdp, $alea = false){
}
else return hash_var(cxor(strtoupper($nom).':'.$mdp.'♂♪',$alea));
}
+
+function redirection($url){
+ header('Location: '.$url);
+ print '';
+}
?>
\ No newline at end of file
diff --git a/game/jeu/Copie de bourse.php b/game/jeu/Copie de bourse.php
new file mode 100644
index 0000000..d845a5f
--- /dev/null
+++ b/game/jeu/Copie de bourse.php
@@ -0,0 +1,128 @@
+= 0 && date('w') != 0 && date('w') != 6 && $queryUser['auth_level'] < 3)
+ erreur('La bourse est actuellement fermée ! Réouverture à 7h00', "orange");
+else*/if ($queryPlanetes[0]['id'] != $planete->id)
+ erreur('Vous devez être sur votre planète mère pour utiliser la bourse.');
+else {
+ $a = gpc('a');
+ $v = gpc('v');
+ $nb = gpc('a'.$a.$v, 'post');
+ if ($nb < 0) erreur("Vous ne pouvez pas acheter ou vendre un nombre négatif d'action !", "red", "?p=bourse");
+ if (!empty($a) && is_numeric($nb)) {
+ $action = new Bourse($a, $id_user);
+ $poss24 = $action->actionIn24Hours();
+ if ($poss24 + $nb > MAX_ACTION_PAR_JOUR) erreur('Vous ne pouvez pas acheter plus de 5 mêmes actions dans les mêmes 24h.');
+ $ressources = $action->prixAchat($nb);
+ if ($ressources[0] > $planete->metal || $ressources[1] > $planete->cristal) erreur('Vous n\'avez pas assez de ressources pour acheter '.$nb.' actions.');
+ $action->addAction($nb);
+ $planete->metal -= $ressources[0];
+ $planete->cristal -= $ressources[1];
+
+ header('Location: ?p=bourse&d='.$a);
+ exit;
+ }
+ elseif (!empty($v) && is_numeric($nb)) {
+ $action = new Bourse($v, $id_user);
+ $ressources = $action->delAction($nb);
+ $planete->metal += $ressources[0];
+ $planete->cristal += $ressources[1];
+
+ header('Location: ?p=bourse&d='.$v);
+ exit;
+ }
+ elseif (gpc('e') && $planete->auth_level >= 3) {
+ $e = gpc('e');
+ if (isset($_POST['nomaction']) && isset($_POST['descaction'])) {
+ $nom = gpc('nomaction', 'post');
+ $description = gpc('descaction', 'post');
+ $bdd->connexion();
+ $bdd->escape($nom);
+ $bdd->escape($description);
+ $bdd->escape($e);
+ $bdd->query("UPDATE $table_bourse SET description = '$description', nom = '$nom' WHERE id = $e;");
+ $bdd->deconnexion();
+ }
+ elseif (isset($_POST['prixAM']) && isset($_POST['prixAC'])) {
+ $prixAM = gpc('prixAM', 'post');
+ $prixAC = gpc('prixAC', 'post');
+ $bdd->connexion();
+ $bdd->escape($prixAM);
+ $bdd->escape($prixAC);
+ $bdd->escape($e);
+ $bdd->query("UPDATE $table_bourse SET metal = $prixAM, cristal = $prixAC WHERE id = $e;");
+ $bdd->deconnexion();
+ }
+ elseif (isset($_POST['newsaction'])) {
+ $news = gpc('newsaction', 'post');
+ $time = time();
+ $bdd->connexion();
+ $bdd->escape($news);
+ $bdd->escape($e);
+ $bdd->query("UPDATE $table_bourse SET news = '$news', timeDesc = '$time' WHERE id = $e;");
+ $bdd->deconnexion();
+ }
+
+ header('Location: ?p=bourse&d='.$e);
+ exit;
+ }
+ elseif (gpc('c') == "new" && $planete->auth_level >= 3 && is_numeric(gpc('prixAM', 'post')) && is_numeric(gpc('prixAC', 'post'))) {
+ if (isset($_POST['nomaction']) && isset($_POST['descaction'])) {
+ $nom = gpc('nomaction', 'post');
+ $description = gpc('descaction', 'post');
+ $prixAM = gpc('prixAM', 'post');
+ $prixAC = gpc('prixAC', 'post');
+ $news = gpc('newsaction', 'post');
+ $time = time();
+ $bdd->connexion();
+ $bdd->escape($nom);
+ $bdd->escape($description);
+ $bdd->escape($prixAM);
+ $bdd->escape($prixAC);
+ $bdd->escape($news);
+ if (!empty($news)) $bdd->query("INSERT INTO $table_bourse (nom, description, news, timeDesc, metal, cristal) VALUES ('$nom', '$description', '$news', '$time', '$prixAM', '$prixAC');");
+ else $bdd->query("INSERT INTO $table_bourse (nom, description, metal, cristal) VALUES ('$nom', '$description', '$prixAM', '$prixAC');");
+ $bdd->deconnexion();
+ }
+
+ header('Location: ?p=bourse');
+ exit;
+ }
+ elseif ($d = gpc('d')) {
+ $action = new Bourse($d, $id_user);
+ $template->assign('taxeA', $action->taxeA);
+ $template->assign('taxeV', $action->taxeV);
+ $template->assign('poss', $action->action());
+ $template->assign('poss24', $action->actionIn24Hours());
+ $action = null;
+
+ $bdd->connexion();
+ $bdd->escape($d);
+ $bourse = $bdd->unique_query("SELECT id, nom, description, news, metal, cristal, (metal/metalAnc-1)*100 AS evolution FROM $table_bourse WHERE id = $d;");
+ $bdd->deconnexion();
+
+ if ($bourse) {
+ $page = 'bourseDetails';
+ $template->assign('bourse', $bourse);
+ }
+ else erreur('Cette action n\'existe pas !', "red", '?p=bourse');
+ }
+ else {
+ $bdd->connexion();
+ $infos = $bdd->query("SELECT id, nom, news AS description FROM $table_bourse WHERE news != '' ORDER BY timeDesc DESC LIMIT 7;");
+ $bourse = $bdd->query("SELECT id, nom, metal, cristal, (metal/metalAnc-1)*100 AS evolution FROM $table_bourse;");
+ $bdd->deconnexion();
+
+ $page = 'bourse';
+ $template->assign('bourse', $bourse);
+ $template->assign('infos', $infos);
+ }
+}
+?>
\ No newline at end of file
diff --git a/game/jeu/accueil.php b/game/jeu/accueil.php
index 542c309..6370957 100644
--- a/game/jeu/accueil.php
+++ b/game/jeu/accueil.php
@@ -11,22 +11,24 @@ $alli = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = '".$planet
$radar = array();
$nbPlan = count($queryPlanetes);
$detect = $planete->technologies[1]*1800;
-for($i = 0; $i < $nbPlan; $i++){
+/*for($i = 0; $i < $nbPlan; $i++){
$end_galaxie = $queryPlanetes[$i]['galaxie'];
$end_ss = $queryPlanetes[$i]['ss'];
$end_position = $queryPlanetes[$i]['position'];
$radar[] = array($bdd->query("SELECT F.mission, F.start_galaxie, F.start_ss, F.start_position, F.start_time, F.end_time, F.start_time + F.end_time - ".time()." AS arrive_time, P.nom_planete, U.pseudo FROM $table_flottes F INNER JOIN $table_planete P ON P.galaxie = F.start_galaxie AND P.ss = F.start_ss AND P.position = F.start_position INNER JOIN $table_user U ON U.id = P.id_user WHERE F.effectue != '1' AND F.end_galaxie = '$end_galaxie' AND F.end_ss = '$end_ss' AND F.end_position = '$end_position' AND F.id_user != $id_user AND F.start_time + F.end_time - ".time()." <= $detect;"), array($queryPlanetes[$i]['nom_planete'], $queryPlanetes[$i]['galaxie'], $queryPlanetes[$i]['ss'], $queryPlanetes[$i]['position']));
-}
+}*/
$bdd->deconnexion();
-//Affichage des informations sur la planète
-$diametre = separerNombres($planete->cases * 92);
-$Classpoints = separerNombres($planete->points);
+if (SURFACE == "planete") {
+ //Affichage des informations sur la planète
+ $diametre = separerNombres($planete->cases * 92);
+ $Classpoints = separerNombres($planete->points);
+ $template->assign('diametre',$diametre);
+ $template->assign('points',$Classpoints);
+}
$template->assign('mail', $queryMail);
$template->assign('radar',$radar);
-$template->assign('diametre',$diametre);
-$template->assign('points',$Classpoints);
$template->assign('alliance', $alli);
?>
\ No newline at end of file
diff --git a/game/jeu/admin/bandeau.php b/game/jeu/admin/bandeau.php
index 30b1c1c..2d76610 100644
--- a/game/jeu/admin/bandeau.php
+++ b/game/jeu/admin/bandeau.php
@@ -53,8 +53,8 @@ elseif (!empty($_GET['d'])) {
}
else {
$chapeau->connexion();
- $req = $chapeau->query("SELECT * FROM $table_infoshead;");
+ $req = $chapeau->query("SELECT * FROM $table_infoshead ORDER BY id ASC;");
$chapeau->deconnexion();
$template->assign('tableau', $req);
}
-?>
\ No newline at end of file
+?>
diff --git a/game/jeu/batiments.php b/game/jeu/batiments.php
index d89332c..2f7d87e 100644
--- a/game/jeu/batiments.php
+++ b/game/jeu/batiments.php
@@ -4,12 +4,11 @@ $page = 'batiments';
$titre = 'Batiments';
$TEMP_batiments = array();
- $nbstop = count($batiment);
//Lancement d'une nouvelle construction
if (isset($_GET['c'])) {
//Vérification que la planète ne soit pas pleine
- if ($planete->casesRest <= 0) erreur('Vous n\'avez plus de place sur votre planète.', "red", "?p=batiments", 3500);
+ if ($planete->casesRest - count($planete->file_bat) + 1 <= 0) erreur('Vous n\'avez plus de place sur votre planète.', "red", "?p=batiments", 3500);
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
if($_GET['c'] == 6 && !empty($planete->file_tech[1])) erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
@@ -27,6 +26,9 @@ $titre = 'Batiments';
}
//Lancement d'une déconstruction
if (isset($_GET['d'])) {
+ //Si l'on ne possède pas de batiment, erreur
+ if ($planete->batiments[intval(gpc('d'))] <= 0) erreur('Vous ne pouvez pas démolir un batiment que vous ne possédez pas !');
+
//Récupération des erreurs de la mise en file d'attente pour traitement
$construction = $planete->file_addObjet("batiments", intval(gpc('d')), -1);
@@ -59,13 +61,52 @@ $titre = 'Batiments';
exit;
}*/
+ //Calcul du bonus de construction des mines en fonction des technologies
+ if ($planete->technologies[0] &262144)
+ {
+ $bonusMine_a = 0.85;
+ $bonusMine_b = 0.85;
+ $bonusMine_c = 0.85;
+ }
+ elseif ($planete->technologies[0] &131072)
+ {
+ $bonusMine_a = 0.9;
+ $bonusMine_b = 0.9;
+ $bonusMine_c = 0.9;
+ }
+ elseif ($planete->technologies[0] &65536)
+ {
+ $bonusMine_a = 0.95;
+ $bonusMine_b = 0.95;
+ $bonusMine_c = 0.95;
+ }
+ else
+ {
+ $bonusMine_a = 1;
+ $bonusMine_b = 1;
+ $bonusMine_c = 1;
+ }
+
foreach($planete->batiments as $i => $PLbatiment) {
+ //Si l'on est pas sur la planète mère, on désactive le laboratoire
+ if ($i == 6 && $queryPlanetes[0]['id'] != $planete->id) continue;
+
$tr = 0; $a = 0; $b = 0; $c = 0; $sec = 0; $enFile = false;
if ($PLbatiment > 0) $niveau = $PLbatiment; else $niveau = 0;
$n = $PLbatiment + 1;
eval($batimentCALC[$i][0]); eval($batimentCALC[$i][1]); eval($batimentCALC[$i][2]); eval($batimentCALC[$i][3]);
if ($planete->file_exist($i, 'file_bat')) $enFile = true; else $enFile = false;
+ if ($i < 4)
+ {
+ $a *= $bonusMine_a;
+ $b *= $bonusMine_b;
+ $c *= $bonusMine_c;
+ }
+
+ //On applique le bonus de temps des ingénieurs et des centrales informatiques
+ if ($i != 11) $sec /= pow(1.23,$planete->batiments[11]) + 0.0025*$planete->casernes[7];
+
//On applique les bonus de test
$sec /= VITESSE;
@@ -105,6 +146,7 @@ $titre = 'Batiments';
$n = $planete->batiments[$bout[0]] + 1;
eval($batimentCALC[$bout[0]][3]);
+ if ($bout[0] != 11) $sec /= pow(1.23,$planete->batiments[11]) + 0.0025*$planete->casernes[7];
if ($bout[1] < 0) $sec *= 0.6;
if ($key == 1) $file[] = array($bout[0], $bout[1], ceil($sec/VITESSE - (time() - $planete->file_bat[0])), $batiment[$bout[0]]);
else $file[] = array($bout[0], $bout[1], ceil($sec/VITESSE), $batiment[$bout[0]]);
diff --git a/game/jeu/bourse.php b/game/jeu/bourse.php
index d845a5f..241f9ae 100644
--- a/game/jeu/bourse.php
+++ b/game/jeu/bourse.php
@@ -1,128 +1,87 @@
99999999) erreur("Nombre de ressources invalide !");
-erreur('Arrêtez de tester la bourse, on attend le nouveau script !');
+ if ($a == 0) $var = 'metal';
+ elseif ($a == 1) $var = 'cristal';
+ elseif ($a == 2) $var = 'hydrogene';
-/*if (date('G') < 7 && date('G') >= 0 && date('w') != 0 && date('w') != 6 && $queryUser['auth_level'] < 3)
- erreur('La bourse est actuellement fermée ! Réouverture à 7h00', "orange");
-else*/if ($queryPlanetes[0]['id'] != $planete->id)
- erreur('Vous devez être sur votre planète mère pour utiliser la bourse.');
-else {
- $a = gpc('a');
- $v = gpc('v');
- $nb = gpc('a'.$a.$v, 'post');
- if ($nb < 0) erreur("Vous ne pouvez pas acheter ou vendre un nombre négatif d'action !", "red", "?p=bourse");
- if (!empty($a) && is_numeric($nb)) {
- $action = new Bourse($a, $id_user);
- $poss24 = $action->actionIn24Hours();
- if ($poss24 + $nb > MAX_ACTION_PAR_JOUR) erreur('Vous ne pouvez pas acheter plus de 5 mêmes actions dans les mêmes 24h.');
- $ressources = $action->prixAchat($nb);
- if ($ressources[0] > $planete->metal || $ressources[1] > $planete->cristal) erreur('Vous n\'avez pas assez de ressources pour acheter '.$nb.' actions.');
- $action->addAction($nb);
- $planete->metal -= $ressources[0];
- $planete->cristal -= $ressources[1];
+ $bdd->connexion();
+ $action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $a;");
+ $bdd->deconnexion();
- header('Location: ?p=bourse&d='.$a);
- exit;
- }
- elseif (!empty($v) && is_numeric($nb)) {
- $action = new Bourse($v, $id_user);
- $ressources = $action->delAction($nb);
- $planete->metal += $ressources[0];
- $planete->cristal += $ressources[1];
+ //On vérifie que la bourse ait suffisament de ressources à distribuer :
+ if ($action['dispo'] <= $nb) erreur("Il n'y a pas assez de ressources dans la galaxie pour que vous puissiez en acheter autant.");
- header('Location: ?p=bourse&d='.$v);
- exit;
- }
- elseif (gpc('e') && $planete->auth_level >= 3) {
- $e = gpc('e');
- if (isset($_POST['nomaction']) && isset($_POST['descaction'])) {
- $nom = gpc('nomaction', 'post');
- $description = gpc('descaction', 'post');
- $bdd->connexion();
- $bdd->escape($nom);
- $bdd->escape($description);
- $bdd->escape($e);
- $bdd->query("UPDATE $table_bourse SET description = '$description', nom = '$nom' WHERE id = $e;");
- $bdd->deconnexion();
- }
- elseif (isset($_POST['prixAM']) && isset($_POST['prixAC'])) {
- $prixAM = gpc('prixAM', 'post');
- $prixAC = gpc('prixAC', 'post');
- $bdd->connexion();
- $bdd->escape($prixAM);
- $bdd->escape($prixAC);
- $bdd->escape($e);
- $bdd->query("UPDATE $table_bourse SET metal = $prixAM, cristal = $prixAC WHERE id = $e;");
- $bdd->deconnexion();
- }
- elseif (isset($_POST['newsaction'])) {
- $news = gpc('newsaction', 'post');
- $time = time();
- $bdd->connexion();
- $bdd->escape($news);
- $bdd->escape($e);
- $bdd->query("UPDATE $table_bourse SET news = '$news', timeDesc = '$time' WHERE id = $e;");
- $bdd->deconnexion();
- }
+ //On vérifie qu'il reste suffisamment de place dans les silos du joueur
+ if ($planete->cap < $planete->$var + $nb) $nb = $planete->cap - $planete->$var;
+ if ($nb <= 0) erreur("Vous n'avez pas assez de place pour stocker ces ressources !");
- header('Location: ?p=bourse&d='.$e);
- exit;
- }
- elseif (gpc('c') == "new" && $planete->auth_level >= 3 && is_numeric(gpc('prixAM', 'post')) && is_numeric(gpc('prixAC', 'post'))) {
- if (isset($_POST['nomaction']) && isset($_POST['descaction'])) {
- $nom = gpc('nomaction', 'post');
- $description = gpc('descaction', 'post');
- $prixAM = gpc('prixAM', 'post');
- $prixAC = gpc('prixAC', 'post');
- $news = gpc('newsaction', 'post');
- $time = time();
- $bdd->connexion();
- $bdd->escape($nom);
- $bdd->escape($description);
- $bdd->escape($prixAM);
- $bdd->escape($prixAC);
- $bdd->escape($news);
- if (!empty($news)) $bdd->query("INSERT INTO $table_bourse (nom, description, news, timeDesc, metal, cristal) VALUES ('$nom', '$description', '$news', '$time', '$prixAM', '$prixAC');");
- else $bdd->query("INSERT INTO $table_bourse (nom, description, metal, cristal) VALUES ('$nom', '$description', '$prixAM', '$prixAC');");
- $bdd->deconnexion();
- }
+ $prix = ceil(pow($action['dispo'], -0.1) * $nb * 1.07)/10;
- header('Location: ?p=bourse');
- exit;
- }
- elseif ($d = gpc('d')) {
- $action = new Bourse($d, $id_user);
- $template->assign('taxeA', $action->taxeA);
- $template->assign('taxeV', $action->taxeV);
- $template->assign('poss', $action->action());
- $template->assign('poss24', $action->actionIn24Hours());
- $action = null;
+ //On vérifie que le joueur ait assez de crédits pour acheter
+ if ($prix <= $planete->credits) {
+ $planete->credits -= $prix;
+ $planete->$var += $nb;
+
+ if (empty($action['graph'])) $action['graph'] = array();
+ else $action['graph'] = unserialize($action['graph']);
+ $action['graph'][date('w')] = $action['dispo'];
+ $graph = serialize($action['graph']);
$bdd->connexion();
- $bdd->escape($d);
- $bourse = $bdd->unique_query("SELECT id, nom, description, news, metal, cristal, (metal/metalAnc-1)*100 AS evolution FROM $table_bourse WHERE id = $d;");
+ $bdd->escape($graph);
+ $bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo - $nb, graph = '$graph' WHERE id = $a;");
$bdd->deconnexion();
-
- if ($bourse) {
- $page = 'bourseDetails';
- $template->assign('bourse', $bourse);
- }
- else erreur('Cette action n\'existe pas !', "red", '?p=bourse');
- }
- else {
- $bdd->connexion();
- $infos = $bdd->query("SELECT id, nom, news AS description FROM $table_bourse WHERE news != '' ORDER BY timeDesc DESC LIMIT 7;");
- $bourse = $bdd->query("SELECT id, nom, metal, cristal, (metal/metalAnc-1)*100 AS evolution FROM $table_bourse;");
- $bdd->deconnexion();
-
- $page = 'bourse';
- $template->assign('bourse', $bourse);
- $template->assign('infos', $infos);
}
+ else erreur("Vous n'avez pas assez de crédits pour faire cet achat !");
}
+elseif(is_numeric($v) && is_numeric(gpc('a'.$v, 'post'))){
+ $nb = gpc('a'.$v, 'post');
+ if ($nb <= 0 || $nb > 99999999) erreur("Nombre de ressources invalide !");
+
+ if ($v == 0) $var = 'metal';
+ elseif ($v == 1) $var = 'cristal';
+ elseif ($v == 2) $var = 'hydrogene';
+
+ //On vérifie que le joueur ait assez de ressources pour vendre, sinon, on ajuste à son maximum
+ if ($nb > $planete->$var) $nb = $planete->$var;
+
+ $bdd->connexion();
+ $action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $v;");
+ $bdd->deconnexion();
+
+ $prix = ceil(pow($action['dispo'], -0.1) * $nb * 0.9)/10;
+ $planete->credits += $prix;
+ $planete->$var -= $nb;
+
+ if (empty($action['graph'])) $action['graph'] = array();
+ else $action['graph'] = unserialize($action['graph']);
+ $action['graph'][date('w')] = $action['dispo'];
+ $graph = serialize($action['graph']);
+
+ $bdd->connexion();
+ $bdd->escape($graph);
+ $bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo + $nb, graph = '$graph' WHERE id = $v;");
+ $bdd->deconnexion();
+}
+
+$bdd->connexion();
+$bourse = $bdd->query("SELECT id, dispo FROM $table_bourse_ressources;");
+$bdd->deconnexion();
+
+foreach($bourse as $key => $action){
+ $bourse[$key]['prix'] = pow($action['dispo'], -0.1) * 200;
+ $bourse[$key]['prixV'] = $bourse[$key]['prix'] * 0.9;
+ $bourse[$key]['prixA'] = $bourse[$key]['prix'] * 1.07;
+}
+
+$page = 'bourse_ressources';
+$template->assign('bourse', $bourse);
?>
\ No newline at end of file
diff --git a/game/jeu/chantierspatial.php b/game/jeu/chantierspatial.php
index 691a46d..74ac755 100644
--- a/game/jeu/chantierspatial.php
+++ b/game/jeu/chantierspatial.php
@@ -4,7 +4,7 @@ $page = 'chantierspatial';
$titre = $batiment[8];
//Vérification que le joueur ait bien un labo avant d'afficher la page
-if ($planete->batiments[8] == 0) erreur('Vous devez d\'abord construire un '.strtolower($batiment[8]), "red", '?p=batiments', 4000);
+if ($planete->batiments[8] <= 0) erreur('Vous devez d\'abord construire un '.strtolower($batiment[8]), "red", '?p=batiments', 4000);
$TEMP_batiments = array();
diff --git a/game/jeu/chantierterrestre.php b/game/jeu/chantierterrestre.php
index d0ec0d8..e1fabea 100644
--- a/game/jeu/chantierterrestre.php
+++ b/game/jeu/chantierterrestre.php
@@ -4,7 +4,7 @@ $page = 'chantierterrestre';
$titre = $batiment[7];
//Vérification que le joueur ait bien un labo avant d'afficher la page
-if ($planete->batiments[7] == 0) erreur('Vous devez d\'abord construire un '.strtolower($batiment[7]), "red", '?p=batiments', 4000);
+if ($planete->batiments[7] <= 0) erreur('Vous devez d\'abord construire un '.strtolower($batiment[7]), "red", '?p=batiments', 4000);
$TEMP_batiments = array();
diff --git a/game/jeu/connexion.php b/game/jeu/connexion.php
new file mode 100644
index 0000000..296c923
--- /dev/null
+++ b/game/jeu/connexion.php
@@ -0,0 +1,189 @@
+assign('message','Nom d\'utilisateur ou mot de passe incorrect.
Code de vérification incorrect : Le texte que vous avez recopier ne correspondait pas au texte de l\'image, veuillez recommencer.
';
}
if ($ok) {
- if (strtolower($_POST['HB_captcha']) == strtolower($_SESSION['aleat_nbr'])) {
+ if (isset($_SESSION['aleat_nbr']) && strtolower($_POST['HB_captcha']) == strtolower($_SESSION['aleat_nbr'])) {
$HB_pseudo = gpc('HB_pseudo', 'post');
$HB_mail = gpc('HB_mail', 'post');
}
diff --git a/game/jeu/~flotte.php b/game/jeu/~flotte.php
new file mode 100644
index 0000000..4f507c9
--- /dev/null
+++ b/game/jeu/~flotte.php
@@ -0,0 +1,304 @@
+connexion();
+ $bdd->escape($end_galaxie);
+ $bdd->escape($end_ss);
+ $bdd->escape($end_pos);
+ $bdd->escape($mission);
+ $bdd->escape($tactique);
+ $bdd->escape($EBmetal);
+ $bdd->escape($EBcristal);
+ $bdd->escape($EBhydrogene);
+ $bdd->escape($vitesse);
+ $resultat = $bdd->unique_query("SELECT COUNT(id) AS cnt FROM $table_flottes WHERE id_user = '$id_user'");
+ $bdd->deconnexion();
+ $nbr = $resultat['cnt'];
+
+ //Vérification du code anti-bots
+ /*if (!isset($sess->values['flcds']) || gpc('cds', 'post') != $sess->values['flcds']) erreur('Impossible d\'authentifier l\'envoie de la flotte. Si le problème perciste, contactez un administrateur.', "red", '?p=flotte', 4000);
+ //Si la mission est d'attaquer, on vérifie que les attaques ne soient pas désactivées
+ else*/if ($mission == 3 && !ATTAQUES) erreur('Les attaques sont désactivées pour le moment. Pour plus d\'informations, consultez le forum.', "red", '?p=flotte', 5000);
+ //Vérification que la destination ne soit pas en dehors de la galaxie
+ elseif ($end_galaxie > MAX_AMAS || $end_ss > MAX_SYSTEME || $end_pos > MAX_PLANETE || $end_galaxie < 0 || $end_ss < 1 || $end_pos < 1 || ($end_galaxie < 1 && $sess->level < 6)) erreur('La destination de la flotte n\'est pas correcte.', "red", '?p=flotte');
+ //Vérification que le nombre de slots ne soit pas dépassé
+ elseif ($nbr > ceil(count($queryPlanetes)/2 + 1)) erreur('Vous n\'avez pas assez de slots disponibles.', "red", '?p=flotte');
+ //On vérifie la mission
+ elseif ($mission < 0 || $mission > 5) erreur('Mission incorrecte !', "red", '?p=flotte');
+ //Si la mission est d'attaquer, on vérifie la tactique
+ elseif ($mission == 3 && !(($tactique == 1 && $planete->technologies[3] & 4096) || ($tactique == 2 && $planete->technologies[3] & 8192) || ($tactique == 3 && $planete->technologies[3] & 16384) || $tactique == 0)) erreur('Vous ne connaissez pas cette tactique de combat !', "red", '?p=flotte');
+ //On vérifie la mission, si elle est d'espionner, il faut qu'il y ait des sondes
+ elseif ($mission == 5 && $sess->values['vais'][6] <= 0 && $sess->values['vais'][13] <= 0) erreur('Vous ne pouvez pas espionner sans sonde d\'espionnage !', "red", '?p=flotte');
+ //On vérifie la mission, si elle est de coloniser, il faut qu'il y ait des vaisseaux de colonisation
+ elseif ($mission == 2 && $sess->values['vais'][2] <= 0) erreur('Vous ne pouvez pas coloniser sans vaisseau de colonisation !', "red", '?p=flotte');
+ //On vérifie la mission, si elle est de recycler, il faut qu'il y ait des reclycleurs
+ elseif ($mission == 4 && $sess->values['vais'][3] <= 0) erreur('Vous ne pouvez pas recycler sans recycleur !', "red", '?p=flotte');
+ //On vérifie que l'on possède assez de ressources
+ elseif ((!empty($EBmetal) && !$EBmetal > $planete->metal) || (!empty($EBcristal) && !$EBcristal > $planete->cristal) || (!empty($EBhydrogene) && !$EBhydrogene > $planete->hydrogene)) erreur('Vous ne pouvez pas envoyer plus de ressources que vous n\'en posséder.', "red", '?p=flotte');
+ //On vérifie que l'on n'envoie pas des ressources négatives
+ elseif ((!empty($EBmetal) && $EBmetal < 0) || (!empty($EBcristal) && $EBcristal < 0) || (!empty($EBhydrogene) && $EBhydrogene < 0)) erreur('Vous avez spécifié des valeurs de ressources à embarquer incorrectes !', "red", '?p=flotte', 4000);
+ //On vérifie la vitesse du vaisseau
+ elseif (!is_numeric($vitesse) || $vitesse < 0 || $vitesse > 1) erreur('La vitesse de votre flotte est incorrecte !', "red", '?p=flotte');
+ else {
+ //On vérifie qu'il n'y ait pas une interaction entre deux multi-comptes
+ $cnt = count($multi);
+ if ($cnt > 1 && $mission == 1) {
+ for($i = 0; $i < $cnt; $i++){
+ if ($multi[$i]['id_util'] == $resultat['id_user']) erreur('Vous ne pouvez pas avoir d\'interaction avec ce joueur pour raison de multi-compte (voir page d\'accueil).');
+ }
+ }
+
+ $bdd->connexion();
+ $resultat = $bdd->unique_query("SELECT id, id_user, debris_met, debris_cri FROM $table_planete WHERE galaxie = '$end_galaxie' AND ss = '$end_ss' AND position = '$end_pos';");
+ $bdd->deconnexion();
+
+ //Si la mission est d'attaquer, on vérifie que le joueur cible ne soit pas ne mode vacances
+ if ($mission == 3) {
+ //Récupération de l'ID du joueur cible
+ $rech_user = $resultat['id_user'];
+ $bdd->connexion();
+ $resultatu = $bdd->unique_query("SELECT mv, time_inscription FROM $table_user WHERE id = '$rech_user';");
+ $bdd->deconnexion();
+ if ($resultatu['mv'] > 0) erreur('Le joueur que vous tentez d\'attaquer est actuellement en mode vacances, vous ne pouvez donc pas l\'attaquer avant son retour de vacances.', "red", '?p=flotte', 3000); //TODO Mettre le numéro du mode vacances et non > 0 !!!
+ elseif ($resultatu['time_inscription'] + 604800 > time()) erreur('Le joueur que vous tentez d\'attaquer s\'est inscrit récemment, laissez-lui le temps de se préparer au combat !', "red", '?p=flotte', 3000);
+ elseif (!$resultat) erreur('La planète que vous tentez d\'attaquer est inhabitée.', "red", '?p=flotte');
+ elseif ($resultat['id_user'] == $id_user) erreur('La planète que vous tentez d\'attaquer vous appartient.', "red", '?p=flotte');
+ }
+ elseif ($mission == 1 && !$resultat) erreur('Impossible de transporter des ressources vers la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
+ elseif ($mission == 2 && $resultat) erreur('La planète que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
+ elseif ($mission == 0 && $resultat['id_user'] != $id_user) erreur('La planète sur laquelle vous désirez stationner ne vous appartient pas.', "red", '?p=flotte', 3000);
+ elseif ($mission == 4 && ($resultat['debris_met'] <= 0 || $resultat['debris_cri'] <= 0) && empty($sess->values['forceFlotte'])) {
+ $sess->values['forceFlotte'] = true;
+ $sess->put();
+ erreur('Il n\'y a rien à recycler sur la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.']. Vous pouvez forcer le lancement de la flotte en rechargeant cette page.', "orange");
+ }
+
+ if (!isset($sess->values['vais']) || !is_array($sess->values['vais'])) erreur('Erreur lors de la création de la flotte, absence de données des vaisseaux', "red", '?p=flotte');
+ else {
+ //Envoie de la flotte
+ $flotte = new flotte();
+
+ $sauv = $planete->vaisseaux; //Sauvegarde du contenu de la flotte avant lancement
+ $nbVais = 0;
+ foreach ($sess->values['vais'] as $key => $vaisseau){
+ if ($vaisseau > 0) {
+ if ($vaisseau > $planete->vaisseaux[$key]) erreur('Vous avez envoyé plus de vaisseaux que vous n\'en posséder sur cette planète.', "red", '?p=flotte');
+ else $nbVais += $vaisseau;
+ }
+ elseif ($vaisseau < 0) $vaisseau = 0;
+
+ $flotte->vaisseaux[$key] = $vaisseau;
+ $sauv[$key] -= $vaisseau;
+ }
+
+ if ($nbVais <= 0) erreur('Vous devez envoyer au moins un vaisseau pour former une flotte !', "red", '?p=flotte');
+ elseif (!isset($sess->values['flnbvais']) || $sess->values['flnbvais'] != $nbVais) erreur('Une erreur est survenue lors de la création de la flotte :
Calcul du nombre de vaisseaux incorrect !
Si le problème perciste, contactez un administrateur.', "red", '?p=flotte', 4500);
+
+ $flotte->nom = gpc('nomflotte', 'post');
+ $flotte->mission = $mission;
+ $flotte->start_planete = $planete;
+ $flotte->start_time = time();
+
+ //On traite le cas des planètes qui n'existent pas (dans le cas de la mission colonisation)
+ if ($mission == 2) $flotte->end_planete = $end_galaxie.':'.$end_ss.':'.$end_pos;
+ else $flotte->end_planete = $resultat['id'];
+
+ $calc = $flotte->calc_deplacement($planete->galaxie, $planete->ss, $planete->position, $end_galaxie, $end_ss, $end_pos, $vitesse, false, true);
+ $flotte->end_time = $calc[0];
+ $conso = $calc[1];
+
+ //On double la consomation si on fait un aller-retour
+ if ($mission == 1 || $mission == 2 || $mission == 4 || $mission == 5) $conso *= 2;
+
+ //On vérifie qu'il y a assez de place dans les cales des vaisseaux avant l'envoie ainsi que de ressources sur la planète
+ $flotte->calculer();
+ if ($flotte->contenuMax < ceil(gpc('metal', 'post')) + ceil(gpc('cristal', 'post')) + ceil(gpc('hydrogene', 'post')) + $conso) erreur('Vous ne pouvez pas embarquer autant de ressources, les cales débordent. '.$flotte->contenuMax, "red", '?p=flotte', 3500);
+ elseif ($planete->metal < ceil(gpc('metal', 'post')) || $planete->cristal < ceil(gpc('cristal', 'post')) || $planete->hydrogene < ceil(gpc('hydrogene', 'post')) + $conso) erreur('Vous n\'avez pas assez de ressources sur cette planète pour envoyer cette flotte.', "red", '?p=flotte', 3500);
+ else {
+ //if ($mission == 3) $flotte->tactique = gpc('tactique', 'post');
+ $flotte->contenu = array(floor(gpc('metal', 'post')), floor(gpc('cristal', 'post')), floor(gpc('hydrogene', 'post')));
+ $flotte->modifFlotte = "INSERT";
+
+ //On actualise la planète
+ $planete->metal -= floor(gpc('metal', 'post'));
+ $planete->cristal -= floor(gpc('cristal', 'post'));
+ $planete->hydrogene -= floor(gpc('hydrogene', 'post') + $conso);
+ $planete->vaisseaux = $sauv;
+ if (!in_array('vaisseaux', $planete->modif)) $planete->modif[] = 'vaisseaux';
+
+ unset($flotte);
+ unset($sess->values['vais']);
+ $sess->put();
+
+ erreur('Votre flotte a été envoyée avec succès.', "green", '?p=flotte', 4000);
+ }
+ }
+ }
+}
+elseif (!empty($_POST['v0']) || !empty($_POST['v1']) || !empty($_POST['v2']) || !empty($_POST['v3']) || !empty($_POST['v4']) || !empty($_POST['v5']) || !empty($_POST['v6']) || !empty($_POST['v7']) || !empty($_POST['v8']) || !empty($_POST['v9']) || !empty($_POST['v10']) || !empty($_POST['v11']) || !empty($_POST['v12']) || !empty($_POST['v13'])) {
+ $nombreVaisseau = 0;
+ foreach ($planete->vaisseaux as $key => $vaisseau){
+ $v = gpc('v'.$key, 'post');
+ if (!is_numeric($v)) $v = 0;
+ else $v = (int)abs($v);
+
+ if ($vaisseau < $v) {
+ erreur('Il ne vous reste plus assez de vaisseaux !', "red", '?p=flotte');
+ }
+
+ $sess->values['vais'][$key] = $v;
+ $nombreVaisseau += $v;
+ }
+ //On vérifie que l'utilisateur a bien envoyé plus d'un vaisseau
+ if ($nombreVaisseau <= 0) erreur('Vous devez envoyer au moins un vaisseau.', "red", '?p=flotte');
+
+ //On enregistre les paramètres en session
+ $sess->values['flnbvais'] = $nombreVaisseau;
+ $sess->values['forceFlotte'] = false;
+
+ //Génération de la liste de mission possible avec les vaisseaux de la flotte
+ $missions = array("Stationner", "Transporter");
+ if ($sess->values['vais'][2]) $missions[2] = "Coloniser";
+ if ($planete->technologies[7] & 16) $missions[3] = "Attaquer";
+ if ($sess->values['vais'][3]) $missions[4] = "Recycler";
+ if ($sess->values['vais'][3] || $sess->values['vais'][3]) $missions[5] = "Espionner";
+ $template->assign('missions', $missions);
+
+ //On enregistre les modification de la session
+ $sess->values['fltime'] = time();
+ $sess->put();
+
+ $page = 'flotte2';
+ $template->assign('scripth', '');
+ $template->assign('script', '');
+
+ //TODO Ajouter les destinations favorites + Colonies
+}
+//Affichage du détail d'une flotte
+elseif (!empty($_GET['n'])) {
+ $idN = ceil(gpc('n'));
+
+ $flotteN = new Flotte($idN);
+ $flotteN->load_planete();
+
+ if ($flotteN->id_flotte == 0 || $flotteN->start_planete->id_user != $planete->id_user) erreur('Impossible de trouver cette flotte !', "red", '?p=flotte', 1500);
+ else {
+ //Annulation de la mission
+ if (isset($_GET['a']) && isset($sess->values['ret_fleet']) && $_GET['a'] == $sess->values['ret_fleet']) {
+ //Calcul du temps passé depuis le lancement de la flotte
+ $tpsDD = time() - $flotteN->start_time;
+ if ($flotteN->mission == '6') erreur('Votre flotte est déjà en train de revenir !', 'red', '?p=flotte&n='.$idN, 1500);
+ elseif ($flotteN->end_time > $tpsDD) {
+ $bdd->query("UPDATE $table_flottes SET mission = '6', effectue = '1', end_time = '$tpsDD', end_galaxie = start_galaxie, end_ss = start_ss, end_position = start_position WHERE id_user = '$id_user' AND id = '$idN';");
+ header('Location: ?p=flotte&n='.$idN);
+ exit;
+ }
+ else erreur('Impossible d\'annuler la mission, elle a déjà commencée.', "red", '?p=flotte&n='.$idN, 1500);
+ }
+
+ $sess->values['ret_fleet'] = sha1('HB.fleet_'.rand().'☺ß☻');
+ $sess->put();
+
+ $template->assign('ret_fleet', $sess->values['ret_fleet']);
+ $template->assign('flotte', $flotteN);
+ $template->assign('nomvais', $nomvaisa);
+ $page = 'flotten';
+ }
+}
+//Affichage de la page générale
+else {
+ //Mise à jour des tactiques par défaut
+ $attaque = gpc('attaque', 'post');
+ $defense = gpc('defense', 'post');
+ if (is_numeric($attaque) && is_numeric($defense)) {
+ $chang = false;
+ if (($attaque != $planete->combatAT_tactique) && (($attaque == 1 && $planete->technologies[3] & 4096) || ($attaque == 2 && $planete->technologies[3] & 8192) || ($attaque == 3 && $planete->technologies[3] & 16384) || $attaque == 0)) {
+ $planete->combatAT_tactique = $attaque;
+ if (!in_array('combatAT_tactique', $planete->modifUser)) $planete->modifUser[] = 'combatAT_tactique';
+ $chang = true;
+ }
+ if (($defense != $planete->combatDE_tactique) && (($defense == 1 && $planete->technologies[3] & 4096) || ($defense == 2 && $planete->technologies[3] & 8192) || ($defense == 3 && $planete->technologies[3] & 16384) || $defense == 0)) {
+ $planete->combatDE_tactique = $defense;
+ if (!in_array('combatDE_tactique', $planete->modifUser)) $planete->modifUser[] = 'combatDE_tactique';
+ $chang = true;
+ }
+
+ if ($chang) erreur('Tactiques mises à jour avec succès.', 'green', '?p=flotte', 1100);
+ }
+
+ //Affichage des flottes en cours dans la galaxie
+ $bdd->connexion();
+ $flottes = $bdd->query("SELECT * FROM $table_flottes WHERE id_user = '$id_user';");
+ $bdd->deconnexion();
+ $nbr = $bdd->num_rows;
+
+ $TEMP_flottesEC = array();
+ if ($flottes) {
+ foreach ($flottes as $flotte){
+ if ($flotte['mission'] != 1 && ($flotte['mission'] != 2 || $flotte['statut'] == '1') && $flotte['mission'] != 0) {
+ $retour = $flotte['start_galaxie'].':'.$flotte['start_ss'].':'.$flotte['start_position'];
+ $Hretour = date('d/m H:i:s',$flotte['start_time']+2*$flotte['end_time']);
+ }
+ /*elseif ($flotte['mission'] == 1) {
+ $retour = $flotte['start_galaxie'].':'.$flotte['start_ss'].':'.$flotte['start_position'];
+ if (empty($flotte['ret_time'])) $Hretour = '-';
+ else $Hretour = date('d/m H:i:s',$flotte['ret_time']+$flotte['end_time']);
+ }*/
+ else {
+ $retour = '-';
+ $Hretour = '-';
+ }
+
+ $end_planete = new Planete($flotte['end_planete']);
+
+ if ($flotte['mission'] == 2) {
+ preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $flotte['mission'], $position);
+ $TEMP_flottesEC[] = array($flotte['id'], $flotte['nom'], txtmission($flotte['mission']), $flotte['nb_vais'], ' ['.$position[1].':'.$position[2].':'.$position[3].']', date('d/m H:i:s',$flotte['start_time']+$flotte['end_time']), $retour, $Hretour);
+ }
+ else $TEMP_flottesEC[] = array($flotte['id'], $flotte['nom'], txtmission($flotte['mission']), $flotte['nb_vais'], $end_planete->nom_planete.' ['.$end_planete->galaxie.':'.$end_planete->ss.':'.$end_planete->position.']', date('d/m H:i:s',$flotte['start_time']+$flotte['end_time']), $retour, $Hretour);
+ }
+ }
+ $template->assign('flottesEC', $TEMP_flottesEC);
+
+ //Affichage des vaisseaux disponible à l'envoie
+ $TEMP_vaisseaux = array();
+ foreach ($planete->vaisseaux as $key => $vaisseau){
+ //On affiche uniquement les vaisseaux que l'on possède hormis la station spatiale
+ if ($vaisseau > 0) $TEMP_vaisseaux[] = array($nomvaisn[$key], separerNombres($vaisseau), $vaisseau, $key);
+ }
+ $template->assign('vaisseaux', $TEMP_vaisseaux);
+
+ //Calcul du nombre de slot disponible et vérouillage de l'envoie si besoin
+ if ($nbr <= ceil(count($queryPlanetes)/2 + 1)) $template->assign('action', '');
+ else $template->assign('action', 'Nombre de flottes maximum simultanées atteint');
+
+ $template->assign('nbflotte', $nbr);
+ $template->assign('nbflottemax', ceil(count($queryPlanetes)/2 + 1));
+
+ //Modification des tactiques
+ $tactiques = array('1');
+ $attaqueT = 0;
+ $defenseT = 0;
+ if ($planete->technologies[3] & 4096) $tactiques[] = '2';
+ if ($planete->technologies[3] & 8192) $tactiques[] = '3';
+ if ($planete->technologies[3] & 16384) $tactiques[] = '4';
+
+ $template->assign('tactiques', $tactiques);
+
+ $page = 'flotte1';
+}
+?>
\ No newline at end of file
diff --git a/game/noms.php b/game/noms.php
index e49fc3e..fccb3bc 100644
--- a/game/noms.php
+++ b/game/noms.php
@@ -1,6 +1,5 @@
values['race'];
-if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
if ($race == 'covenant') {
$ressourc = array('Métal','Cristal','Ions','Énergie','Crédits');
@@ -39,7 +38,7 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
'~#DESCRIPTION MANQUANTE#~ Chambre du Conseil');
$technolo = array(
array('Forage niveau 1', 'Forage niveau 2', 'Forage niveau 3', 'Commerce galactique', 'Rendement métal niveau 1', 'Rendement métal niveau 2', 'Rendement métal niveau 3', 'Rendement cristal niveau 1', 'Rendement cristal niveau 2', 'Rendement cristal niveau 3', 'Rendement hydrogène niveau 1', 'Rendement hydrogène niveau 2', 'Rendement hydrogène niveau 3', 'Théorie du Marché niveau 1', 'Théorie du Marché niveau 2', 'Théorie du Marché niveau 3', 'Fonderies avancées niveau 1', 'Fonderies avancées niveau 2', 'Fonderies avancées niveau 3'),
- array('Maîtrise énergie niveau 1', 'Maîtrise énergie niveau 2', 'Maîtrise énergie niveau 3', 'Réacteur à combustion niveau 1', 'Réacteur à combustion niveau 2', 'Réacteur à combustion niveau 3', 'Réacteur à fusion niveau 1', 'Réacteur à fusion niveau 2', 'Réacteur à fusion niveau 3', 'Réacteur à fusion type II niveau 1', 'Réacteur à fusion type II niveau 2', 'Réacteur à fusion type II niveau 3', 'Informatique niveau 1', 'Informatique niveau 2', 'Informatique niveau 3', 'IA niveau 1', 'IA niveau 2', 'IA niveau 3', 'Télécommunications niveau 1', 'Télécommunications niveau 2', 'Télécommunications niveau 3', 'Polymères radars niveau 1', 'Polymères radars niveau 2', 'Polymères radars niveau 3', 'Espionnage niveau 1', 'Espionnage niveau 2', 'Espionnage niveau 3', 'Contre-espionnage niveau 1', 'Contre-espionnage niveau 2', 'Contre-espionnage niveau 3'),
+ array('Maîtrise énergie niveau 1', 'Maîtrise énergie niveau 2', 'Maîtrise énergie niveau 3', 'Réacteur à combustion niveau 1', 'Réacteur à combustion niveau 2', 'Réacteur à combustion niveau 3', 'Réacteur à fusion niveau 1', 'Réacteur à fusion niveau 2', 'Réacteur à fusion niveau 3', 'Moteur subluminique niveau 1', 'Moteur subluminique niveau 2', 'Moteur subluminique niveau 3', 'Informatique niveau 1', 'Informatique niveau 2', 'Informatique niveau 3', 'IA niveau 1', 'IA niveau 2', 'IA niveau 3', 'Télécommunications niveau 1', 'Télécommunications niveau 2', 'Télécommunications niveau 3', 'Polymères radars niveau 1', 'Polymères radars niveau 2', 'Polymères radars niveau 3', 'Espionnage niveau 1', 'Espionnage niveau 2', 'Espionnage niveau 3', 'Contre-espionnage niveau 1', 'Contre-espionnage niveau 2', 'Contre-espionnage niveau 3'),
array('Constructions planétaires niveau 1', 'Constructions planétaires niveau 2', 'Constructions planétaires niveau 3', 'Construction optimisée', 'Ingénierie orbitale', 'Aménagement territorial niveau 1', 'Aménagement territorial niveau 2', 'Aménagement territorial niveau 3'),
array('Immigration coloniale niveau 1', 'Immigration coloniale niveau 2', 'Immigration coloniale niveau 3', 'Urbanisme niveau 1', 'Urbanisme niveau 2', 'Urbanisme niveau 3', 'Grandes surfaces', 'Centre de loisirs', 'Arcologie', 'Sciences politiques niveau 1', 'Sciences politiques niveau 2', 'Sciences politiques niveau 3', 'Stratégie militaire niveau 1', 'Stratégie militaire niveau 2', 'Stratégie militaire niveau 3'),
@@ -94,7 +93,7 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
'Le canon à plasma n\'a pas besoin de canonnier pour tirer puisque équipé d\'un système de visée automatisé, il utilise une technologie d\'intelligence artificielle rudimentaire pour ensuite envoyer un projectile de plasma surchauffé à haute vitesse carbonisant tout sur son passage.',
'Utilisant un principe similaire de la tourelle à plasma, le lanceur de torpilles plasma utilise un condensateur de matière pour condenser le flux de plasma surchauffé en une masse de destruction pure. Ce système est le système de défense terrestre le plus évolué jamais construit. Son défaut majeur reste sa cadence de tire lente, limitant sa défense face à de multiples adversaires.');
}
- elseif ($auth_level >= 6 && md5($race) == '34c19b21bd4a3dda389e767d32fe9779') {
+ elseif (isset($sess->values['auth_level']) && $sess->values['auth_level'] >= 6 && md5($race) == '34c19b21bd4a3dda389e767d32fe9779') {
$ressourc = array('Métal','Cristal','Hydrogène','Énergie','Crédits');
$casernen = array('Constructor','Sentinelle Légère','Sentinelle Lourde','Enforcer Léger','Enforcer Lourd','Monitor','~#PAS DE NOM#~ Médecin','~#PAS DE NOM#~ Ingénieur','~#PAS DE NOM#~ Brute');
$casernde = array( 'Les Constructors sont des minis sentinelles capable d\'effectuer certaine reparation mineur, ils peuvent réparés les sentinelles endommager ainsi que les chasseurs légers.',
@@ -186,7 +185,7 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
$casernea = array('marine(s)','fusiller(s)','grenadier(s)','T.C.A.O.','sniper(s)','spartan(s)','médecin(s)','ingénieur(s)','soldat(s) exo squelette');
$casernei = array('marines.jpg','marinehf0.jpg','grenadier.jpg','TCAO2.jpg','sniper.jpg','spartan.jpg','medecin.jpg','ingenieurs.jpg','exosquelettehbpb2.jpg');
//$batiment = array('Usine de métallurgie','Usine de cristal','Synchronisateur d\'hydrogène','Centrale solaire','Centrale énergétique','Base radar','Centre de recherches','Chantier terrestre','Chantier spatial','Ecole militaire','Silo de stockage','Centrale informatique', 'Module résidentiel', 'Arcologie', 'Centre commercial', 'Centre de loisirs', 'Centre administratif');
- $batiment = array('Usine de métallurgie','Usine de cristal','Synchronisateur d\'hydrogène','Centrale solaire','Centrale énergétique','Base radar','Centre de recherches','Chantier terrestre','Chantier spatial','Ecole militaire','Silo de stockage','Centrale informatique');
+ $batiment = array('Usine de métallurgie','Usine de cristal','Synchronisateur d\'hydrogène','Centrale solaire','Centrale énergétique','Base radar','Centre de recherches','Chantier terrestre','Chantier spatial','Ecole militaire','Silo de stockage','Centrale informatique', 'Module résidentiel', 'Arcologies', 'Bunker', 'Centre commercial', 'Centre loisir');
$batimede = array( 'Cette usine traite tous les métaux recueillis afin de produire du titanium-A ou différents types d\'alliages de qualité pour vos différentes constructions planétaires ou spatiales. Chaque niveau augmente la production de métal.',
'L\'usine de cristal filtre les déchets récoltés avec les cristaux. Une fois séparés du reste ils sont classés par qualité par une quantité d\'appareils de haute technologie. Plus les cristaux sont purs plus ceux-ci peuvent être transformés en unités de stockage de données ou en conducteurs énergétiques de haute qualité. Plus ce bâtiment sera développé, plus vous pourrez traiter de cristaux rapidement.',
'Ce bâtiment use de l\'eau pour la décomposer et en extraire l\'hydrogène, la base de toutes vos productions énergétiques, pour ensuite l\'acheminer dans des condensateurs ioniques afin de le rendre plus dense et par le fait même plus efficace. Chaque niveau augmente la production du synchronisateur.',
@@ -199,8 +198,9 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
'L\'académie militaire forme les meilleurs officiers et sous-officiers de la galaxie. Ces hommes expérimentés vous aideront à choisir de meilleures stratégies défensives ou offensives ou encore même économiques face aux différentes situations qui vous seront imposées. Plus vous augmenterez le niveau de cette structure plus vos officiers seront rapides et efficaces dans leurs tâches.',
'Comme toutes choses, vos ressources ont besoin d\'espace pour être stockées ; c\'est pourquoi ces énormes silos vous seront d\'une aide précieuse afin d\'y renfermer une grande quantité de matières premières pour toutes vos productions. Plus le niveau du silo est haut, plus il pourra contenir de ressources supplémentaires.',
'La centrale informatique est le coeur de votre planète, le cerveau de votre territoire, analysant chaque particule détectée avec grand soin. Plus votre centrale est améliorée, plus rapidement et aisément les données seront traitées.',
- '~#DESCRIPTION MANQUANTE#~ Module résidentiel',
- '~#DESCRIPTION MANQUANTE#~ Arcologie',
+ '~#DESCRIPTION MANQUANTE#~ Habitation',
+ '~#DESCRIPTION MANQUANTE#~ Arcologies',
+ '~#DESCRIPTION MANQUANTE#~ Bunker',
'~#DESCRIPTION MANQUANTE#~ Centre commercial',
'~#DESCRIPTION MANQUANTE#~ Centre de loisirs',
'~#DESCRIPTION MANQUANTE#~ Centre administratif');
@@ -208,14 +208,14 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
$batimeni = array('mine_m.jpg','mine_c.png','synchroniseur.jpg','centrale solaire.jpg','centrale electrique.jpg','baseradardl3.jpg','recherches.jpg','chantierterrestrecopybj8.jpg','chantier spatial.jpg','ecole militaire.jpg','stockage.jpg','search0yp.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg');
$technolo = array(
array('Forage niveau 1', 'Forage niveau 2', 'Forage niveau 3', 'Commerce galactique', 'Rendement métal niveau 1', 'Rendement métal niveau 2', 'Rendement métal niveau 3', 'Rendement cristal niveau 1', 'Rendement cristal niveau 2', 'Rendement cristal niveau 3', 'Rendement hydrogène niveau 1', 'Rendement hydrogène niveau 2', 'Rendement hydrogène niveau 3', 'Théorie du Marché niveau 1', 'Théorie du Marché niveau 2', 'Théorie du Marché niveau 3', 'Fonderies avancées niveau 1', 'Fonderies avancées niveau 2', 'Fonderies avancées niveau 3'),
- array('Maîtrise énergie niveau 1', 'Maîtrise énergie niveau 2', 'Maîtrise énergie niveau 3', 'Réacteur à combustion niveau 1', 'Réacteur à combustion niveau 2', 'Réacteur à combustion niveau 3', 'Réacteur à fusion niveau 1', 'Réacteur à fusion niveau 2', 'Réacteur à fusion niveau 3', 'Réacteur à fusion type II niveau 1', 'Réacteur à fusion type II niveau 2', 'Réacteur à fusion type II niveau 3', 'Informatique niveau 1', 'Informatique niveau 2', 'Informatique niveau 3', 'IA niveau 1', 'IA niveau 2', 'IA niveau 3', 'Télécommunications niveau 1', 'Télécommunications niveau 2', 'Télécommunications niveau 3', 'Polymères radars niveau 1', 'Polymères radars niveau 2', 'Polymères radars niveau 3', 'Espionnage niveau 1', 'Espionnage niveau 2', 'Espionnage niveau 3', 'Contre-espionnage niveau 1', 'Contre-espionnage niveau 2', 'Contre-espionnage niveau 3'),
+ array('Maîtrise énergie niveau 1', 'Maîtrise énergie niveau 2', 'Maîtrise énergie niveau 3', 'Réacteur à combustion niveau 1', 'Réacteur à combustion niveau 2', 'Réacteur à combustion niveau 3', 'Réacteur à fusion niveau 1', 'Réacteur à fusion niveau 2', 'Réacteur à fusion niveau 3', 'Moteur subluminique niveau 1', 'Moteur subluminique niveau 2', 'Moteur subluminique niveau 3', 'Informatique niveau 1', 'Informatique niveau 2', 'Informatique niveau 3', 'IA niveau 1', 'IA niveau 2', 'IA niveau 3', 'Télécommunications niveau 1', 'Télécommunications niveau 2', 'Télécommunications niveau 3', 'Polymères radars niveau 1', 'Polymères radars niveau 2', 'Polymères radars niveau 3', 'Espionnage niveau 1', 'Espionnage niveau 2', 'Espionnage niveau 3', 'Contre-espionnage niveau 1', 'Contre-espionnage niveau 2', 'Contre-espionnage niveau 3'),
array('Constructions planétaires niveau 1', 'Constructions planétaires niveau 2', 'Constructions planétaires niveau 3', 'Construction optimisée', 'Ingénierie orbitale', 'Aménagement territorial niveau 1', 'Aménagement territorial niveau 2', 'Aménagement territorial niveau 3'),
array('Immigration coloniale niveau 1', 'Immigration coloniale niveau 2', 'Immigration coloniale niveau 3', 'Urbanisme niveau 1', 'Urbanisme niveau 2', 'Urbanisme niveau 3', 'Grandes surfaces', 'Centre de loisirs', 'Arcologie', 'Sciences politiques niveau 1', 'Sciences politiques niveau 2', 'Sciences politiques niveau 3', 'Stratégie militaire niveau 1', 'Stratégie militaire niveau 2', 'Stratégie militaire niveau 3'),
array('Projectile Haut Densité niveau 1', 'Projectile Haut Densité niveau 2', 'Projectile Haut Densité niveau 3', 'Assistance de visée niveau 1', 'Assistance de visée niveau 2', 'Assistance de visée niveau 3', 'Guidage laser niveau 1', 'Guidage laser niveau 2', 'Guidage laser niveau 3', 'Condensateurs rapides niveau 1', 'Condensateurs rapides niveau 2', 'Condensateurs rapides niveau 3', 'Balistique avancée niveau 1', 'Balistique avancée niveau 2', 'Balistique avancée niveau 3', 'Accélération magnétique niveau 1', 'Accélération magnétique niveau 2', 'Accélération magnétique niveau 3'),
array('Robotique niveau 1', 'Robotique niveau 2', 'Robotique niveau 3', 'Ingénierie atomique niveau 1', 'Ingénierie atomique niveau 2', 'Ingénierie atomique niveau 3', 'Nano-régénération niveau ', 'Nano-régénération niveau 2', 'Nano-régénération niveau 3', 'Squelette renforcé niveau 1', 'Squelette renforcé niveau 2', 'Squelette renforcé niveau 3', 'Armatures enrichies niveau 1', 'Armatures enrichies niveau 2', 'Armatures enrichies niveau 3', 'Composés avancés niveau 1', 'Composés avancés niveau 2', 'Composés avancés niveau 3', 'Alliage niveau 1', 'Alliage niveau 2', 'Alliage niveau 3', 'Alliage avancé niveau 1', 'Alliage avancé niveau 2', 'Alliage avancé niveau 3', 'Armure moléculaire niveau 1', 'Armure moléculaire niveau 2', 'Armure moléculaire niveau 3'),
array('Tourelle légère M202 XP', 'Canon de défense automatique', 'Artillerie lourde de 440mm', 'Lance-missiles Archer', 'Batterie de missiles Anaconda', 'Silo de missiles Shiva', 'Canon à accélération magnétique'),
- array('Prototype Intercepteur Longsword', 'Prototype Bombardier Longsword', 'Corvette de classe Mako', 'Prototype de Frégate', 'Récupération', 'Prototype de Croiseur de classe Halcyon', 'Prototype de Croiseur de classe Marathon', 'Prototype de Destroyer', 'Prototype de Porte-vaisseaux', 'Prototype de Super Porte-Vaisseaux', 'Prototype de Vaisseau d\'exfiltration de classe Black Cat', 'Prototype de Super canon à accélération magnétique', 'Bunker souterrain', 'Bunker souterrain', 'Bunker souterrain'),
+ array('Prototype Intercepteur Longsword', 'Prototype Bombardier Longsword', 'Corvette de classe Mako', 'Prototype de Frégate', 'Récupération', 'Prototype de Destroyer', 'Prototype de Croiseur de classe Halcyon', 'Prototype de Croiseur de classe Marathon', 'Prototype de Porte-vaisseaux', 'Prototype de Super Porte-Vaisseaux', 'Prototype de Vaisseau d\'exfiltration de classe Black Cat', 'Prototype de Super canon à accélération magnétique', 'Bunker souterrain', 'Bunker souterrain', 'Bunker souterrain'),
array('Expansion niveau 1', 'Expansion niveau 2', 'Expansion niveau 3', 'Expansion niveau 4', 'Expansion niveau 5', 'Expansion niveau 6', 'Expansion niveau 7', 'Expansion niveau 8', 'Expansion niveau 9', 'Expansion niveau 10', 'Expansion niveau 11', 'Expansion niveau 12', 'Expansion niveau 13', 'Expansion niveau 14', 'Expansion niveau 15', 'Expansion niveau 16', 'Expansion niveau 17', 'Expansion niveau 18')
);
$technode = array( 'Le résultat absolu de l\'informatique. L\'IA ou Intelligence Artificielle est le résultat d\'années de travail acharné pour pouvoir en arriver à cette grande performance technique. Les IA sont des entités non biologiques dotées du pouvoir de la pensée. Développer cette technologie vous permettra non seulement de disposer d\'Intelligences Artificielles, mais de les rendre de plus en plus complexes, créatives et réactives.',
@@ -232,8 +232,8 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
'Les bases de données du CSNU enregistrent des informations de jours en jours. Toutefois il arrive que celles-ci parviennent à saturation et ne peuvent ainsi traiter qu\'un nombre limité d\'informations. Afin de résoudre ce problème, il est possible d\'améliorer la capacité de vos unités de stockage afin de gérer plus d\'informations. Chaque évolution de cette technologie vous permet de rajouter une unité supplémentaire dans votre file d\'attente.');
$technoli = array('IA4.jpg','radar7zr.jpg','arme.png','blindage.jpg','plasma4yl.jpg','reacteuracombustion.jpg','reacteurfusiontype1al5.jpg','reacteurfusiontype2nn6.jpg','medecin1.jpg','tactique.jpg','armuremc8ij.jpg','../humain_na.jpg');
- $nomvaisn = array('Cargos de classe Parabola', 'Cargos de classe Laden', 'Vaisseau de colonisation de classe Odyssey','Recycleur','Intercepteur Longsword', 'Bombardier Longsword', 'Corvette de classe Mako', 'Frégate', 'Croiseur de classe Halcyon', 'Croiseur de classe Marathon', 'Destroyer', 'Porte-vaisseaux', 'Super Porte-Vaisseaux', 'Vaisseau d\'exfiltration de classe Black Cat');
- $nomvaisi = array('csnucargoparabola2mc9.jpg','csnucargoladen2al8.jpg','colonisation.jpg','../humain_na.jpg','longsworduf9.jpg','../humain_na.jpg','../humain_na.jpg','frgatecopiegw1.jpg','halcyo15.jpg','qsu169.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg');
+ $nomvaisn = array('Cargos de classe Parabola', 'Cargos de classe Laden', 'Vaisseau de colonisation de classe Odyssey','Recycleur','Intercepteur Longsword', 'Bombardier Longsword', 'Corvette de classe Mako', 'Frégate', 'Destroyer', 'Croiseur de classe Halcyon', 'Croiseur de classe Marathon', 'Porte-vaisseaux', 'Super Porte-Vaisseaux', 'Vaisseau d\'exfiltration de classe Black Cat');
+ $nomvaisi = array('csnucargoparabola2mc9.jpg','csnucargoladen2al8.jpg','colonisation.jpg','../humain_na.jpg','longsworduf9.jpg','../humain_na.jpg','../humain_na.jpg','frgatecopiegw1.jpg','../humain_na.jpg','halcyo15.jpg','qsu169.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg');
$nomvaisd = array( 'Ces cargos de taille conséquente peuvent transporter assez de ressources et de nourriture pour nourrir une petite ville. Ils sont rapides, très manœuvrables mais peu résistants, ce qui est en fait des proies faciles pour les chasseurs ennemis.',
'Ces cargos de taille massive permettent le transport d\'une énorme quantité de ressources. Ils sont plus résistants que leurs homologues de classe Parabola, mais sont néanmoins les cibles prioritaires des chasseurs ennemis visant à faire le plus de pertes dans le camp adverse.',
'~#DESCRIPTION MANQUANTE#~',
@@ -248,7 +248,7 @@ if (!isset($auth_level)) @$auth_level = $sess->values['auth_level'];
'~#DESCRIPTION MANQUANTE#~',
'~#DESCRIPTION MANQUANTE#~',
'~#DESCRIPTION MANQUANTE#~');
- $nomvaisa = array('cargos de classe Parabola','cargos de classe Laden','vaisseau(x) de colonisation de classe Odyssey','recycleur(s)','intercepteur(s) Longsword','bombardier(s) Longsword','corvette(s) de classe Mako','Frégates','croiseur(s) de classe Halcyon','croiseur(s) de classe Marathon','destroyer(s)','porte-vaisseaux','supers porte-vaisseaux','vaisseau(x) d\'exfiltration de classe Black Cat');
+ $nomvaisa = array('cargos de classe Parabola','cargos de classe Laden','vaisseau(x) de colonisation de classe Odyssey','recycleur(s)','intercepteur(s) Longsword','bombardier(s) Longsword','corvette(s) de classe Mako','Frégates','destroyer(s)','croiseur(s) de classe Halcyon','croiseur(s) de classe Marathon','porte-vaisseaux','supers porte-vaisseaux','vaisseau(x) d\'exfiltration de classe Black Cat');
$nomterra = array( 'sparrowhawk','077-TC Pelican','C703 Shortsword Bomber','SHD Albatros','M12 LRV Warthogs','M12G1 LAAV Warthogs','M12A1 LAAV Warthogs','M808B Scorpions MBT',
'tourelle(s) légère(s) M202 XP','lance(s)-missiles Archer','canon(s) de défense automatique(s)','batterie(s) de missiles Anaconda','artillerie(s) lourde(s) de 440mm', 'silo(s) de missiles Shiva', 'canon(s) à accélération magnétique', 'super(s) canon à accélération magnétique');
diff --git a/game/tables.php b/game/tables.php
index 74ed51f..e4172de 100644
--- a/game/tables.php
+++ b/game/tables.php
@@ -7,6 +7,7 @@ if ($config['db_type'] == "postgresql") {
$table_alliances_creation = '"public"."'.$config['db_prefix'].'alliances_creation"';
$table_alliances_grade = '"public"."'.$config['db_prefix'].'alliances_grade"';
$table_bourse = '"public"."'.$config['db_prefix'].'bourse"';
+ $table_bourse_ressources = '"public"."'.$config['db_prefix'].'bourse_ressources"';
$table_bug = '"public"."'.$config['db_prefix'].'bug"';
$table_classement = '"public"."'.$config['db_prefix'].'classement'.(floor((time()-$config['time_maintenance'])/86400)%2).'"';
$table_classement_alliances = '"public"."'.$config['db_prefix'].'classement_alliances'.(floor((time()-$config['time_maintenance'])/86400)%2).'"';
@@ -34,6 +35,7 @@ elseif ($config['db_type'] == "mysql") {
$table_alliances_emprunt = $config['db_prefix'].'alliances_emprunt';
$table_alliances_grade = $config['db_prefix'].'alliances_grade';
$table_bourse = $config['db_prefix'].'bourse';
+ $table_bourse_ressources = $config['db_prefix'].'bourse_ressources';
$table_bug = $config['db_prefix'].'bug';
$table_classement = $config['db_prefix'].'classement'.(floor((time()-$config['time_maintenance'])/86400)%2);
$table_classement_alliances = $config['db_prefix'].'classement_alliances'.(floor((time()-$config['time_maintenance'])/86400)%2);
diff --git a/game/vars.php b/game/vars.php
index 1133563..38f7f91 100644
--- a/game/vars.php
+++ b/game/vars.php
@@ -123,73 +123,73 @@ array(
),
0
);
-$batimentVAR = array('mine_m','mine_c','mine_h','centrale_s','centrale_f','radar','labo','chantier_terrestre','chantier_spatial','caserne','silo','centre_info');//,'habitation','arcologie','commercial','loisir','administration');
+$batimentVAR = array('mine_m','mine_c','mine_h','centrale_s','centrale_f','radar','labo','chantier_terrestre','chantier_spatial','caserne','silo','centre_info','habitation','arcologies','bunker','commercial','loisir','administration');
$batimentCALC = array(
array(
'$a = ceil(pow(1.5,$n)*68);',
'$b = ceil(pow(1.5,$n)*17);',
'$c = 0;',
- '$sec = (ceil(1.02*(3/(1+$planete->batiments[11]))*pow(1.5,$n))*(1/(1+$planete->casernes[7]*0.005)))*60;'
+ '$sec = pow(1.5,$n)*6;'
),
array(
'$a = ceil(pow(1.6,$n)*53);',
'$b = ceil(pow(1.6,$n)*27);',
'$c = 0;',
- '$sec = (ceil(1.2*(3/(1+$planete->batiments[11]))*pow(1.55,$n))*(1/(1+$planete->casernes[7]*0.005)))*60;'
+ '$sec = pow(1.55,$n)*6;'
),
array(
'$a = ceil(pow(1.5,$n)*242);',
'$b = ceil(pow(1.5,$n)*72);',
'$c = 0;',
- '$sec = (ceil(1.5*(3/(1+$planete->batiments[11]))*pow(1.624,$n))*(1/(1+$planete->casernes[7]*0.005)))*60;'
+ '$sec = pow(1.624,$n)*6;'
),
array(
'$a = ceil(pow(1.5,$n)*92);',
'$b = ceil(pow(1.5,$n)*37);',
'$c = 0;',
- '$sec = (ceil(1.36*(3/(1+$planete->batiments[11]))*pow(1.597,$n))*(1/(1+$planete->casernes[7]*0.005)))*60;'
+ '$sec = pow(1.597,$n)*6;'
),
array(
'$a = ceil(pow(1.73,$n)*800);',
'$b = ceil(pow(1.73,$n)*420);',
'$c = ceil(pow(1.68,$n)*285);',
- '$sec = (ceil(1.8*(3/(1+$planete->batiments[11]))*pow(1.7,$n))*(1/(1+$planete->casernes[7]*0.005)))*60;'
+ '$sec = pow(1.7,$n)*6;'
),
array(
'$a = ceil(pow(2,$planete->batiments[5])*750);',
'$b = ceil(pow(2,$planete->batiments[5])*500);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[5])*720)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[5])*720);'
),
array(
'$a = ceil(pow(2,$planete->batiments[6])*200);',
'$b = ceil(pow(2,$planete->batiments[6])*150);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[6])*720)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[6])*720);'
),
array(
'$a = ceil(pow(2,$planete->batiments[7])*520);',
'$b = ceil(pow(2,$planete->batiments[7])*380);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[7])*420)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[7])*420);'
),
array(
'$a = ceil(pow(2,$planete->batiments[8])*600);',
'$b = ceil(pow(2,$planete->batiments[8])*450);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[8])*600)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[8])*600);'
),
array(
'$a = ceil(pow(2,$planete->batiments[9])*200);',
'$b = ceil(pow(2,$planete->batiments[9])*100);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[9])*300)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[9])*300);'
),
array(
'$a = ceil(pow(2,$planete->batiments[10])*400);',
'$b = ceil(pow(2,$planete->batiments[10])*260);',
'$c = 0;',
- '$sec = ceil((pow(2,$planete->batiments[10])*1200)/(pow(1.23,$planete->batiments[11])+0.0025*$planete->casernes[7]));'
+ '$sec = ceil(pow(2,$planete->batiments[10])*1200);'
),
array(
'$a = ceil(pow(1.7,$planete->batiments[11])*600);',
@@ -197,11 +197,43 @@ $batimentCALC = array(
'$c = ceil(pow(1.7,$planete->batiments[11])*100);',
'$sec = ceil((pow(1.9,$planete->batiments[11])*800)/((0.0025*$planete->casernes[7])+1));'
),
- array(),
- array(),
- array(),
- array(),
- array()
+ //Module rsidentiel
+ array(
+ '$a = ceil(pow($planete->batiments[12],2.075)*1000+1500);',
+ '$b = ceil(pow($planete->batiments[12],1.8)*1000+1000);',
+ '$c = 0;',
+ '$sec = ceil(pow($planete->batiments[12],2.5)*60+4)*60;'
+ ),
+ array(
+ '$a = ceil(pow($planete->batiments[13],2.8)*1000+299000);',
+ '$b = ceil(pow($planete->batiments[13],2.5)*1000+149000);',
+ '$c = 0;',
+ '$sec = ceil(pow($planete->batiments[13],1.6)*60+60)*60;'
+ ),
+ array(
+ '$a = ceil(pow($planete->batiments[14],2)*1200+140000);',
+ '$b = ceil(pow($planete->batiments[14],2)*900+99000);',
+ '$c = ceil(pow($planete->batiments[14],2)*500+30000);',
+ '$sec = ceil(pow($planete->batiments[14],2)*5+3)*60;'
+ ),
+ array(
+ '$a = ceil(pow($planete->batiments[15],2)*1000+80000);',
+ '$b = ceil(pow($planete->batiments[15],2)*750+65000);',
+ '$c = 0;',
+ '$sec = pow($planete->batiments[15],2)*240;'
+ ),
+ array(
+ '$a = ceil(pow($planete->batiments[16],2)*850+60000);',
+ '$b = ceil(pow($planete->batiments[16],2)*650+50000);',
+ '$c = 0;',
+ '$sec = pow($planete->batiments[16],2)*180;'
+ ),
+ array(
+ '$a = ceil(pow($planete->batiments[17],2.5)*500 -300);',
+ '$b = ceil(pow($planete->batiments[17],2.4)*400-250);',
+ '$c = 0;',
+ '$sec = pow($planete->batiments[17],1.65)*3600;'
+ )
);
$batimentTECH = array(
0,
@@ -225,8 +257,12 @@ $batimentTECH = array(
array($technolo[1][12], 'techno_inge', 4096)
),
0,
+ 0,
array(
- array($technolo[3][8], 'techno_poli', 256)
+ array($technolo[7][12], 'techno_proj', 4096)
+ ),
+ array(
+ array($technolo[7][11], 'techno_proj', 2048)
),
array(
array($technolo[3][6], 'techno_poli', 64)
diff --git a/halo-battle/.buildpath b/halo-battle/.buildpath
new file mode 100644
index 0000000..9ce47f1
--- /dev/null
+++ b/halo-battle/.buildpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/halo-battle/.project b/halo-battle/.project
new file mode 100644
index 0000000..8d72b93
--- /dev/null
+++ b/halo-battle/.project
@@ -0,0 +1,28 @@
+
+
+ Halo-Battle
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ org.eclipse.dltk.core.scriptbuilder
+
+
+
+
+
+ org.eclipse.php.core.PHPNature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/htdocs/.htaccess b/htdocs/.htaccess
index e69de29..095d346 100644
--- a/htdocs/.htaccess
+++ b/htdocs/.htaccess
@@ -0,0 +1,7 @@
+Options -Indexes
+ErrorDocument 403 403.html
+ErrorDocument 404 404.html
+
+
+
+
diff --git a/htdocs/.onyx b/htdocs/.onyx
index cbfc0f6..df5cc17 100644
--- a/htdocs/.onyx
+++ b/htdocs/.onyx
@@ -1 +1 @@
-C:/Program Files/xampp/var/HB_new/onyx/
\ No newline at end of file
+/var/www/halo-battle/onyx2/load.php
diff --git a/htdocs/admin.php b/htdocs/admin.php
index 9209420..7c6f5fb 100644
--- a/htdocs/admin.php
+++ b/htdocs/admin.php
@@ -1,92 +1,108 @@
values['connected']) && $sess->values['connected'] && !empty($sess->values['id']) && !empty($sess->level) && $sess->level >= 3 && !empty($sess->values['idPlan']) && $sess->values['id'] != "172") {
- function infoPlan($galaxie, $ss, $pos, $info){
- $base = new bdd();
- $base->connexion();
- $resultat = $base->unique_query("SELECT * FROM planete WHERE galaxie = '$galaxie' AND ss = '$ss' AND position= '$pos';");
- $base->deconnexion();
- return $resultat[$info];
- }
-
- //Connexion à la base de données
- $chapeau = new bdd();
- $chapeau->connexion();
-
- //Passage des valeurs générales au template
- $titre = "Administration";
- $template->assign('page','admin');
- $template->assign('premiere_page', $config['first_page']);
-
- $chapeau->unique_query("SELECT * FROM $table_user WHERE race = 'covenant'");
- $nbcovie = $chapeau->num_rows;
- $chapeau->unique_query("SELECT * FROM $table_user WHERE race = 'humain'");
- $nbhumain = $chapeau->num_rows;
- $template->assign('count',array('humains' => $nbhumain, 'covenants' => $nbcovie, 'serveurs' => 'cette'));
-
- $id_user = $sess->values['id'];
- $queryUser = $chapeau->unique_query("SELECT * FROM $table_user WHERE id = '$id_user'");
- $chapeau->deconnexion();
-
- $race = $queryUser['race'];
- $template->assign('race',$queryUser['race']);
- $template->assign('user',$queryUser);
- $tpsdejeu = time() - $queryUser['last_visite'];
- $heur = floor($tpsdejeu/3600);
- $min = floor(($tpsdejeu - $heur*3600)/60);
- if ($heur > 0) $min = $heur.' h '.$min;
- $template->assign('tpsdejeu',$min.' min');
-
- if (!empty($sess->values['souscontrole'])) {
- $pagea = 'erreur';
-
- $sess->values['id'] = $sess->values['souscontrole'][0];
- $sess->values['idPlan'] = $sess->values['souscontrole'][1];
- $sess->values['souscontrole'] = null;
- $sess->put();
-
- $template->assign('message', 'Droits rétablis avec succès ! ');
- }
- else {
- if (!isset($_GET['p'])) $_GET['p'] = '';
- if ($sess->level >= 5) {
- switch($_GET['p']){
- case 'djoueurs': include(_FCORE."../game/jeu/admin/supprimer_joueur.php"); break;
- case 'bandeau': include(_FCORE."../game/jeu/admin/bandeau.php"); break;
- case 'demarrage': include(_FCORE."../game/jeu/admin/demarrage.php"); break;
- case 'version': include(_FCORE."../game/jeu/admin/version.php"); break;
- case 'inscription': include(_FCORE."../game/jeu/admin/inscription.php"); break;
+if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->level) && $SESS->level >= 3 && !empty($SESS->values['idPlan']))
+ {
+ function infoPlan($galaxie, $ss, $pos, $info)
+ {
+ $base = new BDD();
+ $resultat = $base->unique_query("SELECT * FROM planete WHERE galaxie = '$galaxie' AND ss = '$ss' AND position= '$pos';");
+ $base->deconnexion();
+ return $resultat[$info];
}
- }
- if (empty($pagea)) {
- switch($_GET['p']){
- case 'courrier': include(_FCORE."../game/jeu/admin/mail.php"); break;
- case 'vip': include(_FCORE."../game/jeu/admin/ip.php"); break;
- case 'vflotte': include(_FCORE."../game/jeu/admin/flottes.php"); break;
- case 'vplanetes': include(_FCORE."../game/jeu/admin/planete.php"); break;
- case 'vjoueurs': include(_FCORE."../game/jeu/admin/joueur.php"); break;
- case 'valliances': include(_FCORE."../game/jeu/admin/alliance.php"); break;
- case 'vrapports': include(_FCORE."../game/jeu/admin/rapport.php"); break;
- case 'sjoueurs': include(_FCORE."../game/jeu/admin/sanction_joueur.php"); break;
- case 'cjoueurs': include(_FCORE."../game/jeu/admin/prendre_controle.php"); break;
- default: include(_FCORE."../game/jeu/admin/accueil.php"); break;
+
+ //Passage des valeurs générales au template
+ $titre = "Administration";
+ $template->assign('page', 'admin');
+ $template->assign('menu', $VAR['menu']);
+ $template->assign('premiere_page', $VAR['first_page']);
+ $template->assign('race', $SESS->values['race']);
+ $template->assign("tpsdejeu", "un certain temps");
+
+ if (!empty($SESS->values['souscontrole']))
+ {
+ $pagea = 'erreur';
+
+ $SESS->values['id'] = $SESS->values['souscontrole'][0];
+ $SESS->values['idPlan'] = $SESS->values['souscontrole'][1];
+ $SESS->values['souscontrole'] = null;
+ $SESS->put();
+
+ $template->assign('message', 'Droits rétablis avec succès ! ');
}
- }
+ else
+ {
+ if (!isset($_GET['p']))
+ $_GET['p'] = '';
+ if ($SESS->level >= 5)
+ {
+ switch($_GET['p'])
+ {
+ case 'djoueurs':
+ include("admin/supprimer_joueur.php");
+ break;
+ case 'bandeau':
+ include("admin/bandeau.php");
+ break;
+ case 'demarrage':
+ include("admin/demarrage.php");
+ break;
+ case 'version':
+ include("admin/version.php");
+ break;
+ case 'inscription':
+ include("admin/inscription.php");
+ break;
+ }
+ }
+ if (empty($pagea))
+ {
+ switch($_GET['p'])
+ {
+ case 'courrier':
+ include("admin/mail.php");
+ break;
+ case 'vip':
+ include("admin/ip.php");
+ break;
+ case 'vflottes':
+ include("admin/flottes.php");
+ break;
+ case 'vplanetes':
+ include("admin/planete.php");
+ break;
+ case 'vjoueurs':
+ include("admin/joueur.php");
+ break;
+ case 'valliances':
+ include("admin/alliance.php");
+ break;
+ case 'vrapports':
+ include("admin/rapport.php");
+ break;
+ case 'sjoueurs':
+ include("admin/sanction_joueur.php");
+ break;
+ case 'cjoueurs':
+ include("admin/prendre_controle.php");
+ break;
+ default:
+ include("admin/accueil.php");
+ break;
+ }
+ }
+ }
+
+ $template->assign('titre', $titre);
+ $template->assign('pagea', $pagea);
+ $template->display('admin/'.$pagea.'.tpl');
}
-
- $template->assign('titre',$titre);
- $template->assign('pagea',$pagea);
- $template->display('admin/'.$pagea.'.tpl');
-}
-else header('Location: index.php');
-?>
\ No newline at end of file
+else
+ header('Location: '.$VAR['first_page']);
+?>
diff --git a/htdocs/ajax_flotte.php b/htdocs/ajax_flotte.php
index 5063341..49d84f1 100644
--- a/htdocs/ajax_flotte.php
+++ b/htdocs/ajax_flotte.php
@@ -3,7 +3,7 @@ define("INDEX", 1);
$chrono_start = microtime();
$onyx = @file_get_contents('./.onyx') or die("Configuration introuvable.");
define("_FCORE",trim($onyx));
-require(_FCORE."hb_game/Class/JSON.php");
+require(_FCORE."../game/Class/JSON.php");
require_once(_FCORE."common.php");
if (isset($sess) && isset($sess->values['connected']) && $sess->values['connected'] && !empty($sess->values['id']) && !empty($sess->level) && !empty($sess->values['idPlan'])) {
@@ -47,6 +47,8 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
if (!empty($sess->values['flcontenu']) && $met+$cri+$hyd >= 0 && $met >= 0 && $cri >= 0 && $hyd >= 0) $places = $sess->values['flcontenu'] - ($met+$cri+$hyd);
else $places = 'inconnu';
+
+
if (empty($sess->values['fltime']) || $sess->values['fltime'] + 600 < time() || empty($sess->values['flnbvais']) || empty($sess->values['flvitesse']) && isset($sess->values['auth_level']))
$datas = array(
'root' => array(
diff --git a/htdocs/arbre.php b/htdocs/arbre.php
new file mode 100644
index 0000000..75c4e98
--- /dev/null
+++ b/htdocs/arbre.php
@@ -0,0 +1,41 @@
+ $branche)
+ {
+ print "
';
+
+ if (isset($_GET["check"]))
+ {
+ print 'Contrôle de la somme de la dernière validation ...';
+ if (sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php')) == $_GET["check"])
+ print ' Authentique
';
+ else
+ die (' Invalide ! Arrêt du processus de vérification !');
+ }
+ else
+ print 'Les résultats présentés ci-dessus ne peuvent pas être authentifiés sans la somme d\'un précédent contrôle, rien ne dit que les fichiers de validation n\'ont pas été modifiés !
Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla Bla bla bla bla bla bla bla bla bla bla bla