-
Notifications
You must be signed in to change notification settings - Fork 2
/
Espionage.php
51 lines (46 loc) · 1.66 KB
/
Espionage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @author jstar88
* @copyright 2013
*/
//http://board.ogame.org/board703-miscellaneous/board156-archive-version-2-0/board705-help-questions-archive/board631-faq-s-guides/576831-formula-thread-v3/#espionage
class Espionage
{
/**
* getSpyLevel()
*
* @param int $probes: amount of espionage probes sent to spy
* @param int $yourEspionageTechnology
* @param int $opponentEspionageTechnology
* @return
* >= 2 for resources, activity, and ships
* >= 3 for resources, activity, ships, and defense
* >= 5 for resources, activity, ships, defense, and buildings
* >= 7 for resources, activity, ships, defense, buildings, and research
*/
public static function getSpyLevel($probes, $yourEspionageTechnology, $opponentEspionageTechnology)
{
$diff = $yourEspionageTechnology - $opponentEspionageTechnology;
if ($diff > 0)
{
return $probes + pow($diff, 2);
}
return $probes - pow($diff, 2);
}
/**
* getCounterEspionage()
* This function return the probability to be discovered.
*
* @param int $probes: amount of espionage probes sent to spy
* @param int $ships: amount of enemy ships
* @param int $yourEspionageTechnology
* @param int $opponentEspionageTechnology
* @return int between 0 and 1
*/
public static function getCounterEspionage($probes, $ships, $yourEspionageTechnology, $opponentEspionageTechnology)
{
$theoric = $probes * $ships / (pow(100, ($yourEspionageTechnology - $opponentEspionageTechnology))) + 2;
return mt_rand(0, floor($theoric)) / 100;
}
}
?>