Fix potential div by zero
This commit is contained in:
parent
77db5a33ec
commit
4c61b83227
1 changed files with 4 additions and 0 deletions
4
main.go
4
main.go
|
@ -73,6 +73,10 @@ func (c *Criteria) Meets(c2 *Criteria) bool {
|
|||
|
||||
func (c *Criteria) Score(c2 *Criteria) int64 {
|
||||
if c2.ScoreMode == "time" {
|
||||
time := float64(c.Time)
|
||||
if time < 1 {
|
||||
time = 1
|
||||
}
|
||||
return int64(c2.Coefficient / float64(c.Time))
|
||||
}
|
||||
if c2.ScoreMode == "points" {
|
||||
|
|
Loading…
Add table
Reference in a new issue