git-subtree-dir: server git-subtree-mainline:c4e617ada7git-subtree-split:e64421295f
37 lines
815 B
Go
37 lines
815 B
Go
package agent
|
||
|
||
// weatherScore 天气适宜度(25 分制)
|
||
// 温度匹配每件服装季节 +5;<10℃ 无外套 -10;>30℃ 有外套 -8
|
||
func weatherScore(o CandidateOutfit, ctx ScoreContext) int {
|
||
score := 0
|
||
for _, it := range o.Items {
|
||
switch {
|
||
case ctx.TempAvg >= 28 && it.Season == "夏":
|
||
score += 5
|
||
case ctx.TempAvg >= 18 && ctx.TempAvg < 28 && it.Season == "春":
|
||
score += 5
|
||
case ctx.TempAvg >= 18 && ctx.TempAvg < 28 && it.Season == "秋":
|
||
score += 5
|
||
case ctx.TempAvg < 18 && it.Season == "冬":
|
||
score += 5
|
||
case it.Season == "四季":
|
||
score += 4
|
||
default:
|
||
score += 2
|
||
}
|
||
}
|
||
if ctx.TempAvg < 10 && !o.HasOuterwear {
|
||
score -= 10
|
||
}
|
||
if ctx.TempAvg > 30 && o.HasOuterwear {
|
||
score -= 8
|
||
}
|
||
if score < 0 {
|
||
return 0
|
||
}
|
||
if score > 25 {
|
||
return 25
|
||
}
|
||
return score
|
||
}
|