#include "..\script_component.hpp"

/*
 * Function: forge_client_org_fnc_addReputation
 * Author: IDSolutions
 *
 * [Description]
 * Adds or removes reputation from an organization.
 * Positive values increase reputation, negative values decrease reputation.
 *
 * Arguments:
 * 0: Amount <NUMBER> - Amount of reputation to add (positive) or subtract (negative)
 *
 * Return Value:
 * Success <BOOLEAN> - True if reputation was updated successfully, false otherwise
 *
 * Example:
 * [10] call forge_client_org_fnc_addReputation // Add 10 reputation
 * [-5] call forge_client_org_fnc_addReputation // Remove 5 reputation
 *
 * Public: Yes
 */

params [["_amount", 0, [0]]];

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

// Update the organization's reputation
private _result = _store call ["updateReputation", [_amount]];

// Provide feedback based on success or failure
if (_result) then {
    // Format a user-friendly message based on whether we're adding or subtracting
    private _actionText = ["decreased", "increased"] select (_amount > 0);
    private _absAmount = abs _amount;
    [format ["Organization reputation %1 by %2 points", _actionText, _absAmount], "info", 5, "right"] call forge_client_misc_fnc_notify;
} else {
    ["Failed to update organization reputation", "error", 5, "right"] call forge_client_misc_fnc_notify;
};

// Return the result for further operations
_result