init21
This commit is contained in:
@@ -52,17 +52,25 @@ let playerStamina = 100;
|
||||
let playerLevel = 1;
|
||||
let currentRegionId = 1;
|
||||
|
||||
const CHANCE_LEVEL_UP = 0.10;
|
||||
const CHANCE_FAST_TRAVEL = 0.15;
|
||||
const CHANCE_GEAR_SWAP = 0.10;
|
||||
const CHANCE_TARGET_LOCK = 0.30;
|
||||
|
||||
log("Entering live sync loop (press Ctrl+C to exit)...", colors.gray);
|
||||
|
||||
while (true) {
|
||||
playerHealth = Math.floor(Math.max(10, playerHealth - (Math.random() * 10) + 5));
|
||||
playerStamina = Math.floor(Math.max(10, playerStamina - (Math.random() * 20) + 10));
|
||||
try {
|
||||
// Werte aktualisieren
|
||||
playerHealth = Math.floor(Math.max(10, playerHealth - (Math.random() * 10) + 5));
|
||||
playerStamina = Math.floor(Math.max(10, playerStamina - (Math.random() * 20) + 10));
|
||||
|
||||
if (Math.random() > 0.9) {
|
||||
playerLevel += 1;
|
||||
}
|
||||
if (Math.random() < CHANCE_LEVEL_UP) {
|
||||
playerLevel += 1;
|
||||
}
|
||||
|
||||
if (Math.random() > 0.85) {
|
||||
// Event: Schnellreise
|
||||
if (Math.random() < CHANCE_FAST_TRAVEL) {
|
||||
currentRegionId = Math.floor(Math.random() * 16) + 1;
|
||||
|
||||
const startTravel = performance.now();
|
||||
@@ -85,7 +93,8 @@ while (true) {
|
||||
console.log();
|
||||
}
|
||||
|
||||
if (Math.random() > 0.90) {
|
||||
// Event: Gear-Swap
|
||||
if (Math.random() < CHANCE_GEAR_SWAP) {
|
||||
const newWeaponId = Math.floor(Math.random() * 10) + 1;
|
||||
const newArmorId = Math.floor(Math.random() * 10) + 11;
|
||||
const newTalismanId = Math.floor(Math.random() * 5) + 26;
|
||||
@@ -109,8 +118,9 @@ while (true) {
|
||||
console.log();
|
||||
}
|
||||
|
||||
const startSync = performance.now();
|
||||
await setJson("player:1", {
|
||||
// Aktuellen Stand sichern
|
||||
const startSync = performance.now();
|
||||
await setJson("player:1", {
|
||||
id: 1,
|
||||
name: "Jonas",
|
||||
health: playerHealth,
|
||||
@@ -124,8 +134,9 @@ while (true) {
|
||||
log(`[Live Sync] [ID: 1] Jonas - Lvl: ${playerLevel} | HP: ${playerHealth} | Stamina: ${playerStamina}`, colors.green);
|
||||
log(`[Stats] Query Time: ${syncTime}ms | Reqs in Block: 1 | Total Reqs: ${totalRequests}`, colors.gray);
|
||||
|
||||
if (Math.random() > 0.7) {
|
||||
const startLock = performance.now();
|
||||
// Event: Gegner-Lock
|
||||
if (Math.random() < CHANCE_TARGET_LOCK) {
|
||||
const startLock = performance.now();
|
||||
const enemyIds = (await getJson(`region:${currentRegionId}:enemies`)) || [];
|
||||
totalRequests += 1;
|
||||
const randomEnemyId = enemyIds.length > 0 ? enemyIds[Math.floor(Math.random() * enemyIds.length)] : null;
|
||||
@@ -149,5 +160,9 @@ while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
log("Verbindungsabbruch zu Memcached!", colors.red);
|
||||
}
|
||||
|
||||
await Bun.sleep(2000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user