public async Task <TaskResult> Do(int times) { // Cải tiến tướng đầu tiên. var heroId = barracks.Heroes[0].Id; // Giữ chỉ số cũ (trường hợp đã cải tiến trước). // Tránh lỗi: "Võ tướng có thuộc tính mới chưa thay" var p0 = await writer.KeepStatsAsync(heroId); if (p0 == null) { return(TaskResult.LostConnection); } for (int i = 0; i < times; ++i) { var result = await DoSingle(heroId); if (result != TaskResult.Done) { return(result); } // Tránh kẹt acc. await Task.Delay(250); } return(TaskResult.Done); }