Fix task id generation
This commit is contained in:
parent
61c41e6b03
commit
17de7e52dc
@ -1,21 +0,0 @@
|
|||||||
import { ActionController, registerAction } from './ActionController';
|
|
||||||
import { Args } from '../Command';
|
|
||||||
import { Task } from '../Queue/TaskQueue';
|
|
||||||
import { ActionError } from '../Errors';
|
|
||||||
import { getNumber } from '../utils';
|
|
||||||
|
|
||||||
@registerAction
|
|
||||||
export class GrabHeroAttributesAction extends ActionController {
|
|
||||||
async run(args: Args, task: Task): Promise<any> {
|
|
||||||
const healthElement = jQuery('#attributes .attribute.health .powervalue .value');
|
|
||||||
if (healthElement.length !== 1) {
|
|
||||||
throw new ActionError(task.id, 'Health dom element not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
const text = healthElement.text();
|
|
||||||
let normalized = text.replace(/[^0-9]/g, '');
|
|
||||||
|
|
||||||
const value = getNumber(normalized);
|
|
||||||
// this.state.set('hero', { health: value });
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,6 +18,7 @@ function uniqTaskId(): TaskId {
|
|||||||
} else {
|
} else {
|
||||||
idSequence = 1;
|
idSequence = 1;
|
||||||
}
|
}
|
||||||
|
lastTimestamp = ts;
|
||||||
return 'tid.' + ts + '.' + String(idSequence).padStart(4, '0') + '.' + uniqId('');
|
return 'tid.' + ts + '.' + String(idSequence).padStart(4, '0') + '.' + uniqId('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import { Args, Command } from '../Command';
|
|||||||
import { Task } from '../Queue/TaskQueue';
|
import { Task } from '../Queue/TaskQueue';
|
||||||
import { TaskController, registerTask } from './TaskController';
|
import { TaskController, registerTask } from './TaskController';
|
||||||
import { GoToPageAction } from '../Action/GoToPageAction';
|
import { GoToPageAction } from '../Action/GoToPageAction';
|
||||||
import { GrabHeroAttributesAction } from '../Action/GrabHeroAttributesAction';
|
|
||||||
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
|
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
|
||||||
import { SendOnAdventureAction } from '../Action/SendOnAdventureAction';
|
import { SendOnAdventureAction } from '../Action/SendOnAdventureAction';
|
||||||
import { ClickButtonAction } from '../Action/ClickButtonAction';
|
import { ClickButtonAction } from '../Action/ClickButtonAction';
|
||||||
@ -17,7 +16,6 @@ export class SendOnAdventureTask extends TaskController {
|
|||||||
...args,
|
...args,
|
||||||
path: path('/hero.php'),
|
path: path('/hero.php'),
|
||||||
}),
|
}),
|
||||||
new Command(GrabHeroAttributesAction.name, args),
|
|
||||||
new Command(GoToPageAction.name, {
|
new Command(GoToPageAction.name, {
|
||||||
...args,
|
...args,
|
||||||
path: path('/hero.php', { t: 3 }),
|
path: path('/hero.php', { t: 3 }),
|
||||||
|
Loading…
Reference in New Issue
Block a user