Guten Morgen . Frohe Ostern erst mal.
Habe die letzte Version mit allen neuen Änderungen zum Test install.
Server nur PHP 8,2 aber kein Problem konnte ohne Problem alles Starten.
AiBot hängt in der ersten Ausbaustufe fest schließt den Bau von solar nicht ab.
Display Spoiler
public function runBot(array $botRow, int $universeId): void
{
$botId = (int)($botRow['id'] ?? 0);
$ownerId = (int)($botRow['id_owner'] ?? 0);
$typeId = (int)($botRow['bot_type'] ?? 0);
$personalityName = (string)($botRow['personality'] ?? 'balanced');
if ($botId <= 0
$ownerId <= 0
$typeId <= 0) {
$this->log("SKIP invalid botRow (botId={$botId}, ownerId={$ownerId}, typeId={$typeId})");
return;
}
$settings = $this->getBotSettings($typeId);
if (!$settings) {
$this->log("SKIP botId={$botId} ownerId={$ownerId}: settings missing for typeId={$typeId}");
$this->scheduleNext($botId, 900);
return;
}
// Load Personality
$personalityClass = (defined('ROOT_PATH') ? ROOT_PATH : '') . 'includes/classes/bot/BotPersonality.class.php';
if (file_exists($personalityClass)) {
require_once $personalityClass;
$personality = BotPersonality::get($personalityName);
} else {
$personality = null;
}
if (empty((int)($settings['enabled'] ?? 1))) {
$this->log("SKIP botId={$botId}: disabled by setting");
$this->scheduleNext($botId, 1800);
return;
}
$user = $this->getUser($ownerId);
if (!$user) {
$this->log("SKIP botId={$botId}: user missing ownerId={$ownerId}");
$this->scheduleNext($botId, 1200);
return;
}
$planet = $this->getMainPlanet($ownerId, $universeId);
if (!$planet) {
$this->log("SKIP botId={$botId}: main planet missing ownerId={$ownerId} uni={$universeId}");
$this->scheduleNext($botId, 1200);
return;
}
// Starter-Hilfe nach Reset
$planet = $this->healEmptyPlanet($planet, $universeId);
// Eigene Bot-Bauqueue abschließen
$planet = $this->processBotBuildingQueue($planet, $user);
// Heartbeat like a real player
$this->touchActivity($ownerId, $botId);
$this->log("BOT#{$botId} ({$user['username']}) type={$typeId} personality={$personalityName} tick start");
// 0) Alliance management
$this->doAllianceActions($user, $universeId, $settings);
// 1) Economy
$didAny = false;
$maxActions = max(1, (int)($settings['max_actions_per_tick'] ?? 4));
$actionsLeft = $maxActions;
if ($actionsLeft > 0) {
$didAny = $this->doEconomyActions($user, $planet, $settings, $personality, $actionsLeft)
$didAny;
}
// 2) Fleet
if ($actionsLeft > 0) {
$didAny = $this->doFleetActions($user, $planet, $botRow, $settings, $personality, $actionsLeft)
$didAny;
}
// 3) ACS
$canAcs = !empty((int)($settings['can_acs'] ?? 1));
$acsChance = (int)($settings['acs_chance_percent'] ?? 30);
if ($canAcs && $actionsLeft > 0 && mt_rand(1, 100) <= $acsChance) {
if ($this->doAcsRaid($user, $planet, $settings, $personalityName)) {
$didAny = true;
}
}
// Persist
$this->persistUserAndPlanet($user, $planet);
// Next schedule
$delay = $this->getNextDelaySeconds($settings, $didAny);
$this->scheduleNext($botId, $delay);
$this->log("BOT#{$botId} ({$user['username']}) tick end didAny=" . ($didAny ? "1" : "0") . " nextIn={$delay}s");
}
private function processBotBuildingQueue(array $planet, array &$user): array
{
global $resource;
if (empty($planet['b_building_id'])
empty($planet['b_building'])) {
return $planet;
}
if ((int)$planet['b_building'] > TIMESTAMP) {
return $planet;
}
$queue = @unserialize($planet['b_building_id']);
if (!is_array($queue)
empty($queue)
!isset($queue[0][0], $queue[0][4])) {
$this->log("BOT QUEUE PROCESS: invalid queue on planetId={$planet['id']}, clearing");
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
$this->db->update(
"UPDATE %%PLANETS%% SET b_building = 0, b_building_id = '' WHERE id = :pid",
[':pid' => (int)$planet['id']]
);
return $planet;
}
$elementId = (int)$queue[0][0];
$mode = (string)$queue[0][4];
if (!isset($resource[$elementId])) {
$this->log("BOT QUEUE PROCESS: unknown elementId={$elementId} on planetId={$planet['id']}, clearing");
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
$this->db->update(
"UPDATE %%PLANETS%% SET b_building = 0, b_building_id = '' WHERE id = :pid",
[':pid' => (int)$planet['id']]
);
return $planet;
}
$column = $resource[$elementId];
if ($mode === 'build') {
$planet[$column] = (int)($planet[$column] ?? 0) + 1;
$planet['field_current'] = (int)($planet['field_current'] ?? 0) + 1;
$this->log("BOT QUEUE PROCESS: completed build elementId={$elementId} planetId={$planet['id']} newLevel=" . (int)$planet[$column]);
} else {
$planet[$column] = max(0, (int)($planet[$column] ?? 0) - 1);
$planet['field_current'] = max(0, (int)($planet['field_current'] ?? 0) - 1);
$this->log("BOT QUEUE PROCESS: completed destroy elementId={$elementId} planetId={$planet['id']} newLevel=" . (int)$planet[$column]);
}
array_shift($queue);
if (empty($queue)) {
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
} else {
$planet['b_building_id'] = serialize(array_values($queue));
$planet['b_building'] = (int)($queue[0][3] ?? 0);
}
try {
$this->db->update(
"UPDATE %%PLANETS%% SET
{$column} = :lvl,
field_current = :fc,
b_building = :bb,
b_building_id = :bq
WHERE id = :pid",
[
':lvl' => (int)$planet[$column],
':fc' => (int)$planet['field_current'],
':bb' => (int)$planet['b_building'],
':bq' => (string)$planet['b_building_id'],
':pid' => (int)$planet['id'],
]
);
} catch (Throwable $t) {
$this->log("BOT QUEUE PROCESS failed planetId={$planet['id']}: " . $t->getMessage());
}
return $planet;
}
Damit startet der Aibot
Ach so log einträge müst ihr euch anpassen war nur für mich .
MFG
Habe die letzte Version mit allen neuen Änderungen zum Test install.
Server nur PHP 8,2 aber kein Problem konnte ohne Problem alles Starten.
AiBot hängt in der ersten Ausbaustufe fest schließt den Bau von solar nicht ab.
public function runBot(array $botRow, int $universeId): void
{
$botId = (int)($botRow['id'] ?? 0);
$ownerId = (int)($botRow['id_owner'] ?? 0);
$typeId = (int)($botRow['bot_type'] ?? 0);
$personalityName = (string)($botRow['personality'] ?? 'balanced');
if ($botId <= 0
$ownerId <= 0
$typeId <= 0) {$this->log("SKIP invalid botRow (botId={$botId}, ownerId={$ownerId}, typeId={$typeId})");
return;
}
$settings = $this->getBotSettings($typeId);
if (!$settings) {
$this->log("SKIP botId={$botId} ownerId={$ownerId}: settings missing for typeId={$typeId}");
$this->scheduleNext($botId, 900);
return;
}
// Load Personality
$personalityClass = (defined('ROOT_PATH') ? ROOT_PATH : '') . 'includes/classes/bot/BotPersonality.class.php';
if (file_exists($personalityClass)) {
require_once $personalityClass;
$personality = BotPersonality::get($personalityName);
} else {
$personality = null;
}
if (empty((int)($settings['enabled'] ?? 1))) {
$this->log("SKIP botId={$botId}: disabled by setting");
$this->scheduleNext($botId, 1800);
return;
}
$user = $this->getUser($ownerId);
if (!$user) {
$this->log("SKIP botId={$botId}: user missing ownerId={$ownerId}");
$this->scheduleNext($botId, 1200);
return;
}
$planet = $this->getMainPlanet($ownerId, $universeId);
if (!$planet) {
$this->log("SKIP botId={$botId}: main planet missing ownerId={$ownerId} uni={$universeId}");
$this->scheduleNext($botId, 1200);
return;
}
// Starter-Hilfe nach Reset
$planet = $this->healEmptyPlanet($planet, $universeId);
// Eigene Bot-Bauqueue abschließen
$planet = $this->processBotBuildingQueue($planet, $user);
// Heartbeat like a real player
$this->touchActivity($ownerId, $botId);
$this->log("BOT#{$botId} ({$user['username']}) type={$typeId} personality={$personalityName} tick start");
// 0) Alliance management
$this->doAllianceActions($user, $universeId, $settings);
// 1) Economy
$didAny = false;
$maxActions = max(1, (int)($settings['max_actions_per_tick'] ?? 4));
$actionsLeft = $maxActions;
if ($actionsLeft > 0) {
$didAny = $this->doEconomyActions($user, $planet, $settings, $personality, $actionsLeft)
$didAny;}
// 2) Fleet
if ($actionsLeft > 0) {
$didAny = $this->doFleetActions($user, $planet, $botRow, $settings, $personality, $actionsLeft)
$didAny;}
// 3) ACS
$canAcs = !empty((int)($settings['can_acs'] ?? 1));
$acsChance = (int)($settings['acs_chance_percent'] ?? 30);
if ($canAcs && $actionsLeft > 0 && mt_rand(1, 100) <= $acsChance) {
if ($this->doAcsRaid($user, $planet, $settings, $personalityName)) {
$didAny = true;
}
}
// Persist
$this->persistUserAndPlanet($user, $planet);
// Next schedule
$delay = $this->getNextDelaySeconds($settings, $didAny);
$this->scheduleNext($botId, $delay);
$this->log("BOT#{$botId} ({$user['username']}) tick end didAny=" . ($didAny ? "1" : "0") . " nextIn={$delay}s");
}
private function processBotBuildingQueue(array $planet, array &$user): array
{
global $resource;
if (empty($planet['b_building_id'])
empty($planet['b_building'])) {return $planet;
}
if ((int)$planet['b_building'] > TIMESTAMP) {
return $planet;
}
$queue = @unserialize($planet['b_building_id']);
if (!is_array($queue)
empty($queue)
!isset($queue[0][0], $queue[0][4])) {$this->log("BOT QUEUE PROCESS: invalid queue on planetId={$planet['id']}, clearing");
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
$this->db->update(
"UPDATE %%PLANETS%% SET b_building = 0, b_building_id = '' WHERE id = :pid",
[':pid' => (int)$planet['id']]
);
return $planet;
}
$elementId = (int)$queue[0][0];
$mode = (string)$queue[0][4];
if (!isset($resource[$elementId])) {
$this->log("BOT QUEUE PROCESS: unknown elementId={$elementId} on planetId={$planet['id']}, clearing");
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
$this->db->update(
"UPDATE %%PLANETS%% SET b_building = 0, b_building_id = '' WHERE id = :pid",
[':pid' => (int)$planet['id']]
);
return $planet;
}
$column = $resource[$elementId];
if ($mode === 'build') {
$planet[$column] = (int)($planet[$column] ?? 0) + 1;
$planet['field_current'] = (int)($planet['field_current'] ?? 0) + 1;
$this->log("BOT QUEUE PROCESS: completed build elementId={$elementId} planetId={$planet['id']} newLevel=" . (int)$planet[$column]);
} else {
$planet[$column] = max(0, (int)($planet[$column] ?? 0) - 1);
$planet['field_current'] = max(0, (int)($planet['field_current'] ?? 0) - 1);
$this->log("BOT QUEUE PROCESS: completed destroy elementId={$elementId} planetId={$planet['id']} newLevel=" . (int)$planet[$column]);
}
array_shift($queue);
if (empty($queue)) {
$planet['b_building'] = 0;
$planet['b_building_id'] = '';
} else {
$planet['b_building_id'] = serialize(array_values($queue));
$planet['b_building'] = (int)($queue[0][3] ?? 0);
}
try {
$this->db->update(
"UPDATE %%PLANETS%% SET
{$column} = :lvl,
field_current = :fc,
b_building = :bb,
b_building_id = :bq
WHERE id = :pid",
[
':lvl' => (int)$planet[$column],
':fc' => (int)$planet['field_current'],
':bb' => (int)$planet['b_building'],
':bq' => (string)$planet['b_building_id'],
':pid' => (int)$planet['id'],
]
);
} catch (Throwable $t) {
$this->log("BOT QUEUE PROCESS failed planetId={$planet['id']}: " . $t->getMessage());
}
return $planet;
}
Damit startet der Aibot
Ach so log einträge müst ihr euch anpassen war nur für mich .
MFG