diff --git a/files/defaultActions.owned.json b/files/defaultActions.owned.json index 5ce5970..c999b4b 100644 --- a/files/defaultActions.owned.json +++ b/files/defaultActions.owned.json @@ -973,5 +973,20 @@ "path": "spawning.spawnUptimePercentage", "value": 0, "type": 0 + }, + { + "path": "resourcesStored.score", + "value": 0, + "type": 1 + }, + { + "path": "controller.gclPerTick_upgraded", + "value": 0, + "type": 0 + }, + { + "path": "controller.rclPerTick_upgraded", + "value": 0, + "type": 0 } ] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8117c3f..38dde44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "https-proxy-agent": "^7.0.2", "jest": "^29.7.0", "postgres": "^3.4.3", - "screeps-advanced-api": "^1.5.0", + "screeps-advanced-api": "^1.5.2", "screeps-api": "^1.16.0", "winston": "^3.11.0", "winston-daily-rotate-file": "^4.7.1" @@ -6277,9 +6277,9 @@ } }, "node_modules/screeps-advanced-api": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/screeps-advanced-api/-/screeps-advanced-api-1.5.0.tgz", - "integrity": "sha512-Y34iFKwvfqX4qZ+oAiduolDuzmk/o8vh9uDrgO6Cq63DNXs1gLP/A5PAGa0N5bOHXDDTSc0VD4V0MgCJZ28zIA==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/screeps-advanced-api/-/screeps-advanced-api-1.5.2.tgz", + "integrity": "sha512-MD/X7qbihaNamgBJXMnFPpkjzrNgUL4nX2yo4DNxPxfMpg7zzABPlHdS+xUMM0X3OcztYwOWSiLLnKRz14dyVw==", "dependencies": { "screeps-api": "^1.16.0", "winston": "^3.11.0", diff --git a/package.json b/package.json index 9eb11e7..a0234d4 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "https-proxy-agent": "^7.0.2", "jest": "^29.7.0", "postgres": "^3.4.3", - "screeps-advanced-api": "^1.5.0", + "screeps-advanced-api": "^1.5.2", "screeps-api": "^1.16.0", "winston": "^3.11.0", "winston-daily-rotate-file": "^4.7.1" diff --git a/src/setup/cache.js b/src/setup/cache.js index 8f625b9..dcebb25 100644 --- a/src/setup/cache.js +++ b/src/setup/cache.js @@ -35,7 +35,7 @@ const userRoomsCache = cleanSource(baseCache) export default class Cache { static shouldUpdateCache(type) { let cache; - const shouldUpdateInterval = 1000 * 60 * 30; + const shouldUpdateInterval = 1000 * 60 * 10; switch (type) { case 'rooms': cache = roomsCache; @@ -124,6 +124,23 @@ export default class Cache { roomsCache.data = shards; } + static async updateUserLeaderboardCache() { + const forcedUsers = process.env.USERNAMES && process.env.USERNAMES.length > 0 + ? ("Unknown," + process.env.USERNAMES).split(",") : []; + let users = await advancedScreepsApi.getAllUsers() + users = users.filter(forcedUsers.length > 0 ? (user) => forcedUsers.includes(user.username) : () => true); + users.sort((a, b) => GetRoomTotal(b.shards, 'type') - GetRoomTotal(a.shards, 'type')); + const userValues = Object.values(users); + + for (let u = 0; u < userValues.length; u += 1) { + const user = userValues[u]; + ProcessDataBroker.usernamesById[user.id] = user.username; + } + fs.writeFileSync("./files/users.json", JSON.stringify(users, null, 2)); + UpdateLocalUsersCache(users); + usersCache.data = users; + } + static async updateUsersCache() { const forcedUsers = process.env.USERNAMES && process.env.USERNAMES.length > 0 ? ("Unknown," + process.env.USERNAMES).split(",") : [];