private async Task JoinBossZone(int zonePosition) { for (int i = 0; i < 5; i++) { try { this.Logger?.LogMessage($"{{action}}Joining {{zone}}BOSS zone {zonePosition}{{action}}..."); await SaliensApi.JoinBossZoneAsync(this.Token, zonePosition); // States this.ActiveZone = this.ActivePlanet.Zones[zonePosition]; this.ActiveZoneStartDate = DateTime.Now; this.PlayerInfo.ActiveZoneGame = null; this.PlayerInfo.ActiveBossGame = this.ActiveZone.GameId; this.PlayerInfo.ActiveZonePosition = zonePosition.ToString(); this.PlayerInfo.TimeInZone = TimeSpan.FromSeconds(0); this.State = BotState.InBossZone; this.PresenceUpdateTrigger.SetSaliensPlayerState(this.PlayerInfo); return; } catch (SaliensApiException ex) { switch (ex.EResult) { case EResult.Fail: case EResult.Busy: case EResult.RateLimitExceeded: this.Logger?.LogMessage($"{{warn}}Failed to join boss zone: {ex.Message} - Giving it a few seconds ({i + 1}/5)..."); await Task.Delay(2000); continue; case EResult.Expired: case EResult.NoMatch: default: this.Logger?.LogMessage($"{{warn}}Failed to join boss zone: {ex.Message}"); ResetState(); throw; } } catch (WebException ex) { this.Logger?.LogMessage($"{{warn}}Failed to join boss zone: {ex.Message} - Giving it a few seconds ({i + 1}/5)..."); await Task.Delay(2000); continue; } } // States, only set when failed ResetState(); void ResetState() { this.State = BotState.OnPlanet; } }