-
Notifications
You must be signed in to change notification settings - Fork 35
/
moon_sim.php
81 lines (66 loc) · 2.07 KB
/
moon_sim.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
define('INSIDE', true);
$_EnginePath = './';
include($_EnginePath.'common.php');
loggedCheck();
includeLang('moon_sim');
$_Lang['HideResult'] = 'style="display: none;"';
$_Lang['HideError'] = 'style="display: none;"';
if(isset($_POST['simulate']) && $_POST['simulate'] == 'yes')
{
$_Lang['Input_RawDiameter'] = $_POST['diameter'];
$_Lang['Input_RawShipCount'] = $_POST['ship_count'];
$Data['diameter'] = floor(str_replace(array(',', '.'), '', $_POST['diameter']));
$Data['shipcount'] = floor(str_replace(array(',', '.'), '', $_POST['ship_count']));
if($Data['diameter'] > 0 AND $Data['shipcount'] > 0)
{
if($Data['diameter'] < 10000)
{
$_Lang['HideResult'] = '';
$MoonChance = (100 - sqrt($Data['diameter'])) * sqrt($Data['shipcount']);
$FleetChance = sqrt($Data['diameter']) / 2;
if($MoonChance > 100)
{
$MoonChance = 100;
}
else if($MoonChance <= 0)
{
$MoonChance = 0;
}
else
{
$MoonChance = round($MoonChance, 2);
}
if($FleetChance > 100)
{
$FleetChance = 100;
}
else if($FleetChance <= 0)
{
$FleetChance = 0;
}
else
{
$FleetChance = round($FleetChance, 2);
}
$_Lang['Input_Diamter'] = prettyNumber($Data['diameter']);
$_Lang['Input_ShipCount'] = prettyNumber($Data['shipcount']);
$_Lang['Input_MoonChance'] = $MoonChance;
$_Lang['Input_FleetChance'] = $FleetChance;
}
else
{
$_Lang['HideError'] = '';
$_Lang['Input_Error'] = $_Lang['Error_DiameterTooBig'];
}
}
else
{
$_Lang['HideError'] = '';
$_Lang['Input_Error'] = $_Lang['Error_BadDataGiven'];
}
}
//Display page
$page = parsetemplate(gettemplate('moon_sim_body'), $_Lang);
display($page, $_Lang['Title'], false);
?>