From e3494e5041d417cae38c610eb9bc3eb0b8c04dc7 Mon Sep 17 00:00:00 2001 From: jinsu Date: Mon, 8 Dec 2025 23:25:12 +0900 Subject: [PATCH] =?UTF-8?q?weather=20condition=20=EC=9A=B0=EC=84=A0=20?= =?UTF-8?q?=EC=88=9C=EC=9C=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/domain/weather_condition.go | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/internal/pkg/domain/weather_condition.go b/internal/pkg/domain/weather_condition.go index dea11f1..b0c22bd 100644 --- a/internal/pkg/domain/weather_condition.go +++ b/internal/pkg/domain/weather_condition.go @@ -10,3 +10,31 @@ const ( WeatherConditionSnow WeatherCondition = "SNOW" WeatherConditionRainSnow WeatherCondition = "RAIN_SNOW" ) + +// IsWorseThan은 현재 날씨 조건이 other보다 나쁜 조건인지 확인합니다. +// 우선순위: RAIN > RAIN_SNOW > SNOW > CLOUDY > CLEAR. +func (c WeatherCondition) IsWorseThan(other WeatherCondition) bool { + return c.priority() > other.priority() +} + +// priority는 날씨 조건의 우선순위를 반환합니다. +// 우선순위가 높을수록 더 나쁜 날씨 조건입니다. +// 우선순위: RAIN(4) > RAIN_SNOW(3) > SNOW(2) > CLOUDY(1) > CLEAR(0) > UNKNOWN(-1). +func (c WeatherCondition) priority() int { + switch c { + case WeatherConditionClear: + return 0 + case WeatherConditionCloudy: + return 1 + case WeatherConditionSnow: + return 2 //nolint:mnd + case WeatherConditionRainSnow: + return 3 //nolint:mnd + case WeatherConditionRain: + return 4 //nolint:mnd + case WeatherConditionUnknown: + return -1 + default: + return -1 + } +}