forge/arma/client/addons/bank/functions/fnc_initClass.sqf
Jacob Schmidt 6c0ce9e867 refactor(bank): split monolithic store into focused modules; fix locker grant for attachments
- Split BankBaseStore into SessionManager, Messenger, Model, Store, Validator
- Extract validation logic into BankValidator with try/catch and per-action methods
- Remove duplicate notifications from transaction actions
- Update event handlers to call validator first, forward context to store/session
- Fix locker grantItems: add missing 'attachment' category mapping to 'item'
- Fix locker grantItems: replace exitWith with if/else to prevent skipping remaining items

Co-Authored-By: Oz <oz-agent@warp.dev>
2026-03-16 10:54:25 -05:00

62 lines
1.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* File: fnc_initClass.sqf
* Author: IDSolutions
* Public: No
*
* Description:
* Initializes the bank class for account sync and access helpers.
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(BankBaseClass) = compileFinal createHashMapFromArray [
["#type", "BankBaseClass"],
["#create", compileFinal {
_self set ["uid", getPlayerUID player];
_self set ["account", createHashMapFromArray [
["bank", 0],
["cash", 0],
["earnings", 0],
["transactions", []]
]];
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["getAccountState", compileFinal {
_self getOrDefault ["account", createHashMap]
}],
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _account = _self getOrDefault ["account", createHashMap];
_account getOrDefault [_key, _default]
}],
["init", compileFinal {
[SRPC(bank,requestInitBank), [getPlayerUID player]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["save", compileFinal {
[SRPC(bank,requestSaveBank), [getPlayerUID player]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _account = _self getOrDefault ["account", createHashMap];
{
_account set [_x, _y];
} forEach _data;
_self set ["account", _account];
if !(_self getOrDefault ["isLoaded", false]) then {
_self set ["isLoaded", true];
};
true
}]
];
GVAR(BankClass) = createHashMapObject [GVAR(BankBaseClass)];
GVAR(BankClass)