Prochaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes |
fr:developpers:documentation_library_formula [2021/01/22 22:55] – Création initiale pitch314 | fr:developpers:documentation_library_formula [2021/01/27 22:22] – pitch314 |
---|
* côté PHP (includes/ogame.php), complète permettant d'aider la manipulation des formules Ogame dans les pages OGSpy comme dans les mod. | * côté PHP (includes/ogame.php), complète permettant d'aider la manipulation des formules Ogame dans les pages OGSpy comme dans les mod. |
* programmation terminée | * programmation terminée |
* côté JS (js/ogame_formula.js), les fonctions nécessaires à des utilisations dynamiques (production, consommation, temps, coût, ect.) | * côté JS (js/ogame_formula.js), les fonctions nécessaires à des utilisations dynamiques (production, consommation, temps, coût, etc.) |
* programmation en cours | * programmation en cours |
| |
| <note important>En Javascript, les tableaux sont des objets et sont manipulés par référence (comme en C), pointant vers la localisation du tableau. |
| |
| Contrairement au PHP, il n'y pas de copie explicite ($a = $b), il faut copier manuellement les éléments si l'on veut garder les valeurs du tableau originel.</note> |
| |
===== Types et fonctions de base ===== | ===== Types et fonctions de base ===== |
La manipulation des ressources est un type sous la forme d'un tableau contenant toutes les ressources. | La manipulation des ressources est un type sous la forme d'un tableau contenant toutes les ressources. |
<code php PHP> | <code php PHP> |
/** @brief Get an Ogame ressources array. | /** @brief Get an Ogame resources array. |
* | * |
* @param[in] int $metal,$cristal,$deut The needed ressources | * @param[in] int $metal,$cristal,$deut The needed resources |
* @param[in] int $NRJ,$AM Optional ressources (0 default) | * @param[in] int $NRJ,$AM Optional resources (0 default) |
* @return array('M','C','D','NRJ','AM'), default is 0 | * @return array('M','C','D','NRJ','AM'), default is 0 |
*/ | */ |
function ogame_array_ressource($metal, $cristal, $deut, $NRJ = 0, $AM = 0); | function ogame_array_ressource($metal, $cristal, $deut, $NRJ = 0, $AM = 0); |
| |
//Exemple d'initialisation | //Exemples d'initialisations |
$prod = ogame_array_ressource(0, 0, 0); | $prod = ogame_array_ressource(0, 0, 0); |
$prod['M'] = 44; | $prod['M'] = 44; |
$cout_base['M'] = ogame_array_ressource( 60 , 15 , 0); //Prix de base d'une mine de métal. | $cout_base['M'] = ogame_array_ressource( 60 , 15 , 0); //Prix de base d'une mine de métal. |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_arrayRessource($metal, $cristal, $deut, $NRJ = 0); |
| |
| //Exemples d'utilisations |
| var result = ogame_arrayRessource(0,0,0); |
| result['M'] = 44; |
</code> | </code> |
| |
La fonction suivante, et ses alter-ego (is ?), sont essentielles dans la manipulation automatique. | La fonction suivante, et ses alter-ego (is ?), sont essentielles dans la manipulation automatique. |
<code php PHP> | <code php PHP> |
/** @brief Give database names of a buiding/research/fleet/defence/class/ressources. | /** @brief Give database names of a building/research/fleet/defence/class/ressources. |
* | * |
* @return array('BAT'=>array, 'RECH'=>array, 'VSO'=>array, 'DEF'=>array, 'CLASS'=>array, 'RESS'=>array) | * @return array('BAT'=>array, 'RECH'=>array, 'VSO'=>array, 'DEF'=>array, 'CLASS'=>array, 'RESS'=>array) |
'Lab', //Laboratoire | 'Lab', //Laboratoire |
'Ter', //Terraformeur | 'Ter', //Terraformeur |
'DdR', //Dépot de ravitaillement | 'DdR', //Dépôt de ravitaillement |
'Silo', //Silo de missiles | 'Silo', //Silo de missiles |
'Dock', //Dock spatial | 'Dock', //Dock spatial |
); | ); |
$names['RECH'] = array( // Recherches : | $names['RECH'] = array( // Recherches : |
'Esp', //Technologie espionage | 'Esp', //Technologie espionnage |
'Ordi', //Technologie ordinateur | 'Ordi', //Technologie ordinateur |
'Armes', //Technologie armes | 'Armes', //Technologie armes |
function ogame_is_a_research($nom) { return ogame_is_element($nom) === 'RECH'; } | function ogame_is_a_research($nom) { return ogame_is_element($nom) === 'RECH'; } |
| |
//Exemple d'utilisations : | //Exemples d'utilisations : |
$names = ogame_get_element_names(); | $names = ogame_get_element_names(); |
| |
//Faire quelque chose spécifique pour les vaisseaux | //Faire quelque chose spécifique pour les vaisseaux |
} | } |
| } |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_getElementNames(); |
| function ogame_isElement(nom); |
| |
| //Exemples (utilisation comme en PHP) |
| var names = ogame_getElementNames(); |
| for(var elem in names['RESS']) { //elem ici vaut un entier pour parcourir les noms |
| elem = names['RESS'][elem] |
| result['prod_reel'][elem] = Math.floor(result['prod_base'][elem]); |
} | } |
</code> | </code> |
===== Formules liées à la production ===== | ===== Formules liées à la production ===== |
LA fonction à utiliser pour calculer la production d'un empire est la suivante pour chaque planète : | LA fonction à utiliser pour calculer la production d'un empire est la suivante pour chaque planète : |
<code php> | <code php PHP> |
/** @brief Calculates planet production and consumption. | /** @brief Calculates planet production and consumption. |
* | * |
* @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates','M_percentage','C_percentage','D_percentage','CES_percentage','CEF_percentage','Sat_percentage','FOR_percentage',array 'booster_tab') 0 as default value | * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates','M_percentage','C_percentage','D_percentage','CES_percentage','CEF_percentage','Sat_percentage','FOR_percentage',array 'booster_tab') 0 as default value |
* @param[in] array $user_technology Techno info ('NRJ','Plasma') | * @param[in] array $user_technology Techno info ('NRJ','Plasma') |
* @param[in] array $user_data User info (array('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') | * @param[in] array $user_data User info ('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') |
* @param[in] array $server_config Ogame univers info ('speed_uni') | * @param[in] array $server_config Ogame universe info ('speed_uni') |
* @return array('prod_reel,'prod_theorique','ratio','conso_E','prod_E', //Production totale | * @return array('prod_reel, // (array ress) Production réel en prenant en compte le ratio (M/C/D ressources, NRJ prod moins la conso) |
* 'prod_CES','prod_CEF','prod_SAT','prod_FOR', //production énergie de chaque unité | * 'prod_theorique', // (array ress) Producton théorique M/C/D (ratio=1, 100%) |
* 'prod_M','prod_C','prod_D','prod_base', //production ressources de chaque mine | * 'ratio', // (float) le ratio de production NRJ (prod_E / conso_E) |
* 'prod_booster','prod_off','prod_Plasma','prod_classe', //production des bonus | * 'conso_E','prod_E', // (float) Production NRJ prod_E > 0, conso_E < 0 |
| * 'prod_CES','prod_CEF','prod_SAT', // (array ress) production énergie de chaque unité ('D' de prod_CEF contient la conso en deut de la CEF) |
| * 'prod_FOR', // (array ress) production M/C/D et conso NRJ |
| * 'prod_M','prod_C','prod_D','prod_base', // (array ress) Production ressources de chaque mine (M/C/D) et leur conso (NRJ) |
| * 'prod_booster','prod_off','prod_Plasma','prod_classe', // (array ress) Production des bonus |
* 'M','C','D','NRJ','AM', =>héritage du type ressource pour les valeurs retournées. | * 'M','C','D','NRJ','AM', =>héritage du type ressource pour les valeurs retournées. |
* 'nb_FOR_maxed', | * 'nb_FOR_maxed', // (int) Nombre max de foreuse utilisées |
* ) à part ratio/conso_E/prod_E (float) les autres sont array('M','C','D','NRJ','AM') | * ) à part ratio/conso_E/prod_E (float) les autres sont array('M','C','D','NRJ','AM') |
* | |
* @details remplace les fonctions ratio et bilan_production_ratio | |
*/ | */ |
function ogame_production_planet($user_building, $user_technology = null, $user_data = null, $server_config = null); | function ogame_production_planet($user_building, $user_technology = null, $user_data = null, $server_config = null); |
| |
//Exemple d'utilisations : | //Exemples d'utilisations : |
$user_empire = user_get_empire($user_data['user_id']); | $user_empire = user_get_empire($user_data['user_id']); |
$user_production = user_empire_production($user_empire, $user_data, $server_config['speed_uni']); //=>Vous devrez utiliser cette fonction qui fait le calcul d'un empire | $user_production = user_empire_production($user_empire, $user_data, $server_config['speed_uni']); //=>Vous devrez utiliser cette fonction qui fait le calcul d'un empire |
echo $planet_prod[1]['prod_M']['NRJ']; //=> consommation d'énergie de la mine de métal (!nombre négatif!) | echo $planet_prod[1]['prod_M']['NRJ']; //=> consommation d'énergie de la mine de métal (!nombre négatif!) |
echo $planet_prod[1]['prod_reel']['M']; //=> production totale de métal de la planète (mine,classe,officiers,booster,plasma,etc.) | echo $planet_prod[1]['prod_reel']['M']; //=> production totale de métal de la planète (mine,classe,officiers,booster,plasma,etc.) |
//Mais aussi individullement : | //Mais aussi individuellement : |
| |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_productionPlanet(user_building, user_technology=null, user_data=null, server_config=null); |
| |
| //Exemples d'utilisations |
| console.log(ogame_productionPlanet({M:38,C:34,D:34,CES:28,CEF:20,CEF_percentage:80,SAT:2200,FOR:858,FOR_percentage:150,coordinates:'::8',temperature_max:47},{Plasma:19,NRJ:20},{user_class:'COL'})); |
| </code> |
| |
| C'est cette fonction qui calcule la production en prenant tout en compte. C'est aussi la seule permettant de connaître la prod des différents bonus. |
| Sinon pour la production de base d'un bâtiment |
| <code php PHP> |
| /** @brief Calculates building/sat/for or base production and consumption. |
| * |
| * @param[in] string $building The wanted building/sat/for ('base','M','C','D','CES','CEF','SAT','FOR') |
| * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates') 0 as default value |
| * @param[in] array $user_technology Techno info ('NRJ') 0 as default value |
| * @param[in] array $user_data User info for FOR only (array('user_class'=>'COL'/...,'off_geologue' or 'off_full') |
| * @param[in] array $server_config Ogame universe info ('speed_uni',(bool)'final_calcul') / final_calcul permet de déterminer si les valeurs retournées seront manipulées avec les % de production ressources, et donc sans arrondi. |
| * @return array('M','C','D','NRJ','AM') of production |
| */ |
| function ogame_production_building($building, $user_building = null, $user_technology = null, $user_data = null, $server_config = null); |
| |
| //Exemples d'utilisations : |
| $prod = ogame_production_building('M',array('M'=>38,'coordinates'=>'2:2:8'),null,null,array('speed_uni'=>8); |
| //$prod['M'] = production d'une mine de métal 38 en position 8 sur un X8 |
| $prod = ogame_production_building('CEF',array('CEF'=>25),array('NRJ'=>20),null,array('speed_uni'=>8); |
| //$prod['NRJ'] = production d'énergie d'une centrale de fusion 25 avec la techno 20 |
| //$prod['D'] = la consommation (nombre négatif) de deutérium de cette CEF23 sur un univers X8 |
| $prod = ogame_production_building('FOR',array('FOR'=>800,'M'=>35,'C'=>35,'D'=>35),null,array('user_class'=>'COL','off_ingenieur'=>1),array('speed_uni'=>8); |
| //$prod[M/C/D] = la production des FOR pour mines 35/35/35 en fonction de la classe, en fonction du nombre max de FOR autorisé (8*MCD + 10%COL+ing) sur un X8 |
| //$prod[NRJ] = la conso NRJ du nombre max de FOR autorisées de base (0-100%) |
| |
| //Connaître le nombre de FOR max : |
| /** @brief Calculates maximum number of foreuse. |
| * @param[in] int $mine_M,$mine_C,$mine_D Mine level |
| * @param[in] array $user_data array with class and officiers infos (array('user_class'=>'COL'/...,'off_geologue' or 'off_full')) |
| * @return int The max |
| */ |
| function ogame_production_foreuse_max($mine_M, $mine_C, $mine_D, $user_data); |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_productionBuilding(building, user_building=null, user_technology=null, user_data=null, server_config=null); |
| function ogame_productionForeuseMax(mine_M, mine_C, mine_D, user_data); |
| |
| //Exemples d'utilisations |
| console.log(ogame_productionBuilding('base',{M:38,CES:38,coordinates:'::8'},null,null,{speed_uni:8})) |
</code> | </code> |
| |
===== Formules des coûts ===== | ===== Formules des coûts ===== |
| Connaître le coût d'un élément (bat/vso/def/rech) notamment pour un évolution ou le prix de plusieurs défenses : |
| <code php PHP> |
| /** @brief Calculates price of an Ogame bat/vso/def/rech |
| * @param[in] string $name The chosen name, as in Database |
| * @param[in] int $level The chosen level for bat/rech or the number of def/vso |
| * @return array('M', 'C','D, 'NRJ') |
| */ |
| function ogame_element_cout($name, $level); |
| |
| //Exemples d'utilisations : |
| $cout = ogame_element_cout('M', 39); // Le prix en ressource d'une M39 |
| $cout = ogame_element_cout('NRJ', 21); // Le prix en ressource d'une NRJ21 |
| $cout = ogame_element_cout('EDLM', 1000); // Le prix en ressource de 1000 EDLM |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_elementCoutBase(name = 'all'); |
| </code> |
| |
| Afin de connaître le nombre total de ressource investit il faut utilisation la fonction suivante : |
| <code php PHP> |
| /** @brief Calculates the price of an Ogame element to it current level. |
| * |
| * @param[in] string $name Name of building/research/fleet/defence, like in name in database |
| * @param[in] int $level The current level or the number of fleet/defence |
| * @return array('M', 'C','D, 'NRJ') resources used to it current level |
| * NOTE : pour les vso/def cette fonction est identique à ogame_element_cout() |
| */ |
| function ogame_element_cumulate($name, $level); |
| |
| //Exemples d'utilisations |
| $cout = ogame_element_cumulate('M', 39); // Le nombre de ressource investit, en cumul, pour une M39 |
| </code> |
| |
| Néanmoins, dans le calcul des points d'une planète, il sera plus simple d'utiliser la fonction suivante : |
| <code php PHP> |
| /** @brief Calculates the price of all element of type (building,defence,fleet,research). |
| * |
| * @param[in] array $user Array of element each planet or moon |
| * @param[in] string $type Type of element ('BAT' pour bâtiment, 'RECH' pour recherche, 'DEF' pour défense, 'VSO' pour vaisseau) |
| * @return float Total price (M+C+D). |
| */ |
| function ogame_all_cumulate($user, $type); |
| |
| //Exemples d'utilisations : |
| $point_building = ogame_all_cumulate($user_empire['building'], 'BAT'); //à faire pour chaque planète |
| $point_defense = ogame_all_cumulate($user_empire['defense'], 'DEF'); //à faire pour chaque planète |
| $point_techno = ogame_all_cumulate($user_empire['technology'], 'RECH'); |
| $point_fleet = ogame_all_cumulate($user_fleet, 'VSO'); //Nécessite le mod-flotte pour un utilisateur |
| |
| $point_fleet_exp = ogame_all_cumulate($expedition_fleet, 'VSO'); //Soit pour la flotte la notre, l'alien/pirate ou pour les vaisseaux rapportés d'expédition. |
| //Il suffit que dans $expedition_fleet il y ait les id des vaiseaux (PT,GT, etc.) et leur nombre, tout le reste est ignoré. |
| </code> |
| |
| À tout hasard, si l'on veut le prix de la destruction d'un bâtiment : |
| <code php PHP> |
| /** @brief Calculates destroy price of a building. |
| * |
| * @param[in] string $name Building name, as in Database |
| * @param[in] int $level Building level |
| * @param[in] int $techno_ions Level of techno ions |
| * @return false|array('M', 'C','D, 'NRJ'), false if undestroyable |
| */ |
| function ogame_building_destroy($name, $level, $techno_ions = 0); |
| </code> |
| |
===== Formules du temps ===== | ===== Formules du temps ===== |
| <code php PHP> |
| /** @brief Calculates construction time of a OGame element bat/vso/def/rech. |
| * |
| * @param[in] string $name The name, like name in Database |
| * @param[in] int $level The level or number for def/vso |
| * @param[in] array $user_building Array of bat level ('CSp','UdR','UdN','Lab' / le reste est ignoré) |
| * @param[in] int $cumul_labo Number of cumulate lab network (only for rech) |
| * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return float Time in seconds |
| */ |
| function ogame_construction_time($name, $level, $user_building, $cumul_labo = 0, $user_class = 'none'); |
| |
===== Les caratéristiques Ogame ===== | //Exemples d'utilisations : |
| $temps_M = ogame_construction_time('M', 38, array('UdR'=>10,'UdN'=>8); //Temps de construction en seconde d'une M38 avec robot 10 et nanite 8. |
| $temps_RIP = ogame_construction_time('EDLM',1000,array('UdR'=>10,'UdN'=>8,'CSp'=>20); //Temps de construction en seconde de 1000RIP avec robot 10 et nanite 8 dans un chantier 20. |
| $temps_RIP = ogame_construction_time('EDLM',1000,$user_building); //Sinon plus automatique pour la planète courante |
| |
| $cumul_labo = ogame_labo_cumulate($user_empire['building'], $current_planet_id); //Si déterminé avec le labo d'un planète donnée |
| $cumul_labo = ogame_labo_cumulate($user_empire['building']); //Sinon en prennant les plus haut labos |
| $temp_NRJ = ogame_construction_time('NRJ', 21, array('Lab'=>20)); //Si l'on veut savoir sur 1 seul labo. |
| $temp_NRJ = ogame_construction_time('NRJ', 21, null, 200); //Temps de construction de NRJ21 avec 200 labo connectés. |
| $temp_NRJ = ogame_construction_time('NRJ', 21, null, 200, 'EXP'); //Temps de construction de NRJ21 avec 200 labos connectés et avec les -25% de l'explorateur. |
| |
| $a=ogame_construction_time('NRJ',21,array('Lab'=>18,'CSp'=>12,'UdR'=>10,'UdN'=>7),234); |
| $year=gmdate('Y',$a)-1970; |
| $week=gmdate('W',$a)-1; |
| $day=gmdate('z',$a)-$week*7; |
| echo $year.'a '.$week.'s '.$day.'j '.gmdate('H:i:s',$a);" //0a 21s 1j 17:37:13 |
| </code> |
| |
| ===== Formules liées à la flotte ===== |
| En préliminaire, un formule permettant de fournir la distance entre 2 coordonées : |
| <code php PHP> |
| /** |
| * @brief Calculates distance between 2 coordinates. |
| * |
| * @param[in] string $a, $b Coordinates ('g:s:p') |
| * 'g1:s1:p1'->'g2:s2:p2' : normal distance calcul |
| * ':s1:p1'->'x:s2:p2 : distance between system/planet (only system is ':s1:') |
| * '::p1'->'x:x:p2 : distance between planet |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', only these are checked) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @param[in] array $server_config Info of universe ('num_of_galaxies','num_of_systems','donutGalaxy','donutSystem' only these are checked) default 9/499/1/1 |
| * @return array(int 'distance','type') [default=O,'p'], type='g' for between galaxy, 's' for between system and 'p' for between a sub-system |
| */ |
| function ogame_fleet_distance($a, $b, $user_techno=null, $class='none', $server_config=null); |
| |
| //Exemples d'utilisations : |
| $distance = ogame_fleet_distance($coord_from, $coord_to, $server_config); |
| switch ($distance['type']) { |
| case 'g': //between galaxy |
| //faire quelque chose avec $distance['distance'] pour une distance entre galaxies |
| break; |
| case 's': //between system (so inside same galaxy) |
| //faire quelque chose avec $distance['distance'] pour une distance entre systèmes d'une même galaxie |
| break; |
| case 'p': //between sub-system (so in same galaxy and same system) |
| if ($distance['distance'] === 0) { // to moon/cdr |
| //faire quelque chose avec $distance['distance'] pour une distance sur la même planète (lune ou cdr) |
| } else { //to other planet in same system |
| //faire quelque chose avec $distance['distance'] pour une distance entre planète d'un même sous-système |
| } |
| break; |
| default: |
| break; |
| } |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_fleetDistance(a, b, user_techno=null, classe='none', server_config=null); |
| |
| //Exemples d'utilisations |
| var distance = ogame_fleetDistance(coord_from, coord_to, server_config); |
| </code> |
| |
| Pour connaître la consommation d'un stationnement ou expédition la fonction est la suivante : |
| <code php PHP> |
| /** @brief Calculates deut consummation for parking/expe of a fleet. |
| * @param[in] int $conso The conso of the fleet |
| * @param[in] int $hour Number of hours in parking |
| * @return float Deut conso for this hour of parking |
| */ |
| function ogame_fleet_conso_statio($conso, $hour); |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_fleetConsoStatio(conso, hour); |
| </code> |
| |
| <code php PHP> |
| /** |
| * @brief Calculates the slowest chip speed of a fleet. |
| * |
| * @param[in] array $fleet List of chips |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', le reste est ignoré) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return int the slowest speed |
| */ |
| function ogame_fleet_slowest_speed($fleet, $user_techno=null, $class='none'); |
| /** |
| * @brief Calculates time and conso to send a fleet. |
| * |
| * @param[in] string $coord_from,$coord_to Coordinates begin and end |
| * @param[in] array $fleet Array of fleet and their number (array('PT'=>10,etc.)) |
| * @param[in] int $speed_per Percentage of speed wanted |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', le reste est ignoré) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @param[in] array $server_config Info of universe ('num_of_galaxies','num_of_systems','donutGalaxy','donutSystem' only these are checked) default 9/499/1/1 |
| * @param[in] string $type Indicates specific mission ('statio'/'expe', 'fuite') |
| * @param[in] int $hour_mission Number of hour of the specific mission |
| * @return array('conso', 'time'), time in seconds (one trip only) |
| */ |
| function ogame_fleet_send($coord_from, $coord_to, $fleet, $speed_per=100, $user_techno=null, $class='none', $server_config=null, $type='', $hour_mission=0) |
| |
| //Exemples d'utilisations |
| ogame_fleet_send('1:1:1','1:1:1',array('PT'=>260),100,array('RC'=>20,'RI'=>17,'PH'=>16),'COL')); |
| echo gmdate('z:H:i:s',$a['time']); //jour:heure:minute:seconde |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_fleetSlowestSpeed(fleet, user_techno=null, classe='none'); |
| function ogame_fleetSend(coord_from, coord_to, fleet, speed_per=100, user_techno=null, classe='none', server_config=null, type='', hour_mission=0); |
| |
| //Exemples d'utilisations |
| var a=ogame_fleetSend('1:1:1','1:1:1',{'PT':260},100,{'RC':20,'RI':17,'PH':16},'COL'); |
| console.log(a); // { conso: 4, time: 117 } |
| var d = new Date(a['time']*1000); |
| console.log((d.getUTCDate()-1)+ ':'+ d.getUTCHours()+':'+d.getUTCMinutes()+':'+d.getUTCSeconds()) |
| </code> |
| |
| ===== Les caractéristiques Ogame ===== |
==== Les détails d'infos pour les vaisseaux et défenses ==== | ==== Les détails d'infos pour les vaisseaux et défenses ==== |
| Les vaisseaux et les défenses dans Ogame ont des caractéristiques supplémentaires définie permettant leur utilisation dans les combats (structure,attaque,bouclier,rapidfire fait et subi,consommation,vitesse,fret). |
| La fonction suivante permet de récupérer ses valeurs de base, mais si les technologies sont fournies en les calculant à la bonne valeur. |
| <code php PHP> |
| function ogame_elements_details_base($name = 'all'); //Si on veut seulement les détails de base |
| /** @brief Calculates technical data of a fleet or defence. |
| * |
| * @param[in] string $name The name, like name in Database |
| * @param[in] array $user_techno The array of technologies (utilisées : Armes/Bouclier/Protection/RC/RI/PH/Hyp) |
| * @param[in] string|int $classe The user class //array('none','COL','GEN','EXP') - (1=Collectionneur)[0=aucune, 2=général, 3=explorateur]) |
| * @return array('nom','structure','bouclier','attaque','vitesse','fret','conso',(array)'rapidfire',(bool)'civil',(array)'cout') of the wanted fleet or defence. |
| * rapidfire=array('PT'=>x, ...) array of all fleet and defence; if x>0 then again else from |
| * cout=array of ogame_element_cumulate()=array('M','C','D','NRJ) |
| */ |
| function ogame_elements_details($name, $user_techno = null, $classe = 'none'); |
| /** @brief Calculates technical data of all fleet/defence. |
| * @return array of all fleet/defence with are array of details from ogame_elements_details |
| */ |
| function ogame_all_details($user_techno = null, $classe = 0); |
| |
==== Les prérequis de chaque élement OGame ==== | $detail_PT = ogame_elements_details_base('PT'); |
| //identique à ogame_elements_details('PT'); |
| print_r($detail_PT); |
| // Array( 'nom'=>'PT',structure'=>4000,'Bouclier'=>10,'attaque'=>5,'vitesse'=>5000,'fret'=>5000,'conso'=>10,'civil'=>true,'cout'=>['M'=>2000,'C'=>2000,D/NRJ/AM=>0], |
| // rapidfire=>['SE'=>5,'SAT'=>5,'FOR'=>5 : rapidfire fait |
| // 'CLO'=>-3,'TRA'=>-3,'EDLM'=>-250 : rapidfire subi |
| // 'PT'=>0,GT'=>0, etc pour tout les autres vaisseaux] ) |
| $detail_PT = ogame_elements_details_base('PT',array('Armes'=>20,'Bouclier'=>20,'Protection'=>20,'RC'=>20,'RI'=>17,'Hyp'=>20),'COL'); |
| //ou simplement ogame_elements_details_base('PT',$user_techno,$user_data['user_class']); |
| //Calcule les les infos du PT en fonction des techno militaire 20/20/20, des techno de vitesse 20/17 et de l'hyperespace et de la classe pour le fret. |
| print_r($detail_PT); |
| // Array( 'nom'=>'PT',structure'=>12000,'Bouclier'=>30,'attaque'=>15,'vitesse'=>54000,'fret'=>11250,'conso'=>20,'civil'=>true,'cout'=>inchangé,'rapidfire'=>inchangé) |
| </code> |
| |
| Détails spécifique pour les flottes, sous-partie de PHP, qui n'offre seulement vitesse,fret et conso : |
| <code Javascript JS> |
| /** @brief Return fleet moving details of Ogame vso. |
| * @param[in] string name The name as in Database, all for all element |
| * @return array('vitesse','fret','conso',(bool)'civil') |
| */ |
| function ogame_fleetSubDetailsBase(name = 'all'); |
| /** @brief Calculates technical data of a fleet or defence. |
| * @return array('nom','vitesse','fret','conso',(bool)'civil') of the wanted fleet. |
| */ |
| function ogame_fleetSubDetails(name, user_techno = null, classe = 'none'); |
| |
| console.log(ogame_fleetSubDetails('PT',{'Hyp':18,'RC':21,'RI':17,'PH':16},'GEN')); |
| </code> |
| |
| ==== Les prérequis de chaque élément OGame ==== |
| La plus part des éléments Ogame ont des prérequis pour les débloquer, que ce soit un niveau de bâtiment, de technologies. |
| <code php PHP> |
| /** @brief Calculates technical data of Ogame requirement for bat/vso/def/rech. |
| * |
| * @param[in] string $nom The name, like name in Database |
| * @return array('none','COL','GEN','EXP' : bool for class, 'CES',etc. : int for all bat/rech name in database) |
| */ |
| function ogame_elements_requirement($name = 'all'); |
| /** @brief Calculates technical data of Ogame requirement of all building/research/fleet/defence. |
| * @return array of all building/research/fleet/defence with are array of requirement from ogame_elements_requirement |
| */ |
| function ogame_all_requirement(); |
| |
| //Exemples d'utilisations : |
| $requi_graviton = ogame_elements_requirement('Graviton'); |
| $names = ogame_get_element_names(); |
| foreach ($names['RECH'] as $element) { |
| if ($requi_graviton[$element] !== 0) { |
| echo 'Prérequis de la techno' . $element . 'au niveau minimum : ' . $requi_graviton[$element]; |
| } |
| } |
| $current_lab = $user_building['Lab']; |
| if ($current_lab < $requi_graviton['Lab']) { |
| echo 'Graviton impossible car le niveau du laboratoire est insiffisant (min=' . $requi_graviton['Lab'] . ').'; |
| } |
| </code> |
| |
===== Autres formules ===== | ===== Autres formules ===== |
| ==== Hangars ==== |
| Capacité des hangars : |
| <code php PHP> |
| /** @brief Calculates the planet storage capacity (taille hangar). |
| * @param[in] int $level Storage building level |
| * @return float capacity |
| */ |
| function ogame_depot_capacity($level); |
| </code> |
| |
| ==== Phalange ==== |
| Portée de la phalange : |
| <code php PHP> |
| /** @brief Calculates phalanx range. |
| * @param[in] int $level Level of the phalanx |
| * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return int Range in system |
| */ |
| function ogame_phalanx_range($level, $user_class = 'none'); |
| </code> |
| |
| ==== Missile ==== |
| Fonction en relation avec les missiles (portée et vitesse): |
| <code php PHP> |
| /** @brief Calculates MIP range. |
| * @param[in] int $impulsion Techno impulsion (RI) |
| * @return int Range in system |
| */ |
| function ogame_missile_range($impulsion = 1); |
| |
| /** @brief Calculates MIP speed. |
| * @param[in] int $nb_system Number of sub-system from current planet |
| * @param[in] int $speed_uni Universe speed |
| * @return int Speed in seconds |
| */ |
| function ogame_missile_speed($nb_system, $speed_uni = 1); |
| </code> |
| ==== Case avec terraformer ==== |
| <code php PHP> |
| /** @brief Calculates additional case given by terraformer. |
| * @param[in] int $level The terra level |
| * @return int Number of additional case |
| */ |
| function ogame_terra_case($level); |
| </code> |
| |
===== Fonctions utilitaires ===== | ===== Fonctions utilitaires ===== |
<code php> | <code php PHP> |
/** @brief Return planet position from coordinates. | /** @brief Return planet position from coordinates. |
* @param[in] string $coordinates planet coordinates (galaxy:system:position) | * @param[in] string $coordinates planet coordinates (galaxy:system:position) |
*/ | */ |
function ogame_find_planet_position($coordinates); | function ogame_find_planet_position($coordinates); |
| /** @brief Return coordinates in array. |
| * @param[in] string $string_coord Coordinates, in string like in Database ('2:3:4') |
| * @return array('g','s','p') of int, default is 0 ('::6' give planet position of 6) |
| */ |
| function ogame_find_coordinates($string_coord); |
| </code> |
| <code Javascript JS> |
| /** Voir description des fonctions côté PHP **/ |
| function ogame_findPlanetPosition(coordinates); |
| function ogame_findCoordinates(string_coord); |
</code> | </code> |
| |
===== Récapitulatif des prototypes de fonctions de la Ogame formula Library ===== | ===== Récapitulatif des prototypes de fonctions de la Ogame formula Library ===== |
<code php> | <code php> |
/** @brief Get an Ogame ressources array. | //////////////////////////// BASE fonctions : ////////////////////////////////// |
| /** @brief Get an Ogame resources array. |
* | * |
* @param[in] int $metal,$cristal,$deut The needed ressources | * @param[in] int $metal,$cristal,$deut The needed resources |
* @param[in] int $NRJ,$AM Optional ressources (0 default) | * @param[in] int $NRJ,$AM Optional resources (0 default) |
* @return array('M','C','D','NRJ','AM'), default is 0 | * @return array('M','C','D','NRJ','AM'), default is 0 |
*/ | */ |
*/ | */ |
function ogame_array_detail($structure, $bouclier, $attaque, $vitesse=0, $fret=0, $conso=0, $civil=true); | function ogame_array_detail($structure, $bouclier, $attaque, $vitesse=0, $fret=0, $conso=0, $civil=true); |
/** @brief Give database names of a buiding/research/fleet/defence/class/ressources. | /** @brief Give database names of a building/research/fleet/defence/class/resources. |
* | * |
* @return array('BAT'=>array, 'RECH'=>array, 'VSO'=>array, 'DEF'=>array, 'CLASS'=>array, 'RESS'=>array) | * @return array('BAT'=>array, 'RECH'=>array, 'VSO'=>array, 'DEF'=>array, 'CLASS'=>array, 'RESS'=>array) |
*/ | */ |
function ogame_find_planet_position($coordinates); | function ogame_find_planet_position($coordinates); |
| /** @brief Return coordinates in array. |
| * @param[in] string $string_coord Coordinates, in string like in Database ('2:3:4') |
| * @return array('g','s','p') of int, default is 0 ('::6' give planet position of 6) |
| */ |
| function ogame_find_coordinates($string_coord); |
| |
////////////PRODUCTION fonctions : | ////////////////////////// PRODUCTION fonctions : ////////////////////////////// |
/** | /** @brief Return position resources bonus in Ogame. |
* @brief Return position ressources bonus in Ogame. | |
* | |
* @param[in] int $position The wanted position | * @param[in] int $position The wanted position |
* @return array('M','C','D','NRJ','AM') of bonus, default is 0% | * @return array('M','C','D','NRJ','AM') of bonus, default is 0% |
*/ | */ |
function ogame_production_position($position); | function ogame_production_position($position); |
/** | /** @brief Calculates maximum number of foreuse. |
* @brief Calculates foreuse coefficient on base production. | * @param[in] int $mine_M,$mine_C,$mine_D Mine level |
* | * @param[in] array $user_data array with class and officiers infos (array('user_class'=>'COL'/...,'off_geologue' or 'off_full')) |
| * @return int The max |
| */ |
| function ogame_production_foreuse_max($mine_M, $mine_C, $mine_D, $user_data); |
| /** @brief Calculates foreuse coefficient on base production. |
* @param[in] array $user_building array of mines level and FOR number (array('M','C','D','FOR')) | * @param[in] array $user_building array of mines level and FOR number (array('M','C','D','FOR')) |
* @param[in] array $user_data array with class and officiers infos (array('user_class'=>'COL'/...,'off_geologue' or 'off_full')) | * @param[in] array $user_data array with class and officers infos (array('user_class'=>'COL'/...,'off_geologue' or 'off_full')) |
* @return array('bonus', 'nb_FOR_maxed') bonus=foreuse bonus coefficient ; nb_FOR_maxed=limit nb if too much | * @return array('bonus', 'nb_FOR_maxed') bonus=foreuse bonus coefficient ; nb_FOR_maxed=limit nb if too much |
*/ | */ |
function ogame_production_bonus_foreuse($user_building, $user_data); | function ogame_production_foreuse_bonus($user_building, $user_data); |
/** | /** @brief Calculates building/sat/for or base production and consumption. |
* @brief Calculates building/sat/for or base production and consumption. | |
* | * |
* @param[in] string $building The wanted building/sat/for ('base','M','C','D','CES','CEF','SAT','FOR') | * @param[in] string $building The wanted building/sat/for ('base','M','C','D','CES','CEF','SAT','FOR') |
* @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates') 0 as default value | * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates') 0 as default value |
* @param[in] array $user_technology Techno info ('NRJ','Plasma') 0 as default value | * @param[in] array $user_technology Techno info ('NRJ') 0 as default value |
* @param[in] array $user_data User info (array('user_class'=>'COL'/...,'off_geologue' or 'off_full') | * @param[in] array $user_data User info for FOR only (array('user_class'=>'COL'/...,'off_geologue' or 'off_full') |
* @param[in] array $server_config Ogame univers info ('speed_uni',(bool)'final_calcul') / final_calcul permet de déterminer si les valeurs retournées seront manipulées avec les % de production ressources, et donc sans arrondi. | * @param[in] array $server_config Ogame universe info ('speed_uni',(bool)'final_calcul') / final_calcul permet de déterminer si les valeurs retournées seront manipulées avec les % de production ressources, et donc sans arrondi. |
* @return array('M','C','D','NRJ','AM') of production | * @return array('M','C','D','NRJ','AM') of production |
* | */ |
* @details remplace les fonctions consumption et partiellement production,production_sat,production_foreuse | |
*/ | |
function ogame_production_building($building, $user_building = null, $user_technology = null, $user_data = null, $server_config = null); | function ogame_production_building($building, $user_building = null, $user_technology = null, $user_data = null, $server_config = null); |
/** | /** @brief Calculates planet production and consumption. |
* @brief Calculates planet production and consumption. | |
* | * |
* @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates','M_percentage','C_percentage','D_percentage','CES_percentage','CEF_percentage','Sat_percentage','FOR_percentage',array 'booster_tab') 0 as default value | * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates','M_percentage','C_percentage','D_percentage','CES_percentage','CEF_percentage','Sat_percentage','FOR_percentage',array 'booster_tab') 0 as default value |
* @param[in] array $user_technology Techno info ('NRJ','Plasma') | * @param[in] array $user_technology Techno info ('NRJ','Plasma') |
* @param[in] array $user_data User info (array('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') | * @param[in] array $user_data User info ('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') |
* @param[in] array $server_config Ogame univers info ('speed_uni') | * @param[in] array $server_config Ogame universe info ('speed_uni') |
* @return array('prod_reel,'prod_theorique','ratio','conso_E','prod_E', //Production totale | * @return array('prod_reel, // (array ress) Production réel en prenant en compte le ratio (M/C/D ressources, NRJ prod moins la conso) |
* 'prod_CES','prod_CEF','prod_SAT','prod_FOR', //production énergie de chaque unité | * 'prod_theorique', // (array ress) Producton théorique M/C/D (ratio=1, 100%) |
* 'prod_M','prod_C','prod_D','prod_base', //production ressources de chaque mine | * 'ratio', // (float) le ratio de production NRJ (prod_E / conso_E) |
* 'prod_booster','prod_off','prod_Plasma','prod_classe', //production des bonus | * 'conso_E','prod_E', // (float) Production NRJ prod_E > 0, conso_E < 0 |
| * 'prod_CES','prod_CEF','prod_SAT', // (array ress) production énergie de chaque unité ('D' de prod_CEF contient la conso en deut de la CEF) |
| * 'prod_FOR', // (array ress) production M/C/D et conso NRJ |
| * 'prod_M','prod_C','prod_D','prod_base', // (array ress) Production ressources de chaque mine (M/C/D) et leur conso (NRJ) |
| * 'prod_booster','prod_off','prod_Plasma','prod_classe', // (array ress) Production des bonus |
* 'M','C','D','NRJ','AM', =>héritage du type ressource pour les valeurs retournées. | * 'M','C','D','NRJ','AM', =>héritage du type ressource pour les valeurs retournées. |
* 'nb_FOR_maxed', | * 'nb_FOR_maxed', // (int) Nombre max de foreuse utilisées |
* ) à part conso_E/prod_E (float) les autres sont array('M','C','D','NRJ','AM') | * ) à part ratio/conso_E/prod_E (float) les autres sont array('M','C','D','NRJ','AM') |
* | |
* @details remplace les fonctions ratio et bilan_production_ratio | |
*/ | */ |
function ogame_production_planet($user_building, $user_technology = null, $user_data = null, $server_config = null); | function ogame_production_planet($user_building, $user_technology = null, $user_data = null, $server_config = null); |
| |
/** | //////////////////////////// COUT fonctions : ////////////////////////////////// |
* @brief Calculates the planet storage capacity (taille hangar). | /** @brief Return base price of an Ogame bat/vso/def/rech |
* | |
* @param[in] int $level Storage building level | |
* @return float capacity | |
*/ | |
function ogame_depot_capacity($level); | |
/** | |
* @brief Calculates phalanx range. | |
* | |
* @param[in] int $level Level of the phalanx | |
* @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) | |
* @return Range in system | |
*/ | |
function ogame_phalanx_range($level, $user_class = 'none'); | |
/** | |
* @brief Calculates MIP range. | |
* | |
* @param[in] int $impulsion Techno impulsion (RI) | |
* @return int Range in system | |
*/ | |
function ogame_missile_range($impulsion = 1); | |
/** | |
* @brief Calculates MIP speed. | |
* | |
* @param[in] int $nb_system Number of sub-system from current planet | |
* @param[in] int $speed_uni Univers speed | |
* @return int Speed in seconds | |
*/ | |
function ogame_missile_speed($nb_system, $speed_uni = 1); | |
/** | |
* @brief Calculates additional case given by terraformer. | |
* | |
* @param[in] int $level The terra level | |
* @return int Number of additional case | |
*/ | |
function ogame_terra_case($level); | |
| |
/** | |
* @brief Return base price of an Ogame bat/vso/def/rech | |
* | |
* @param[in] string $name The name as in Database, all for all element | * @param[in] string $name The name as in Database, all for all element |
* @return array('M', 'C','D, 'NRJ') of the chosen element (array of these if 'all') | * @return array('M', 'C','D, 'NRJ') of the chosen element (array of these if 'all') |
*/ | */ |
function ogame_element_cout_base($name = 'all'); | function ogame_element_cout_base($name = 'all'); |
/** | /** @brief Calculates price of an Ogame bat/vso/def/rech |
* @brief Calculates price of an Ogame bat/vso/def/rech | |
* | * |
* @param[in] string $name The chosen name, as in Database | * @param[in] string $name The chosen name, as in Database |
*/ | */ |
function ogame_element_cout($name, $level); | function ogame_element_cout($name, $level); |
/** | /** @brief Calculates the evolve coefficient of a building and research. |
* @brief Calculates the evolve coefficient of a building and research. | |
* | |
* @param[in] string $name Building/research name, as in Database | * @param[in] string $name Building/research name, as in Database |
* @return array('M', 'C','D, 'NRJ') array of coefficient by ressource | * @return array('M', 'C','D, 'NRJ') array of coefficient by resource |
*/ | */ |
function ogame_element_evolve_coef($name); | function ogame_element_evolve_coef($name); |
/** | /** @brief Calculates the price of an Ogame element to it current level. |
* @brief Calculates the price of an Ogame element to it current level. | |
* | * |
* @param[in] string $name Name of building/research/fleet/defence, like in name in database | * @param[in] string $name Name of building/research/fleet/defence, like in name in database |
* @param[in] int $level The current level or the number of fleet/defence | * @param[in] int $level The current level or the number of fleet/defence |
* @return array('M', 'C','D, 'NRJ') ressources used to it current level | * @return array('M', 'C','D, 'NRJ') resources used to it current level |
*/ | */ |
function ogame_element_cumulate($name, $level); | function ogame_element_cumulate($name, $level); |
/** | /** @brief Calculates the price of all element of type (building,defence,fleet,research). |
* @brief Calculates the price of all element of type (building,defence,fleet,research). | |
* | * |
* @param[in] array $user Array of element each planet or moon | * @param[in] array $user Array of element each planet or moon |
function all_fleet_cumulate($user_fleet) { return ogame_all_cumulate($user_fleet, 'VSO'); } | function all_fleet_cumulate($user_fleet) { return ogame_all_cumulate($user_fleet, 'VSO'); } |
function all_technology_cumulate($user_techno) { return ogame_all_cumulate($user_techno, 'RECH'); } | function all_technology_cumulate($user_techno) { return ogame_all_cumulate($user_techno, 'RECH'); } |
/** | /** @brief Calculates destroy price of a building. |
* @brief Calculates destroy price of a building. | |
* | * |
* @param[in] string $name Building name, as in Database | * @param[in] string $name Building name, as in Database |
function ogame_building_destroy($name, $level, $techno_ions = 0); | function ogame_building_destroy($name, $level, $techno_ions = 0); |
| |
//////FLOTTE | //////////////////////////// TEMPS fonctions : ///////////////////////////////// |
| /** @brief Calculates cumulate lab network. |
| * @param[in] array $user_empire From user_get_empire() |
| * @param[in] int $current_planet_id Current planet to run a research, if not best lab (theory). |
| * @return int Number of cumulate lab network |
| */ |
| function ogame_labo_cumulate($user_empire, $current_planet_id = -1); |
| /** @brief Calculates construction time of a OGame element bat/vso/def/rech. |
| * |
| * @param[in] string $name The name, like name in Database |
| * @param[in] int $level The level or number for def/vso |
| * @param[in] array $user_building Array of bat level ('CSp','UdR','UdN','Lab') |
| * @param[in] int $cumul_labo Number of cumulate lab network (only for rech) |
| * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return float Time in seconds |
| */ |
| function ogame_construction_time($name, $level, $user_building, $cumul_labo = 0, $user_class = 'none'); |
| |
| //////////////////////////// FLOTTE fonctions : //////////////////////////////// |
/** | /** |
* @brief Calculates deut consommation for parking of a fleet. | * @brief Calculates deut consummation for parking of a fleet. |
* | * |
* @param[in] int $conso The conso of the fleet | * @param[in] int $conso The conso of the fleet |
function ogame_fleet_conso_statio($conso, $hour); | function ogame_fleet_conso_statio($conso, $hour); |
/** | /** |
* @brief Return base details of Ogame def/vso. | * @brief Calculates the slowest chip speed of a fleet. |
* | * |
| * @param[in] array $fleet List of chips |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', le reste est ignoré) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return int the slowest speed |
| */ |
| function ogame_fleet_slowest_speed($fleet, $user_techno=null, $class='none'); |
| /** |
| * @brief Calculates distance between 2 coordinates. |
| * |
| * @param[in] string $a, $b Coordinates ('g:s:p') |
| * 'g1:s1:p1'->'g2:s2:p2' : normal distance calcul |
| * ':s1:p1'->'x:s2:p2 : distance between system/planet (only system is ':s1:') |
| * '::p1'->'x:x:p2 : distance between planet |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', only these are checked) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @param[in] array $server_config Info of universe ('num_of_galaxies','num_of_systems','donutGalaxy','donutSystem' only these are checked) default 9/499/1/1 |
| * @return array(int 'distance','type') [default=O,'p'], type='g' for between galaxy, 's' for between system and 'p' for between a sub-system |
| */ |
| function ogame_fleet_distance($a, $b, $user_techno=null, $class='none', $server_config=null); |
| /** |
| * @brief Calculates time and conso to send a fleet. |
| * |
| * @param[in] string $coord_from,$coord_to Coordinates begin and end |
| * @param[in] array $fleet Array of fleet and their number (array('PT'=>10,etc.)) |
| * @param[in] int $speed_per Percentage of speed wanted |
| * @param[in] array $user_techno List of techno ('RC','RI','PH', le reste est ignoré) |
| * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @param[in] array $server_config Info of universe ('num_of_galaxies','num_of_systems','donutGalaxy','donutSystem' only these are checked) default 9/499/1/1 |
| * @param[in] string $type Indicates specific mission ('statio'/'expe', 'fuite') |
| * @param[in] int $hour_mission Number of hour of the specific mission |
| * @return array('conso', 'time'), time in seconds (one trip only) |
| */ |
| function ogame_fleet_send($coord_from, $coord_to, $fleet, $speed_per=100, $user_techno=null, $class='none', $server_config=null, $type='', $hour_mission=0) |
| /** @brief Return base details of Ogame def/vso. |
* @param[in] string $name The name as in Database, all for all element | * @param[in] string $name The name as in Database, all for all element |
* @return array('structure','bouclier','attaque','vitesse','fret','conso',(array)'rapidfire',(bool)'civil') | * @return array('structure','bouclier','attaque','vitesse','fret','conso',(array)'rapidfire',(bool)'civil') |
* rapidfire=array('PT'=>x, ...) array of all fleet and defence; if x>0 then again else from | * rapidfire=array('PT'=>x, ...) array of all fleet and defence; if x>0 then again else from |
*//Coût de base des vaisseaux structure,bouclier,attaque,vitesse ,fret ,conso,civil) | |
$details_base['PT'] = ogame_array_detail(4000 , 10 , 5 , 5000 , 5000 , 10); | |
$details_base['PT']['rapidfire'] = array('SE'=>5,'SAT'=>5,'FOR'=>5, 'CLO'=>-3,'TRA'=>-3,'EDLM'=>-250); | |
*/ | */ |
| |
function ogame_elements_details_base($name = 'all'); | function ogame_elements_details_base($name = 'all'); |
/** | /** @brief Calculates technical data of a fleet or defence. |
* @brief Calculates technical data of a fleet or defence. | |
* | * |
* @param[in] string $name The name, like name in Database | * @param[in] string $name The name, like name in Database |
* @param[in] array $user_techno The array of technologies | * @param[in] array $user_techno The array of technologies (utilisées : Armes/Bouclier/Protection/RC/RI/PH/Hyp) |
* @param[in] string|int $classe The user class //array('none','COL','GEN','EXP') - (1=Collectionneur)[0=aucune, 2=général, 3=explorateur]) | * @param[in] string|int $classe The user class //array('none','COL','GEN','EXP') - (1=Collectionneur)[0=aucune, 2=général, 3=explorateur]) |
* @return array('nom','structure','bouclier','attaque','vitesse','fret','conso',(array)'rapidfire',(bool)'civil',(array)'cout') of the wanted fleet or defence. | * @return array('nom','structure','bouclier','attaque','vitesse','fret','conso',(array)'rapidfire',(bool)'civil',(array)'cout') of the wanted fleet or defence. |
* rapidfire=array('PT'=>x, ...) array of all fleet and defence; if x>0 then again else from | * rapidfire=array('PT'=>x, ...) array of all fleet and defence; if x>0 then again else from |
* cout=array of ogame_element_cumulate()=array('M','C','D','NRJ) | * cout=array of ogame_element_cumulate()=array('M','C','D','NRJ') |
*/ | */ |
function ogame_elements_details($name, $user_techno = null, $classe = 0); | function ogame_elements_details($name, $user_techno = null, $classe = 0); |
/** | /** @brief Calculates technical data of all fleet/defence. |
* @brief Calculates technical data of all fleet/defence. | |
* | |
* @param[in] array $user_techno The array of technologies | * @param[in] array $user_techno The array of technologies |
* @param[in] string|int $classe The user class //array('none','COL','GEN','EXP') - (1=Collectionneur)[0=aucune, 2=général, 3=explorateur]) | * @param[in] string|int $classe The user class //array('none','COL','GEN','EXP') |
* @return array of all fleet/defence with are array of details from ogame_elements_details() | * @return array of all fleet/defence with are array of details from ogame_elements_details() |
*/ | */ |
function ogame_all_details($user_techno = null, $classe = 0); | function ogame_all_details($user_techno = null, $classe = 0); |
| |
/** | /** @brief Calculates technical data of Ogame requirement. |
* @brief Calculates technical data of Ogame requirement. | |
* | * |
* @param[in] string $nom The name, like name in Database | * @param[in] string $nom The name, like name in Database |
*/ | */ |
function ogame_elements_requirement($name = 'all'); | function ogame_elements_requirement($name = 'all'); |
/** | /** @brief Calculates technical data of Ogame requirement of all building/research/fleet/defence. |
* @brief Calculates technical data of Ogame requirement of all building/research/fleet/defence. | * @return array of all building/research/fleet/defence with are array of requirement from ogame_elements_requirement |
* | |
* @return array of all building/research/fleet/defence with are array of requirement from ogame_elements_requirement() | |
*/ | */ |
function ogame_all_requirement(); | function ogame_all_requirement(); |
| |
/** | //////////////////////////// DIVERS fonctions : //////////////////////////////// |
* @brief Calculates cumulate lab network. | /** @brief Calculates the planet storage capacity (taille hangar). |
* | * @param[in] int $level Storage building level |
* @param[in] array $user_empire From user_get_empire() | * @return float capacity |
* @param[in] int $current_planet_id Current planet to run a research, if not best lab (theory). | |
* @return int Number of cumulate lab network | |
*/ | */ |
function ogame_labo_cumulate($user_empire, $current_planet_id = -1); | function ogame_depot_capacity($level); |
| /** @brief Calculates phalanx range. |
| * @param[in] int $level Level of the phalanx |
| * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) |
| * @return Range in system |
| */ |
| function ogame_phalanx_range($level, $user_class = 'none'); |
| /** @brief Calculates MIP range. |
| * @param[in] int $impulsion Techno impulsion (RI) |
| * @return int Range in system |
| */ |
| function ogame_missile_range($impulsion = 1); |
| /** @brief Calculates MIP speed. |
| * @param[in] int $nb_system Number of sub-system from current planet |
| * @param[in] int $speed_uni Universe speed |
| * @return int Speed in seconds |
| */ |
| function ogame_missile_speed($nb_system, $speed_uni = 1); |
| /** @brief Calculates additional case given by terraformer. |
| * @param[in] int $level The terra level |
| * @return int Number of additional case |
| */ |
| function ogame_terra_case($level); |
| </code> |
| |
/** | <code Javascript JS> |
* @brief Calculates construction time of a OGame element bat/vso/def/rech. | /** Voir description des fonctions côté PHP **/ |
| //////////////////////////// BASE fonctions : ////////////////////////////////// |
| /** @return array('M','C','D','NRJ'), default is 0 */ |
| function ogame_arrayRessource($metal, $cristal, $deut, $NRJ = 0); |
| function ogame_getElementNames(); |
| function ogame_isElement(nom); |
| function ogame_findPlanetPosition(coordinates); |
| function ogame_findCoordinates(string_coord); /** return array('g','s','p') of int, default is 0 */ |
| |
| ////////////////////////// PRODUCTION fonctions : ////////////////////////////// |
| function ogame_productionPosition(position); |
| function ogame_productionForeuseMax(mine_M, mine_C, mine_D, user_data); |
| function ogame_productionForeuseBonus(user_building, user_data); /** return array('bonus','nb_FOR_maxed') bonus=foreuse bonus coefficient ; nb_FOR_maxed=limit nb if too much */ |
| /** @brief Calculates building/sat/for or base production and consumption. |
* | * |
* @param[in] string $name The name, like name in Database | * @param[in] string $building The wanted building/sat/for ('base','M','C','D','CES','CEF','SAT','FOR') |
* @param[in] int $level The level or number for def/vso | * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates') 0 as default value |
* @param[in] array $user_building Array of bat level ('CSp','UdR','UdN','Lab') | * @param[in] array $user_technology Techno info ('NRJ') 0 as default value |
* @param[in] int $cumul_labo Number of cumulate lab network (only for rech) | * @param[in] array $user_data User info for FOR only (array('user_class'=>'COL'/...,'off_geologue' or 'off_full') |
* @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) | * @param[in] array $server_config Ogame universe info ('speed_uni',(bool)'final_calcul') / final_calcul permet de déterminer si les valeurs retournées seront manipulées avec les % de production ressources, et donc sans arrondi. |
* @return float Time in seconds | * @return array('M','C','D','NRJ') of production |
| */ |
| function ogame_productionBuilding(building, user_building=null, user_technology=null, user_data=null, server_config=null); |
| /** @brief Calculates planet production and consumption. |
| * |
| * @param[in] array $user_building Planet info ('M','C','D','CES','CEF','SAT','FOR','temperature_max','coordinates','M_percentage','C_percentage','D_percentage','CES_percentage','CEF_percentage','Sat_percentage','FOR_percentage',array 'booster_tab') 0 as default value |
| * @param[in] array $user_technology Techno info ('NRJ','Plasma') |
| * @param[in] array $user_data User info ('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') |
| * @param[in] array $server_config Ogame universe info ('speed_uni') |
| * @return array('prod_reel, // (array ress) Production réel en prenant en compte le ratio (M/C/D ressources, NRJ prod moins la conso) |
| * 'prod_theorique', // (array ress) Producton théorique M/C/D (ratio=1, 100%) |
| * 'ratio', // (float) le ratio de production NRJ (prod_E / conso_E) |
| * 'conso_E','prod_E', // (float) Production NRJ prod_E > 0, conso_E < 0 |
| * 'prod_CES','prod_CEF','prod_SAT', // (array ress) production énergie de chaque unité ('D' de prod_CEF contient la conso en deut de la CEF) |
| * 'prod_FOR', // (array ress) production M/C/D et conso NRJ |
| * 'prod_M','prod_C','prod_D','prod_base', // (array ress) Production ressources de chaque mine (M/C/D) et leur conso (NRJ) |
| * 'prod_booster','prod_off','prod_Plasma','prod_classe', // (array ress) Production des bonus |
| * 'M','C','D','NRJ', =>héritage du type ressource pour les valeurs retournées. |
| * 'nb_FOR_maxed', // (int) Nombre max de foreuse utilisées |
| * ) à part ratio/conso_E/prod_E (float) les autres sont array('M','C','D','NRJ') |
*/ | */ |
function ogame_construction_time($name, $level, $user_building, $cumul_labo = 0, $user_class = 'none'); | function ogame_productionPlanet(user_building, user_technology=null, user_data=null, server_config=null); |
| |
| //////////////////////////// FLOTTE fonctions : //////////////////////////////// |
| /** return array('vitesse','fret','conso',(bool)'civil') */ |
| function ogame_arraySubDetail(vitesse=0, fret=0, conso=0, civil=true); |
| /** @brief Return fleet moving details of Ogame vso. |
| * @param[in] string name The name as in Database, all for all element |
| * @return array('vitesse','fret','conso',(bool)'civil') |
| */ |
| function ogame_fleetSubDetailsBase(name = 'all'); |
| /** @brief Calculates technical data of a fleet or defence. |
| * @return array('nom','vitesse','fret','conso',(bool)'civil') of the wanted fleet. |
| */ |
| function ogame_fleetSubDetails(name, user_techno = null, classe = 'none'); |
| function ogame_fleetConsoStatio(conso, hour); |
| function ogame_fleetSlowestSpeed(fleet, user_techno=null, classe='none'); |
| function ogame_fleetDistance(a, b, user_techno=null, classe='none', server_config=null); |
| function ogame_fleetSend(coord_from, coord_to, fleet, speed_per=100, user_techno=null, classe='none', server_config=null, type='', hour_mission=0); |
| |
| //////////////////////////// COUT fonctions : ////////////////////////////////// |
| function ogame_elementCoutBase(name = 'all'); |
</code> | </code> |