task init fixes

This commit is contained in:
Kolby Nottingham 2024-12-12 12:33:00 -08:00
parent d0140aa542
commit 58d38af369

View file

@ -66,6 +66,9 @@ export class Task {
if (!task) { if (!task) {
throw new Error(`Task ${task_id} not found`); throw new Error(`Task ${task_id} not found`);
} }
if ((!task.agent_count || task.agent_count <= 1) && this.agent.count_id > 0) {
task = null;
}
return task; return task;
} catch (error) { } catch (error) {
@ -104,7 +107,7 @@ export class Task {
//wait for a bit so inventory is cleared //wait for a bit so inventory is cleared
await new Promise((resolve) => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
if (this.data.agent_number > 1) { if (this.data.agent_count > 1) {
var initial_inventory = this.data.initial_inventory[this.agent.count_id.toString()]; var initial_inventory = this.data.initial_inventory[this.agent.count_id.toString()];
console.log("Initial inventory:", initial_inventory); console.log("Initial inventory:", initial_inventory);
} else if (this.data) { } else if (this.data) {
@ -135,7 +138,7 @@ export class Task {
// Finding if there is a human player on the server // Finding if there is a human player on the server
for (const playerName in bot.players) { for (const playerName in bot.players) {
const player = bot.players[playerName]; const player = bot.players[playerName];
if (!available_agents.some((n) => n === name)) { if (!available_agents.some((n) => n === playerName)) {
console.log('Found human player:', player.username); console.log('Found human player:', player.username);
human_player_name = player.username human_player_name = player.username
break; break;