## 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
79 lines
2.4 KiB
Plaintext
79 lines
2.4 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
PREP_RECOMPILE_START;
|
|
#include "XEH_PREP.hpp"
|
|
PREP_RECOMPILE_END;
|
|
|
|
GVAR(PlayerBootstrapRegistry) = createHashMap;
|
|
|
|
["forge_icom_event", {
|
|
params [["_event", "", [""]], ["_data", createHashMap, [createHashMap]]];
|
|
|
|
systemChat format ["ICOM Event: %1", _event];
|
|
diag_log format ["[ICOM] Event received: %1 | Data: %2", _event, _data];
|
|
|
|
switch (_event) do {
|
|
case "supply_drop": {
|
|
systemChat "Supply drop event received";
|
|
|
|
private _coords = _data getOrDefault ["coords", []];
|
|
private _supplies = _data getOrDefault ["supplies", []];
|
|
|
|
diag_log format ["[ICOM] Supply drop at %1 with supplies: %2", _coords, _supplies];
|
|
};
|
|
case "spawn_mission": {
|
|
systemChat "Mission spawn event received";
|
|
|
|
private _missionType = _data getOrDefault ["mission_type", ""];
|
|
private _location = _data getOrDefault ["location", []];
|
|
|
|
diag_log format ["[ICOM] Spawning mission type '%1' at %2", _missionType, _location];
|
|
};
|
|
case "global_alert": {
|
|
systemChat "Global event received";
|
|
|
|
private _message = _data getOrDefault ["message", ""];
|
|
private _severity = _data getOrDefault ["severity", ""];
|
|
|
|
diag_log format ["[ICOM] Global event '%1' severity: %2", _message, _severity];
|
|
};
|
|
default {
|
|
diag_log format ["[ICOM] Unhandled event: %1", _event];
|
|
};
|
|
};
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
diag_log "[ICOM] Event handler initialized";
|
|
|
|
addMissionEventHandler ["ExtensionCallback", {
|
|
params ["_name", "_function", "_data"];
|
|
|
|
if (_name isEqualTo "icom") then {
|
|
["forge_icom_event", (fromJSON _data)] call CFUNC(serverEvent);
|
|
} else {
|
|
(fromJSON _data) call (missionNamespace getVariable [_function, {
|
|
diag_log "[FORGE:Server] Function does not exist!";
|
|
}]);
|
|
};
|
|
}];
|
|
|
|
addMissionEventHandler ["PlayerConnected", {
|
|
params ["_id", "_uid", "_name", "_jip", "_owner", "_idStr"];
|
|
}];
|
|
|
|
addMissionEventHandler ["PlayerDisconnected", {
|
|
params ["_id", "_uid", "_name", "_jip", "_owner", "_idStr"];
|
|
|
|
if (_uid isEqualTo "") exitWith {};
|
|
|
|
[_uid] call FUNC(saveHotState);
|
|
}];
|
|
|
|
addMissionEventHandler ["Ended", {
|
|
[""] call FUNC(saveHotState);
|
|
}];
|
|
|
|
addMissionEventHandler ["MPEnded", {
|
|
[""] call FUNC(saveHotState);
|
|
}];
|