forge/arma/server/addons/task/functions/fnc_defendModule.sqf
Jacob Schmidt ff7ff0c4e5 Implement org credit line debt and bank repayment flow (#2)
## Summary

This finishes the org credit line workflow so it behaves like reserved treasury-backed credit instead of a simple member allowance.

## What changed

- reserve org funds immediately when a credit line is assigned
- track credit lines with:
  - approved amount
  - available amount
  - outstanding principal
  - interest rate
  - amount due
- consume reserved credit during store checkout without charging org funds a second time
- add credit line repayment through the bank app
- sync richer credit line state into org and bank payloads/UI
- keep legacy `amount` compatibility mapped to available credit for older consumers

## User-facing behavior

- assigning a credit line now reduces available org funds immediately
- spending on `credit_line` reduces available credit and creates debt with interest
- the bank app now shows outstanding credit debt and allows repayment from personal bank funds
- the org treasury view now shows reserved credit and outstanding due totals

## Validation

- `cargo fmt`
- `npm run build:webui`
- `cargo test -p forge-services --quiet`
- `cargo test -p forge-server --quiet`

## Follow-up checks

- validate in-game that assigning a credit line reduces org funds immediately
- validate store checkout with `credit_line` updates available credit and debt correctly
- validate bank repayment decreases player bank balance, increases org funds, and reduces amount due

Co-authored-by: Jacob Schmidt <innovativestudios@outlook.com>
Reviewed-on: #2
2026-04-02 16:50:38 -05:00

62 lines
2.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Creates a defend task module
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call forge_server_task_fnc_defendModule;
*
* Public: No
*/
// Module category
private _category = "Forge Tasks";
private _subCategory = "Defense Tasks";
// Create the module
private _module = createDialog "RscDisplayAttributes";
_module setVariable ["category", _category];
_module setVariable ["subcategory", _subCategory];
_module setVariable ["description", "Configure a defend task"];
// Add fields for task configuration
[_module, "Task ID", "taskID", "", true] call BIS_fnc_addAttribute;
[_module, "Defense Zone Marker", "defenseZone", "", true] call BIS_fnc_addAttribute;
[_module, "Defense Time (seconds)", "defendTime", "600", true] call BIS_fnc_addAttribute;
[_module, "Min BLUFOR in Zone", "minBlufor", "1", true] call BIS_fnc_addAttribute;
[_module, "Company Funds Reward", "companyFunds", "500000", true] call BIS_fnc_addAttribute;
[_module, "Rating Loss on Fail", "ratingFail", "-100", true] call BIS_fnc_addAttribute;
[_module, "Rating Gain on Success", "ratingSuccess", "400", true] call BIS_fnc_addAttribute;
[_module, "End Mission on Success", "endSuccess", "false", false] call BIS_fnc_addAttribute;
[_module, "End Mission on Fail", "endFail", "false", false] call BIS_fnc_addAttribute;
[_module, "Enemy Wave Count", "waveCount", "3", false] call BIS_fnc_addAttribute;
[_module, "Time Between Waves (seconds)", "waveCooldown", "300", false] call BIS_fnc_addAttribute;
// Add confirm button handler
_module setVariable ["onConfirm", {
params ["_module"];
private _taskID = _module getVariable ["taskID", ""];
private _defenseZone = _module getVariable ["defenseZone", ""];
private _defendTime = parseNumber (_module getVariable ["defendTime", "600"]);
private _companyFunds = parseNumber (_module getVariable ["companyFunds", "500000"]);
private _ratingFail = parseNumber (_module getVariable ["ratingFail", "-100"]);
private _ratingSuccess = parseNumber (_module getVariable ["ratingSuccess", "400"]);
private _endSuccess = _module getVariable ["endSuccess", "false"] == "true";
private _endFail = _module getVariable ["endFail", "false"] == "true";
private _waveCount = parseNumber (_module getVariable ["waveCount", "3"]);
private _waveCooldown = parseNumber (_module getVariable ["waveCooldown", "300"]);
private _minBlufor = parseNumber (_module getVariable ["minBlufor", "1"]);
// Create the task
private _params = [_taskID, _defenseZone, _defendTime, _companyFunds, _ratingFail, _ratingSuccess, _endSuccess, _endFail, _waveCount, _waveCooldown, _minBlufor];
private _requesterUid = ["", getPlayerUID player] select hasInterface;
["defend", _params, 0, _requesterUid] spawn FUNC(handler);
}];