mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
26 lines
855 B
JavaScript
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).`,
|
|
});
|
|
},
|
|
};
|