private async void BuildBorders_Click(object sender, RoutedEventArgs e) { EnableSpecialButtons(false); await BlockChecker.Of(client).FinishChecksAsync(); EnableSpecialButtons(true); }
private async void OnScanRequest(ScanRequestEvent e) { var spots = EmptyMapSpots; if (spots.Count == 0) { new ScanResultEvent(false, "No empty slots left.").RaiseIn(BotBits); return; } List <Map> maps; try { maps = await new MapScanner(MapWidth, MapHeight).LoadMapsAsync(e.TargetWorldId, ScanSignFormat, MapPositionMapper); } catch (MapLoadException ex) { new ScanResultEvent(false, ex.Message).RaiseIn(BotBits); return; } if (maps.Count == 0) { new ScanResultEvent(false, "No maps found.").RaiseIn(BotBits); return; } var blocks = Blocks.Of(BotBits); var spotNumber = 0; var numAccepted = 0; var numRejected = 0; var result = ReviewResult.Rejected; foreach (var map in maps) { spots[spotNumber].AddMap(blocks, map); await PlaceSendMessage.Of(BotBits).FinishQueueAsync(); await BlockChecker.Of(BotBits).FinishChecksAsync(); reviewResult = new TaskCompletionSource <ReviewResult>(); waitingForResponse = true; new MapForReviewEvent(map.Name, map.Creators, numAccepted + numRejected + 1, maps.Count).RaiseIn(BotBits); result = await reviewResult.Task; waitingForResponse = false; switch (result) { case ReviewResult.Accepted: { numAccepted++; spotNumber++; if (spotNumber < spots.Count) { continue; } new ScanResultEvent(false, "Scan not finished completely. Ran out of free spots.", numAccepted, numRejected).RaiseIn(BotBits); return; } case ReviewResult.Rejected: { numRejected++; break; } case ReviewResult.Stopped: { spots[spotNumber].Clear(blocks); new ScanResultEvent(false, "Scan stopped.", numAccepted, numRejected).RaiseIn(BotBits); return; } } } // Clear last map when rejected if (result == ReviewResult.Rejected) { spots[spotNumber].Clear(blocks); } new ScanResultEvent(true, "Scan succeeded.", numAccepted, numRejected).RaiseIn(BotBits); }