Page 6 of 8

Posted: Thu Dec 07, 2006 6:35 pm
by agapooka
I've been getting questions about my calc's source, so I thought I'd refresh a bit. :)

And a late thank-you to Paul-ish for seeing a detail I didn't see :P

Calc URL: http://www.calc.streamdown.net

Source:

<?php
$a = $HTTP_GET_VARS['a'];
$b = $HTTP_GET_VARS['b'];
$c = $HTTP_GET_VARS['c'];
$d = $HTTP_GET_VARS['d'];
$e = $HTTP_GET_VARS['e'];
$f = $HTTP_GET_VARS['f'];
$p = $HTTP_GET_VARS['p'];

if ($a == '') { $a = '0'; }
if ($b == '') { $b = '0'; }
if ($c == '') { $c = '0'; }
if ($d == '') { $d = '0'; }
if ($e == '') { $e = '0'; }
if ($f == '') { $f = '0'; }
if ($p == '') { $p = '0'; }

$title = "Pookie's TGW Calculator";
$nav = "<a href='?p=0'>Calculator Home</a> | <a href='?p=donate'>Donate</a> | <a href='?p=about'>About</a> | <small>(<a href='admin' target='_blank'>Admin Panel</a>)</small>";
$fname = "index.php";
$version = "2.0.3";
$release = "21st of June 2006";
$disclaimer = "Property of Jason Lambert (Agapooka)<br />Pookie TGW Calculator version ".$version.", released on the ".$release."."; [/color]
$filename = //well, you don't need to know this part
$announce = //well, you don't need to know this part

{
$lines = file($filename);
$disabled = $lines[0];
}

if ($disabled == 1)
{
$status = " disabled='disabled'";
$why = "<b>".$lines[1]."</b><br /><br />";
$n = '0';
}
else
{
$status = "";
$why = "";
$n = '1';
}

{
$lines = file($announce);
$message = $lines[1];
}

for ($ia=0; $ia<=8; $ia++) {
if ($ia == $p)
{
$sel[$ia] = " selected";
}
else
{
$sel[$ia] = "";
}
}

$head = "<html>
<title>".$title."</title>
<head><center>
<h1>".$title."</h1><br />
".$nav."
</center></head>
<style type='text/css'>
a:link { color: darkblue; text-decoration: none }
a:active { color: darkblue; text-decoration: none }
a:visited { color: darkblue; text-decoration: none }
a:hover { color: darkred; text-decoration: underline }
</style>";
$body = "<body><center>
<table width=500 cellspacing=3 cellpadding=3 border=1>";
$tbl0 = "<tr><td width=100%><center>
<form action='".$fname."' method=get>
";
$frma = "Current: <input size=8 maxlength=22".$status." value=".$a." name=a />
<br />";
$frmb = "Desired: <input size=8 maxlength=22".$status." value=".$b." name=b />
<br />";
$frmc = "<input size=8 maxlength=22".$status." value=".$c." name=c />
<br />";
$frmd = "<select name='d'".$status.">
<option value='0'>DefCon Level:</option>
<option value='1'>None</option>
<option value='1.45'>Unsure</option>
<option value='2'>Critical</option></select>
<br />";
$frme = "<input size=8 maxlength=22".$status." value=".$e." name=e />
<br />";
$frmf = "<input size=8 maxlength=22".$status." value=".$f." name=f />
<br />";
$frmp = "
<h3><b>".$message."</b></h3>
".$why."
<select name='p'>
<option value=0".$sel[0].">Calculate:</option>
<option value=1".$sel[1].">Unit Production Cost</option>
<option value=2".$sel[2].">Ascended Fleet Cost</option>
<option value=3".$sel[3].">MS Weapon Capacity and Weapon Cost</option>
<option value=4".$sel[4].">MS Shield Capacity and Shield Cost</option>
<option value=8".$sel[8].">Fleet (and soon fleet) Hangar Cost</option>
<option value=5".$sel[5].">Spy Levels</option>
<option value=6".$sel[6].">Sabotage</option>
<option value=7".$sel[7].">Planets (coming soon!)</option>
</select>";
$frm0 = "
<input type=submit value='GO!' />
<br />";
$foot = "</form>
</center></td>
</tr></table>
<small>
".$disclaimer."
</small><br /><br />
<img src='/cgi-sys/Count.cgi?df=jason.dat|display=Counter|ft=2|md=6|frgb=100;139;216|dd=E' /><small>&nbsp page views since 00:00 GMT on July 14th 2006</small>
<table width=402 border=0 cellspacing=1 cellpadding=1><tr><td>
<br /><small>Sponsored by:<small><br /></td></tr></table>
<table width=402 border=1 bordercolor=#000000 cellspacing=1 cellpadding=1><tr><td>
<center><a href='http://dreadlords.jconserv.net' target='_blank'><img src='ads/dreadlords.gif' alt='Check out the Dread Lords alliance!' /></a><br />+<br />
<a href='http://s11.invisionfree.com/law7441/index.php' target='_blank'><img src='ads/ufor.jpg' alt='Check out the United Federation of Races!' /></a>
</center>
</td></tr><table>
</center></body>
</html>";

if ($p == '0')
{
echo $head,$body,$tbl0."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$foot;
}
if ($p == '1')
{
$currency = "Naquadah";
$ans = (-1*($a-$b)/3)*((15000*(($b-1)/3)+15000*(($a+2)/3))/2);
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frma,$frmb."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$answ,$foot;
}
if ($p == '2')
{
$currency = "Dark Matter Units";
$ans = (-1*($a-$b))*(((5000*($b-1)+5000*($a+4))/2));
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frma,$frmb."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$answ,$foot;
}
if ($p == '3')
{
$currency = "Naquadah";
$ans = (-1*($a-$b))*(((10000*($b-1)+10000*($a+2))/2));
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency."<br />Cost with weapons included: ".number_format($n*$ans+(($b-$a)*2100800), 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frma,$frmb."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$answ,$foot;
}
if ($p == '4')
{
$currency = "Naquadah";
$ans = (-1*($a-$b))*(((12000*($b-1)+12000*($a+(10/12)))/2));
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency."<br />Cost with shields included: ".number_format($n*$ans+(($b-$a)*2250000), 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frma,$frmb."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$answ,$foot;
}
if ($p == '8')
{
$currency = "Naquadah";
$ans = (-1*($a-$b))*(((10000*($b-1)+10000*($a+2))/2));
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frma,$frmb."<input type='hidden' value=".$c." name=c />".$frmp,$frm0,$answ,$foot;
}
if ($p == '5')
{
$currency = "Naquadah";
$ans = (6000*pow(2,($c-1)));
$answ = "<br />Cost: ".number_format($n*$ans, 0, '.', ',')." ".$currency."<br />Cost for Replicators: ".number_format($n*0.9*$ans, 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0,$frmc,$frmp,$frm0,$answ,$foot;
}
if ($p == '6')
{
$currency = "spies must be sent";
$ans = str_replace(",", "", $d)*(1.01*(str_replace(",", "", $e)/((str_replace(",", "", $f)+1)/(str_replace(",", "", $c)+1)))+1);
$answ = "<br />".number_format($n*$ans, 0, '.', ',')." ".$currency;
echo $head,$body,$tbl0."Enemy covert action: ".$frme."(<b>NOT</b> SPY LEVEL)<br />Your covert action: ".$frmf."(<b>NOT</b> SPY LEVEL)<br />How many spies you have:".$frmc."Enemy's DefCon level:".$frmd.$frmp,$frm0,$answ."<br /><br /><small>*Please remember to exclude any commas from any fields. They are parsed as decimals. I might change this in the future, but this seems to be the default option for now.</small>".$foot;
}
if ($p == '7')
{
echo $head,$body,$tbl0,$frmp,$frm0."<br /><br />Coming when they are updated and actually useful! <img src='http://www.jason.streamdown.net/icon_razz.gif' alt=':-P' />".$foot;
}
if ($p == 'donate')
{
echo $head,$body,$tbl0."<b><u>Feel free to donate ingame resources to Agapooka (10649)</u></b>
<br />If you are signed into <b><i>www</i></b>.stargatewar<b><i>s</i></b>.com (note the 'www' and the 's'), and have Supporter Status, you can do this from here! Note, however, that giving is not obligatory.
<br /><br />
//well, you don't need to know this part
<br /><br />
Your gifts are appreciated!
".$foot;
}
if ($p == 'about')
{
echo $head,$body,$tbl0."<p align='justify'>Pookie's TGW Calculator is made in Agapooka's spare time. It was made for fun, and I hope that you enjoy using it as much as I enjoyed making it! :)</p>".$foot;
}
?>


-Pooka

Posted: Wed Jan 03, 2007 5:30 pm
by Kasack
I there any way i could get this calc in an exe form so i can tack it with me ?

Posted: Wed Jan 03, 2007 5:52 pm
by Grand Admiral Martin
any idea when planet part will be working?

Posted: Wed Jan 03, 2007 7:27 pm
by agapooka
Whenever I can find out what the formulas are - and to be honest, I haven't really tried.

You know why? I don't believe it to be worth my time. The game got boring. Will it get fun again? Hopefully :twisted:

Oh and... yes, my noobie PHP is messy. Don't mention it. Not that you have, but someone is bound to notice :P


Kasack wrote:I there any way i could get this calc in an exe form so i can tack it with me ?


Feel free to try. I could probably do it, but I don't really want to... but if enough people want me to, I will.

-Pooka

Posted: Wed Jan 03, 2007 7:40 pm
by *~Starry~*
me wants!!!


~starry :P

Posted: Wed Jan 03, 2007 7:49 pm
by [SGC_ReplicĂ…tors]
planets.....coming soon......been waiting for well a longs time now no rush no rush

Posted: Wed Jan 03, 2007 8:14 pm
by agapooka
Back when I wrote "coming soon", I had no idea that the formulas were so impossible and I actually planned to work on them. What the hell, screw planets. :D I also noticed something weird with my UP planets... when I upgrade 1 upgrade at a time, the UP bonus goes up by 2, but otherwise, it goes up by one per upgrade??? What's up with that? Oh well...

-Pooka

Posted: Wed Jan 03, 2007 9:26 pm
by Grand Admiral Martin
Agapooka wrote:I also noticed something weird with my UP planets... when I upgrade 1 upgrade at a time, the UP bonus goes up by 2, but otherwise, it goes up by one per upgrade??? What's up with that? Oh well...

-Pooka


I've been looking into that for some time now.
Clicking one at a time gives 2Up.
So you click 30 times you'll get a 60UP bonus but when the turn comes you lose 20% therefore only getting 48up.

But if you upgrade 30 times at once UP only goes up by 51, but after turn nothing happens.

Therefore it is better to upgrade in large amounts rather than clicking individually.

If anyone else has had a different outcome let me know. I've done that over and over about 8 times now.

Posted: Thu Jan 04, 2007 2:58 am
by Varros
Nice handy little tool :) thanks! :)

Posted: Thu Jan 04, 2007 6:27 am
by Legoless
I was doing a research on planets, and I always thought, UP upgraded by multiply of 1.5. :?

Posted: Thu Jan 04, 2007 6:40 am
by Brdavs
That "1.5" is dependant on planet size, I believe...

the size of the planet is also now a multiplier of the base value, as well as allowing for more defences to be built on the planet. The smallest (tiny) is x1 while the top size so far is x9. This applies to everything except UP where the increase is time 1. (ie 1.1, 1.2, 1.3....1.9)


So a normal one gives number of cliks X 1.5 but a small one only gives x 1.4... How this is regulated as to add/substract a number after a turn/several turns is a mystery to me...(I even had it vary like 4 turns after building up... from 999 to 1k back to 999 etc.)

Posted: Thu Jan 04, 2007 7:41 am
by Zeratul
would be really useful if someone could make a planet calculator... might be easier if several people found the calculations for each type and size and then posted that in a topic, and someone else could then code it...

anyways, we can tell you that income planet production grows by the following:
large grows by 230 400 per single upgrade
above average grows by 192 000 per single upgrade

and when upgraded 7 at once, goes up at same rate...

Posted: Thu Apr 12, 2007 5:26 am
by agapooka
Thanks to Acolyte of Eternity, the planet calculator is now available on my page.

http://www.calc.streamdown.net

Thanks. :-D

J

Posted: Wed Apr 18, 2007 10:13 am
by The O-Neill
Sweet, thanks

Posted: Wed Apr 18, 2007 5:04 pm
by Mystake
I can make an EXE based version in Visual VB.NET

I just need some equations. Shouldn't be terribly long to do. May do it this weekend!