publicstring commited on
Commit
cee13f8
·
verified ·
1 Parent(s): 11151e6

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +15 -11
app.js CHANGED
@@ -48,11 +48,18 @@ const BOT_TEMPLATES = [
48
  }
49
  ];
50
 
51
- const BOT_NAMES = ['Alpha', 'Beta', 'Gamma', 'Delta', 'Omega', 'Zeta', 'Sigma', 'Prime'];
 
 
 
 
 
 
 
52
 
53
- function populateBots(room, guaranteeBot = false) {
54
- if (!guaranteeBot && Math.random() > 0.5) return;
55
- const numBots = Math.floor(Math.random() * 6) + 8;
56
 
57
  for (let i = 0; i < numBots; i++) {
58
  const botId = `bot-${uuidv4()}`;
@@ -70,11 +77,11 @@ function randomBiome() {
70
  return ['DESERT', 'RAINFOREST', 'UNDERWATER'][Math.floor(Math.random() * 3)];
71
  }
72
 
73
- function makeRoom(forceBots = false) {
74
  roomCounter++;
75
  const id = `room-${roomCounter}`;
76
  const room = { id, status: 'LOBBY', players: {}, startTime: 0, biome: randomBiome(), groups: {}, hasRealPlayers: false };
77
- populateBots(room, forceBots);
78
  return room;
79
  }
80
 
@@ -95,13 +102,10 @@ const ZONE_PHASES = [
95
  ];
96
 
97
  for (let i = 0; i < MIN_ROOMS; i++) {
98
- const r = makeRoom(i < 3);
99
  rooms[r.id] = r;
100
  }
101
 
102
- // A room only self-locks from idle time once a REAL player has actually
103
- // joined it. Bot-only rooms sit idle indefinitely (e.g. HF cron keep-alive
104
- // with no traffic) and must never lock themselves before anyone can join.
105
  function isRoomJoinable(room) {
106
  if (room.status === 'EXTINCTION') return false;
107
  if (!room.hasRealPlayers) return true;
@@ -122,7 +126,7 @@ function resetRoomToLobby(room) {
122
  room.players[pid].ready = false;
123
  room.players[pid].state = JSON.parse(JSON.stringify(INITIAL_STATE));
124
  }
125
- populateBots(room, false);
126
  roomStates.delete(room.id);
127
  roomChatLogs.delete(room.id);
128
  roomEmptySince.delete(room.id);
 
48
  }
49
  ];
50
 
51
+ // Expanded to 25 unique variants!
52
+ const BOT_NAMES = [
53
+ 'Alpha', 'Beta', 'Gamma', 'Delta', 'Omega',
54
+ 'Zeta', 'Sigma', 'Prime', 'Apex', 'Titan',
55
+ 'Leviathan', 'Chimera', 'Vertex', 'Nebula', 'Pulsar',
56
+ 'Quasar', 'Zenith', 'Onyx', 'Kestrel', 'Raptor',
57
+ 'Vortex', 'Echo', 'Talon', 'Nova', 'Orion'
58
+ ];
59
 
60
+ function populateBots(room) {
61
+ // Always add between 8 and 12 bots (0-4 + 8)
62
+ const numBots = Math.floor(Math.random() * 5) + 8;
63
 
64
  for (let i = 0; i < numBots; i++) {
65
  const botId = `bot-${uuidv4()}`;
 
77
  return ['DESERT', 'RAINFOREST', 'UNDERWATER'][Math.floor(Math.random() * 3)];
78
  }
79
 
80
+ function makeRoom() {
81
  roomCounter++;
82
  const id = `room-${roomCounter}`;
83
  const room = { id, status: 'LOBBY', players: {}, startTime: 0, biome: randomBiome(), groups: {}, hasRealPlayers: false };
84
+ populateBots(room);
85
  return room;
86
  }
87
 
 
102
  ];
103
 
104
  for (let i = 0; i < MIN_ROOMS; i++) {
105
+ const r = makeRoom();
106
  rooms[r.id] = r;
107
  }
108
 
 
 
 
109
  function isRoomJoinable(room) {
110
  if (room.status === 'EXTINCTION') return false;
111
  if (!room.hasRealPlayers) return true;
 
126
  room.players[pid].ready = false;
127
  room.players[pid].state = JSON.parse(JSON.stringify(INITIAL_STATE));
128
  }
129
+ populateBots(room);
130
  roomStates.delete(room.id);
131
  roomChatLogs.delete(room.id);
132
  roomEmptySince.delete(room.id);