Adding repo after 2 days of vibecoding
This commit is contained in:
17
server/worldSeed.js
Normal file
17
server/worldSeed.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* One world seed per UTC-aligned period: floor(utcUnixSeconds / rotationSeconds).
|
||||
* Changing the slot triggers a full grid wipe on the server.
|
||||
*/
|
||||
export function computeWorldSeedState(rotationSeconds) {
|
||||
const rot = Math.max(60, Math.floor(rotationSeconds));
|
||||
const nowSec = Math.floor(Date.now() / 1000);
|
||||
const slot = Math.floor(nowSec / rot);
|
||||
const periodStart = slot * rot;
|
||||
const periodEnd = periodStart + rot;
|
||||
return {
|
||||
worldSeed: `swg-${slot}`,
|
||||
seedSlot: slot,
|
||||
seedPeriodEndsAtUtc: new Date(periodEnd * 1000).toISOString(),
|
||||
seedPeriodStartsAtUtc: new Date(periodStart * 1000).toISOString(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user