mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-11 17:55:34 +02:00
Bug fix for validator execution before the bot initialization
This commit is contained in:
parent
1195a194d5
commit
7c96cca59c
1 changed files with 22 additions and 10 deletions
|
@ -126,7 +126,9 @@ class CookingCraftingTaskValidator {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
}
|
}
|
||||||
validate() {
|
validate(has_initiated) {
|
||||||
|
if (has_initiated) {
|
||||||
|
|
||||||
const result = checkItemPresence(this.data, this.agent);
|
const result = checkItemPresence(this.data, this.agent);
|
||||||
let score = 0;
|
let score = 0;
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
@ -137,6 +139,13 @@ class CookingCraftingTaskValidator {
|
||||||
"score": score,
|
"score": score,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return {
|
||||||
|
"valid": false,
|
||||||
|
"score": 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Task {
|
export class Task {
|
||||||
|
@ -188,6 +197,7 @@ export class Task {
|
||||||
|
|
||||||
this.name = this.agent.name;
|
this.name = this.agent.name;
|
||||||
this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
|
this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
|
||||||
|
this.agent_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAgentGoal() {
|
getAgentGoal() {
|
||||||
|
@ -239,7 +249,7 @@ export class Task {
|
||||||
isDone() {
|
isDone() {
|
||||||
let res = null;
|
let res = null;
|
||||||
if (this.validator)
|
if (this.validator)
|
||||||
res = this.validator.validate();
|
res = this.validator.validate(this.agent_initialized);
|
||||||
if (res && res.valid) {
|
if (res && res.valid) {
|
||||||
return {"message": 'Task successful', "score": res.score};
|
return {"message": 'Task successful', "score": res.score};
|
||||||
}
|
}
|
||||||
|
@ -311,6 +321,8 @@ export class Task {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.agent_initialized = true;
|
||||||
|
|
||||||
if (this.initiator) {
|
if (this.initiator) {
|
||||||
await this.initiator.init();
|
await this.initiator.init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue