function AM_farmGold_restore($getInfo, $getFarm) { $IDs = $getInfo['IDs']; $building = $getInfo['building']; $farm = $getFarm; $objects = array(); $objects = TB_loadObjects(); $itemName = array(); $newIDs = array(); $positions = array(); Addlog2('ToolBox: Restoring Farm'); foreach ($objects as $object) { if (in_array($object['id'], $IDs)) { $itemName[] = $object['itemName']; $newIDs[] = $object['id']; $positions[] = $object['position']; } } $re = AM_farmGold_moveAnimalsToBuilding($building, count($IDs), $farm, $newIDs, $itemName, $positions); if (is_array($re)) { $farm = $re; } else { return false; } AM_farmGold_deletIDs(); //Addlog2('-> OK'); return $farm; }
function TB_checkSpot($x, $y) { $units = array(); $units = TB_loadUnits(); $objects = array(); $objects = TB_loadObjects(); foreach ($objects as $object) { if ($object['position']['x'] == $x && $object['position']['y'] == $y) { return false; } //if( isset($units[$object['itemName']])) { $unit = $units[$object['itemName']]; $xMin = $object['position']['x']; $yMin = $object['position']['y']; if (isset($unit['sizeX'])) { $xMax = $xMin + $unit['sizeX'] - 1; $yMax = $yMin + $unit['sizeY'] - 1; } else { $xMax = $xMin; $yMax = $yMin; } if (isset($object['state'])) { if ($object['state'] == 'vertical') { $tmp = $objSizeX; $objSizeX = $objSizeY; $objSizeY = $tmp; } } if ($xMin <= $x && $x <= $xMax && $yMin <= $y && $y <= $yMax) { return false; } //} else { // echo '<small><pre>'; // echo print_r($object); // echo '</pre></small>'; //} } return true; }