public override async Task <bool> ResolveEvent(EventHall eventHall, GameContext context, CancellationToken cancellationToken) { await Activate(context, cancellationToken); await context.ClickAt(DialogButton1, cancellationToken); var battle = new PrepareBattle(context); var ct = new CancellationTokenSource(TimeSpan.FromSeconds(3)); try { await battle.Activation(CancellationTokenSource.CreateLinkedTokenSource(ct.Token, cancellationToken).Token); } catch (TaskCanceledException) { //F**k, we've mistaken, it is a boss event! await context.ClickAt(600, 430, cancellationToken); var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)); try { await battle.Activation(CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, cts.Token).Token); } catch (TaskCanceledException) { await TryClose(context, cancellationToken); return(false); } } await battle.Engage(cancellationToken); await WaitCombatEnd(context, cancellationToken); return(true); }
protected async Task Dismiss(GameContext context, CancellationToken cancellationToken) { await context.ClickAt(DialogDeleteButton, cancellationToken); await Task.Delay(200, cancellationToken); await context.ClickAt(DialogDeleteOkButton, cancellationToken); await Task.Delay(200, cancellationToken); }
public override async Task <bool> ResolveEvent(EventHall eventHall, GameContext context, CancellationToken cancellationToken) { await Activate(context, cancellationToken); await context.ClickAt(DialogButton1, cancellationToken); return(true); }
protected Task TryClose(GameContext context, CancellationToken cancellationToken) => context.ClickAt(905, 106, cancellationToken);
protected async Task Activate(GameContext context, CancellationToken cancellationToken) { await context.ClickAt(ClickBox.Left + ClickBox.Width / 2, ClickBox.Top + ClickBox.Height / 2, cancellationToken); await Task.Delay(200, cancellationToken); }