} if ($_GET) { if (isset($_GET['command'])) { switch ($_GET['command']) { case "insert": $id = $_GET['building']; $itemName = ResourceParser::Instance()->GetItemNameByID($id); $action = new UserAction($user); // Check if this is the first item to be inserted $count = BuildingBuildGroup::GetListCount($user->CurrentColony()); $firstItem = false; if ($count == 0) { $firstItem = true; } // Only calculate commissioned time on first insertion $action->PurchaseBuildings(array($itemName), $firstItem); break; case "cancel": $id = $_GET['building']; $itemName = ResourceParser::Instance()->GetItemNameByID($id); $pos = $_GET['build_position']; $action = new UserAction($user); // Check if we want to delete the first item $firstItem = false; $visualPos = $_GET['viewposition']; if ($visualPos == 1) { $firstItem = true; } // Only recalculate commissioned time when first item is deleted $action->CancelBuildings(array($itemName), array($pos), $firstItem); break;