Files
MultiRoombaRover/server/src/rewards/definitions/dockPanic.js
T
2026-06-29 02:18:53 -04:00

26 lines
855 B
JavaScript

// Reward Definition: Dock Panic
// Purpose: Defines the dock-panic deterrence reward behavior and metadata. Scope: Produces a deterministic action payload used by reward execution pipelines.
const DOCK_COMMAND_BASE64 = Buffer.from([143]).toString('base64');
module.exports = {
id: 'dockPanic',
name: 'All Dock',
description: 'Forces all rovers into docking mode.',
goal: 180,
async run(ctx) {
const rovers = ctx.listOnlineRovers();
rovers.forEach((rover) => {
try {
ctx.issueCommand(String(rover.id), { type: 'raw', raw: DOCK_COMMAND_BASE64 });
} catch (err) {
ctx.logger.warn('dockPanic failed', { roverId: rover.id, error: err.message });
}
});
ctx.sendAlert({
color: '#ff9800',
title: 'All Dock',
message: `Issued seek-dock to ${rovers.length} rover(s).`,
});
},
};