Posted: Wed Jan 16, 2008 8:54 pm
have a fun rest of game guys, i hope you have fun TESTING.
Welcome to the Worlds of Kaomaris
http://forums.kaomaris.com/
Code: Select all
<?php
/* Function calculates players scores*/
function score($player)
{
global $provinces, $provincesstart, $active, $constants, $players, $db, $GameID, $TurnNR, $gamedata, $commentary, $attacked, $TurnNR, $colour, $GameID;
$score = 0;
$tec = $players[$player][TEC];
$gold = $players[$player][Gold];
$bank = $players[$player][Bank];
$corn = $players[$player][Corn];
$wood = $players[$player][Wood];
$white = $players[$player][White] * $constants[whitecost];
$yellow = $players[$player][Yellow] * $constants[yellowcost];
$red = $players[$player][RedD] * $constants[redcost];
$green = $players[$player][Green] * $constants[greencost];
$blue = $players[$player][Blue] * $constants[bluecost];
$grey = $players[$player][Grey] * $constants[greycost];
$black = $players[$player][Black] * $constants[blackcost];
$eff = $players[$player][EFF];
$score = $gold + $bank + $corn + $wood + $white + $yellow + $red + $green + $blue + $grey + $black;
for ($i = 1; $i <= 10; $i++)
{
if ($i < 10)
{
$slot = "SPP0" . $i;
}
else
{
$slot = "SPP" . $i;
}
$id = $players[$player][$slot];
if ($id > 0)
{
$needwhite = $stone[$id][White];
$needyellow = $stone[$id][Yellow];
$needred = $stone[$id][Red];
$needgreen = $stone[$id][Green];
$needblue = $stone[$id][Blue];
$needgrey = $stone[$id][Grey];
$needblack = $stone[$id][Black];
$cost = $needwhite * $constants[whitecost] + $needyellow * $constants[yellowcost] + $needred * $constants[redcost] + $needgreen * $constants[greencost] + $needblue * $constants[bluecost] + $needgrey * $constants[greycost] + $needblack * $constants[blackcost];
$cost = intval($cost);
$score = $score + $cost;
}
}
for ($i = 1; $i <= 70; $i++)
{
if ($provinces[$i][Owner] == $player)
{
/* Add POP & WOK to score */
$pop = $provinces[$i][POP];
$wok = $provinces[$i][WOK];
$score = $score + $pop + $wok;
/* Get Number, type, level and defense of units.*/
$armd = $provinces[$i][ARM];
$pikd = $provinces[$i][PIK];
$arcd = $provinces[$i][ARC];
$knid = $provinces[$i][KNI];
$catd = $provinces[$i][CAT];
$cread = $provinces[$i][CREA];
$levd = $provinces[$i][LEV];
$defd = $provinces[$i][DEF];
$levd = sprintf("%01.3f", $levd);
$defd = sprintf("%01.1f", $defd);
$terd = $provinces[$i][TER];
$city = $provinces[$i][CITY];
$totald = $armd + $pikd + $arcd + $knid + $catd;
if ($cread > 0)
{
$totald = $totald + 1;
}
/* Calculate creature bonus */
$white = array(1,8,15,22,29,36);
$yellow = array(2,9,16,23,30,37);
$red = array(3,10,17,24,31,38);
$green = array(4,11,18,25,32,39);
$blue = array(5,12,19,26,33,40);
$grey = array(6,13,20,27,34,41);
$black = array(7,14,21,28,35,42);
$dragon = array(1,2,3,4,5,6,7);
$golem = array(8,9,10,11,12,13,14);
$lizard = array(15,16,17,18,19,20,21);
$spirit = array(22,23,24,25,26,27,28);
$bear = array(29,30,31,32,33,34,35);
$snake = array(36,37,38,39,40,41,42);
if (in_array($cread, $white))
{$bonusd = 0.2;}
if (in_array($cread, $yellow))
{$bonusd = 0.3;}
if (in_array($cread, $red))
{$bonusd = 0.4;}
if (in_array($cread, $green))
{$bonusd = 0.5;}
if (in_array($cread, $blue))
{$bonusd = 0.6;}
if (in_array($cread, $grey))
{$bonusd = 0.8;}
if (in_array($cread, $black))
{$bonusd = 1.0;}
switch ($terd)
{
case("PL"):
if (in_array($cread, $spirit))
{$bonusd = $bonusd * 2;}
$pikx = 0.0;
$arcx = 0.0;
$knix = 0.06;
$catx = 0.0;
$defx = 0.0;
break;
case("DS"):
if (in_array($cread, $snake))
{$bonusd = $bonusd * 2;}
$pikx = 0.02;
$arcx = 0.0;
$knix = 0.0;
$catx = 0.0;
$defx = 0.0;
break;
case("FO"):
if (in_array($cread, $dragon))
{$bonusd = $bonusd * 2;}
$pikx = 0.0;
$arcx = 0.04;
$knix = 0.0;
$catx = 0.0;
$defx = 0.3;
break;
case("MO"):
if (in_array($cread, $golem))
{$bonusd = $bonusd * 2;}
$pikx = 0.0;
$arcx = 0.0;
$knix = 0.0;
$catx = 0.08;
$defx = 0.4;
break;
case("SW"):
if (in_array($cread, $lizard))
{$bonusd = $bonusd * 2;}
$pikx = 0.0;
$arcx = 0.0;
$knix = 0.0;
$catx = 0.0;
$defx = 0.2;
break;
case("TU"):
if (in_array($cread, $bear))
{$bonusd = $bonusd * 2;}
$pikx = 0.02;
$arcx = 0.0;
$knix = 0.0;
$catx = 0.0;
$defx = 0.0;
break;
}
$bld = $provinces[$i][LEV];
$eld = ($pikd * $pikx) + ($arcd * $arcx) +($knid * $knix) + ($catd * $catx);
$cbdmax = ($bld + $eld) / 3;
if ($cread > 0)
{$cbd = $bonusd;}
else
{$cbd = 0.0;}
if ($cbd >= $cbdmax)
{$cbd = $cbdmax;}
$bld = sprintf("%01.3f", $bld);
$eld = sprintf("%01.3f", $eld);
$cbd = sprintf("%01.3f", $cbd);
$cbdmax = sprintf("%01.3f", $cbdmax);
$fld = $bld + $eld + $cbd;
if ($city == "Yes")
{$defcity = 0.5;}
else
{$defcity = 0.0;}
$deftotal = $defd + $defx;
$pdef = ($fld * 10 + $deftotal * 4) * $eff / 100;
$score = $score + ($pdef * $totald);
}
}
$score = intval($score);
Return($score);
}
?>