Here's the current set of logic!
$sql = 'SELECT map_x, map_y FROM War_Map WHERE nation_id = :nation_id';
$query = $COMMON->DB()->prepare($sql);
$query->execute(array(':nation_id' => $this->nation_id));
$counter = 0;
$coords = array();
while($row = $query->fetch())
{
++$counter;
$coords[$row['map_x']][$row['map_y']] = 1;
}
if($counter < 50)
{
$this->set('nation_geo_eff',1);
return 1;
}
$faces = 0;
foreach($coords as $x => $batch)
{
foreach($batch as $y => $junk)
{
$hits = 4;
if(isset($coords[$x + 1][$y]))
{
--$hits;
}
if(isset($coords[$x - 1][$y]))
{
--$hits;
}
if(isset($coords[$x][$y - 1]))
{
--$hits;
}
if(isset($coords[$x][$y + 1]))
{
--$hits;
}
$faces += $hits;
}
}
// Each air combat removes 2 faces worth of damage
// Defensive counts towards this value
// Every 500 tiles adds 1 to the bonus value
$bonus = 50 + $this->nation_attr_d_air_combat + $this->nation_attr_g_air_combat + floor($counter / 500);
if($faces < $bonus)
{
$this->set('nation_geo_eff',1);
return 1;
}
//Need to base this on the total divided out.
$value = ($counter - ($faces/2) + $bonus) / $counter;
if($value < 0.01)
{
$this->set('nation_geo_eff',0.01);
return 0.01;
}
if($value > 1)
{
$this->set('nation_geo_eff',1);
return 1;
}
$this->set('nation_geo_eff',round($value,2));
return round($value,2);