refactor: add fuel efficiency tracking to Turtle class

This commit is contained in:
MayaTheShy
2026-02-20 04:17:47 -05:00
parent e3abdb612c
commit 88fdd1c46d

View File

@@ -98,6 +98,11 @@ export class Turtle extends EventEmitter {
this._messageIndex = 0;
this._lastPromise = Promise.resolve(); // Promise chain for sequential exec
// Fuel efficiency tracking
this._stepsSinceLastRefuel = 0;
this._totalSteps = 0;
this._totalFuelUsed = 0;
// Connection tracking
this.connected = false;
this.lastUpdate = Date.now();
@@ -447,6 +452,8 @@ export class Turtle extends EventEmitter {
if (result === true || (Array.isArray(result) && result[0] === true)) {
this.updatePositionForward();
this._deleteBlockAtPosition(this._position);
this._stepsSinceLastRefuel++;
this._totalSteps++;
}
return result;
}