Initial commit

This commit is contained in:
2026-08-24 22:20:36 +02:00
commit 62f7b1278a
251 changed files with 16670 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
class PlayerBehaviour {
constructor(info) {
this.id = info.id;
this.size = info.size ?? 32;
this.entries = Array.from({ length: this.size }, () => ({ isProcessed: false, timestamp: Infinity, entry: {}, id: 0 }));
this.accumulator = 0;
this.buffer = info.buffer;
};
add(entry) {
const index = this.accumulator++ % this.size;
this.entries[index] = {
timestamp: Date.now(),
entry,
id: this.id,
isProcessed: false
};
}
save(threshold) {
const now = Date.now();
for (let i = 0; i < this.size; i++) {
const entry = this.entries[i];
if (entry.id === 0) continue;
if (entry.isProcessed) continue;
if (entry.timestamp + threshold < now) continue;
entry.isProcessed = true;
// require("../Miscellaneous/winston").error(entry)
this.buffer.push(entry.entry); // entry.entry
};
return this.buffer;
}
};
module.exports = PlayerBehaviour;