From 977a27f991a9e18fa659844f025aa11543674b02 Mon Sep 17 00:00:00 2001 From: Nigel Sheldon Date: Sun, 22 Nov 2020 14:38:17 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20function=20pour=20r=C3=A9cup?= =?UTF-8?q?=C3=A9rer=20le=20niveau=20d'une=20techno=20d'un=20joueur,=20ain?= =?UTF-8?q?si=20que=20le=20niveau=20max=20que=20peut=20avoir=20cette=20tec?= =?UTF-8?q?hno?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- onyx2/include/Class/Donnees/technologies.php | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/onyx2/include/Class/Donnees/technologies.php b/onyx2/include/Class/Donnees/technologies.php index 2612938..7b23ba8 100644 --- a/onyx2/include/Class/Donnees/technologies.php +++ b/onyx2/include/Class/Donnees/technologies.php @@ -1442,6 +1442,42 @@ class dTechnologies implements Donnees } } + public static function niveau_du_joueur($branche, $id, surface $planete) + { + $niveau = 0; + // Si jamais cette techno a été recherchée au niveau 2 ou 3, aditionne les niveaux des trois technos + if (($niv = self::niveau($branche, $id)) > 0 && (self::idToBit($id) & $planete->technologies[$branche])) { + if ((self::idToBit($id+1) & $planete->technologies[$branche])) { + $niveau += $niv; + } + $niveau += $niv; + } + if (self::idToBit($id) & $planete->technologies[$branche]) { + // Gère les technos qui n'ont qu'un seul niveau + $ret = self::niveau($branche, $id); + if ($ret == 0) { + $niv = 1; + } else { + $niv = $ret; + } + $niveau += $niv; + } + return $niveau; + } + + + public static function niveau_max($branche, $id, surface $planete, $LANG) + { + $niveau_max = 1; + if ((self::idToBit($id) & $planete->technologies[$branche]) && isset($LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id+1]) && $LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id] == $LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id+1]) { + if (isset($LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id+2]) && $LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id+1] == $LANG[$planete->race]["technologies"]["noms_sing"][$branche][$id+2]) { + $niveau_max = 3; + } else { + $niveau_max = 2; + } + } + return $niveau_max; + } /* Fonction qui transpforme l'id d'une technologie en son équivalent en bit dans la liste */ public static function idToBit($id)