Emit task and CAD state changes on the event bus
- Add task reward, notification, and rating events - Emit CAD assignment, request, and group updates - Route org and bank sync through event bus listeners
This commit is contained in:
parent
9deb73ec8e
commit
c6a0982450
@ -1,3 +1,21 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
call FUNC(initBank);
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
|
||||
if (isNil QGVAR(AccountSyncEventTokens)) then {
|
||||
private _sendAccountSync = {
|
||||
params ["_event"];
|
||||
|
||||
private _uid = _event getOrDefault ["uid", ""];
|
||||
private _account = _event getOrDefault ["account", createHashMap];
|
||||
private _responseEvent = _event getOrDefault ["responseEvent", CRPC(bank,responseSyncBank)];
|
||||
|
||||
if (_uid isEqualTo "" || { _account isEqualTo createHashMap }) exitWith {};
|
||||
GVAR(BankMessenger) call ["sendAccountSync", [_uid, _account, _responseEvent]];
|
||||
};
|
||||
|
||||
GVAR(AccountSyncEventTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["bank.account.sync.requested", _sendAccountSync, "bank.account.sync"]]
|
||||
];
|
||||
};
|
||||
|
||||
@ -35,7 +35,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadAssignment),
|
||||
"assignTaskToGroup",
|
||||
[_uid, _taskID, _groupID, _note],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -60,7 +60,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadAssignment),
|
||||
"createDispatchOrder",
|
||||
[_uid, _assigneeGroupID, _targetGroupID, _note, _priority, _request],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -83,7 +83,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadRequest),
|
||||
"submitSupportRequest",
|
||||
[_uid, _type, _fields, _priority],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -101,7 +101,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadRequest),
|
||||
"closeSupportRequest",
|
||||
[_uid, _requestID],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -119,7 +119,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadAssignment),
|
||||
"acknowledgeTask",
|
||||
[_uid, _taskID],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -137,7 +137,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadAssignment),
|
||||
"closeDispatchOrder",
|
||||
[_uid, _taskID],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -155,7 +155,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadAssignment),
|
||||
"declineTask",
|
||||
[_uid, _taskID],
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -173,7 +173,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadGroupUpdate),
|
||||
"updateGroupStatus",
|
||||
[_uid, _groupID, _status],
|
||||
true,
|
||||
false,
|
||||
true
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -191,7 +191,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadGroupUpdate),
|
||||
"updateGroupRole",
|
||||
[_uid, _groupID, _role],
|
||||
true,
|
||||
false,
|
||||
true
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
@ -214,7 +214,7 @@ call FUNC(registerTaskEventListeners);
|
||||
CRPC(cad,responseCadGroupUpdate),
|
||||
"updateGroupProfile",
|
||||
[_uid, _groupID, _status, _role],
|
||||
true,
|
||||
false,
|
||||
true
|
||||
]];
|
||||
}] call CFUNC(addEventHandler);
|
||||
|
||||
@ -130,6 +130,71 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
|
||||
_self call ["sendRpcResult", [_player, _responseRpc, _result, _invalidateOnSuccess, _requireChanged]];
|
||||
_result
|
||||
}],
|
||||
["emitAssignmentEvent", compileFinal {
|
||||
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
|
||||
|
||||
if (_eventName isEqualTo "" || { !(_result getOrDefault ["success", false]) }) exitWith { createHashMap };
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
|
||||
|
||||
private _assignment = +(_result getOrDefault ["assignment", createHashMap]);
|
||||
private _payload = createHashMapFromArray [
|
||||
["taskID", _assignment getOrDefault ["taskId", ""]],
|
||||
["assignment", _assignment],
|
||||
["leaderUid", _result getOrDefault ["leaderUid", ""]],
|
||||
["isDispatchOrder", _result getOrDefault ["isDispatchOrder", false]],
|
||||
["message", _result getOrDefault ["message", ""]]
|
||||
];
|
||||
|
||||
if (_result getOrDefault ["isDispatchOrder", false]) then {
|
||||
_payload set ["order", +(_result getOrDefault ["order", createHashMap])];
|
||||
};
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
_eventName,
|
||||
_payload,
|
||||
createHashMapFromArray [["source", "cad"]]
|
||||
]]
|
||||
}],
|
||||
["emitRequestEvent", compileFinal {
|
||||
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
|
||||
|
||||
if (_eventName isEqualTo "" || { !(_result getOrDefault ["success", false]) }) exitWith { createHashMap };
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
|
||||
|
||||
private _request = +(_result getOrDefault ["request", createHashMap]);
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
_eventName,
|
||||
createHashMapFromArray [
|
||||
["requestID", _request getOrDefault ["requestId", ""]],
|
||||
["groupID", _request getOrDefault ["groupId", ""]],
|
||||
["request", _request],
|
||||
["message", _result getOrDefault ["message", ""]]
|
||||
],
|
||||
createHashMapFromArray [["source", "cad"]]
|
||||
]]
|
||||
}],
|
||||
["emitGroupEvent", compileFinal {
|
||||
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
|
||||
|
||||
if (
|
||||
_eventName isEqualTo ""
|
||||
|| { !(_result getOrDefault ["success", false]) }
|
||||
|| { !(_result getOrDefault ["changed", true]) }
|
||||
) exitWith { createHashMap };
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
|
||||
|
||||
private _group = +(_result getOrDefault ["group", createHashMap]);
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
_eventName,
|
||||
createHashMapFromArray [
|
||||
["groupID", _group getOrDefault ["groupId", ""]],
|
||||
["group", _group],
|
||||
["message", _result getOrDefault ["message", ""]],
|
||||
["changed", _result getOrDefault ["changed", true]]
|
||||
],
|
||||
createHashMapFromArray [["source", "cad"]]
|
||||
]]
|
||||
}],
|
||||
["notifyAssignmentLeader", compileFinal {
|
||||
params [["_result", createHashMap, [createHashMap]]];
|
||||
|
||||
@ -165,6 +230,7 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
|
||||
if !(_result getOrDefault ["success", false]) exitWith { _result };
|
||||
|
||||
_self call ["notifyAssignmentLeader", [_result]];
|
||||
_self call ["emitAssignmentEvent", ["cad.assignment.assigned", _result]];
|
||||
_result
|
||||
}],
|
||||
["createDispatchOrder", compileFinal {
|
||||
@ -172,31 +238,48 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
|
||||
if !(_result getOrDefault ["success", false]) exitWith { _result };
|
||||
|
||||
_self call ["notifyAssignmentLeader", [_result]];
|
||||
_self call ["emitAssignmentEvent", ["cad.assignment.created", _result]];
|
||||
_result
|
||||
}],
|
||||
["closeDispatchOrder", compileFinal {
|
||||
(_self get "AssignmentRepository") call ["closeDispatchOrder", _this]
|
||||
private _result = (_self get "AssignmentRepository") call ["closeDispatchOrder", _this];
|
||||
_self call ["emitAssignmentEvent", ["cad.assignment.closed", _result]];
|
||||
_result
|
||||
}],
|
||||
["submitSupportRequest", compileFinal {
|
||||
(_self get "RequestRepository") call ["submitRequest", _this]
|
||||
private _result = (_self get "RequestRepository") call ["submitRequest", _this];
|
||||
_self call ["emitRequestEvent", ["cad.request.submitted", _result]];
|
||||
_result
|
||||
}],
|
||||
["closeSupportRequest", compileFinal {
|
||||
(_self get "RequestRepository") call ["closeRequest", _this]
|
||||
private _result = (_self get "RequestRepository") call ["closeRequest", _this];
|
||||
_self call ["emitRequestEvent", ["cad.request.closed", _result]];
|
||||
_result
|
||||
}],
|
||||
["acknowledgeTask", compileFinal {
|
||||
(_self get "AssignmentRepository") call ["acknowledgeTask", _this]
|
||||
private _result = (_self get "AssignmentRepository") call ["acknowledgeTask", _this];
|
||||
_self call ["emitAssignmentEvent", ["cad.assignment.acknowledged", _result]];
|
||||
_result
|
||||
}],
|
||||
["declineTask", compileFinal {
|
||||
(_self get "AssignmentRepository") call ["declineTask", _this]
|
||||
private _result = (_self get "AssignmentRepository") call ["declineTask", _this];
|
||||
_self call ["emitAssignmentEvent", ["cad.assignment.declined", _result]];
|
||||
_result
|
||||
}],
|
||||
["updateGroupStatus", compileFinal {
|
||||
(_self get "GroupRepository") call ["updateGroupStatus", _this]
|
||||
private _result = (_self get "GroupRepository") call ["updateGroupStatus", _this];
|
||||
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
|
||||
_result
|
||||
}],
|
||||
["updateGroupRole", compileFinal {
|
||||
(_self get "GroupRepository") call ["updateGroupRole", _this]
|
||||
private _result = (_self get "GroupRepository") call ["updateGroupRole", _this];
|
||||
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
|
||||
_result
|
||||
}],
|
||||
["updateGroupProfile", compileFinal {
|
||||
(_self get "GroupRepository") call ["updateGroupProfile", _this]
|
||||
private _result = (_self get "GroupRepository") call ["updateGroupProfile", _this];
|
||||
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
|
||||
_result
|
||||
}],
|
||||
["buildHydratePayload", compileFinal {
|
||||
params [["_uid", "", [""]]];
|
||||
|
||||
@ -36,12 +36,63 @@ private _invalidateCadState = {
|
||||
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
|
||||
};
|
||||
|
||||
private _invalidateCadAssignmentState = {
|
||||
params ["_event"];
|
||||
|
||||
private _assignment = _event getOrDefault ["assignment", createHashMap];
|
||||
["INFO", format [
|
||||
"CAD assignment event received: %1 taskID=%2 groupID=%3 state=%4",
|
||||
_event getOrDefault ["event", ""],
|
||||
_event getOrDefault ["taskID", ""],
|
||||
_assignment getOrDefault ["groupId", ""],
|
||||
_assignment getOrDefault ["state", ""]
|
||||
]] call EFUNC(common,log);
|
||||
|
||||
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
|
||||
};
|
||||
|
||||
private _invalidateCadRequestState = {
|
||||
params ["_event"];
|
||||
|
||||
["INFO", format [
|
||||
"CAD request event received: %1 requestID=%2 groupID=%3",
|
||||
_event getOrDefault ["event", ""],
|
||||
_event getOrDefault ["requestID", ""],
|
||||
_event getOrDefault ["groupID", ""]
|
||||
]] call EFUNC(common,log);
|
||||
|
||||
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
|
||||
};
|
||||
|
||||
private _invalidateCadGroupState = {
|
||||
params ["_event"];
|
||||
|
||||
private _group = _event getOrDefault ["group", createHashMap];
|
||||
["INFO", format [
|
||||
"CAD group event received: %1 groupID=%2 status=%3 role=%4",
|
||||
_event getOrDefault ["event", ""],
|
||||
_event getOrDefault ["groupID", ""],
|
||||
_group getOrDefault ["status", ""],
|
||||
_group getOrDefault ["role", ""]
|
||||
]] call EFUNC(common,log);
|
||||
|
||||
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
|
||||
};
|
||||
|
||||
GVAR(TaskEventListenerTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["task.created", _invalidateCadState, "cad.task.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.started", _invalidateCadState, "cad.task.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.completed", _invalidateCadState, "cad.task.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.failed", _invalidateCadState, "cad.task.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.cleared", _invalidateCadState, "cad.task.invalidate"]]
|
||||
EGVAR(common,EventBus) call ["on", ["task.cleared", _invalidateCadState, "cad.task.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.assignment.assigned", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.assignment.created", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.assignment.acknowledged", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.assignment.declined", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.assignment.closed", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.request.submitted", _invalidateCadRequestState, "cad.request.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.request.closed", _invalidateCadRequestState, "cad.request.invalidate"]],
|
||||
EGVAR(common,EventBus) call ["on", ["cad.group.updated", _invalidateCadGroupState, "cad.group.invalidate"]]
|
||||
];
|
||||
|
||||
GVAR(TaskEventListenerTokens)
|
||||
|
||||
@ -29,6 +29,20 @@ The event bus is initialized as `forge_server_common_EventBus` during store
|
||||
bootstrap. It is synchronous and in-process: listeners run immediately when an
|
||||
event is emitted.
|
||||
|
||||
### Event Naming
|
||||
Use lower-case dot-separated names:
|
||||
|
||||
- `<domain>.<entity>.<action>` for domain events, such as `cad.assignment.assigned`
|
||||
- `<domain>.<action>` for simple lifecycle events, such as `task.started`
|
||||
|
||||
Prefer past-tense action names for events that report completed state changes:
|
||||
`created`, `started`, `assigned`, `acknowledged`, `declined`, `completed`,
|
||||
`failed`, `cleared`, `updated`, `closed`.
|
||||
|
||||
Payloads should be hash maps and should include stable identifiers first:
|
||||
`taskID`, `requestID`, `groupID`, `uid`, `orgID`, or `accountID` as appropriate.
|
||||
The event bus adds `event`, `source`, and `timestamp` when the event is emitted.
|
||||
|
||||
```sqf
|
||||
private _token = EGVAR(common,EventBus) call ["on", [
|
||||
"task.completed",
|
||||
|
||||
@ -1 +1,23 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
|
||||
if (isNil QGVAR(SyncEventTokens)) then {
|
||||
private _sendOrgSync = {
|
||||
params ["_event"];
|
||||
|
||||
private _patch = _event getOrDefault ["patch", createHashMap];
|
||||
private _memberUids = +(_event getOrDefault ["memberUids", []]);
|
||||
|
||||
if (_memberUids isEqualTo []) exitWith {};
|
||||
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
|
||||
} forEach _memberUids;
|
||||
};
|
||||
|
||||
GVAR(SyncEventTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["org.sync.requested", _sendOrgSync, "org.sync"]]
|
||||
];
|
||||
};
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
|
||||
|
||||
// Temporary migration instrumentation. Keep this visible while task lifecycle
|
||||
// events are being moved onto the framework event bus.
|
||||
if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
|
||||
private _logTaskLifecycleEvent = {
|
||||
params ["_event"];
|
||||
|
||||
if !(missionNamespace getVariable [QGVAR(enableEventLogs), true]) exitWith {};
|
||||
|
||||
["INFO", format [
|
||||
"Task lifecycle event: %1 taskID=%2 taskType=%3 status=%4 participants=%5",
|
||||
_event getOrDefault ["event", ""],
|
||||
@ -18,12 +17,92 @@ if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
|
||||
]] call EFUNC(common,log);
|
||||
};
|
||||
|
||||
private _logTaskRewardEvent = {
|
||||
params ["_event"];
|
||||
|
||||
if !(missionNamespace getVariable [QGVAR(enableEventLogs), true]) exitWith {};
|
||||
|
||||
["INFO", format [
|
||||
"Task reward event: %1 taskID=%2 success=%3 message=%4",
|
||||
_event getOrDefault ["event", ""],
|
||||
_event getOrDefault ["taskID", ""],
|
||||
!((_event getOrDefault ["event", ""]) in ["task.reward.failed", "task.rating.failed"]),
|
||||
_event getOrDefault ["message", ""]
|
||||
]] call EFUNC(common,log);
|
||||
};
|
||||
|
||||
GVAR(TaskLifecycleEventLogTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["task.created", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.started", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.completed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.failed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.cleared", _logTaskLifecycleEvent, "task.lifecycle.log"]]
|
||||
EGVAR(common,EventBus) call ["on", ["task.cleared", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.reward.requested", _logTaskRewardEvent, "task.reward.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.reward.applied", _logTaskRewardEvent, "task.reward.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.reward.failed", _logTaskRewardEvent, "task.reward.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.rating.applied", _logTaskRewardEvent, "task.reward.log"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.rating.failed", _logTaskRewardEvent, "task.reward.log"]]
|
||||
];
|
||||
};
|
||||
|
||||
if (isNil QGVAR(TaskNotificationEventTokens)) then {
|
||||
private _sendTaskNotification = {
|
||||
params ["_event"];
|
||||
|
||||
private _type = _event getOrDefault ["notificationType", "info"];
|
||||
private _title = _event getOrDefault ["title", "Tasks"];
|
||||
private _message = _event getOrDefault ["message", ""];
|
||||
private _participantUids = +(_event getOrDefault ["participantUids", []]);
|
||||
|
||||
if (_message isEqualTo "" || { _participantUids isEqualTo [] }) exitWith {};
|
||||
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
|
||||
} forEach _participantUids;
|
||||
|
||||
if (missionNamespace getVariable [QGVAR(enableEventLogs), true]) then {
|
||||
["INFO", format [
|
||||
"Task notification event: taskID=%1 type=%2 recipients=%3 message=%4",
|
||||
_event getOrDefault ["taskID", ""],
|
||||
_type,
|
||||
_participantUids,
|
||||
_message
|
||||
]] call EFUNC(common,log);
|
||||
};
|
||||
};
|
||||
|
||||
private _sendRewardNotification = {
|
||||
params ["_event"];
|
||||
|
||||
private _type = _event getOrDefault ["notificationType", "info"];
|
||||
private _title = _event getOrDefault ["title", "Tasks"];
|
||||
private _message = _event getOrDefault ["message", ""];
|
||||
private _memberUids = +(_event getOrDefault ["memberUids", []]);
|
||||
|
||||
if (_message isEqualTo "" || { _memberUids isEqualTo [] }) exitWith {};
|
||||
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
|
||||
} forEach _memberUids;
|
||||
|
||||
if (missionNamespace getVariable [QGVAR(enableEventLogs), true]) then {
|
||||
["INFO", format [
|
||||
"Task reward notification event: taskID=%1 type=%2 recipients=%3 message=%4",
|
||||
_event getOrDefault ["taskID", ""],
|
||||
_type,
|
||||
_memberUids,
|
||||
_message
|
||||
]] call EFUNC(common,log);
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(TaskNotificationEventTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["task.notification.requested", _sendTaskNotification, "task.notification.send"]],
|
||||
EGVAR(common,EventBus) call ["on", ["task.reward.notification.requested", _sendRewardNotification, "task.reward.notification.send"]]
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
@ -574,11 +574,29 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
private _participantSnapshots = +(_participantRegistry getOrDefault [_taskID, createHashMap]);
|
||||
if (_participantSnapshots isEqualTo createHashMap) exitWith { false };
|
||||
|
||||
private _participantUids = keys _participantSnapshots;
|
||||
if (_participantUids isEqualTo []) exitWith { false };
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith {
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
|
||||
} forEach (keys _participantSnapshots);
|
||||
} forEach _participantUids;
|
||||
true
|
||||
};
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
"task.notification.requested",
|
||||
createHashMapFromArray [
|
||||
["taskID", _taskID],
|
||||
["notificationType", _type],
|
||||
["title", _title],
|
||||
["message", _message],
|
||||
["participantUids", _participantUids]
|
||||
],
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]];
|
||||
|
||||
true
|
||||
}],
|
||||
@ -586,9 +604,6 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
params [["_taskID", "", [""]]];
|
||||
|
||||
if (_taskID isEqualTo "") exitWith { false };
|
||||
if !(isNil QGVAR(MissionManager)) then {
|
||||
GVAR(MissionManager) call ["completeMission", [_taskID]];
|
||||
};
|
||||
|
||||
_self call ["emitTaskLifecycleEvent", ["task.cleared", _taskID, "cleared", createHashMap]];
|
||||
|
||||
@ -607,6 +622,22 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
["applyRatingOutcome", compileFinal {
|
||||
params [["_taskID", "", [""]], ["_delta", 0, [0]]];
|
||||
|
||||
private _emitRatingEvent = {
|
||||
params [["_eventName", "", [""]], ["_payload", createHashMap, [createHashMap]]];
|
||||
|
||||
if (_eventName isEqualTo "" || { isNil QEGVAR(common,EventBus) }) exitWith { createHashMap };
|
||||
|
||||
private _eventPayload = +_payload;
|
||||
_eventPayload set ["taskID", _taskID];
|
||||
_eventPayload set ["ratingDelta", _delta];
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
_eventName,
|
||||
_eventPayload,
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]]
|
||||
};
|
||||
|
||||
private _result = createHashMapFromArray [
|
||||
["participantUids", []],
|
||||
["orgIds", []],
|
||||
@ -640,7 +671,19 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
};
|
||||
};
|
||||
};
|
||||
if (_participantUids isEqualTo []) exitWith { _result };
|
||||
if (_participantUids isEqualTo []) exitWith {
|
||||
_result set ["success", false];
|
||||
_result set ["message", "No task participants were available for rating outcome."];
|
||||
["task.rating.failed", createHashMapFromArray [
|
||||
["participantUids", []],
|
||||
["orgIds", []],
|
||||
["contributions", createHashMap],
|
||||
["mutationFailures", []],
|
||||
["persistenceFailures", []],
|
||||
["message", _result get "message"]
|
||||
]] call _emitRatingEvent;
|
||||
_result
|
||||
};
|
||||
|
||||
private _orgIds = [];
|
||||
private _contributions = createHashMap;
|
||||
@ -660,6 +703,16 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
};
|
||||
|
||||
if (_totalContribution <= 0) exitWith {
|
||||
_result set ["success", false];
|
||||
_result set ["message", "No eligible participant contribution was available for rating outcome."];
|
||||
["task.rating.failed", createHashMapFromArray [
|
||||
["participantUids", +_participantUids],
|
||||
["orgIds", +_orgIds],
|
||||
["contributions", +_contributions],
|
||||
["mutationFailures", []],
|
||||
["persistenceFailures", []],
|
||||
["message", _result get "message"]
|
||||
]] call _emitRatingEvent;
|
||||
_self call ["clearTask", [_taskID]];
|
||||
_result
|
||||
};
|
||||
@ -696,7 +749,19 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
if !(_patch isEqualType createHashMap) then { continue; };
|
||||
if (_patch isEqualTo createHashMap) then { continue; };
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) then {
|
||||
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
|
||||
} else {
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
"bank.account.sync.requested",
|
||||
createHashMapFromArray [
|
||||
["uid", _uid],
|
||||
["account", +_patch]
|
||||
],
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]];
|
||||
};
|
||||
|
||||
if ((EGVAR(bank,BankStore) call ["save", [_uid]]) isEqualTo createHashMap) then {
|
||||
_persistenceFailures pushBackUnique format ["bank:%1", _uid];
|
||||
["ERROR", format ["Task %1 updated bank earnings for %2, but durable save failed.", _taskID, _uid]] call EFUNC(common,log);
|
||||
@ -724,11 +789,23 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
if (_updatedOrg isNotEqualTo createHashMap) then {
|
||||
private _patch = createHashMapFromArray [["reputation", _nextReputation]];
|
||||
private _memberUids = _rewardContext getOrDefault ["memberUids", []];
|
||||
if (isNil QEGVAR(common,EventBus)) then {
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
|
||||
} forEach _memberUids;
|
||||
} else {
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
"org.sync.requested",
|
||||
createHashMapFromArray [
|
||||
["orgID", _ownerOrgID],
|
||||
["memberUids", +_memberUids],
|
||||
["patch", +_patch]
|
||||
],
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]];
|
||||
};
|
||||
|
||||
_orgIds = [_ownerOrgID];
|
||||
if ((EGVAR(org,OrgStore) call ["saveById", [_ownerOrgID]]) isEqualTo createHashMap) then {
|
||||
@ -758,6 +835,17 @@ GVAR(TaskStore) = createHashMapObject [[
|
||||
};
|
||||
_result set ["message", _messageParts joinString "; "];
|
||||
};
|
||||
|
||||
private _eventName = ["task.rating.failed", "task.rating.applied"] select (_result getOrDefault ["success", false]);
|
||||
[_eventName, createHashMapFromArray [
|
||||
["participantUids", +(_result getOrDefault ["participantUids", []])],
|
||||
["orgIds", +(_result getOrDefault ["orgIds", []])],
|
||||
["contributions", +(_result getOrDefault ["contributions", createHashMap])],
|
||||
["mutationFailures", +(_result getOrDefault ["mutationFailures", []])],
|
||||
["persistenceFailures", +(_result getOrDefault ["persistenceFailures", []])],
|
||||
["message", _result getOrDefault ["message", ""]]
|
||||
]] call _emitRatingEvent;
|
||||
|
||||
_result
|
||||
}]
|
||||
]];
|
||||
|
||||
@ -131,6 +131,26 @@ GVAR(MissionManagerBaseClass) = compileFinal createHashMapFromArray [
|
||||
];
|
||||
|
||||
GVAR(MissionManager) = createHashMapObject [GVAR(MissionManagerBaseClass)];
|
||||
|
||||
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
|
||||
if (isNil QGVAR(MissionManagerTaskEventTokens)) then {
|
||||
private _handleTaskCleared = {
|
||||
params ["_event"];
|
||||
|
||||
private _taskID = _event getOrDefault ["taskID", ""];
|
||||
if (_taskID isEqualTo "") exitWith {};
|
||||
if (isNil QGVAR(MissionManager)) exitWith {};
|
||||
|
||||
if (GVAR(MissionManager) call ["completeMission", [_taskID]]) then {
|
||||
["INFO", format ["Mission manager completed generated mission from event. TaskID=%1", _taskID]] call EFUNC(common,log);
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(MissionManagerTaskEventTokens) = [
|
||||
EGVAR(common,EventBus) call ["on", ["task.cleared", _handleTaskCleared, "task.missionManager.cleanup"]]
|
||||
];
|
||||
};
|
||||
|
||||
if (GVAR(enableGenerator)) then {
|
||||
GVAR(MissionManagerPFH) = [{
|
||||
GVAR(MissionManager) call ["cleanupCompletedMissions", []];
|
||||
|
||||
@ -39,15 +39,39 @@ if (_taskID == "") exitWith {
|
||||
false
|
||||
};
|
||||
|
||||
private _emitRewardEvent = {
|
||||
params [["_eventName", "", [""]], ["_payload", createHashMap, [createHashMap]]];
|
||||
|
||||
if (_eventName isEqualTo "" || { isNil QEGVAR(common,EventBus) }) exitWith { createHashMap };
|
||||
|
||||
private _eventPayload = +_payload;
|
||||
_eventPayload set ["taskID", _taskID];
|
||||
_eventPayload set ["rewardData", +_rewards];
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
_eventName,
|
||||
_eventPayload,
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]]
|
||||
};
|
||||
|
||||
private _rewardContext = GVAR(TaskStore) call ["resolveRewardContext", [_taskID]];
|
||||
private _requesterUid = _rewardContext getOrDefault ["requesterUid", ""];
|
||||
private _orgID = _rewardContext getOrDefault ["orgID", ""];
|
||||
private _memberUids = _rewardContext getOrDefault ["memberUids", []];
|
||||
if (_orgID isEqualTo "") exitWith {
|
||||
["ERROR", format ["No organization reward context found for task %1.", _taskID]] call EFUNC(common,log);
|
||||
["task.reward.failed", createHashMapFromArray [
|
||||
["rewardContext", _rewardContext],
|
||||
["failureMessages", ["missing organization reward context"]]
|
||||
]] call _emitRewardEvent;
|
||||
false
|
||||
};
|
||||
|
||||
["task.reward.requested", createHashMapFromArray [
|
||||
["rewardContext", _rewardContext]
|
||||
]] call _emitRewardEvent;
|
||||
|
||||
private _success = true;
|
||||
private _funds = _rewards getOrDefault ["funds", 0];
|
||||
private _rewardMessages = [];
|
||||
@ -78,22 +102,48 @@ private _notifyMembers = {
|
||||
params [["_type", "info", [""]], ["_title", "Tasks", [""]], ["_message", "", [""]]];
|
||||
|
||||
if (_message isEqualTo "") exitWith {};
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith {
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
|
||||
} forEach _memberUids;
|
||||
};
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
"task.reward.notification.requested",
|
||||
createHashMapFromArray [
|
||||
["taskID", _taskID],
|
||||
["notificationType", _type],
|
||||
["title", _title],
|
||||
["message", _message],
|
||||
["memberUids", +_memberUids]
|
||||
],
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]];
|
||||
};
|
||||
|
||||
private _syncOrgPatch = {
|
||||
params [["_patch", createHashMap, [createHashMap]]];
|
||||
|
||||
if (_patch isEqualTo createHashMap) exitWith {};
|
||||
if (isNil QEGVAR(common,EventBus)) exitWith {
|
||||
{
|
||||
private _player = [_x] call EFUNC(common,getPlayer);
|
||||
if (isNull _player) then { continue; };
|
||||
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
|
||||
} forEach _memberUids;
|
||||
};
|
||||
|
||||
EGVAR(common,EventBus) call ["emit", [
|
||||
"org.sync.requested",
|
||||
createHashMapFromArray [
|
||||
["orgID", _orgID],
|
||||
["memberUids", +_memberUids],
|
||||
["patch", +_patch]
|
||||
],
|
||||
createHashMapFromArray [["source", "task"]]
|
||||
]];
|
||||
};
|
||||
|
||||
if (_funds > 0) then {
|
||||
@ -227,6 +277,11 @@ if (_success) then {
|
||||
|
||||
["INFO", _message] call EFUNC(common,log);
|
||||
["success", "Tasks", _message] call _notifyMembers;
|
||||
["task.reward.applied", createHashMapFromArray [
|
||||
["rewardContext", _rewardContext],
|
||||
["rewardMessages", +_rewardMessages],
|
||||
["message", _message]
|
||||
]] call _emitRewardEvent;
|
||||
} else {
|
||||
private _warningMessage = format ["Task %1 completed, but one or more org rewards failed to apply.", _taskID];
|
||||
if (_failureMessages isNotEqualTo []) then {
|
||||
@ -234,6 +289,12 @@ if (_success) then {
|
||||
};
|
||||
|
||||
["warning", "Tasks", _warningMessage] call _notifyMembers;
|
||||
["task.reward.failed", createHashMapFromArray [
|
||||
["rewardContext", _rewardContext],
|
||||
["rewardMessages", +_rewardMessages],
|
||||
["failureMessages", +_failureMessages],
|
||||
["message", _warningMessage]
|
||||
]] call _emitRewardEvent;
|
||||
};
|
||||
|
||||
_success
|
||||
|
||||
@ -203,8 +203,8 @@ GVAR(AttackTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -214,14 +214,14 @@ GVAR(AttackTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _targets;
|
||||
|
||||
if (_useTaskStore) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -149,8 +149,8 @@ GVAR(DefendTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -165,14 +165,14 @@ GVAR(DefendTaskBaseClass) = createHashMapFromArray [
|
||||
private _endSuccess = (_self getOrDefault ["taskParams", createHashMap]) getOrDefault ["endSuccess", false];
|
||||
|
||||
if (_self getOrDefault ["useTaskStore", false]) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -197,8 +197,8 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -218,14 +218,14 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _protected;
|
||||
|
||||
if (_self getOrDefault ["useTaskStore", false]) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -140,8 +140,8 @@ GVAR(DeliveryTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -159,14 +159,14 @@ GVAR(DeliveryTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _cargo;
|
||||
|
||||
if (_self getOrDefault ["useTaskStore", false]) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -120,8 +120,8 @@ GVAR(DestroyTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -139,14 +139,14 @@ GVAR(DestroyTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _targets;
|
||||
|
||||
if (_self getOrDefault ["useTaskStore", false]) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -175,8 +175,8 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -194,14 +194,14 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _hvts;
|
||||
|
||||
if (_self getOrDefault ["useTaskStore", false]) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -299,8 +299,8 @@ GVAR(HostageTaskBaseClass) = createHashMapFromArray [
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
@ -321,13 +321,14 @@ GVAR(HostageTaskBaseClass) = createHashMapFromArray [
|
||||
{ deleteVehicle _x } forEach _shooters;
|
||||
|
||||
if (_useTaskStore) then {
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
|
||||
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
|
||||
[_taskID, _rewardData] call FUNC(handleTaskRewards);
|
||||
|
||||
sleep 1;
|
||||
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
|
||||
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
|
||||
GVAR(TaskStore) call ["clearTask", [_taskID]];
|
||||
};
|
||||
|
||||
|
||||
@ -3,3 +3,9 @@
|
||||
[LSTRING(enableGenerator), LSTRING(enableGeneratorTooltip)],
|
||||
_category, false, true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(enableEventLogs), "CHECKBOX",
|
||||
[LSTRING(enableEventLogs), LSTRING(enableEventLogsTooltip)],
|
||||
_category, true, true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
<Key ID="STR_forge_server_task_displayName">
|
||||
<English>Task</English>
|
||||
</Key>
|
||||
<Key ID="STR_forge_server_task_enableEventLogs">
|
||||
<English>Enable Event Logs</English>
|
||||
</Key>
|
||||
<Key ID="STR_forge_server_task_enableEventLogsTooltip">
|
||||
<English>Log task event bus lifecycle, reward, rating, and notification events.</English>
|
||||
</Key>
|
||||
<Key ID="STR_forge_server_task_enableGenerator">
|
||||
<English>Enable Generator</English>
|
||||
</Key>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user