#include "..\script_component.hpp"

/*
 * Function: forge_client_org_fnc_create
 * Author: IDSolutions
 *
 * [Description]
 * Creates a new organization for a player.
 * Initializes the organization with the specified name, owner, and optional starting funds and reputation.
 *
 * Arguments:
 * 0: Owner UID <STRING> - Player UID who will own the organization
 * 1: Organization Name <STRING> - Name of the organization
 * 2: Initial Funds <NUMBER> (Optional, default: 0) - Starting funds for the organization
 * 3: Initial Reputation <NUMBER> (Optional, default: 0) - Starting reputation for the organization
 *
 * Return Value:
 * Organization Data <HASHMAP> - The newly created organization data, or nil if creation failed
 *
 * Example:
 * [getPlayerUID player, "Alpha Squad", 5000, 100] call forge_client_org_fnc_create
 * [getPlayerUID player, "Bravo Team"] call forge_client_org_fnc_create // With default funds and reputation
 *
 * Public: Yes
 */

params [
    ["_ownerUID", "", [""]],
    ["_name", "", [""]], 
    ["_initialFunds", 0, [0]], 
    ["_initialReputation", 0, [0]]
];

// Validate input parameters
if (_ownerUID == "" || _name == "") exitWith {
    ["Invalid parameters for organization creation", "error", 5, "right"] call forge_client_misc_fnc_notify;
    nil 
};

// Get the organization store interface
private _store = call FUNC(verifyOrgStore);

// Create the organization with the provided parameters
private _orgData = _store call ["createOrg", [_ownerUID, _name, _initialFunds, _initialReputation]];

// Provide feedback based on success or failure
if (isNil "_orgData") then {
    [format ["Failed to create organization '%1'", _name], "error", 5, "right"] call forge_client_misc_fnc_notify;
} else {
    [format ["Organization '%1' created successfully", _name], "success", 5, "right"] call forge_client_misc_fnc_notify;
};

// Return the organization data for further operations
_orgData